/*!
 * Mini Tokyo 3D v3.6.0
 * https://minitokyo3d.com
 * (c) 2019-2025 Akihiko Kusanagi
 * Released under the MIT license
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).mt3d=e()}(this,(function(){"use strict";function _mergeNamespaces(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){if("default"!==n&&!(n in t)){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}))})),Object.freeze(t)}var u8=Uint8Array,u16=Uint16Array,i32=Int32Array,fleb=new u8([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]),fdeb=new u8([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]),clim=new u8([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),freb=function(t,e){for(var n=new u16(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];var r=new i32(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}},_a=freb(fleb,2),fl=_a.b,revfl=_a.r;fl[28]=258,revfl[258]=28;for(var _b=freb(fdeb,0),fd=_b.b,rev=new u16(32768),i$1=0;i$1<32768;++i$1){var x=(43690&i$1)>>1|(21845&i$1)<<1;x=(52428&x)>>2|(13107&x)<<2,x=(61680&x)>>4|(3855&x)<<4,rev[i$1]=((65280&x)>>8|(255&x)<<8)>>1}for(var hMap=function(t,e,n){for(var i=t.length,r=0,o=new u16(e);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new u16(e);for(r=1;r<e;++r)a[r]=a[r-1]+o[r-1]<<1;if(n){s=new u16(1<<e);var l=15-e;for(r=0;r<i;++r)if(t[r])for(var c=r<<4|t[r],u=e-t[r],h=a[t[r]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)s[rev[h]>>l]=c}else for(s=new u16(i),r=0;r<i;++r)t[r]&&(s[r]=rev[a[t[r]-1]++]>>15-t[r]);return s},flt=new u8(288),i$1=0;i$1<144;++i$1)flt[i$1]=8;for(var i$1=144;i$1<256;++i$1)flt[i$1]=9;for(var i$1=256;i$1<280;++i$1)flt[i$1]=7;for(var i$1=280;i$1<288;++i$1)flt[i$1]=8;for(var fdt=new u8(32),i$1=0;i$1<32;++i$1)fdt[i$1]=5;var flrm=hMap(flt,9,1),fdrm=hMap(fdt,5,1),max=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},bits=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},bits16=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},shft=function(t){return(t+7)/8|0},slc=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new u8(t.subarray(e,n))},ec=["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"],err=function(t,e,n){var i=new Error(e||ec[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,err),!n)throw i;return i},inflt=function(t,e,n,i){var r=t.length;if(!r||e.f&&!e.l)return n||new u8(0);var o=!n,s=o||2!=e.i,a=e.i;o&&(n=new u8(3*r));var l=function(t){var e=n.length;if(t>e){var i=new u8(Math.max(2*e,t));i.set(n),n=i}},c=e.f||0,u=e.p||0,h=e.b||0,d=e.l,p=e.d,f=e.m,m=e.n,g=8*r;do{if(!d){c=bits(t,u,1);var _=bits(t,u+1,3);if(u+=3,!_){var y=t[(I=shft(u)+4)-4]|t[I-3]<<8,v=I+y;if(v>r){a&&err(0);break}s&&l(h+y),n.set(t.subarray(I,v),h),e.b=h+=y,e.p=u=8*v,e.f=c;continue}if(1==_)d=flrm,p=fdrm,f=9,m=5;else if(2==_){var x=bits(t,u,31)+257,b=bits(t,u+10,15)+4,T=x+bits(t,u+5,31)+1;u+=14;for(var E=new u8(T),S=new u8(19),w=0;w<b;++w)S[clim[w]]=bits(t,u+3*w,7);u+=3*b;var A=max(S),M=(1<<A)-1,C=hMap(S,A,1);for(w=0;w<T;){var I,P=C[bits(t,u,M)];if(u+=15&P,(I=P>>4)<16)E[w++]=I;else{var L=0,R=0;for(16==I?(R=3+bits(t,u,3),u+=2,L=E[w-1]):17==I?(R=3+bits(t,u,7),u+=3):18==I&&(R=11+bits(t,u,127),u+=7);R--;)E[w++]=L}}var O=E.subarray(0,x),D=E.subarray(x);f=max(O),m=max(D),d=hMap(O,f,1),p=hMap(D,m,1)}else err(1);if(u>g){a&&err(0);break}}s&&l(h+131072);for(var B=(1<<f)-1,N=(1<<m)-1,F=u;;F=u){var U=(L=d[bits16(t,u)&B])>>4;if((u+=15&L)>g){a&&err(0);break}if(L||err(2),U<256)n[h++]=U;else{if(256==U){F=u,d=null;break}var k=U-254;U>264&&(k=bits(t,u,(1<<(V=fleb[w=U-257]))-1)+fl[w],u+=V);var z=p[bits16(t,u)&N],G=z>>4;z||err(3),u+=15&z;D=fd[G];if(G>3){var V=fdeb[G];D+=bits16(t,u)&(1<<V)-1,u+=V}if(u>g){a&&err(0);break}s&&l(h+131072);var j=h+k;if(h<D){var $=0-D,H=Math.min(D,j);for($+h<0&&err(3);h<H;++h)n[h]=i[$+h]}for(;h<j;++h)n[h]=n[h-D]}}e.l=d,e.p=F,e.b=h,e.f=c,d&&(c=1,e.m=f,e.d=p,e.n=m)}while(!c);return h!=n.length&&o?slc(n,0,h):n.subarray(0,h)},et=new u8(0),gzs=function(t){31==t[0]&&139==t[1]&&8==t[2]||err(6,"invalid gzip data");var e=t[3],n=10;4&e&&(n+=2+(t[10]|t[11]<<8));for(var i=(e>>3&1)+(e>>4&1);i>0;i-=!t[n++]);return n+(2&e)},Inflate=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 u8(32768),this.p=new u8(0),n&&this.o.set(n)}return t.prototype.e=function(t){if(this.ondata||err(5),this.d&&err(4),this.p.length){if(t.length){var e=new u8(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=inflt(this.p,this.s,this.o);this.ondata(slc(n,e,this.s.b),this.d),this.o=slc(n,this.s.b-32768),this.s.b=this.o.length,this.p=slc(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}(),Gunzip=function(){function t(t,e){this.v=1,this.r=0,Inflate.call(this,t,e)}return t.prototype.push=function(t,e){if(Inflate.prototype.e.call(this,t),this.r+=t.length,this.v){var n=this.p.subarray(this.v-1),i=n.length>3?gzs(n):4;if(i>n.length){if(!e)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(i),this.v=0}Inflate.prototype.c.call(this,e),!this.s.f||this.s.l||e||(this.v=shft(this.s.p)+9,this.s={i:0},this.o=new u8(0),this.push(new u8(0),e))},t}(),td="undefined"!=typeof TextDecoder&&new TextDecoder,tds=0;try{td.decode(et,{stream:!0}),tds=1}catch(t){}var dutf8=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:slc(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)}},DecodeUTF8=function(){function t(t){this.ondata=t,tds?this.t=new TextDecoder:this.p=et}return t.prototype.push=function(t,e){if(this.ondata||err(5),e=!!e,this.t)return this.ondata(this.t.decode(t,{stream:!0}),e),void(e&&(this.t.decode().length&&err(8),this.t=null));this.p||err(4);var n=new u8(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var i=dutf8(n),r=i.s,o=i.r;e?(o.length&&err(8),this.p=null):this.p=o,this.ondata(r,e)},t}();const configs={standingDuration:6e4,minStandingDuration:3e4,trainRefreshInterval:6e4,refreshTimeout:1e4,realtimeCheckInterval:15e3,maxSpeedKMPH:80,accelerationKMPHPS:3,get maxSpeed(){return configs.maxSpeedKMPH/36e5},get acceleration(){return configs.accelerationKMPHPS/36e8},get maxAccelerationTime(){return configs.maxSpeed/configs.acceleration},get maxAccDistance(){return configs.maxAccelerationTime*configs.maxSpeed/2},maxFlightSpeedKMPH:500,flightAccelerationKMPHPS:12,get maxFlightSpeed(){return configs.maxFlightSpeedKMPH/36e5},get flightAcceleration(){return configs.flightAccelerationKMPHPS/36e8},maxBusSpeedKMPH:30,busAccelerationKMPHPS:3,get maxBusSpeed(){return configs.maxBusSpeedKMPH/36e5},get busAcceleration(){return configs.busAccelerationKMPHPS/36e8},get maxBusAccelerationTime(){return configs.maxBusSpeed/configs.busAcceleration},get maxBusAccDistance(){return configs.maxBusAccelerationTime*configs.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",defaultEcoMode:"normal",apiUrl:{odpt:"https://api.odpt.org/api/v4/",challenge2024:"https://api-challenge2024.odpt.org/api/v4/"},tidUrl:"https://mini-tokyo.appspot.com/tid",trainInfoUrl:"https://mini-tokyo.appspot.com/traininfo",atisUrl:"https://mini-tokyo.appspot.com/atisinfo",flightUrl:"https://mini-tokyo.appspot.com/flight",dataUrl:"https://minitokyo3d.com/data",dataSources:[],searchUrl:"https://search.minitokyo3d.com/api/v1/routes",lastStaticUpdate:"2024-11-25 15:00:00",customAttribution:'<a href="https://github.com/nagix/mini-tokyo-3d">© Akihiko Kusanagi</a>',copyright:"© 2019-2025 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"]};let touchDevice=!1;function isTouchDevice(){return touchDevice}function loadJSON(t){return fetch(t).then((e=>{if(t.endsWith(".gz")){let t="";const n=e.body.getReader(),i=new DecodeUTF8((e=>{t+=e})),r=new Gunzip(((t,e)=>{i.push(t,e)}));return n.read().then((function e({done:i,value:o}){return i?(r.push(new Uint8Array(0),!0),JSON.parse(t)):(r.push(o),n.read().then(e))}))}return e.json()}))}function lerp$5(t,e,n){return t*(1-n)+e*n}function clamp$3(t,e,n){return Math.min(Math.max(t,e),n)}function includes(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 flat$1(t){return t.reduce(((t,e)=>t.concat(e)),[])}function normalize$5(t){return t.normalize("NFD").replace(/\(.*\)|<.*>|〈.*〉|[\u0300-\u036F]/g,"")}function valueOrDefault(t,e){return void 0===t?e:t}function numberOrDefault(t,e){return isNaN(t)?e:t}function getTimeString(t){return`${("0"+(Math.floor(t/36e5)+3)%24).slice(-2)}:${("0"+Math.floor(t/6e4)%60).slice(-2)}`}function getTimeOffset(t){return 6e4*((+t.substring(0,2)+21)%24*60+ +t.substring(3,5))}function bindAll(t,e){for(const n of t)e[n]&&(e[n]=e[n].bind(e))}function removePrefix(t){return"string"==typeof t?t.replace(/.*:/,""):Array.isArray(t)?t.map(removePrefix):t}function blink(){const t=performance.now()%1500/1500*2;return t<1?t:2-t}function measureFrameRate(){return new Promise((t=>{let e=0;const n=performance.now(),i=()=>{e++<60?requestAnimationFrame(i):t(1e3/((performance.now()-n)/60))};i()}))}function bufferTrapezoid(t,e){const[[n,i],[r,o],[s,a],[l,c]]=t,u=r-n,h=s-r,d=l-s,p=n-l,f=o-i,m=a-o,g=c-a,_=i-c,y=e/Math.sqrt(u*u+f*f),v=e/Math.sqrt(h*h+m*m),x=e/Math.sqrt(d*d+g*g),b=e/Math.sqrt(p*p+_*_),T=n-f*y,E=r-m*v,S=s-g*x,w=l-_*b,A=i+u*y,M=o+h*v,C=a+d*x,I=c+p*b,P=u*m,L=h*g,R=d*_,O=p*f,D=f*h,B=m*d,N=g*p,F=_*u,U=P-D,k=L-B,z=R-N,G=O-F;return[[(u*h*(A-M)+P*E-D*T)/U,(P*A-D*M-f*m*(T-E))/U],[(h*d*(M-C)+L*S-B*E)/k,(L*M-B*C-m*g*(E-S))/k],[(d*p*(C-I)+R*w-N*S)/z,(R*C-N*I-g*_*(S-w))/z],[(p*u*(I-A)+O*T-F*w)/G,(O*I-F*A-_*f*(w-T))/G]]}function pointInTrapezoid(t,e){const[n,i]=t,[[r,o],[s,a],[l,c],[u,h]]=e;return(s-r)*(i-o)<(a-o)*(n-r)&&(l-s)*(i-a)<(c-a)*(n-s)&&(u-l)*(i-c)<(h-c)*(n-l)&&(r-u)*(i-h)<(o-h)*(n-u)}function luminance(t){return.2126*t.r+.7152*t.g+.0722*t.b}function colorToRGBArray(t){const e=parseInt(t.replace("#",""),16);return[Math.floor(e/65536)%256,Math.floor(e/256)%256,e%256]}function createElement$1(t,e,n){const i=document.createElement(t);for(const t of Object.keys(e))try{i[t]=e[t]}catch(n){i.setAttribute(t,e[t])}return n&&n.appendChild(i),i}function showNotification(t,e){const n=createElement$1("div",{className:"notification",innerHTML:e},t);setTimeout((()=>{n.style.opacity=0}),1e3),setTimeout((()=>{t.removeChild(n)}),2e3)}function normalizeLang(t){return includes(configs.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 getLang(t){if(!includes(configs.langs,t)){const e=window.navigator;t=e.languages&&e.languages[0]||e.language||e.userLanguage||e.browserLanguage||""}return normalizeLang(t)||"en"}"undefined"!=typeof window&&window.addEventListener("touchstart",(()=>{touchDevice=!0}),{once:!0});var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function getAugmentedNamespace(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})})),n}var mapboxGl$1={exports:{}},mapboxGl=mapboxGl$1.exports,hasRequiredMapboxGl;function requireMapboxGl(){return hasRequiredMapboxGl||(hasRequiredMapboxGl=1,function(t){t.exports=function(){var t,e,n;function i(i,r){if(t)if(e){var o="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 = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",s={};t(s),n=r(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(n.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=r;else t=r}i(["exports"],(function(t){var e="undefined"!=typeof self?self:{},n="2.15.0";let i;const r={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==i){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{i=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t}catch(e){i=t}}return i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!r.API_URL)return null;try{const t=new URL(r.API_URL);return"api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},o={supported:!1,testSupport:function(t){!l&&a&&(c?u(t):s=t)}};let s,a,l=!1,c=!1;function u(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,a),t.isContextLost())return;o.supported=!0}catch(t){}t.deleteTexture(e),l=!0}e.document&&(a=e.document.createElement("img"),a.onload=function(){s&&u(s),s=null,c=!0},a.onerror=function(){l=!0,s=null},a.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const h="01";function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var p=f;function f(t,e,n,i){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(i-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=n,this.p2y=i}f.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var n=t,i=0;i<8;i++){var r=this.sampleCurveX(n)-t;if(Math.abs(r)<e)return n;var o=this.sampleCurveDerivativeX(n);if(Math.abs(o)<1e-6)break;n-=r/o}var s=0,a=1;for(n=t,i=0;i<20&&(r=this.sampleCurveX(n),!(Math.abs(r-t)<e));i++)t>r?s=n:a=n,n=.5*(a-s)+s;return n},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var m=d(p),g=_;function _(t,e){this.x=t,this.y=e}_.prototype={clone:function(){return new _(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),i=n*this.x+e*this.y;return this.x=e*this.x-n*this.y,this.y=i,this},_rotateAround:function(t,e){var n=Math.cos(t),i=Math.sin(t),r=e.y+i*(this.x-e.x)+n*(this.y-e.y);return this.x=e.x+n*(this.x-e.x)-i*(this.y-e.y),this.y=r,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},_.convert=function(t){return t instanceof _?t:Array.isArray(t)?new _(t[0],t[1]):t};var y=d(g);const v=Math.PI/180,x=180/Math.PI;function b(t){return t*v}function T(t){return t*x}const E=[[0,0],[1,0],[1,1],[0,1]];function S(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function w(t,e,n,i){const r=new m(t,e,n,i);return function(t){return r.solve(t)}}const A=w(.25,.1,.25,1);function M(t,e,n){return Math.min(n,Math.max(e,t))}function C(t,e,n){return(n=M((n-t)/(e-t),0,1))*n*(3-2*n)}function I(t,e,n){const i=n-e,r=((t-e)%i+i)%i+e;return r===e?n:r}function P(t,e,n){if(!t.length)return n(null,[]);let i=t.length;const r=new Array(t.length);let o=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(o=t),r[s]=e,0==--i&&n(o,r)}))}))}function L(t){const e=[];for(const n in t)e.push(t[n]);return e}function R(t,...e){for(const n of e)for(const e in n)t[e]=n[e];return t}let O=1;function D(){return O++}function B(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function N(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function F(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function U(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function k(t,e){return-1!==t.indexOf(e,t.length-e.length)}function z(t,e,n){const i={};for(const n in t)i[n]=e.call(this,t[n],n,t);return i}function G(t,e,n){const i={};for(const r in t)e.call(n||this,t[r],r,t)&&(i[r]=t[r]);return i}function V(t){return Array.isArray(t)?t.map(V):"object"==typeof t&&t?z(t,V):t}const j={};function $(t){j[t]||(j[t]=!0)}function H(t,e,n){return(n.y-t.y)*(e.x-t.x)>(e.y-t.y)*(n.x-t.x)}function W(t){let e=0;for(let n,i,r=0,o=t.length,s=o-1;r<o;s=r++)n=t[r],i=t[s],e+=(i.x-n.x)*(n.y+i.y);return e}function q(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function X(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,n,i,r)=>{const o=i||r;return e[n]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let Y=null;function Z(t){if(null==Y){const e=t.navigator?t.navigator.userAgent:null;Y=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Y}function J(t){try{const n=e[t];return n.setItem("_mapbox_test_",1),n.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function K(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}const Q="mapbox-tiles";let tt,et,nt=500,it=50;function rt(){try{return e.caches}catch(t){}}function ot(){rt()&&!tt&&(tt=e.caches.open(Q))}function st(t){const e=t.indexOf("?");if(e<0)return t;const n=function(t){const e=t.indexOf("?");return e>0?t.slice(e+1).split("&"):[]}(t),i=n.filter((t=>{const e=t.split("=");return"language"===e[0]||"worldview"===e[0]}));return i.length?`${t.slice(0,e)}?${i.join("&")}`:t.slice(0,e)}let at=1/0;const lt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(lt);class ct extends Error{constructor(t,e,n){401===e&&xt(n)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ut=q()?()=>self.worker&&self.worker.referrer:()=>("blob:"===e.location.protocol?e.parent:e).location.href,ht=function(t,n){if(!(/^file:/.test(i=t.url)||/^file:/.test(ut())&&!/^\w+:/.test(i))){if(e.fetch&&e.Request&&e.AbortController&&e.Request.prototype.hasOwnProperty("signal"))return function(t,n){const i=new e.AbortController,r=new e.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:ut(),referrerPolicy:t.referrerPolicy,signal:i.signal});let o=!1,s=!1;const a=(l=r.url).indexOf("sku=")>0&&xt(l);var l;"json"===t.type&&r.headers.set("Accept","application/json");const c=(i,o,l)=>{if(s)return;if(i&&"SecurityError"!==i.message&&$(i.toString()),o&&l)return u(o);const c=Date.now();e.fetch(r).then((e=>{if(e.ok){const t=a?e.clone():null;return u(e,t,c)}return n(new ct(e.statusText,e.status,t.url))})).catch((e=>{"AbortError"!==e.name&&n(new Error(`${e.message} ${t.url}`))}))},u=(i,a,l)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{s||(a&&l&&function(t,n,i){if(ot(),!tt)return;const r={status:n.status,statusText:n.statusText,headers:new e.Headers};n.headers.forEach(((t,e)=>r.headers.set(e,t)));const o=X(n.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&r.headers.set("Expires",new Date(i+1e3*o["max-age"]).toUTCString());const s=r.headers.get("Expires");s&&(new Date(s).getTime()-i<42e4||function(t,e){if(void 0===et)try{new Response(new ReadableStream),et=!0}catch(t){et=!1}et?e(t.body):t.blob().then(e)}(n,(n=>{const i=new e.Response(n,r);ot(),tt&&tt.then((e=>e.put(st(t.url),i))).catch((t=>$(t.message)))})))}(r,a,l),o=!0,n(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{s||n(new Error(t.message))}))};return a?function(t,e){if(ot(),!tt)return e(null);const n=st(t.url);tt.then((t=>{t.match(n).then((i=>{const r=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),n=X(t.headers.get("Cache-Control")||"");return e>Date.now()&&!n["no-cache"]}(i);t.delete(n),r&&t.put(n,i.clone()),e(null,i,r)})).catch(e)})).catch(e)}(r,c):c(null,null),{cancel:()=>{s=!0,o||i.abort()}}}(t,n);if(q()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,n,void 0,!0)}var i;return function(t,n){const i=new e.XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{n(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let e=i.response;if("json"===t.type)try{e=JSON.parse(i.response)}catch(t){return n(t)}n(null,e,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else n(new ct(i.statusText,i.status,t.url))},i.send(t.body),{cancel:()=>i.abort()}}(t,n)},dt=function(t,e){return ht(R(t,{type:"arrayBuffer"}),e)};function pt(t){const n=e.document.createElement("a");return n.href=t,n.protocol===e.document.location.protocol&&n.host===e.document.location.host}const ft="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let mt,gt;mt=[],gt=0;const _t=function(t,n){if(o.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),gt>=r.MAX_PARALLEL_IMAGE_REQUESTS){const e={requestParameters:t,callback:n,cancelled:!1,cancel(){this.cancelled=!0}};return mt.push(e),e}gt++;let i=!1;const s=()=>{if(!i)for(i=!0,gt--;mt.length&&gt<r.MAX_PARALLEL_IMAGE_REQUESTS;){const t=mt.shift(),{requestParameters:e,callback:n,cancelled:i}=t;i||(t.cancel=_t(e,n).cancel)}},a=dt(t,((t,i,r,o)=>{s(),t?n(t):i&&(e.createImageBitmap?function(t,n){const i=new e.Blob([new Uint8Array(t)],{type:"image/png"});e.createImageBitmap(i).then((t=>{n(null,t)})).catch((t=>{n(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((t,e)=>n(t,e,r,o))):function(t,n){const i=new e.Image,r=e.URL;i.onload=()=>{n(null,i),r.revokeObjectURL(i.src),i.onload=null,e.requestAnimationFrame((()=>{i.src=ft}))},i.onerror=()=>n(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new e.Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?r.createObjectURL(o):ft}(i,((t,e)=>n(t,e,r,o))))}));return{cancel:()=>{a.cancel(),s()}}},yt="NO_ACCESS_TOKEN";function vt(t){return 0===t.indexOf("mapbox:")}function xt(t){return r.API_URL_REGEX.test(t)}function bt(t){return r.API_CDN_URL_REGEX.test(t)}function Tt(t){return r.API_STYLE_REGEX.test(t)&&!Et(t)}function Et(t){return r.API_SPRITE_REGEX.test(t)}const St=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function wt(t){const e=t.match(St);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function At(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const Mt="mapbox.eventData";function Ct(t){if(!t)return null;const n=t.split(".");if(!n||3!==n.length)return null;try{return JSON.parse(decodeURIComponent(e.atob(n[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class It{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const n=Ct(r.ACCESS_TOKEN);let i="";return i=n&&n.u?e.btoa(encodeURIComponent(n.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):r.ACCESS_TOKEN||"",t?`${Mt}.${t}:${i}`:`${Mt}:${i}`}fetchEventData(){const t=J("localStorage"),n=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{const t=e.localStorage.getItem(n);t&&(this.eventData=JSON.parse(t));const r=e.localStorage.getItem(i);r&&(this.anonId=r)}catch(t){$("Unable to read from LocalStorage")}}saveEventData(){const t=J("localStorage"),n=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{e.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&e.localStorage.setItem(n,JSON.stringify(this.eventData))}catch(t){$("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,n,i){if(!r.EVENTS_URL)return;const o=wt(r.EVENTS_URL);o.params.push(`access_token=${i||r.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=e?R(s,e):s,l={url:At(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=function(t,e){return ht(R(t,{method:"POST"}),e)}(l,(t=>{this.pendingRequest=null,n(t),this.saveEventData(),this.processRequests(i)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const Pt=new class extends It{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){r.EVENTS_URL&&r.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>vt(t)||xt(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=Ct(r.ACCESS_TOKEN),i=e?e.u:r.ACCESS_TOKEN;let o=i!==this.eventData.tokenU;F(this.anonId)||(this.anonId=B(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(s),n=(s-this.eventData.lastSuccess)/864e5;o=o||n>=1||n<-1||t.getDate()!==e.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:h,"enabled.telemetry":!1,userId:this.anonId},(t=>{t||(this.eventData.lastSuccess=s,this.eventData.tokenU=i)}),t):this.processRequests()}},Lt=Pt.postTurnstileEvent.bind(Pt),Rt=new class extends It{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,n,i){this.skuToken=e,this.errorCb=i,r.EVENTS_URL&&(n||r.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(yt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),F(this.anonId)||(this.anonId=B()),this.postEvent(i,{sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:h,skuToken:this.skuToken,userId:this.anonId},(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t))}},Ot=Rt.postMapLoadEvent.bind(Rt),Dt=new class extends It{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){r.EVENTS_URL&&(t||r.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:i,performanceData:r}=this.queue.shift(),o=function(t){const i=e.performance.getEntriesByType("resource"),r=e.performance.getEntriesByType("mark"),o=function(t){const e={};if(t)for(const n in t)if("other"!==n)for(const i of t[n]){const t=`${n}ResolveRangeMin`,r=`${n}ResolveRangeMax`,o=`${n}RequestCount`,s=`${n}RequestCachedCount`;e[t]=Math.min(e[t]||1/0,i.startTime),e[r]=Math.max(e[r]||-1/0,i.responseEnd);const a=t=>{void 0===e[t]&&(e[t]=0),++e[t]};void 0!==i.transferSize&&0===i.transferSize&&a(s),a(o)}return e}(function(t,e){const n={};if(t)for(const i of t){const t=e(i);void 0===n[t]&&(n[t]=[]),n[t].push(i)}return n}(i,Gt)),s=e.devicePixelRatio,a=e.navigator.connection||e.navigator.mozConnection||e.navigator.webkitConnection,l={counters:[],metadata:[],attributes:[]},c=(t,e,n)=>{null!=n&&t.push({name:e,value:n.toString()})};for(const t in o)c(l.counters,t,o[t]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(c(l.counters,"interactionRangeMin",t.interactionRange[0]),c(l.counters,"interactionRangeMax",t.interactionRange[1])),r)for(const t of Object.keys(kt)){const e=kt[t],n=r.find((t=>t.name===e));n&&c(l.counters,e,n.startTime)}return c(l.counters,"visibilityHidden",t.visibilityHidden),c(l.attributes,"style",function(t){if(t)for(const e of t){const t=e.name.split("?")[0];if(Tt(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(i)),c(l.attributes,"terrainEnabled",t.terrainEnabled?"true":"false"),c(l.attributes,"fogEnabled",t.fogEnabled?"true":"false"),c(l.attributes,"projection",t.projection),c(l.attributes,"zoom",t.zoom),c(l.metadata,"devicePixelRatio",s),c(l.metadata,"connectionEffectiveType",a?a.effectiveType:void 0),c(l.metadata,"navigatorUserAgent",e.navigator.userAgent),c(l.metadata,"screenWidth",e.screen.width),c(l.metadata,"screenHeight",e.screen.height),c(l.metadata,"windowWidth",e.innerWidth),c(l.metadata,"windowHeight",e.innerHeight),c(l.metadata,"mapWidth",t.width/s),c(l.metadata,"mapHeight",t.height/s),c(l.metadata,"webglRenderer",t.renderer),c(l.metadata,"webglVendor",t.vendor),c(l.metadata,"sdkVersion",n),c(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(r);for(const t of o.metadata);for(const t of o.counters);for(const t of o.attributes);this.postEvent(i,o,(()=>{}),t)}},Bt=Dt.postPerformanceEvent.bind(Dt),Nt=new class extends It{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,n,i){if(!r.API_URL||!r.SESSION_PATH)return;const o=wt(r.API_URL+r.SESSION_PATH);o.params.push(`sku=${e||""}`),o.params.push(`access_token=${i||r.ACCESS_TOKEN||""}`);const s={url:At(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(t,e){return ht(R(t,{method:"GET"}),e)}(s,(t=>{this.pendingRequest=null,n(t),this.saveEventData(),this.processRequests(i)}))}getSessionAPI(t,e,n,i){this.skuToken=e,this.errorCb=i,r.SESSION_PATH&&r.API_URL&&(n||r.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(yt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:n}=this.queue.shift();e&&this.success[e]||this.getSession(n,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}},Ft=Nt.getSessionAPI.bind(Nt),Ut=new Set,kt={create:"create",load:"load",fullLoad:"fullLoad"},zt={mark(t){e.performance.mark(t)},measure(t,n,i){e.performance.measure(t,n,i)}};function Gt(t){const e=t.name.split("?")[0];return bt(e)&&e.includes("mapbox-gl.js")?"javascript":bt(e)&&e.includes("mapbox-gl.css")?"css":function(t){return r.API_FONTS_REGEX.test(t)}(e)?"fontRange":Et(e)?"sprite":Tt(e)?"style":function(t){return r.API_TILEJSON_REGEX.test(t)}(e)?"tilejson":"other"}const Vt=e.performance;function jt(t){const e=t?t.url.toString():void 0;return Vt.getEntriesByName(e)}let $t,Ht,Wt,qt;const Xt={now:()=>void 0!==Wt?Wt:e.performance.now(),setNow(t){Wt=t},restoreNow(){Wt=void 0},frame(t){const n=e.requestAnimationFrame(t);return{cancel:()=>e.cancelAnimationFrame(n)}},getImageData(t,n=0){const{width:i,height:r}=t;qt||(qt=e.document.createElement("canvas"));const o=qt.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return(i>qt.width||r>qt.height)&&(qt.width=i,qt.height=r),o.clearRect(-n,-n,i+2*n,r+2*n),o.drawImage(t,0,0,i,r),o.getImageData(-n,-n,i+2*n,r+2*n)},resolveURL:t=>($t||($t=e.document.createElement("a")),$t.href=t,$t.href),get devicePixelRatio(){return e.devicePixelRatio},get prefersReducedMotion(){return!!e.matchMedia&&(null==Ht&&(Ht=e.matchMedia("(prefers-reduced-motion: reduce)")),Ht.matches)}};function Yt(t,e,n){n[t]&&-1!==n[t].indexOf(e)||(n[t]=n[t]||[],n[t].push(e))}function Zt(t,e,n){if(n&&n[t]){const i=n[t].indexOf(e);-1!==i&&n[t].splice(i,1)}}class Jt{constructor(t,e={}){R(this,e),this.type=t}}class Kt extends Jt{constructor(t,e={}){super("error",R({error:t},e))}}class Qt{on(t,e){return this._listeners=this._listeners||{},Yt(t,e,this._listeners),this}off(t,e){return Zt(t,e,this._listeners),Zt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Yt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new Jt(t,e||{}));const n=t.type;if(this.listens(n)){t.target=this;const e=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const n of e)n.call(this,t);const i=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const e of i)Zt(n,e,this._oneTimeListeners),e.call(this,t);const r=this._eventedParent;r&&(R(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(t))}return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var te=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"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":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"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"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"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"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"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":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"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","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","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"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"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"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"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"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function ee(t,...e){for(const n of e)for(const e in n)t[e]=n[e];return t}function ne(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function ie(t){if(Array.isArray(t))return t.map(ie);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const n in t)e[n]=ie(t[n]);return e}return ne(t)}class re extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}var oe=re;class se{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,n]of e)this.bindings[t]=n}concat(t){return new se(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var ae=se;const le={kind:"null"},ce={kind:"number"},ue={kind:"string"},he={kind:"boolean"},de={kind:"color"},pe={kind:"object"},fe={kind:"value"},me={kind:"collator"},ge={kind:"formatted"},_e={kind:"resolvedImage"};function ye(t,e){return{kind:"array",itemType:t,N:e}}function ve(t){if("array"===t.kind){const e=ve(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const xe=[le,ce,ue,he,de,ge,pe,ye(fe),_e];function be(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!be(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of xe)if(!be(t,e))return null}return`Expected ${ve(t)} but found ${ve(e)} instead.`}function Te(t,e){return e.some((e=>e.kind===t.kind))}function Ee(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}var Se,we={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 Ae(t){return(t=Math.round(t))<0?0:t>255?255:t}function Me(t){return Ae("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function Ce(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function Ie(t,e,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?t+(e-t)*n*6:2*n<1?e:3*n<2?t+(e-t)*(2/3-n)*6:t}try{Se={}.parseCSSColor=function(t){var e,n=t.replace(/ /g,"").toLowerCase();if(n in we)return we[n].slice();if("#"===n[0])return 4===n.length?(e=parseInt(n.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===n.length&&(e=parseInt(n.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var i=n.indexOf("("),r=n.indexOf(")");if(-1!==i&&r+1===n.length){var o=n.substr(0,i),s=n.substr(i+1,r-(i+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=Ce(s.pop());case"rgb":return 3!==s.length?null:[Me(s[0]),Me(s[1]),Me(s[2]),a];case"hsla":if(4!==s.length)return null;a=Ce(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=Ce(s[1]),u=Ce(s[2]),h=u<=.5?u*(c+1):u+c-u*c,d=2*u-h;return[Ae(255*Ie(d,h,l+1/3)),Ae(255*Ie(d,h,l)),Ae(255*Ie(d,h,l-1/3)),a];default:return null}}return null}}catch(t){}class Pe{constructor(t,e,n,i=1){this.r=t,this.g=e,this.b=n,this.a=i}static parse(t){if(!t)return;if(t instanceof Pe)return t;if("string"!=typeof t)return;const e=Se(t);return e?new Pe(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,n,i]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(n)},${i})`}toArray(){const{r:t,g:e,b:n,a:i}=this;return 0===i?[0,0,0,0]:[255*t/i,255*e/i,255*n/i,i]}toArray01(){const{r:t,g:e,b:n,a:i}=this;return 0===i?[0,0,0,0]:[t/i,e/i,n/i,i]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:n,a:i}=this;return[t,e,n,i]}}Pe.black=new Pe(0,0,0,1),Pe.white=new Pe(1,1,1,1),Pe.transparent=new Pe(0,0,0,0),Pe.red=new Pe(1,0,0,1),Pe.blue=new Pe(0,0,1,1);var Le=Pe;class Re{constructor(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Oe{constructor(t,e,n,i,r){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=n,this.fontStack=i,this.textColor=r}}class De{constructor(t){this.sections=t}static fromString(t){return new De([new Oe(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof De?t:De.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const n={};e.fontStack&&(n["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(n["font-scale"]=e.scale),e.textColor&&(n["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(n)}return t}}class Be{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Be({name:t,available:!1}):null}serialize(){return["image",this.name]}}function Ne(t,e,n,i){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===i||"number"==typeof i&&i>=0&&i<=1?null:`Invalid rgba value [${[t,e,n,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof i?[t,e,n,i]:[t,e,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Fe(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof Le)return!0;if(t instanceof Re)return!0;if(t instanceof De)return!0;if(t instanceof Be)return!0;if(Array.isArray(t)){for(const e of t)if(!Fe(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Fe(t[e]))return!1;return!0}return!1}function Ue(t){if(null===t)return le;if("string"==typeof t)return ue;if("boolean"==typeof t)return he;if("number"==typeof t)return ce;if(t instanceof Le)return de;if(t instanceof Re)return me;if(t instanceof De)return ge;if(t instanceof Be)return _e;if(Array.isArray(t)){const e=t.length;let n;for(const e of t){const t=Ue(e);if(n){if(n===t)continue;n=fe;break}n=t}return ye(n||fe,e)}return pe}function ke(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Le||t instanceof De||t instanceof Be?t.toString():JSON.stringify(t)}class ze{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Fe(t[1]))return e.error("invalid value");const n=t[1];let i=Ue(n);const r=e.expectedType;return"array"!==i.kind||0!==i.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(i=r),new ze(i,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Le?["rgba"].concat(this.value.toArray()):this.value instanceof De?this.value.serialize():this.value}}var Ge=ze,Ve=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const je={string:ue,number:ce,boolean:he,object:pe};class $e{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let n,i=1;const r=t[0];if("array"===r){let r,o;if(t.length>2){const n=t[1];if("string"!=typeof n||!(n in je)||"object"===n)return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=je[n],i++}else r=fe;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);o=t[2],i++}n=ye(r,o)}else n=je[r];const o=[];for(;i<t.length;i++){const n=e.parse(t[i],i,fe);if(!n)return null;o.push(n)}return new $e(n,o)}evaluate(t){for(let e=0;e<this.args.length;e++){const n=this.args[e].evaluate(t);if(!be(this.type,Ue(n)))return n;if(e===this.args.length-1)throw new Ve(`Expected value to be of type ${ve(this.type)}, but found ${ve(Ue(n))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const n=t.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){e.push(n.kind);const i=t.N;("number"==typeof i||this.args.length>1)&&e.push(i)}}return e.concat(this.args.map((t=>t.serialize())))}}var He=$e;class We{constructor(t){this.type=ge,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const n=t[1];if(!Array.isArray(n)&&"object"==typeof n)return e.error("First argument must be an image or text section.");const i=[];let r=!1;for(let n=1;n<=t.length-1;++n){const o=t[n];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let t=null;if(o["font-scale"]&&(t=e.parse(o["font-scale"],1,ce),!t))return null;let n=null;if(o["text-font"]&&(n=e.parse(o["text-font"],1,ye(ue)),!n))return null;let s=null;if(o["text-color"]&&(s=e.parse(o["text-color"],1,de),!s))return null;const a=i[i.length-1];a.scale=t,a.font=n,a.textColor=s}else{const o=e.parse(t[n],1,fe);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,i.push({content:o,scale:null,font:null,textColor:null})}}return new We(i)}evaluate(t){return new De(this.sections.map((e=>{const n=e.content.evaluate(t);return Ue(n)===_e?new Oe("",n,null,null,null):new Oe(ke(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const n={};e.scale&&(n["font-scale"]=e.scale.serialize()),e.font&&(n["text-font"]=e.font.serialize()),e.textColor&&(n["text-color"]=e.textColor.serialize()),t.push(n)}return t}}class qe{constructor(t){this.type=_e,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const n=e.parse(t[1],1,ue);return n?new qe(n):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),n=Be.fromString(e);return n&&t.availableImages&&(n.available=t.availableImages.indexOf(e)>-1),n}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Xe={"to-boolean":he,"to-color":de,"to-number":ce,"to-string":ue};class Ye{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const n=t[0];if(("to-boolean"===n||"to-string"===n)&&2!==t.length)return e.error("Expected one argument.");const i=Xe[n],r=[];for(let n=1;n<t.length;n++){const i=e.parse(t[n],n,fe);if(!i)return null;r.push(i)}return new Ye(i,r)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,n;for(const i of this.args){if(e=i.evaluate(t),n=null,e instanceof Le)return e;if("string"==typeof e){const n=t.parseColor(e);if(n)return n}else if(Array.isArray(e)&&(n=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Ne(e[0],e[1],e[2],e[3]),!n))return new Le(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ve(n||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const n of this.args){if(e=n.evaluate(t),null===e)return 0;const i=Number(e);if(!isNaN(i))return i}throw new Ve(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?De.fromString(ke(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Be.fromString(ke(this.args[0].evaluate(t))):ke(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new We([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new qe(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Ze=Ye;const Je=["Unknown","Point","LineString","Polygon"];var Ke=class{constructor(){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}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Je[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||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:n,y:i}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*e-t[0])+this.featureDistanceData.bearing[1]*(i*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Le.parse(t)),e}};class Qe{constructor(t,e,n,i){this.name=t,this.type=e,this._evaluate=n,this.args=i}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const n=t[0],i=Qe.definitions[n];if(!i)return e.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(i)?i[0]:i.type,o=Array.isArray(i)?[[i[1],i[2]]]:i.overloads,s=o.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[i,o]of s){a=new Mn(e.registry,e.path,null,e.scope);const s=[];let l=!1;for(let e=1;e<t.length;e++){const n=t[e],r=Array.isArray(i)?i[e-1]:i.type,o=a.parse(n,1+s.length,r);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(i)&&i.length!==s.length)a.error(`Expected ${i.length} arguments, but found ${s.length} instead.`);else{for(let t=0;t<s.length;t++){const e=Array.isArray(i)?i[t]:i.type,n=s[t];a.concat(t+1).checkSubtype(e,n.type)}if(0===a.errors.length)return new Qe(n,r,o,s)}}if(1===s.length)e.errors.push(...a.errors);else{const n=(s.length?s:o).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(ve).join(", ")})`:`(${ve(e.type)}...)`;var e})).join(" | "),i=[];for(let n=1;n<t.length;n++){const r=e.parse(t[n],1+i.length);if(!r)return null;i.push(ve(r.type))}e.error(`Expected arguments of type ${n}, but found (${i.join(", ")}) instead.`)}return null}static register(t,e){Qe.definitions=e;for(const n in e)t[n]=Qe}}var tn=Qe;class en{constructor(t,e,n){this.type=me,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const n=t[1];if("object"!=typeof n||Array.isArray(n))return e.error("Collator options argument must be an object.");const i=e.parse(void 0!==n["case-sensitive"]&&n["case-sensitive"],1,he);if(!i)return null;const r=e.parse(void 0!==n["diacritic-sensitive"]&&n["diacritic-sensitive"],1,he);if(!r)return null;let o=null;return n.locale&&(o=e.parse(n.locale,1,ue),!o)?null:new en(i,r,o)}evaluate(t){return new Re(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}const nn=8192;function rn(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function on(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function sn(t,e){const n=(180+t[0])/360,i=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,r=Math.pow(2,e.z);return[Math.round(n*r*nn),Math.round(i*r*nn)]}function an(t,e,n){const i=t[0]-e[0],r=t[1]-e[1],o=t[0]-n[0],s=t[1]-n[1];return i*s-o*r==0&&i*o<=0&&r*s<=0}function ln(t,e){let n=!1;for(let s=0,a=e.length;s<a;s++){const a=e[s];for(let e=0,s=a.length;e<s-1;e++){if(an(t,a[e],a[e+1]))return!1;(r=a[e])[1]>(i=t)[1]!=(o=a[e+1])[1]>i[1]&&i[0]<(o[0]-r[0])*(i[1]-r[1])/(o[1]-r[1])+r[0]&&(n=!n)}}var i,r,o;return n}function cn(t,e){for(let n=0;n<e.length;n++)if(ln(t,e[n]))return!0;return!1}function un(t,e,n,i){const r=i[0]-n[0],o=i[1]-n[1],s=(t[0]-n[0])*o-r*(t[1]-n[1]),a=(e[0]-n[0])*o-r*(e[1]-n[1]);return s>0&&a<0||s<0&&a>0}function hn(t,e,n){for(const c of n)for(let n=0;n<c.length-1;++n)if(0!=(a=[(s=c[n+1])[0]-(o=c[n])[0],s[1]-o[1]])[0]*(l=[(r=e)[0]-(i=t)[0],r[1]-i[1]])[1]-a[1]*l[0]&&un(i,r,o,s)&&un(o,s,i,r))return!0;var i,r,o,s,a,l;return!1}function dn(t,e){for(let n=0;n<t.length;++n)if(!ln(t[n],e))return!1;for(let n=0;n<t.length-1;++n)if(hn(t[n],t[n+1],e))return!1;return!0}function pn(t,e){for(let n=0;n<e.length;n++)if(dn(t,e[n]))return!0;return!1}function fn(t,e,n){const i=[];for(let r=0;r<t.length;r++){const o=[];for(let i=0;i<t[r].length;i++){const s=sn(t[r][i],n);rn(e,s),o.push(s)}i.push(o)}return i}function mn(t,e,n){const i=[];for(let r=0;r<t.length;r++){const o=fn(t[r],e,n);i.push(o)}return i}function gn(t,e,n,i){if(t[0]<n[0]||t[0]>n[2]){const e=.5*i;let r=t[0]-n[0]>e?-i:n[0]-t[0]>e?i:0;0===r&&(r=t[0]-n[2]>e?-i:n[2]-t[0]>e?i:0),t[0]+=r}rn(e,t)}function _n(t,e,n,i){const r=Math.pow(2,i.z)*nn,o=[i.x*nn,i.y*nn],s=[];if(!t)return s;for(const i of t)for(const t of i){const i=[t.x+o[0],t.y+o[1]];gn(i,e,n,r),s.push(i)}return s}function yn(t,e,n,i){const r=Math.pow(2,i.z)*nn,o=[i.x*nn,i.y*nn],s=[];if(!t)return s;for(const n of t){const t=[];for(const i of n){const n=[i.x+o[0],i.y+o[1]];rn(e,n),t.push(n)}s.push(t)}if(e[2]-e[0]<=r/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of s)for(const i of t)gn(i,e,n,r)}var a;return s}class vn{constructor(t,e){this.type=he,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Fe(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const n=e.features[t].geometry.type;if("Polygon"===n||"MultiPolygon"===n)return new vn(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new vn(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new vn(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],r=t.canonicalID();if(!r)return!1;if("Polygon"===e.type){const o=fn(e.coordinates,i,r),s=_n(t.geometry(),n,i,r);if(!on(n,i))return!1;for(const t of s)if(!ln(t,o))return!1}if("MultiPolygon"===e.type){const o=mn(e.coordinates,i,r),s=_n(t.geometry(),n,i,r);if(!on(n,i))return!1;for(const t of s)if(!cn(t,o))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],r=t.canonicalID();if(!r)return!1;if("Polygon"===e.type){const o=fn(e.coordinates,i,r),s=yn(t.geometry(),n,i,r);if(!on(n,i))return!1;for(const t of s)if(!dn(t,o))return!1}if("MultiPolygon"===e.type){const o=mn(e.coordinates,i,r),s=yn(t.geometry(),n,i,r);if(!on(n,i))return!1;for(const t of s)if(!pn(t,o))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var xn=vn;function bn(t){if(t instanceof tn){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof xn)return!1;let e=!0;return t.eachChild((t=>{e&&!bn(t)&&(e=!1)})),e}function Tn(t){if(t instanceof tn&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Tn(t)&&(e=!1)})),e}function En(t,e){if(t instanceof tn&&e.indexOf(t.name)>=0)return!1;let n=!0;return t.eachChild((t=>{n&&!En(t,e)&&(n=!1)})),n}class Sn{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const n=t[1];return e.scope.has(n)?new Sn(n,e.scope.get(n)):e.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var wn=Sn;class An{constructor(t,e=[],n,i=new ae,r=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=r,this.expectedType=n}parse(t,e,n,i,r={}){return e?this.concat(e,n,i)._parse(t,r):this._parse(t,r)}_parse(t,e){function n(t,e,n){return"assert"===n?new He(e,[t]):"coerce"===n?new Ze(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const i=t[0];if("string"!=typeof i)return this.error(`Expression name must be a string, but found ${typeof i} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[i];if(r){let i=r.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,r=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==r.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(t,r))return null}else i=n(i,t,e.typeAnnotation||"coerce");else i=n(i,t,e.typeAnnotation||"assert")}if(!(i instanceof Ge)&&"resolvedImage"!==i.type.kind&&Cn(i)){const e=new Ke;try{i=new Ge(i.type,i.evaluate(e))}catch(t){return this.error(t.message),null}}return i}return this.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,n){const i="number"==typeof t?this.path.concat(t):this.path,r=n?this.scope.concat(n):this.scope;return new An(this.registry,i,e||null,r,this.errors)}error(t,...e){const n=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new oe(n,t))}checkSubtype(t,e){const n=be(t,e);return n&&this.error(n),n}}var Mn=An;function Cn(t){if(t instanceof wn)return Cn(t.boundExpression);if(t instanceof tn&&"error"===t.name)return!1;if(t instanceof en)return!1;if(t instanceof xn)return!1;const e=t instanceof Ze||t instanceof He;let n=!0;return t.eachChild((t=>{n=e?n&&Cn(t):n&&t instanceof Ge})),!!n&&bn(t)&&En(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function In(t,e){const n=t.length-1;let i,r,o=0,s=n,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),i=t[a],r=t[a+1],i<=e){if(a===n||e<r)return a;o=a+1}else{if(!(i>e))throw new Ve("Input is not a number.");s=a-1}return 0}class Pn{constructor(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const n=e.parse(t[1],1,ce);if(!n)return null;const i=[];let r=null;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);for(let n=1;n<t.length;n+=2){const o=1===n?-1/0:t[n],s=t[n+1],a=n,l=n+1;if("number"!=typeof o)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(i.length&&i[i.length-1][0]>=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,i.push([o,c])}return new Pn(r,n,i)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const i=this.input.evaluate(t);if(i<=e[0])return n[0].evaluate(t);const r=e.length;return i>=e[r-1]?n[r-1].evaluate(t):n[In(e,i)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var Ln=Pn;function Rn(t,e,n){return t*(1-n)+e*n}var On=Object.freeze({__proto__:null,array:function(t,e,n){return t.map(((t,i)=>Rn(t,e[i],n)))},color:function(t,e,n){return new Le(Rn(t.r,e.r,n),Rn(t.g,e.g,n),Rn(t.b,e.b,n),Rn(t.a,e.a,n))},number:Rn});const Dn=.95047,Bn=1.08883,Nn=4/29,Fn=6/29,Un=3*Fn*Fn,kn=Fn*Fn*Fn,zn=Math.PI/180,Gn=180/Math.PI;function Vn(t){return t>kn?Math.pow(t,1/3):t/Un+Nn}function jn(t){return t>Fn?t*t*t:Un*(t-Nn)}function $n(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Hn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Wn(t){const e=Hn(t.r),n=Hn(t.g),i=Hn(t.b),r=Vn((.4124564*e+.3575761*n+.1804375*i)/Dn),o=Vn((.2126729*e+.7151522*n+.072175*i)/1);return{l:116*o-16,a:500*(r-o),b:200*(o-Vn((.0193339*e+.119192*n+.9503041*i)/Bn)),alpha:t.a}}function qn(t){let e=(t.l+16)/116,n=isNaN(t.a)?e:e+t.a/500,i=isNaN(t.b)?e:e-t.b/200;return e=1*jn(e),n=Dn*jn(n),i=Bn*jn(i),new Le($n(3.2404542*n-1.5371385*e-.4985314*i),$n(-.969266*n+1.8760108*e+.041556*i),$n(.0556434*n-.2040259*e+1.0572252*i),t.alpha)}function Xn(t,e,n){const i=e-t;return t+n*(i>180||i<-180?i-360*Math.round(i/360):i)}const Yn={forward:Wn,reverse:qn,interpolate:function(t,e,n){return{l:Rn(t.l,e.l,n),a:Rn(t.a,e.a,n),b:Rn(t.b,e.b,n),alpha:Rn(t.alpha,e.alpha,n)}}},Zn={forward:function(t){const{l:e,a:n,b:i}=Wn(t),r=Math.atan2(i,n)*Gn;return{h:r<0?r+360:r,c:Math.sqrt(n*n+i*i),l:e,alpha:t.a}},reverse:function(t){const e=t.h*zn,n=t.c;return qn({l:t.l,a:Math.cos(e)*n,b:Math.sin(e)*n,alpha:t.alpha})},interpolate:function(t,e,n){return{h:Xn(t.h,e.h,n),c:Rn(t.c,e.c,n),l:Rn(t.l,e.l,n),alpha:Rn(t.alpha,e.alpha,n)}}};var Jn=Object.freeze({__proto__:null,hcl:Zn,lab:Yn});class Kn{constructor(t,e,n,i,r){this.type=t,this.operator=e,this.interpolation=n,this.input=i,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,n,i){let r=0;if("exponential"===t.name)r=Qn(e,t.base,n,i);else if("linear"===t.name)r=Qn(e,1,n,i);else if("cubic-bezier"===t.name){const o=t.controlPoints;r=new m(o[0],o[1],o[2],o[3]).solve(Qn(e,1,n,i))}return r}static parse(t,e){let[n,i,r,...o]=t;if(!Array.isArray(i)||0===i.length)return e.error("Expected an interpolation type expression.",1);if("linear"===i[0])i={name:"linear"};else if("exponential"===i[0]){const t=i[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);i={name:"exponential",base:t}}else{if("cubic-bezier"!==i[0])return e.error(`Unknown interpolation type ${String(i[0])}`,1,0);{const t=i.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);i={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(r=e.parse(r,2,ce),!r)return null;const s=[];let a=null;"interpolate-hcl"===n||"interpolate-lab"===n?a=de:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t<o.length;t+=2){const n=o[t],i=o[t+1],r=t+3,l=t+4;if("number"!=typeof n)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',r);if(s.length&&s[s.length-1][0]>=n)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(i,l,a);if(!c)return null;a=a||c.type,s.push([n,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Kn(a,n,i,r,s):e.error(`Type ${ve(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const i=this.input.evaluate(t);if(i<=e[0])return n[0].evaluate(t);const r=e.length;if(i>=e[r-1])return n[r-1].evaluate(t);const o=In(e,i),s=Kn.interpolationFactor(this.interpolation,i,e[o],e[o+1]),a=n[o].evaluate(t),l=n[o+1].evaluate(t);return"interpolate"===this.operator?On[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Zn.reverse(Zn.interpolate(Zn.forward(a),Zn.forward(l),s)):Yn.reverse(Yn.interpolate(Yn.forward(a),Yn.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function Qn(t,e,n,i){const r=i-n,o=t-n;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}var ti=Kn;class ei{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let n=null;const i=e.expectedType;i&&"value"!==i.kind&&(n=i);const r=[];for(const i of t.slice(1)){const t=e.parse(i,1+r.length,n,void 0,{typeAnnotation:"omit"});if(!t)return null;n=n||t.type,r.push(t)}const o=i&&r.some((t=>be(i,t.type)));return new ei(o?fe:n,r)}evaluate(t){let e,n=null,i=0;for(const r of this.args){if(i++,n=r.evaluate(t),n&&n instanceof Be&&!n.available&&(e||(e=n),n=null,i===this.args.length))return e;if(null!==n)break}return n}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var ni=ei;class ii{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const n=[];for(let i=1;i<t.length-1;i+=2){const r=t[i];if("string"!=typeof r)return e.error(`Expected string, but found ${typeof r} instead.`,i);if(/[^a-zA-Z0-9_]/.test(r))return e.error("Variable names must contain only alphanumeric characters or '_'.",i);const o=e.parse(t[i+1],i+1);if(!o)return null;n.push([r,o])}const i=e.parse(t[t.length-1],t.length-1,e.expectedType,n);return i?new ii(n,i):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,n]of this.bindings)t.push(e,n.serialize());return t.push(this.result.serialize()),t}}var ri=ii;class oi{constructor(t,e,n){this.type=t,this.index=e,this.input=n}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,ce),i=e.parse(t[2],2,ye(e.expectedType||fe));return n&&i?new oi(i.type.itemType,n,i):null}evaluate(t){const e=this.index.evaluate(t),n=this.input.evaluate(t);if(e<0)throw new Ve(`Array index out of bounds: ${e} < 0.`);if(e>=n.length)throw new Ve(`Array index out of bounds: ${e} > ${n.length-1}.`);if(e!==Math.floor(e))throw new Ve(`Array index must be an integer, but found ${e} instead.`);return n[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var si=oi;class ai{constructor(t,e){this.type=he,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,fe),i=e.parse(t[2],2,fe);return n&&i?Te(n.type,[he,ue,ce,le,fe])?new ai(n,i):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ve(n.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(null==n)return!1;if(!Ee(e,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${ve(Ue(e))} instead.`);if(!Ee(n,["string","array"]))throw new Ve(`Expected second argument to be of type array or string, but found ${ve(Ue(n))} instead.`);return n.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var li=ai;class ci{constructor(t,e,n){this.type=ce,this.needle=t,this.haystack=e,this.fromIndex=n}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,fe),i=e.parse(t[2],2,fe);if(!n||!i)return null;if(!Te(n.type,[he,ue,ce,le,fe]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ve(n.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ce);return r?new ci(n,i,r):null}return new ci(n,i)}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!Ee(e,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${ve(Ue(e))} instead.`);if(!Ee(n,["string","array"]))throw new Ve(`Expected second argument to be of type array or string, but found ${ve(Ue(n))} instead.`);if(this.fromIndex){const i=this.fromIndex.evaluate(t);return n.indexOf(e,i)}return n.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var ui=ci;class hi{constructor(t,e,n,i,r,o){this.inputType=t,this.type=e,this.input=n,this.cases=i,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let n,i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r={},o=[];for(let s=2;s<t.length-1;s+=2){let a=t[s];const l=t[s+1];Array.isArray(a)||(a=[a]);const c=e.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(n){if(c.checkSubtype(n,Ue(t)))return null}else n=Ue(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const u=e.parse(l,s,i);if(!u)return null;i=i||u.type,o.push(u)}const s=e.parse(t[1],1,fe);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,i);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(n,s.type)?null:new hi(n,i,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(Ue(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),n=[],i={};for(const t of e){const e=i[this.cases[t]];void 0===e?(i[this.cases[t]]=n.length,n.push([this.cases[t],[t]])):n[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,i]of n)t.push(1===i.length?r(i[0]):i.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}var di=hi;class pi{constructor(t,e,n){this.type=t,this.branches=e,this.otherwise=n}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i=[];for(let r=1;r<t.length-1;r+=2){const o=e.parse(t[r],r,he);if(!o)return null;const s=e.parse(t[r+1],r+1,n);if(!s)return null;i.push([o,s]),n=n||s.type}const r=e.parse(t[t.length-1],t.length-1,n);return r?new pi(n,i,r):null}evaluate(t){for(const[e,n]of this.branches)if(e.evaluate(t))return n.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,n]of this.branches)t(e),t(n);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var fi=pi;class mi{constructor(t,e,n,i){this.type=t,this.input=e,this.beginIndex=n,this.endIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,fe),i=e.parse(t[2],2,ce);if(!n||!i)return null;if(!Te(n.type,[ye(fe),ue,fe]))return e.error(`Expected first argument to be of type array or string, but found ${ve(n.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ce);return r?new mi(n.type,n,i,r):null}return new mi(n.type,n,i)}evaluate(t){const e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);if(!Ee(e,["string","array"]))throw new Ve(`Expected first argument to be of type array or string, but found ${ve(Ue(e))} instead.`);if(this.endIndex){const i=this.endIndex.evaluate(t);return e.slice(n,i)}return e.slice(n)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var gi=mi;function _i(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function yi(t,e,n,i){return 0===i.compare(e,n)}function vi(t,e,n){const i="=="!==t&&"!="!==t;return class r{constructor(t,e,n){this.type=he,this.lhs=t,this.rhs=e,this.collator=n,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const n=t[0];let o=e.parse(t[1],1,fe);if(!o)return null;if(!_i(n,o.type))return e.concat(1).error(`"${n}" comparisons are not supported for type '${ve(o.type)}'.`);let s=e.parse(t[2],2,fe);if(!s)return null;if(!_i(n,s.type))return e.concat(2).error(`"${n}" comparisons are not supported for type '${ve(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${ve(o.type)}' and '${ve(s.type)}'.`);i&&("value"===o.type.kind&&"value"!==s.type.kind?o=new He(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new He(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,me),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(i&&this.hasUntypedArgument){const e=Ue(o),n=Ue(s);if(e.kind!==n.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ve(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${n.kind}) instead.`)}if(this.collator&&!i&&this.hasUntypedArgument){const t=Ue(o),n=Ue(s);if("string"!==t.kind||"string"!==n.kind)return e(r,o,s)}return this.collator?n(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const xi=vi("==",(function(t,e,n){return e===n}),yi),bi=vi("!=",(function(t,e,n){return e!==n}),(function(t,e,n,i){return!yi(0,e,n,i)})),Ti=vi("<",(function(t,e,n){return e<n}),(function(t,e,n,i){return i.compare(e,n)<0})),Ei=vi(">",(function(t,e,n){return e>n}),(function(t,e,n,i){return i.compare(e,n)>0})),Si=vi("<=",(function(t,e,n){return e<=n}),(function(t,e,n,i){return i.compare(e,n)<=0})),wi=vi(">=",(function(t,e,n){return e>=n}),(function(t,e,n,i){return i.compare(e,n)>=0}));class Ai{constructor(t,e,n,i,r,o){this.type=ue,this.number=t,this.locale=e,this.currency=n,this.unit=i,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const n=e.parse(t[1],1,ce);if(!n)return null;const i=t[2];if("object"!=typeof i||Array.isArray(i))return e.error("NumberFormat options argument must be an object.");let r=null;if(i.locale&&(r=e.parse(i.locale,1,ue),!r))return null;let o=null;if(i.currency&&(o=e.parse(i.currency,1,ue),!o))return null;let s=null;if(i.unit&&(s=e.parse(i.unit,1,ue),!s))return null;let a=null;if(i["min-fraction-digits"]&&(a=e.parse(i["min-fraction-digits"],1,ce),!a))return null;let l=null;return i["max-fraction-digits"]&&(l=e.parse(i["max-fraction-digits"],1,ce),!l)?null:new Ai(n,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Mi{constructor(t){this.type=ce,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const n=e.parse(t[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?e.error(`Expected argument of type string or array, but found ${ve(n.type)} instead.`):new Mi(n):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new Ve(`Expected value to be of type string or array, but found ${ve(Ue(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Ci={"==":xi,"!=":bi,">":Ei,"<":Ti,">=":wi,"<=":Si,array:He,at:si,boolean:He,case:fi,coalesce:ni,collator:en,format:We,image:qe,in:li,"index-of":ui,interpolate:ti,"interpolate-hcl":ti,"interpolate-lab":ti,length:Mi,let:ri,literal:Ge,match:di,number:He,"number-format":Ai,object:He,slice:gi,step:Ln,string:He,"to-boolean":Ze,"to-color":Ze,"to-number":Ze,"to-string":Ze,var:wn,within:xn};function Ii(t,[e,n,i,r]){e=e.evaluate(t),n=n.evaluate(t),i=i.evaluate(t);const o=r?r.evaluate(t):1,s=Ne(e,n,i,o);if(s)throw new Ve(s);return new Le(e/255*o,n/255*o,i/255*o,o)}function Pi(t,e){return t in e}function Li(t,e){const n=e[t];return void 0===n?null:n}function Ri(t){return{type:t}}tn.register(Ci,{error:[{kind:"error"},[ue],(t,[e])=>{throw new Ve(e.evaluate(t))}],typeof:[ue,[fe],(t,[e])=>ve(Ue(e.evaluate(t)))],"to-rgba":[ye(ce,4),[de],(t,[e])=>e.evaluate(t).toArray()],rgb:[de,[ce,ce,ce],Ii],rgba:[de,[ce,ce,ce,ce],Ii],has:{type:he,overloads:[[[ue],(t,[e])=>Pi(e.evaluate(t),t.properties())],[[ue,pe],(t,[e,n])=>Pi(e.evaluate(t),n.evaluate(t))]]},get:{type:fe,overloads:[[[ue],(t,[e])=>Li(e.evaluate(t),t.properties())],[[ue,pe],(t,[e,n])=>Li(e.evaluate(t),n.evaluate(t))]]},"feature-state":[fe,[ue],(t,[e])=>Li(e.evaluate(t),t.featureState||{})],properties:[pe,[],t=>t.properties()],"geometry-type":[ue,[],t=>t.geometryType()],id:[fe,[],t=>t.id()],zoom:[ce,[],t=>t.globals.zoom],pitch:[ce,[],t=>t.globals.pitch||0],"distance-from-center":[ce,[],t=>t.distanceFromCenter()],"heatmap-density":[ce,[],t=>t.globals.heatmapDensity||0],"line-progress":[ce,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[ce,[],t=>t.globals.skyRadialProgress||0],accumulated:[fe,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ce,Ri(ce),(t,e)=>{let n=0;for(const i of e)n+=i.evaluate(t);return n}],"*":[ce,Ri(ce),(t,e)=>{let n=1;for(const i of e)n*=i.evaluate(t);return n}],"-":{type:ce,overloads:[[[ce,ce],(t,[e,n])=>e.evaluate(t)-n.evaluate(t)],[[ce],(t,[e])=>-e.evaluate(t)]]},"/":[ce,[ce,ce],(t,[e,n])=>e.evaluate(t)/n.evaluate(t)],"%":[ce,[ce,ce],(t,[e,n])=>e.evaluate(t)%n.evaluate(t)],ln2:[ce,[],()=>Math.LN2],pi:[ce,[],()=>Math.PI],e:[ce,[],()=>Math.E],"^":[ce,[ce,ce],(t,[e,n])=>Math.pow(e.evaluate(t),n.evaluate(t))],sqrt:[ce,[ce],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ce,[ce],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ce,[ce],(t,[e])=>Math.log(e.evaluate(t))],log2:[ce,[ce],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ce,[ce],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ce,[ce],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ce,[ce],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ce,[ce],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ce,[ce],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ce,[ce],(t,[e])=>Math.atan(e.evaluate(t))],min:[ce,Ri(ce),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ce,Ri(ce),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ce,[ce],(t,[e])=>Math.abs(e.evaluate(t))],round:[ce,[ce],(t,[e])=>{const n=e.evaluate(t);return n<0?-Math.round(-n):Math.round(n)}],floor:[ce,[ce],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[ce,[ce],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[he,[ue,fe],(t,[e,n])=>t.properties()[e.value]===n.value],"filter-id-==":[he,[fe],(t,[e])=>t.id()===e.value],"filter-type-==":[he,[ue],(t,[e])=>t.geometryType()===e.value],"filter-<":[he,[ue,fe],(t,[e,n])=>{const i=t.properties()[e.value],r=n.value;return typeof i==typeof r&&i<r}],"filter-id-<":[he,[fe],(t,[e])=>{const n=t.id(),i=e.value;return typeof n==typeof i&&n<i}],"filter->":[he,[ue,fe],(t,[e,n])=>{const i=t.properties()[e.value],r=n.value;return typeof i==typeof r&&i>r}],"filter-id->":[he,[fe],(t,[e])=>{const n=t.id(),i=e.value;return typeof n==typeof i&&n>i}],"filter-<=":[he,[ue,fe],(t,[e,n])=>{const i=t.properties()[e.value],r=n.value;return typeof i==typeof r&&i<=r}],"filter-id-<=":[he,[fe],(t,[e])=>{const n=t.id(),i=e.value;return typeof n==typeof i&&n<=i}],"filter->=":[he,[ue,fe],(t,[e,n])=>{const i=t.properties()[e.value],r=n.value;return typeof i==typeof r&&i>=r}],"filter-id->=":[he,[fe],(t,[e])=>{const n=t.id(),i=e.value;return typeof n==typeof i&&n>=i}],"filter-has":[he,[fe],(t,[e])=>e.value in t.properties()],"filter-has-id":[he,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[he,[ye(ue)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[he,[ye(fe)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[he,[ue,ye(fe)],(t,[e,n])=>n.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[he,[ue,ye(fe)],(t,[e,n])=>function(t,e,n,i){for(;n<=i;){const r=n+i>>1;if(e[r]===t)return!0;e[r]>t?i=r-1:n=r+1}return!1}(t.properties()[e.value],n.value,0,n.value.length-1)],all:{type:he,overloads:[[[he,he],(t,[e,n])=>e.evaluate(t)&&n.evaluate(t)],[Ri(he),(t,e)=>{for(const n of e)if(!n.evaluate(t))return!1;return!0}]]},any:{type:he,overloads:[[[he,he],(t,[e,n])=>e.evaluate(t)||n.evaluate(t)],[Ri(he),(t,e)=>{for(const n of e)if(n.evaluate(t))return!0;return!1}]]},"!":[he,[he],(t,[e])=>!e.evaluate(t)],"is-supported-script":[he,[ue],(t,[e])=>{const n=t.globals&&t.globals.isSupportedScript;return!n||n(e.evaluate(t))}],upcase:[ue,[ue],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ue,[ue],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ue,Ri(fe),(t,e)=>e.map((e=>ke(e.evaluate(t)))).join("")],"resolved-locale":[ue,[me],(t,[e])=>e.evaluate(t).resolvedLocale()]});var Oi=Ci;function Di(t){return{result:"success",value:t}}function Bi(t){return{result:"error",value:t}}function Ni(t){return"data-driven"===t["property-type"]}function Fi(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Ui(t){return!!t.expression&&t.expression.interpolated}function ki(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function zi(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Gi(t){return t}function Vi(t,e){const n="color"===e.type,i=t.stops&&"object"==typeof t.stops[0][0],r=i||!(i||void 0!==t.property),o=t.type||(Ui(e)?"exponential":"interval");if(n&&((t=ee({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Le.parse(t[1])]))),t.default=Le.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Jn[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=Wi;else if("interval"===o)s=Hi;else if("categorical"===o){s=$i,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=qi}if(i){const n={},i=[];for(let e=0;e<t.stops.length;e++){const r=t.stops[e],o=r[0].zoom;void 0===n[o]&&(n[o]={zoom:o,type:t.type,property:t.property,default:t.default,stops:[]},i.push(o)),n[o].stops.push([r[0].value,r[1]])}const r=[];for(const t of i)r.push([n[t].zoom,Vi(n[t],e)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:ti.interpolationFactor.bind(void 0,o),zoomStops:r.map((t=>t[0])),evaluate:({zoom:n},i)=>Wi({stops:r,base:t.base},e,n).evaluate(n,i)}}if(r){const n="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:n,interpolationFactor:ti.interpolationFactor.bind(void 0,n),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:n})=>s(t,e,n,a,l)}}return{kind:"source",evaluate(n,i){const r=i&&i.properties?i.properties[t.property]:void 0;return void 0===r?ji(t.default,e.default):s(t,e,r,a,l)}}}function ji(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:void 0}function $i(t,e,n,i,r){return ji(typeof n===r?i[n]:void 0,t.default,e.default)}function Hi(t,e,n){if("number"!==ki(n))return ji(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[i-1][0])return t.stops[i-1][1];const r=In(t.stops.map((t=>t[0])),n);return t.stops[r][1]}function Wi(t,e,n){const i=void 0!==t.base?t.base:1;if("number"!==ki(n))return ji(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[r-1][0])return t.stops[r-1][1];const o=In(t.stops.map((t=>t[0])),n),s=function(t,e,n,i){const r=i-n,o=t-n;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(n,i,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=On[e.type]||Gi;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Jn[t.colorSpace];c=(t,n)=>e.reverse(e.interpolate(e.forward(t),e.forward(n),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==n)return c(e,n,s)}}:c(a,l,s)}function qi(t,e,n){return"color"===e.type?n=Le.parse(n):"formatted"===e.type?n=De.fromString(n.toString()):"resolvedImage"===e.type?n=Be.fromString(n.toString()):ki(n)===e.type||"enum"===e.type&&e.values[n]||(n=void 0),ji(n,t.default,e.default)}class Xi{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=e?function(t){return"color"===t.type&&(zi(t.default)||Array.isArray(t.default))?new Le(0,0,0,0):"color"===t.type?Le.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,n,i,r,o,s,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=i||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,n,i,r,o,s,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=i||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ve(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0),this._defaultValue}}}function Yi(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Oi}function Zi(t,e){const n=new Mn(Oi,[],e?function(t){const e={color:de,string:ue,number:ce,enum:ue,boolean:he,formatted:ge,resolvedImage:_e};return"array"===t.type?ye(e[t.value]||fe,t.length):e[t.type]}(e):void 0),i=n.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return i?Di(new Xi(i,e)):Bi(n.errors)}class Ji{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Tn(e.expression)}evaluateWithoutErrorHandling(t,e,n,i,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,n,i,r,o)}evaluate(t,e,n,i,r,o){return this._styleExpression.evaluate(t,e,n,i,r,o)}}class Ki{constructor(t,e,n,i){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Tn(e.expression),this.interpolationType=i}evaluateWithoutErrorHandling(t,e,n,i,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,n,i,r,o)}evaluate(t,e,n,i,r,o){return this._styleExpression.evaluate(t,e,n,i,r,o)}interpolationFactor(t,e,n){return this.interpolationType?ti.interpolationFactor(this.interpolationType,t,e,n):0}}function Qi(t,e){if("error"===(t=Zi(t,e)).result)return t;const n=t.value.expression,i=bn(n);if(!i&&!Ni(e))return Bi([new oe("","data expressions not supported")]);const r=En(n,["zoom","pitch","distance-from-center"]);if(!r&&!Fi(e))return Bi([new oe("","zoom expressions not supported")]);const o=er(n);return o||r?o instanceof oe?Bi([o]):o instanceof ti&&!Ui(e)?Bi([new oe("",'"interpolate" expressions cannot be used with this property')]):Di(o?new Ki(i?"camera":"composite",t.value,o.labels,o instanceof ti?o.interpolation:void 0):new Ji(i?"constant":"source",t.value)):Bi([new oe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class tr{constructor(t,e){this._parameters=t,this._specification=e,ee(this,Vi(this._parameters,this._specification))}static deserialize(t){return new tr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function er(t){let e=null;if(t instanceof ri)e=er(t.result);else if(t instanceof ni){for(const n of t.args)if(e=er(n),e)break}else(t instanceof Ln||t instanceof ti)&&t.input instanceof tn&&"zoom"===t.input.name&&(e=t);return e instanceof oe||t.eachChild((t=>{const n=er(t);n instanceof oe?e=n:!e&&n?e=new oe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new oe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}class nr{constructor(t,e,n,i){this.message=(t?`${t}: `:"")+n,i&&(this.identifier=i),null!=e&&e.__line__&&(this.line=e.__line__)}}function ir(t){const e=t.key,n=t.value,i=t.valueSpec||{},r=t.objectElementValidators||{},o=t.style,s=t.styleSpec;let a=[];const l=ki(n);if("object"!==l)return[new nr(e,n,`object expected, ${l} found`)];for(const t in n){const l=t.split(".")[0];let c;r[l]?c=r[l]:i[l]?c=Fr:r["*"]?c=r["*"]:i["*"]&&(c=Fr),c?a=a.concat(c({key:(e?`${e}.`:e)+t,value:n[t],valueSpec:i[l]||i["*"],style:o,styleSpec:s,object:n,objectKey:t},n)):a.push(new nr(e,n[t],`unknown property "${t}"`))}for(const t in i)r[t]||i[t].required&&void 0===i[t].default&&void 0===n[t]&&a.push(new nr(e,n,`missing required property "${t}"`));return a}function rr(t){const e=t.value,n=t.valueSpec,i=t.style,r=t.styleSpec,o=t.key,s=t.arrayElementValidator||Fr;if("array"!==ki(e))return[new nr(o,e,`array expected, ${ki(e)} found`)];if(n.length&&e.length!==n.length)return[new nr(o,e,`array length ${n.length} expected, length ${e.length} found`)];if(n["min-length"]&&e.length<n["min-length"])return[new nr(o,e,`array length at least ${n["min-length"]} expected, length ${e.length} found`)];let a={type:n.value,values:n.values,minimum:n.minimum,maximum:n.maximum,function:void 0};r.$version<7&&(a.function=n.function),"object"===ki(n.value)&&(a=n.value);let l=[];for(let t=0;t<e.length;t++)l=l.concat(s({array:e,arrayIndex:t,value:e[t],valueSpec:a,style:i,styleSpec:r,key:`${o}[${t}]`}));return l}function or(t){const e=t.key,n=t.value,i=t.valueSpec;let r=ki(n);if("number"===r&&n!=n&&(r="NaN"),"number"!==r)return[new nr(e,n,`number expected, ${r} found`)];if("minimum"in i){let r=i.minimum;if("array"===ki(i.minimum)&&(r=i.minimum[t.arrayIndex]),n<r)return[new nr(e,n,`${n} is less than the minimum value ${r}`)]}if("maximum"in i){let r=i.maximum;if("array"===ki(i.maximum)&&(r=i.maximum[t.arrayIndex]),n>r)return[new nr(e,n,`${n} is greater than the maximum value ${r}`)]}return[]}function sr(t){const e=t.valueSpec,n=ne(t.value.type);let i,r,o,s={};const a="categorical"!==n&&void 0===t.value.property,l=!a,c="array"===ki(t.value.stops)&&"array"===ki(t.value.stops[0])&&"object"===ki(t.value.stops[0][0]),u=ir({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===n)return[new nr(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const i=t.value;return e=e.concat(rr({key:t.key,value:i,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===ki(i)&&0===i.length&&e.push(new nr(t.key,i,"array must have at least one stop")),e},default:function(t){return Fr({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===n&&a&&u.push(new nr(t.key,t.value,'missing required property "property"')),"identity"===n||t.value.stops||u.push(new nr(t.key,t.value,'missing required property "stops"')),"exponential"===n&&t.valueSpec.expression&&!Ui(t.valueSpec)&&u.push(new nr(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Ni(t.valueSpec)?u.push(new nr(t.key,t.value,"property functions not supported")):a&&!Fi(t.valueSpec)&&u.push(new nr(t.key,t.value,"zoom functions not supported"))),"categorical"!==n&&!c||void 0!==t.value.property||u.push(new nr(t.key,t.value,'"property" property is required')),u;function h(t){let n=[];const i=t.value,a=t.key;if("array"!==ki(i))return[new nr(a,i,`array expected, ${ki(i)} found`)];if(2!==i.length)return[new nr(a,i,`array length 2 expected, length ${i.length} found`)];if(c){if("object"!==ki(i[0]))return[new nr(a,i,`object expected, ${ki(i[0])} found`)];if(void 0===i[0].zoom)return[new nr(a,i,"object stop key must have zoom")];if(void 0===i[0].value)return[new nr(a,i,"object stop key must have value")];const e=ne(i[0].zoom);if("number"!=typeof e)return[new nr(a,i[0].zoom,"stop zoom values must be numbers")];if(o&&o>e)return[new nr(a,i[0].zoom,"stop zoom values must appear in ascending order")];e!==o&&(o=e,r=void 0,s={}),n=n.concat(ir({key:`${a}[0]`,value:i[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:or,value:d}}))}else n=n.concat(d({key:`${a}[0]`,value:i[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},i));return Yi(ie(i[1]))?n.concat([new nr(`${a}[1]`,i[1],"expressions are not allowed in function stops.")]):n.concat(Fr({key:`${a}[1]`,value:i[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function d(t,o){const a=ki(t.value),l=ne(t.value),c=null!==t.value?t.value:o;if(i){if(a!==i)return[new nr(t.key,c,`${a} stop domain type must match previous stop domain type ${i}`)]}else i=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new nr(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==n){let i=`number expected, ${a} found`;return Ni(e)&&void 0===n&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new nr(t.key,c,i)]}return"categorical"!==n||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===a&&"number"==typeof l&&"number"==typeof r&&void 0!==r&&l<r?[new nr(t.key,c,"stop domain values must appear in ascending order")]:(r=l,"categorical"===n&&l in s?[new nr(t.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new nr(t.key,c,`integer expected, found ${String(l)}`)]}}function ar(t){const e=("property"===t.expressionContext?Qi:Zi)(ie(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new nr(`${t.key}${e.key}`,t.value,e.message)));const n=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return[new nr(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&&!Tn(n))return[new nr(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return lr(n,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!En(n,["zoom","feature-state"]))return[new nr(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!bn(n))return[new nr(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function lr(t,e){const n=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const t of e.valueSpec.expression.parameters)n.delete(t);if(0===n.size)return[];const i=[];return t instanceof tn&&n.has(t.name)?[new nr(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild((t=>{i.push(...lr(t,e))})),i)}function cr(t){const e=t.key,n=t.value,i=t.valueSpec,r=[];return Array.isArray(i.values)?-1===i.values.indexOf(ne(n))&&r.push(new nr(e,n,`expected one of [${i.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(i.values).indexOf(ne(n))&&r.push(new nr(e,n,`expected one of [${Object.keys(i.values).join(", ")}], ${JSON.stringify(n)} found`)),r}function ur(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!ur(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function hr(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};ur(t)||(t=yr(t));const n=t;let i=!0;try{i=function(t){if(!fr(t))return t;let e=ie(t);return pr(e),e=dr(e),e}(n)}catch(t){}const r=te[`filter_${e}`],o=Zi(i,r);let s=null;if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,n)=>o.value.evaluate(t,e,{},n);let a=null,l=null;if(i!==n){const t=Zi(n,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,n,i,r,o)=>t.value.evaluate(e,n,{},i,void 0,void 0,r,o),l=!bn(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:_r(i),needFeature:!!l}}function dr(t){if(!Array.isArray(t))return t;const e=function(t){if(mr.has(t[0]))for(let e=1;e<t.length;e++)if(fr(t[e]))return!0;return t}(t);return!0===e?e:e.map((t=>dr(t)))}function pr(t){let e=!1;const n=[];if("case"===t[0]){for(let i=1;i<t.length-1;i+=2)e=e||fr(t[i]),n.push(t[i+1]);n.push(t[t.length-1])}else if("match"===t[0]){e=e||fr(t[1]);for(let e=2;e<t.length-1;e+=2)n.push(t[e+1]);n.push(t[t.length-1])}else if("step"===t[0]){e=e||fr(t[1]);for(let e=1;e<t.length-1;e+=2)n.push(t[e+1])}e&&(t.length=0,t.push("any",...n));for(let e=1;e<t.length;e++)pr(t[e])}function fr(t){if(!Array.isArray(t))return!1;if("pitch"===(e=t[0])||"distance-from-center"===e)return!0;var e;for(let e=1;e<t.length;e++)if(fr(t[e]))return!0;return!1}const mr=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function gr(t,e){return t<e?-1:t>e?1:0}function _r(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(_r(t[e]))return!0;return!1}function yr(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?vr(t[1],t[2],"=="):"!="===e?Tr(vr(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?vr(t[1],t[2],e):"any"===e?(n=t.slice(1),["any"].concat(n.map(yr))):"all"===e?["all"].concat(t.slice(1).map(yr)):"none"===e?["all"].concat(t.slice(1).map(yr).map(Tr)):"in"===e?xr(t[1],t.slice(2)):"!in"===e?Tr(xr(t[1],t.slice(2))):"has"===e?br(t[1]):"!has"===e?Tr(br(t[1])):"within"!==e||t;var n}function vr(t,e,n){switch(t){case"$type":return[`filter-type-${n}`,e];case"$id":return[`filter-id-${n}`,e];default:return[`filter-${n}`,t,e]}}function xr(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(gr)]]:["filter-in-small",t,["literal",e]]}}function br(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Tr(t){return["!",t]}function Er(t){return ur(ie(t.value))?ar(ee({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):Sr(t)}function Sr(t){const e=t.value,n=t.key;if("array"!==ki(e))return[new nr(n,e,`array expected, ${ki(e)} found`)];const i=t.styleSpec;let r,o=[];if(e.length<1)return[new nr(n,e,"filter array must have at least 1 element")];switch(o=o.concat(cr({key:`${n}[0]`,value:e[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),ne(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===ne(e[1])&&o.push(new nr(n,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&o.push(new nr(n,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(r=ki(e[1]),"string"!==r&&o.push(new nr(`${n}[1]`,e[1],`string expected, ${r} found`)));for(let s=2;s<e.length;s++)r=ki(e[s]),"$type"===ne(e[1])?o=o.concat(cr({key:`${n}[${s}]`,value:e[s],valueSpec:i.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==r&&"number"!==r&&"boolean"!==r&&o.push(new nr(`${n}[${s}]`,e[s],`string, number, or boolean expected, ${r} found`));break;case"any":case"all":case"none":for(let i=1;i<e.length;i++)o=o.concat(Sr({key:`${n}[${i}]`,value:e[i],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":r=ki(e[1]),2!==e.length?o.push(new nr(n,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==r&&o.push(new nr(`${n}[1]`,e[1],`string expected, ${r} found`));break;case"within":r=ki(e[1]),2!==e.length?o.push(new nr(n,e,`filter array for "${e[0]}" operator must have 2 elements`)):"object"!==r&&o.push(new nr(`${n}[1]`,e[1],`object expected, ${r} found`))}return o}function wr(t,e){const n=t.key,i=t.style,r=t.styleSpec,o=t.value,s=t.objectKey,a=r[`${e}_${t.layerType}`];if(!a)return[];const l=s.match(/^(.*)-transition$/);if("paint"===e&&l&&a[l[1]]&&a[l[1]].transition)return Fr({key:n,value:o,valueSpec:r.transition,style:i,styleSpec:r});const c=t.valueSpec||a[s];if(!c)return[new nr(n,o,`unknown property "${s}"`)];let u;if("string"===ki(o)&&Ni(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o))){const t=`\`{ "type": "identity", "property": ${u?JSON.stringify(u[1]):'"_"'} }\``;return[new nr(n,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: ${t}.`)]}const h=[];return"symbol"===t.layerType&&("text-field"===s&&i&&!i.glyphs&&h.push(new nr(n,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===s&&zi(ie(o))&&"identity"===ne(o.type)&&h.push(new nr(n,o,'"text-font" does not support identity functions'))),h.concat(Fr({key:t.key,value:o,valueSpec:c,style:i,styleSpec:r,expressionContext:"property",propertyType:e,propertyKey:s}))}function Ar(t){return wr(t,"paint")}function Mr(t){return wr(t,"layout")}function Cr(t){let e=[];const n=t.value,i=t.key,r=t.style,o=t.styleSpec;n.type||n.ref||e.push(new nr(i,n,'either "type" or "ref" is required'));let s=ne(n.type);const a=ne(n.ref);if(n.id){const o=ne(n.id);for(let s=0;s<t.arrayIndex;s++){const t=r.layers[s];ne(t.id)===o&&e.push(new nr(i,n.id,`duplicate layer id "${n.id}", previously used at line ${t.id.__line__}`))}}if("ref"in n){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in n&&e.push(new nr(i,n[t],`"${t}" is prohibited for ref layers`))})),r.layers.forEach((e=>{ne(e.id)===a&&(t=e)})),t?t.ref?e.push(new nr(i,n.ref,"ref cannot reference another ref layer")):s=ne(t.type):"string"==typeof a&&e.push(new nr(i,n.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(n.source){const t=r.sources&&r.sources[n.source],o=t&&ne(t.type);t?"vector"===o&&"raster"===s?e.push(new nr(i,n.source,`layer "${n.id}" requires a raster source`)):"raster"===o&&"raster"!==s?e.push(new nr(i,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==o||n["source-layer"]?"raster-dem"===o&&"hillshade"!==s?e.push(new nr(i,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!n.paint||!n.paint["line-gradient"]&&!n.paint["line-trim-offset"]||"geojson"===o&&t.lineMetrics||e.push(new nr(i,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new nr(i,n,`layer "${n.id}" must specify a "source-layer"`)):e.push(new nr(i,n.source,`source "${n.source}" not found`))}else e.push(new nr(i,n,'missing required property "source"'));return e=e.concat(ir({key:i,value:n,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Fr({key:`${i}.type`,value:n.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,object:n,objectKey:"type"}),filter:t=>Er(ee({layerType:s},t)),layout:t=>ir({layer:n,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>Mr(ee({layerType:s},t))}}),paint:t=>ir({layer:n,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>Ar(ee({layerType:s},t))}})}})),e}function Ir(t){const e=t.value,n=t.key,i=ki(e);return"string"!==i?[new nr(n,e,`string expected, ${i} found`)]:[]}const Pr={promoteId:function({key:t,value:e}){if("string"===ki(e))return Ir({key:t,value:e});{const n=[];for(const i in e)n.push(...Ir({key:`${t}.${i}`,value:e[i]}));return n}}};function Lr(t){const e=t.value,n=t.key,i=t.styleSpec,r=t.style;if(!e.type)return[new nr(n,e,'"type" is required')];const o=ne(e.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=ir({key:n,value:e,valueSpec:i[`source_${o.replace("-","_")}`],style:t.style,styleSpec:i,objectElementValidators:Pr}),s;case"geojson":if(s=ir({key:n,value:e,valueSpec:i.source_geojson,style:r,styleSpec:i,objectElementValidators:Pr}),e.cluster)for(const t in e.clusterProperties){const[i,r]=e.clusterProperties[t],o="string"==typeof i?[i,["accumulated"],["get",t]]:i;s.push(...ar({key:`${n}.${t}.map`,value:r,expressionContext:"cluster-map"})),s.push(...ar({key:`${n}.${t}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return ir({key:n,value:e,valueSpec:i.source_video,style:r,styleSpec:i});case"image":return ir({key:n,value:e,valueSpec:i.source_image,style:r,styleSpec:i});case"canvas":return[new nr(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return cr({key:`${n}.type`,value:e.type,valueSpec:{values:Rr(i)},style:r,styleSpec:i})}}function Rr(t){return t.source.reduce(((e,n)=>{const i=t[n];return"enum"===i.type.type&&(e=e.concat(Object.keys(i.type.values))),e}),[])}function Or(t){const e=t.value,n=t.styleSpec,i=n.light,r=t.style;let o=[];const s=ki(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new nr("light",e,`object expected, ${s} found`)]),o;for(const t in e){const s=t.match(/^(.*)-transition$/);o=o.concat(s&&i[s[1]]&&i[s[1]].transition?Fr({key:t,value:e[t],valueSpec:n.transition,style:r,styleSpec:n}):i[t]?Fr({key:t,value:e[t],valueSpec:i[t],style:r,styleSpec:n}):[new nr(t,e[t],`unknown property "${t}"`)])}return o}function Dr(t){const e=t.value,n=t.key,i=t.style,r=t.styleSpec,o=r.terrain;let s=[];const a=ki(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new nr("terrain",e,`object expected, ${a} found`)]),s;for(const t in e){const n=t.match(/^(.*)-transition$/);s=s.concat(n&&o[n[1]]&&o[n[1]].transition?Fr({key:t,value:e[t],valueSpec:r.transition,style:i,styleSpec:r}):o[t]?Fr({key:t,value:e[t],valueSpec:o[t],style:i,styleSpec:r}):[new nr(t,e[t],`unknown property "${t}"`)])}if(e.source){const t=i.sources&&i.sources[e.source],r=t&&ne(t.type);t?"raster-dem"!==r&&s.push(new nr(n,e.source,`terrain cannot be used with a source of type ${String(r)}, it only be used with a "raster-dem" source type`)):s.push(new nr(n,e.source,`source "${e.source}" not found`))}else s.push(new nr(n,e,'terrain is missing required property "source"'));return s}function Br(t){const e=t.value,n=t.style,i=t.styleSpec,r=i.fog;let o=[];const s=ki(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new nr("fog",e,`object expected, ${s} found`)]),o;for(const t in e){const s=t.match(/^(.*)-transition$/);o=o.concat(s&&r[s[1]]&&r[s[1]].transition?Fr({key:t,value:e[t],valueSpec:i.transition,style:n,styleSpec:i}):r[t]?Fr({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}):[new nr(t,e[t],`unknown property "${t}"`)])}return o}const Nr={"*":()=>[],array:rr,boolean:function(t){const e=t.value,n=t.key,i=ki(e);return"boolean"!==i?[new nr(n,e,`boolean expected, ${i} found`)]:[]},number:or,color:function(t){const e=t.key,n=t.value,i=ki(n);return"string"!==i?[new nr(e,n,`color expected, ${i} found`)]:null===Se(n)?[new nr(e,n,`color expected, "${n}" found`)]:[]},enum:cr,filter:Er,function:sr,layer:Cr,object:ir,source:Lr,light:Or,terrain:Dr,fog:Br,string:Ir,formatted:function(t){return 0===Ir(t).length?[]:ar(t)},resolvedImage:function(t){return 0===Ir(t).length?[]:ar(t)},projection:function(t){const e=t.value,n=t.styleSpec,i=n.projection,r=t.style;let o=[];const s=ki(e);if("object"===s)for(const t in e)o=o.concat(Fr({key:t,value:e[t],valueSpec:i[t],style:r,styleSpec:n}));else"string"!==s&&(o=o.concat([new nr("projection",e,`object or string expected, ${s} found`)]));return o}};function Fr(t){const e=t.value,n=t.valueSpec,i=t.styleSpec;return n.expression&&zi(ne(e))?sr(t):n.expression&&Yi(ie(e))?ar(t):n.type&&Nr[n.type]?Nr[n.type](t):ir(ee({},t,{valueSpec:n.type?i[n.type]:n}))}function Ur(t){const e=t.value,n=t.key,i=Ir(t);return i.length||(-1===e.indexOf("{fontstack}")&&i.push(new nr(n,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&i.push(new nr(n,e,'"glyphs" url must include a "{range}" token'))),i}function kr(t,e=te){return Vr(Fr({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:Ur,"*":()=>[]}}))}const zr=t=>Vr(Ar(t)),Gr=t=>Vr(Mr(t));function Vr(t){return t.slice().sort(((t,e)=>t.line&&e.line?t.line-e.line:0))}function jr(t,e){let n=!1;if(e&&e.length)for(const i of e)t.fire(new Kt(new Error(i.message))),n=!0;return n}var $r=Wr,Hr=3;function Wr(t,e,n){var i=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var r=new Int32Array(this.arrayBuffer);t=r[0],this.d=(e=r[1])+2*(n=r[2]);for(var o=0;o<this.d*this.d;o++){var s=r[Hr+o],a=r[Hr+o+1];i.push(s===a?null:r.subarray(s,a))}var l=r[Hr+i.length+1];this.keys=r.subarray(r[Hr+i.length],l),this.bboxes=r.subarray(l),this.insert=this._insertReadonly}else{this.d=e+2*n;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=n,this.scale=e/t,this.uid=0;var u=n/e*t;this.min=-u,this.max=t+u}Wr.prototype.insert=function(t,e,n,i,r){this._forEachCell(e,n,i,r,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(n),this.bboxes.push(i),this.bboxes.push(r)},Wr.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Wr.prototype._insertCell=function(t,e,n,i,r,o){this.cells[r].push(o)},Wr.prototype.query=function(t,e,n,i,r){var o=this.min,s=this.max;if(t<=o&&e<=o&&s<=n&&s<=i&&!r)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,n,i,this._queryCell,a,{},r),a},Wr.prototype._queryCell=function(t,e,n,i,r,o,s,a){var l=this.cells[r];if(null!==l)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var d=l[h];if(void 0===s[d]){var p=4*d;(a?a(u[p+0],u[p+1],u[p+2],u[p+3]):t<=u[p+2]&&e<=u[p+3]&&n>=u[p+0]&&i>=u[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},Wr.prototype._forEachCell=function(t,e,n,i,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(n),h=this._convertToCellCoord(i),d=l;d<=u;d++)for(var p=c;p<=h;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&r.call(this,t,e,n,i,f,o,s,a))return}},Wr.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Wr.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Wr.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=Hr+this.cells.length+1+1,n=0,i=0;i<this.cells.length;i++)n+=this.cells[i].length;var r=new Int32Array(e+n+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;for(var o=e,s=0;s<t.length;s++){var a=t[s];r[Hr+s]=o,r.set(a,o),o+=a.length}return r[Hr+t.length]=o,r.set(this.keys,o),r[Hr+t.length+1]=o+=this.keys.length,r.set(this.bboxes,o),o+=this.bboxes.length,r.buffer};var qr=d($r);const Xr={};function Yr(t,e,n={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),Xr[e]={klass:t,omit:n.omit||[]}}Yr(Object,"Object"),qr.serialize=function(t,e){const n=t.toArrayBuffer();return e&&e.push(n),{buffer:n}},qr.deserialize=function(t){return new qr(t.buffer)},Object.defineProperty(qr,"name",{value:"Grid"}),Yr(qr,"Grid"),Yr(Le,"Color"),Yr(Error,"Error"),Yr(ct,"AJAXError"),Yr(Be,"ResolvedImage"),Yr(tr,"StylePropertyFunction"),Yr(Xi,"StyleExpression",{omit:["_evaluator"]}),Yr(Ki,"ZoomDependentExpression"),Yr(Ji,"ZoomConstantExpression"),Yr(tn,"CompoundExpression",{omit:["_evaluate"]});for(const t in Oi)Xr[Oi[t]._classRegistryKey]||Yr(Oi[t],`Expression${t}`);function Zr(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Jr(t){return e.ImageBitmap&&t instanceof e.ImageBitmap}function Kr(t,n){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Zr(t)||Jr(t))return n&&n.push(t),t;if(ArrayBuffer.isView(t)){const e=t;return n&&n.push(e.buffer),e}if(t instanceof e.ImageData)return n&&n.push(t.data.buffer),t;if(Array.isArray(t)){const e=[];for(const i of t)e.push(Kr(i,n));return e}if("object"==typeof t){const e=t.constructor,i=e._classRegistryKey;if(!i)throw new Error(`can't serialize object of unregistered class ${i}`);const r=e.serialize?e.serialize(t,n):{};if(!e.serialize){for(const e in t)t.hasOwnProperty(e)&&(Xr[i].omit.indexOf(e)>=0||(r[e]=Kr(t[e],n)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(r.$name=i),r}throw new Error("can't serialize object of type "+typeof t)}function Qr(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Zr(t)||Jr(t)||ArrayBuffer.isView(t)||t instanceof e.ImageData)return t;if(Array.isArray(t))return t.map(Qr);if("object"==typeof t){const e=t.$name||"Object",{klass:n}=Xr[e];if(!n)throw new Error(`can't deserialize unregistered class ${e}`);if(n.deserialize)return n.deserialize(t);const i=Object.create(n.prototype);for(const e of Object.keys(t))"$name"!==e&&(i[e]=Qr(t[e]));return i}throw new Error("can't deserialize object of type "+typeof t)}const to={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function eo(t){for(const e of t)if(ro(e.charCodeAt(0)))return!0;return!1}function no(t){for(const e of t)if(!io(e.charCodeAt(0)))return!1;return!0}function io(t){return!(to.Arabic(t)||to["Arabic Supplement"](t)||to["Arabic Extended-A"](t)||to["Arabic Presentation Forms-A"](t)||to["Arabic Presentation Forms-B"](t))}function ro(t){return!(746!==t&&747!==t&&(t<4352||!(to["Bopomofo Extended"](t)||to.Bopomofo(t)||to["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||to["CJK Compatibility Ideographs"](t)||to["CJK Compatibility"](t)||to["CJK Radicals Supplement"](t)||to["CJK Strokes"](t)||!(!to["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||to["CJK Unified Ideographs Extension A"](t)||to["CJK Unified Ideographs"](t)||to["Enclosed CJK Letters and Months"](t)||to["Hangul Compatibility Jamo"](t)||to["Hangul Jamo Extended-A"](t)||to["Hangul Jamo Extended-B"](t)||to["Hangul Jamo"](t)||to["Hangul Syllables"](t)||to.Hiragana(t)||to["Ideographic Description Characters"](t)||to.Kanbun(t)||to["Kangxi Radicals"](t)||to["Katakana Phonetic Extensions"](t)||to.Katakana(t)&&12540!==t||!(!to["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!to["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||to["Unified Canadian Aboriginal Syllabics"](t)||to["Unified Canadian Aboriginal Syllabics Extended"](t)||to["Vertical Forms"](t)||to["Yijing Hexagram Symbols"](t)||to["Yi Syllables"](t)||to["Yi Radicals"](t))))}function oo(t){return!(ro(t)||function(t){return!!(to["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||to["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||to["Letterlike Symbols"](t)||to["Number Forms"](t)||to["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||to["Control Pictures"](t)&&9251!==t||to["Optical Character Recognition"](t)||to["Enclosed Alphanumerics"](t)||to["Geometric Shapes"](t)||to["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||to["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||to["CJK Symbols and Punctuation"](t)||to.Katakana(t)||to["Private Use Area"](t)||to["CJK Compatibility Forms"](t)||to["Small Form Variants"](t)||to["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function so(t){return t>=1424&&t<=2303||to["Arabic Presentation Forms-A"](t)||to["Arabic Presentation Forms-B"](t)}function ao(t,e){return!(!e&&so(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||to.Khmer(t))}function lo(t){for(const e of t)if(so(e.charCodeAt(0)))return!0;return!1}const co="deferred",uo="loading",ho="loaded";let po=null,fo="unavailable",mo=null;const go=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(fo="error"),po&&po(t)};function _o(){yo.fire(new Jt("pluginStateChange",{pluginStatus:fo,pluginURL:mo}))}const yo=new Qt,vo=function(){return fo},xo=function(){if(fo!==co||!mo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");fo=uo,_o(),mo&&dt({url:mo},(t=>{t?go(t):(fo=ho,_o())}))},bo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>fo===ho||null!=bo.applyArabicShaping,isLoading:()=>fo===uo,setState(t){fo=t.pluginStatus,mo=t.pluginURL},isParsed:()=>null!=bo.applyArabicShaping&&null!=bo.processBidirectionalText&&null!=bo.processStyledBidirectionalText,getPluginURL:()=>mo};class To{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(t){return function(t,e){for(const n of t)if(!ao(n.charCodeAt(0),e))return!1;return!0}(t,bo.isLoaded())}}class Eo{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(zi(t))return new tr(t,e);if(Yi(t)){const n=Qi(t,e);if("error"===n.result)throw new Error(n.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return n.value}{let n=t;return"string"==typeof t&&"color"===e.type&&(n=Le.parse(t)),{kind:"constant",evaluate:()=>n}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,n){return this.property.possiblyEvaluate(this,t,e,n)}}class So{constructor(t){this.property=t,this.value=new Eo(t,void 0)}transitioned(t,e){return new Ao(this.property,this.value,e,R({},t.transition,this.transition),t.now)}untransitioned(){return new Ao(this.property,this.value,null,{},0)}}class wo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return V(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new So(this._values[t].property)),this._values[t].value=new Eo(this._values[t].property,null===e?void 0:V(e))}getTransition(t){return V(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new So(this._values[t].property)),this._values[t].transition=V(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const n=this.getValue(e);void 0!==n&&(t[e]=n);const i=this.getTransition(e);void 0!==i&&(t[`${e}-transition`]=i)}return t}transitioned(t,e){const n=new Mo(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].transitioned(t,e._values[i]);return n}untransitioned(){const t=new Mo(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ao{constructor(t,e,n,i,r){const o=i.delay||0,s=i.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(i.delay||i.duration)&&(this.prior=n)}possiblyEvaluate(t,e,n){const i=t.now||0,r=this.value.possiblyEvaluate(t,e,n),o=this.prior;if(o){if(i>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(i<this.begin)return o.possiblyEvaluate(t,e,n);{const s=(i-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(t,e,n),r,S(s))}}return r}}class Mo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,n){const i=new Po(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].possiblyEvaluate(t,e,n);return i}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Co{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return V(this._values[t].value)}setValue(t,e){this._values[t]=new Eo(this._values[t].property,null===e?void 0:V(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const n=this.getValue(e);void 0!==n&&(t[e]=n)}return t}possiblyEvaluate(t,e,n){const i=new Po(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].possiblyEvaluate(t,e,n);return i}}class Io{constructor(t,e,n){this.property=t,this.value=e,this.parameters=n}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,n,i){return this.property.evaluate(this.value,this.parameters,t,e,n,i)}}class Po{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Lo{constructor(t){this.specification=t}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,n){const i=On[this.specification.type];return i?i(t,e,n):t}}class Ro{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,n,i){return new Io(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},n,i)}:t.expression,e)}interpolate(t,e,n){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Io(this,{kind:"constant",value:void 0},t.parameters);const i=On[this.specification.type];return i?new Io(this,{kind:"constant",value:i(t.value.value,e.value.value,n)},t.parameters):t}evaluate(t,e,n,i,r,o){return"constant"===t.kind?t.value:t.evaluate(e,n,i,r,o)}}class Oo{constructor(t){this.specification=t}possiblyEvaluate(t,e,n,i){return!!t.expression.evaluate(e,null,{},n,i)}interpolate(){return!1}}class Do{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const e=new To(0,{});for(const n in t){const i=t[n];i.specification.overridable&&this.overridableProperties.push(n);const r=this.defaultPropertyValues[n]=new Eo(i,void 0),o=this.defaultTransitionablePropertyValues[n]=new So(i);this.defaultTransitioningPropertyValues[n]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[n]=r.possiblyEvaluate(e)}}}function Bo(t,e){return 256*(t=M(Math.floor(t),0,255))+M(Math.floor(e),0,255)}Yr(Ro,"DataDrivenProperty"),Yr(Lo,"DataConstantProperty"),Yr(Oo,"ColorRampProperty");const No={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Fo{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Uo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_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(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() 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 ko(t,e=1){let n=0,i=0;return{members:t.map((t=>{const r=No[t.type].BYTES_PER_ELEMENT,o=n=zo(n,Math.max(e,r)),s=t.components||1;return i=Math.max(i,r),n+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:zo(n,Math.max(i,e)),alignment:e}}function zo(t,e){return Math.ceil(t/e)*e}class Go extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const n=this.length;return this.resize(n+1),this.emplace(n,t,e)}emplace(t,e,n){const i=2*t;return this.int16[i+0]=e,this.int16[i+1]=n,t}}Go.prototype.bytesPerElement=4,Yr(Go,"StructArrayLayout2i4");class Vo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,n)}emplace(t,e,n,i){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=n,this.int16[r+2]=i,t}}Vo.prototype.bytesPerElement=6,Yr(Vo,"StructArrayLayout3i6");class jo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,n,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n,i)}emplace(t,e,n,i,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=n,this.int16[o+2]=i,this.int16[o+3]=r,t}}jo.prototype.bytesPerElement=8,Yr(jo,"StructArrayLayout4i8");class $o extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,n,i,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,i,r,o,s)}emplace(t,e,n,i,r,o,s,a){const l=6*t,c=12*t,u=3*t;return this.int16[l+0]=e,this.int16[l+1]=n,this.uint8[c+4]=i,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,t}}$o.prototype.bytesPerElement=12,Yr($o,"StructArrayLayout2i4ub1f12");class Ho extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,n,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n,i)}emplace(t,e,n,i,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=n,this.float32[o+2]=i,this.float32[o+3]=r,t}}Ho.prototype.bytesPerElement=16,Yr(Ho,"StructArrayLayout4f16");class Wo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,n,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,i,r)}emplace(t,e,n,i,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=n,this.uint16[s+2]=i,this.uint16[s+3]=r,this.float32[a+2]=o,t}}Wo.prototype.bytesPerElement=12,Yr(Wo,"StructArrayLayout4ui1f12");class qo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,n,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n,i)}emplace(t,e,n,i,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=n,this.uint16[o+2]=i,this.uint16[o+3]=r,t}}qo.prototype.bytesPerElement=8,Yr(qo,"StructArrayLayout4ui8");class Xo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,n,i,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,n,i,r,o)}emplace(t,e,n,i,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=n,this.int16[a+2]=i,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}Xo.prototype.bytesPerElement=12,Yr(Xo,"StructArrayLayout6i12");class Yo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,n,i,r,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,n,i,r,o,s,a,l,c,u,h)}emplace(t,e,n,i,r,o,s,a,l,c,u,h,d){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=n,this.int16[p+2]=i,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,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,t}}Yo.prototype.bytesPerElement=24,Yr(Yo,"StructArrayLayout4i4ui4i24");class Zo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,n,i,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,n,i,r,o)}emplace(t,e,n,i,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=n,this.int16[a+2]=i,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Zo.prototype.bytesPerElement=20,Yr(Zo,"StructArrayLayout3i3f20");class Jo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Jo.prototype.bytesPerElement=4,Yr(Jo,"StructArrayLayout1ul4");class Ko extends Uo{_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(t,e,n,i,r,o,s,a,l,c,u,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,n,i,r,o,s,a,l,c,u,h,d)}emplace(t,e,n,i,r,o,s,a,l,c,u,h,d,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=n,this.int16[f+2]=i,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,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,t}}Ko.prototype.bytesPerElement=40,Yr(Ko,"StructArrayLayout5i4f1i1ul2ui40");class Qo extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,n,i,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,i,r,o,s)}emplace(t,e,n,i,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=n,this.int16[l+2]=i,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Qo.prototype.bytesPerElement=16,Yr(Qo,"StructArrayLayout3i2i2i16");class ts extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,n,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,i,r)}emplace(t,e,n,i,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=n,this.float32[s+2]=i,this.int16[a+6]=r,this.int16[a+7]=o,t}}ts.prototype.bytesPerElement=16,Yr(ts,"StructArrayLayout2f1f2i16");class es extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,n,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n,i)}emplace(t,e,n,i,r){const o=12*t,s=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=n,this.float32[s+1]=i,this.float32[s+2]=r,t}}es.prototype.bytesPerElement=12,Yr(es,"StructArrayLayout2ub2f12");class ns extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,n)}emplace(t,e,n,i){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=n,this.float32[r+2]=i,t}}ns.prototype.bytesPerElement=12,Yr(ns,"StructArrayLayout3f12");class is extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,n)}emplace(t,e,n,i){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=n,this.uint16[r+2]=i,t}}is.prototype.bytesPerElement=6,Yr(is,"StructArrayLayout3ui6");class rs extends Uo{_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(t,e,n,i,r,o,s,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,t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v,x)}emplace(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b){const T=30*t,E=15*t,S=60*t;return this.int16[T+0]=e,this.int16[T+1]=n,this.int16[T+2]=i,this.float32[E+2]=r,this.float32[E+3]=o,this.uint16[T+8]=s,this.uint16[T+9]=a,this.uint32[E+5]=l,this.uint32[E+6]=c,this.uint32[E+7]=u,this.uint16[T+16]=h,this.uint16[T+17]=d,this.uint16[T+18]=p,this.float32[E+10]=f,this.float32[E+11]=m,this.uint8[S+48]=g,this.uint8[S+49]=_,this.uint8[S+50]=y,this.uint32[E+13]=v,this.int16[T+28]=x,this.uint8[S+58]=b,t}}rs.prototype.bytesPerElement=60,Yr(rs,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class os extends Uo{_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(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,T,E,S,w,A,M,C,I){const P=this.length;return this.resize(P+1),this.emplace(P,t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,T,E,S,w,A,M,C,I)}emplace(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,T,E,S,w,A,M,C,I,P){const L=38*t,R=19*t;return this.int16[L+0]=e,this.int16[L+1]=n,this.int16[L+2]=i,this.float32[R+2]=r,this.float32[R+3]=o,this.int16[L+8]=s,this.int16[L+9]=a,this.int16[L+10]=l,this.int16[L+11]=c,this.int16[L+12]=u,this.int16[L+13]=h,this.uint16[L+14]=d,this.uint16[L+15]=p,this.uint16[L+16]=f,this.uint16[L+17]=m,this.uint16[L+18]=g,this.uint16[L+19]=_,this.uint16[L+20]=y,this.uint16[L+21]=v,this.uint16[L+22]=x,this.uint16[L+23]=b,this.uint16[L+24]=T,this.uint16[L+25]=E,this.uint16[L+26]=S,this.uint16[L+27]=w,this.uint16[L+28]=A,this.uint32[R+15]=M,this.float32[R+16]=C,this.float32[R+17]=I,this.float32[R+18]=P,t}}os.prototype.bytesPerElement=76,Yr(os,"StructArrayLayout3i2f6i15ui1ul3f76");class ss extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}ss.prototype.bytesPerElement=4,Yr(ss,"StructArrayLayout1f4");class as extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,n,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,i,r)}emplace(t,e,n,i,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=n,this.float32[s+2]=i,this.float32[s+3]=r,this.float32[s+4]=o,t}}as.prototype.bytesPerElement=20,Yr(as,"StructArrayLayout5f20");class ls extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,n,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,n,i)}emplace(t,e,n,i,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=n,this.uint16[o+3]=i,this.uint16[o+4]=r,t}}ls.prototype.bytesPerElement=12,Yr(ls,"StructArrayLayout1ul3ui12");class cs extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const n=this.length;return this.resize(n+1),this.emplace(n,t,e)}emplace(t,e,n){const i=2*t;return this.uint16[i+0]=e,this.uint16[i+1]=n,t}}cs.prototype.bytesPerElement=4,Yr(cs,"StructArrayLayout2ui4");class us extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}us.prototype.bytesPerElement=2,Yr(us,"StructArrayLayout1ui2");class hs extends Uo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const n=this.length;return this.resize(n+1),this.emplace(n,t,e)}emplace(t,e,n){const i=2*t;return this.float32[i+0]=e,this.float32[i+1]=n,t}}hs.prototype.bytesPerElement=8,Yr(hs,"StructArrayLayout2f8");class ds extends Fo{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]}}ds.prototype.size=40;class ps extends Ko{get(t){return new ds(this,t)}}Yr(ps,"CollisionBoxArray");class fs extends Fo{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(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}fs.prototype.size=60;class ms extends rs{get(t){return new fs(this,t)}}Yr(ms,"PlacedSymbolArray");class gs extends Fo{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 rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(t){this._structArray.uint32[this._pos4+15]=t}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}gs.prototype.size=76;class _s extends os{get(t){return new gs(this,t)}}Yr(_s,"SymbolInstanceArray");class ys extends ss{getoffsetX(t){return this.float32[1*t+0]}}Yr(ys,"GlyphOffsetArray");class vs extends Go{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}Yr(vs,"SymbolLineVertexArray");class xs extends Fo{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]}}xs.prototype.size=12;class bs extends ls{get(t){return new xs(this,t)}}Yr(bs,"FeatureIndexArray");class Ts extends cs{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}Yr(Ts,"FillExtrusionCentroidArray");const Es=ko([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ss=ko([{name:"a_dash",components:4,type:"Uint16"}]);var ws={exports:{}},As={exports:{}};As.exports=function(t,e){var n,i,r,o,s,a,l,c;for(i=t.length-(n=3&t.length),r=e,s=3432918353,a=461845907,c=0;c<i;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,r=27492+(65535&(o=5*(65535&(r=(r^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:r^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return r^=t.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};var Ms=As.exports,Cs={exports:{}};Cs.exports=function(t,e){for(var n,i=t.length,r=e^i,o=0;i>=4;)n=1540483477*(65535&(n=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),i-=4,++o;switch(i){case 3:r^=(255&t.charCodeAt(o+2))<<16;case 2:r^=(255&t.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&t.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0};var Is=Ms,Ps=Cs.exports;ws.exports=Is,ws.exports.murmur3=Is,ws.exports.murmur2=Ps;var Ls=d(ws.exports);class Rs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,n,i){this.ids.push(Os(t)),this.positions.push(e,n,i)}getPositions(t){const e=Os(t);let n=0,i=this.ids.length-1;for(;n<i;){const t=n+i>>1;this.ids[t]>=e?i=t:n=t+1}const r=[];for(;this.ids[n]===e;)r.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return r}static serialize(t,e){const n=new Float64Array(t.ids),i=new Uint32Array(t.positions);return Ds(n,i,0,n.length-1),e&&e.push(n.buffer,i.buffer),{ids:n,positions:i}}static deserialize(t){const e=new Rs;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Os(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Ls(String(t))}function Ds(t,e,n,i){for(;n<i;){const r=t[n+i>>1];let o=n-1,s=i+1;for(;;){do{o++}while(t[o]<r);do{s--}while(t[s]>r);if(o>=s)break;Bs(t,o,s),Bs(e,3*o,3*s),Bs(e,3*o+1,3*s+1),Bs(e,3*o+2,3*s+2)}s-n<i-s?(Ds(t,e,n,s),n=s+1):(Ds(t,e,s+1,i),i=s)}}function Bs(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}Yr(Rs,"FeaturePositionMap");class Ns{constructor(t){this.gl=t.gl,this.initialized=!1}fetchUniformLocation(t,e){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(t,e),this.initialized=!0),!!this.location}}class Fs extends Ns{constructor(t){super(t),this.current=0}set(t,e,n){this.fetchUniformLocation(t,e)&&this.current!==n&&(this.current=n,this.gl.uniform1f(this.location,n))}}class Us extends Ns{constructor(t){super(t),this.current=[0,0,0,0]}set(t,e,n){this.fetchUniformLocation(t,e)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]&&n[3]===this.current[3]||(this.current=n,this.gl.uniform4f(this.location,n[0],n[1],n[2],n[3])))}}class ks extends Ns{constructor(t){super(t),this.current=Le.transparent}set(t,e,n){this.fetchUniformLocation(t,e)&&(n.r===this.current.r&&n.g===this.current.g&&n.b===this.current.b&&n.a===this.current.a||(this.current=n,this.gl.uniform4f(this.location,n.r,n.g,n.b,n.a)))}}const zs=new Float32Array(16),Gs=new Float32Array(9),Vs=new Float32Array(4);function js(t){return[Bo(255*t.r,255*t.g),Bo(255*t.b,255*t.a)]}class $s{constructor(t,e,n){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=n}setUniform(t,e,n,i,r){e.set(t,r,i.constantOr(this.value))}getBinding(t,e){return"color"===this.type?new ks(t):new Fs(t)}}class Hs{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,n,i,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new Us(t):new Fs(t)}}class Ws{constructor(t,e,n,i){this.expression=t,this.type=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===n?2:1,offset:0}))),this.paintVertexArray=new i}populatePaintArray(t,e,n,i,r,o){const s=this.paintVertexArray.length,a=this.expression.evaluate(new To(0),e,{},r,i,o);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a)}updatePaintArray(t,e,n,i,r){const o=this.expression.evaluate({zoom:0},n,i,void 0,r);this._setPaintValue(t,e,o)}_setPaintValue(t,e,n){if("color"===this.type){const i=js(n);for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i[0],i[1])}else{for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class qs{constructor(t,e,n,i,r,o){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=n,this.useIntegerZoom=i,this.zoom=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===n?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,n,i,r,o){const s=this.expression.evaluate(new To(this.zoom),e,{},r,i,o),a=this.expression.evaluate(new To(this.zoom+1),e,{},r,i,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(l,t,s,a)}updatePaintArray(t,e,n,i,r){const o=this.expression.evaluate({zoom:this.zoom},n,i,void 0,r),s=this.expression.evaluate({zoom:this.zoom+1},n,i,void 0,r);this._setPaintValue(t,e,o,s)}_setPaintValue(t,e,n,i){if("color"===this.type){const r=js(n),o=js(i);for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,r[0],r[1],o[0],o[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,n,i);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e,n,i,r){const o=this.useIntegerZoom?Math.floor(n.zoom):n.zoom,s=M(this.expression.interpolationFactor(o,this.zoom,this.zoom+1),0,1);e.set(t,r,s)}getBinding(t,e){return new Fs(t)}}class Xs{constructor(t,e,n,i,r){this.expression=t,this.layerId=r,this.paintVertexAttributes=("array"===n?Ss:Es).members;for(let t=0;t<e.length;++t);this.paintVertexArray=new i}populatePaintArray(t,e,n){const i=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValues(i,t,e.patterns&&e.patterns[this.layerId],n)}updatePaintArray(t,e,n,i,r,o){this._setPaintValues(t,e,n.patterns&&n.patterns[this.layerId],o)}_setPaintValues(t,e,n,i){if(!i||!n)return;const r=i[n];if(!r)return;const{tl:o,br:s,pixelRatio:a}=r;for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,o[0],o[1],s[0],s[1],a)}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Ys{constructor(t,e,n=()=>!0){this.binders={},this._buffers=[];const i=[];for(const r in t.paint._values){if(!n(r))continue;const o=t.paint.get(r);if(!(o instanceof Io&&Ni(o.property.specification)))continue;const s=Ks(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,u="line-dasharray"===r||r.endsWith("pattern"),h="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||h)if("source"===a.kind||h||u){const e=ea(r,l,"source");this.binders[r]=u?new Xs(a,s,l,e,t.id):new Ws(a,s,l,e),i.push(`/a_${r}`)}else{const t=ea(r,l,"composite");this.binders[r]=new qs(a,s,l,c,e,t),i.push(`/z_${r}`)}else this.binders[r]=u?new Hs(a.value,s):new $s(a.value,s,l),i.push(`/u_${r}`)}this.cacheKey=i.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Ws||e instanceof qs?e.maxValue:0}populatePaintArrays(t,e,n,i,r,o){for(const s in this.binders){const a=this.binders[s];(a instanceof Ws||a instanceof qs||a instanceof Xs)&&a.populatePaintArray(t,e,n,i,r,o)}}setConstantPatternPositions(t){for(const e in this.binders){const n=this.binders[e];n instanceof Hs&&n.setConstantPatternPositions(t)}}updatePaintArrays(t,e,n,i,r,o){let s=!1;for(const a in t){const l=e.getPositions(a);for(const e of l){const l=n.feature(e.index);for(const n in this.binders){const c=this.binders[n];if((c instanceof Ws||c instanceof qs||c instanceof Xs)&&!0===c.expression.isStateDependent){const u=i.paint.get(n);c.expression=u.value,c.updatePaintArray(e.start,e.end,l,t[a],r,o),s=!0}}}}return s}defines(){const t=[];for(const e in this.binders){const n=this.binders[e];(n instanceof $s||n instanceof Hs)&&t.push(...n.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const n=this.binders[e];if(n instanceof Ws||n instanceof qs||n instanceof Xs)for(let e=0;e<n.paintVertexAttributes.length;e++)t.push(n.paintVertexAttributes[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const n=this.binders[e];if(n instanceof $s||n instanceof Hs||n instanceof qs)for(const e of n.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t){const e=[];for(const n in this.binders){const i=this.binders[n];if(i instanceof $s||i instanceof Hs||i instanceof qs)for(const r of i.uniformNames)e.push({name:r,property:n,binding:i.getBinding(t,r)})}return e}setUniforms(t,e,n,i,r){for(const{name:e,property:o,binding:s}of n)this.binders[o].setUniform(t,s,r,i.get(o),e)}updatePaintBuffers(){this._buffers=[];for(const t in this.binders){const e=this.binders[t];(e instanceof Ws||e instanceof qs||e instanceof Xs)&&e.paintVertexBuffer&&this._buffers.push(e.paintVertexBuffer)}}upload(t){for(const e in this.binders){const n=this.binders[e];(n instanceof Ws||n instanceof qs||n instanceof Xs)&&n.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof Ws||e instanceof qs||e instanceof Xs)&&e.destroy()}}}class Zs{constructor(t,e,n=()=>!0){this.programConfigurations={};for(const i of t)this.programConfigurations[i.id]=new Ys(i,e,n);this.needsUpload=!1,this._featureMap=new Rs,this._bufferOffset=0}populatePaintArrays(t,e,n,i,r,o,s){for(const n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(t,e,i,r,o,s);void 0!==e.id&&this._featureMap.add(e.id,n,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,n,i,r){for(const o of n)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(t,this._featureMap,e,o,i,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Js={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"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"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Ks(t,e){return Js[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Qs={"line-pattern":{source:Wo,composite:Wo},"fill-pattern":{source:Wo,composite:Wo},"fill-extrusion-pattern":{source:Wo,composite:Wo},"line-dasharray":{source:qo,composite:qo}},ta={color:{source:hs,composite:Ho},number:{source:ss,composite:hs}};function ea(t,e,n){const i=Qs[t];return i&&i[n]||ta[e][n]}Yr($s,"ConstantBinder"),Yr(Hs,"PatternConstantBinder"),Yr(Ws,"SourceExpressionBinder"),Yr(Xs,"PatternCompositeBinder"),Yr(qs,"CompositeExpressionBinder"),Yr(Ys,"ProgramConfiguration",{omit:["_buffers"]}),Yr(Zs,"ProgramConfigurationSet");const na="-transition";class ia extends Qt{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Co(e.layout)),e.paint)){this._transitionablePaint=new wo(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Po(e.paint)}}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,n={}){null!=e&&this._validate(Gr,`layers.${this.id}.layout.${t}`,t,e,n)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return k(t,na)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,n={}){if(null!=e&&this._validate(zr,`layers.${this.id}.paint.${t}`,t,e,n))return!1;if(k(t,na))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const n=this._transitionablePaint._values[t],i=n.value.isDataDriven(),r=n.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value,s=o.isDataDriven(),a=k(t,"pattern")||"line-dasharray"===t;return s||i||a||this._handleOverridablePaintPropertyUpdate(t,r,o)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,e,n){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,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 this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),G(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,n,i,r={}){return(!r||!1!==r.validate)&&jr(this,t.call(kr,{key:e,layerType:this.type,objectKey:n,value:i,styleSpec:te,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Io&&Ni(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=hr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ra=ko([{name:"a_pos",components:2,type:"Int16"}],4),oa=ko([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class sa{constructor(t=[]){this.segments=t}prepareSegment(t,e,n,i){let r=this.segments[this.segments.length-1];return t>sa.MAX_VERTEX_ARRAY_LENGTH&&$(`Max vertices per segment is ${sa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>sa.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==i)&&(r={vertexOffset:e.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==i&&(r.sortKey=i),this.segments.push(r)),r}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,n,i){return new sa([{vertexOffset:t,primitiveOffset:e,vertexLength:n,primitiveLength:i,vaos:{},sortKey:0}])}}sa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Yr(sa,"SegmentVector");var aa=8192;class la{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof Vl?new Vl(t.lng,t.lat):Vl.convert(t),this}setSouthWest(t){return this._sw=t instanceof Vl?new Vl(t.lng,t.lat):Vl.convert(t),this}extend(t){const e=this._sw,n=this._ne;let i,r;if(t instanceof Vl)i=t,r=t;else{if(!(t instanceof la))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(la.convert(t)):this.extend(Vl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(Vl.convert(t)):this;if(i=t._sw,r=t._ne,!i||!r)return this}return e||n?(e.lng=Math.min(i.lng,e.lng),e.lat=Math.min(i.lat,e.lat),n.lng=Math.max(r.lng,n.lng),n.lat=Math.max(r.lat,n.lat)):(this._sw=new Vl(i.lng,i.lat),this._ne=new Vl(r.lng,r.lat)),this}getCenter(){return new Vl((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 Vl(this.getWest(),this.getNorth())}getSouthEast(){return new Vl(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(t){const{lng:e,lat:n}=Vl.convert(t);let i=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&i}static convert(t){return!t||t instanceof la?t:new la(t)}}var ca=1e-6,ua="undefined"!=typeof Float32Array?Float32Array:Array;function ha(){var t=new ua(9);return ua!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function da(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=n[0],p=n[1],f=n[2],m=n[3],g=n[4],_=n[5],y=n[6],v=n[7],x=n[8];return t[0]=d*i+p*s+f*c,t[1]=d*r+p*a+f*u,t[2]=d*o+p*l+f*h,t[3]=m*i+g*s+_*c,t[4]=m*r+g*a+_*u,t[5]=m*o+g*l+_*h,t[6]=y*i+v*s+x*c,t[7]=y*r+v*a+x*u,t[8]=y*o+v*l+x*h,t}function pa(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fa(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=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],m=e[13],g=e[14],_=e[15],y=n*a-i*s,v=n*l-r*s,x=n*c-o*s,b=i*l-r*a,T=i*c-o*a,E=r*c-o*l,S=u*m-h*f,w=u*g-d*f,A=u*_-p*f,M=h*g-d*m,C=h*_-p*m,I=d*_-p*g,P=y*I-v*C+x*M+b*A-T*w+E*S;return P?(t[0]=(a*I-l*C+c*M)*(P=1/P),t[1]=(r*C-i*I-o*M)*P,t[2]=(m*E-g*T+_*b)*P,t[3]=(d*T-h*E-p*b)*P,t[4]=(l*A-s*I-c*w)*P,t[5]=(n*I-r*A+o*w)*P,t[6]=(g*x-f*E-_*v)*P,t[7]=(u*E-d*x+p*v)*P,t[8]=(s*C-a*A+c*S)*P,t[9]=(i*A-n*C-o*S)*P,t[10]=(f*T-m*x+_*y)*P,t[11]=(h*x-u*T-p*y)*P,t[12]=(a*w-s*M-l*S)*P,t[13]=(n*M-i*w+r*S)*P,t[14]=(m*v-f*b-g*y)*P,t[15]=(u*b-h*v+d*y)*P,t):null}function ma(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],y=e[15],v=n[0],x=n[1],b=n[2],T=n[3];return t[0]=v*i+x*a+b*h+T*m,t[1]=v*r+x*l+b*d+T*g,t[2]=v*o+x*c+b*p+T*_,t[3]=v*s+x*u+b*f+T*y,t[4]=(v=n[4])*i+(x=n[5])*a+(b=n[6])*h+(T=n[7])*m,t[5]=v*r+x*l+b*d+T*g,t[6]=v*o+x*c+b*p+T*_,t[7]=v*s+x*u+b*f+T*y,t[8]=(v=n[8])*i+(x=n[9])*a+(b=n[10])*h+(T=n[11])*m,t[9]=v*r+x*l+b*d+T*g,t[10]=v*o+x*c+b*p+T*_,t[11]=v*s+x*u+b*f+T*y,t[12]=(v=n[12])*i+(x=n[13])*a+(b=n[14])*h+(T=n[15])*m,t[13]=v*r+x*l+b*d+T*g,t[14]=v*o+x*c+b*p+T*_,t[15]=v*s+x*u+b*f+T*y,t}function ga(t,e,n){var i,r,o,s,a,l,c,u,h,d,p,f,m=n[0],g=n[1],_=n[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*_+e[12],t[13]=e[1]*m+e[5]*g+e[9]*_+e[13],t[14]=e[2]*m+e[6]*g+e[10]*_+e[14],t[15]=e[3]*m+e[7]*g+e[11]*_+e[15]):(r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=e[9],p=e[10],f=e[11],t[0]=i=e[0],t[1]=r,t[2]=o,t[3]=s,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]=i*m+a*g+h*_+e[12],t[13]=r*m+l*g+d*_+e[13],t[14]=o*m+c*g+p*_+e[14],t[15]=s*m+u*g+f*_+e[15]),t}function _a(t,e,n){var i=n[0],r=n[1],o=n[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ya(t,e,n){var i=Math.sin(n),r=Math.cos(n),o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*r+c*i,t[5]=s*r+u*i,t[6]=a*r+h*i,t[7]=l*r+d*i,t[8]=c*r-o*i,t[9]=u*r-s*i,t[10]=h*r-a*i,t[11]=d*r-l*i,t}function va(t,e,n){var i=Math.sin(n),r=Math.cos(n),o=e[0],s=e[1],a=e[2],l=e[3],c=e[8],u=e[9],h=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r-c*i,t[1]=s*r-u*i,t[2]=a*r-h*i,t[3]=l*r-d*i,t[8]=o*i+c*r,t[9]=s*i+u*r,t[10]=a*i+h*r,t[11]=l*i+d*r,t}function xa(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ba(t,e,n){var i,r,o,s=n[0],a=n[1],l=n[2],c=Math.hypot(s,a,l);return c<ca?null:(s*=c=1/c,a*=c,l*=c,i=Math.sin(e),r=Math.cos(e),t[0]=s*s*(o=1-r)+r,t[1]=a*s*o+l*i,t[2]=l*s*o-a*i,t[3]=0,t[4]=s*a*o-l*i,t[5]=a*a*o+r,t[6]=l*a*o+s*i,t[7]=0,t[8]=s*l*o+a*i,t[9]=a*l*o-s*i,t[10]=l*l*o+r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Ta=ma;function Ea(){var t=new ua(3);return ua!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Sa(t){var e=new ua(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function wa(t){return Math.hypot(t[0],t[1],t[2])}function Aa(t,e,n){var i=new ua(3);return i[0]=t,i[1]=e,i[2]=n,i}function Ma(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function Ca(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Ia(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function Pa(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}function La(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}function Ra(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Oa(t,e,n,i){return t[0]=e[0]+n[0]*i,t[1]=e[1]+n[1]*i,t[2]=e[2]+n[2]*i,t}function Da(t,e){var n=e[0],i=e[1],r=e[2],o=n*n+i*i+r*r;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function Ba(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Na(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[0],a=n[1],l=n[2];return t[0]=r*l-o*a,t[1]=o*s-i*l,t[2]=i*a-r*s,t}function Fa(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[3]*i+n[7]*r+n[11]*o+n[15];return t[0]=(n[0]*i+n[4]*r+n[8]*o+n[12])/(s=s||1),t[1]=(n[1]*i+n[5]*r+n[9]*o+n[13])/s,t[2]=(n[2]*i+n[6]*r+n[10]*o+n[14])/s,t}function Ua(t,e,n){var i=n[0],r=n[1],o=n[2],s=e[0],a=e[1],l=e[2],c=r*l-o*a,u=o*s-i*l,h=i*a-r*s,d=r*h-o*u,p=o*c-i*h,f=i*u-r*c,m=2*n[3];return u*=m,h*=m,p*=2,f*=2,t[0]=s+(c*=m)+(d*=2),t[1]=a+u+p,t[2]=l+h+f,t}var ka,za=Ca,Ga=Ia,Va=wa;function ja(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t}function $a(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n*n+i*i+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=n*s,t[1]=i*s,t[2]=r*s,t[3]=o*s,t}function Ha(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3];return t[0]=n[0]*i+n[4]*r+n[8]*o+n[12]*s,t[1]=n[1]*i+n[5]*r+n[9]*o+n[13]*s,t[2]=n[2]*i+n[6]*r+n[10]*o+n[14]*s,t[3]=n[3]*i+n[7]*r+n[11]*o+n[15]*s,t}function Wa(){var t=new ua(4);return ua!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function qa(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Xa(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),l=Math.cos(n);return t[0]=i*l+s*a,t[1]=r*l+o*a,t[2]=o*l-r*a,t[3]=s*l-i*a,t}function Ya(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),l=Math.cos(n);return t[0]=i*l-o*a,t[1]=r*l+s*a,t[2]=o*l+i*a,t[3]=s*l-r*a,t}Ea(),ka=new ua(4),ua!=Float32Array&&(ka[0]=0,ka[1]=0,ka[2]=0,ka[3]=0);var Za=$a;Ea(),Aa(1,0,0),Aa(0,1,0),Wa(),Wa(),ha();const Ja=ko([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Ka}=Ja,Qa=ko([{name:"a_pos_3",components:3,type:"Int16"}]);var tl=ko([{name:"a_pos",type:"Int16",components:2}]);class el{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,n){const i=Ba(e,this.dir);if(Math.abs(i)<1e-6)return!1;const r=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[2])/i;return n[0]=this.pos[0]+this.dir[0]*r,n[1]=this.pos[1]+this.dir[1]*r,n[2]=this.pos[2]+this.dir[2]*r,!0}closestPointOnSphere(t,e,n){if(function(t,e){var n=t[0],i=t[1],r=t[2],o=e[0],s=e[1],a=e[2];return Math.abs(n-o)<=ca*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-s)<=ca*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=ca*Math.max(1,Math.abs(r),Math.abs(a))}(this.pos,t)||0===e)return n[0]=n[1]=n[2]=0,!1;const[i,r,o]=this.dir,s=this.pos[0]-t[0],a=this.pos[1]-t[1],l=this.pos[2]-t[2],c=i*i+r*r+o*o,u=2*(s*i+a*r+l*o),h=u*u-4*c*(s*s+a*a+l*l-e*e);if(h<0){const t=Math.max(-u/2,0),c=s+i*t,h=a+r*t,d=l+o*t,p=Math.hypot(c,h,d);return n[0]=c*e/p,n[1]=h*e/p,n[2]=d*e/p,!1}{const t=(-u-Math.sqrt(h))/(2*c);if(t<0){const t=Math.hypot(s,a,l);return n[0]=s*e/t,n[1]=a*e/t,n[2]=l*e/t,!1}return n[0]=s+i*t,n[1]=a+r*t,n[2]=l+o*t,!0}}}class nl{constructor(t,e,n,i,r){this.TL=t,this.TR=e,this.BR=n,this.BL=i,this.horizon=r}static fromInvProjectionMatrix(t,e,n){const i=[-1,1,1],r=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Fa(i,i,t),l=Fa(r,r,t),c=Fa(o,o,t),u=Fa(s,s,t);return new nl(a,l,c,u,e/n)}}class il{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,n,i){const r=Math.pow(2,n),o=[[-1,1,-1,1],[1,1,-1,1],[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((n=>{const o=Ha([],n,t),s=1/o[3]/e*r;return function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t[3]=e[3]*n[3],t}(o,o,[s,s,i?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=Da([],Na([],za([],o[t[0]],o[t[1]]),za([],o[t[2]],o[t[1]]))),n=-Ba(e,o[t[1]]);return e.concat(n)}));return new il(o,s)}}class rl{static fromPoints(t){const e=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const i of t)Pa(e,e,i),La(n,n,i);return new rl(e,n)}static applyTransform(t,e){const n=t.getCorners();for(let t=0;t<n.length;++t)Fa(n[t],n[t],e);return rl.fromPoints(n)}constructor(t,e){this.min=t,this.max=e,this.center=Ra([],Ma([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],n=Sa(this.min),i=Sa(this.max);for(let t=0;t<e.length;t++)n[t]=e[t]?this.min[t]:this.center[t],i[t]=e[t]?this.center[t]:this.max[t];return i[2]=this.max[2],new rl(n,i)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){const t=this.min,e=this.max;return[[t[0],t[1],t[2]],[e[0],t[1],t[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],e[2]],[t[0],e[1],e[2]]]}intersects(t){const e=this.getCorners();let n=!0;for(let i=0;i<t.planes.length;i++){const r=t.planes[i];let o=0;for(let t=0;t<e.length;t++)o+=Ba(r,e[t])+r[3]>=0;if(0===o)return 0;o!==e.length&&(n=!1)}if(n)return 2;for(let e=0;e<3;e++){let n=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let r=0;r<t.points.length;r++){const o=t.points[r][e]-this.min[e];n=Math.min(n,o),i=Math.max(i,o)}if(i<0||n>this.max[e]-this.min[e])return 0}return 1}}const ol=5,sl=6,al=aa/Math.PI/2,ll=16383,cl=64,ul=[cl,32,16],hl=-al,dl=al,pl=[new rl([hl,hl,hl],[dl,dl,dl]),new rl([hl,hl,hl],[0,0,dl]),new rl([0,hl,hl],[dl,0,dl]),new rl([hl,0,hl],[0,dl,dl]),new rl([0,0,hl],[dl,dl,dl])];function fl(t){return t*al/kl}function ml(t,e,n,i=!0){const r=Ra([],t._camera.position,t.worldSize),o=[e,n,1,1];Ha(o,o,t.pixelMatrixInverse),ja(o,o,1/o[3]);const s=Da([],za([],o,r)),a=t.globeMatrix,l=[a[12],a[13],a[14]],c=za([],l,r),u=wa(c),h=Da([],c),d=t.worldSize/(2*Math.PI),p=Ba(h,s),f=Math.asin(d/u);if(f<Math.acos(p)){if(!i)return null;const t=[],e=[];Ra(t,s,u/p),Da(e,za(e,t,c)),Da(s,Ma(s,c,Ra(s,e,Math.tan(f)*u)))}const m=[];new el(r,s).closestPointOnSphere(l,d,m);const g=Da([],K(a,0)),_=Da([],K(a,1)),y=Da([],K(a,2)),v=Ba(g,m),x=Ba(_,m),b=Ba(y,m),E=T(Math.asin(-x/d));let S=T(Math.atan2(v,b));S=t.center.lng+function(t,e){const n=(e-t+180)%360-180;return n<-180?n+360:n}(t.center.lng,S);const w=$l(S),A=M(Hl(E),0,1);return new Kl(w,A)}class gl{constructor(t,e,n){this.a=za([],t,n),this.b=za([],e,n),this.center=n;const i=Da([],this.a),r=Da([],this.b);this.angle=Math.acos(Ba(i,r))}}function _l(t,e){if(0===t.angle)return null;let n;return n=0===t.a[e]?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[e]/t.a[e]/Math.sin(t.angle)-1/Math.tan(t.angle)),n<0||n>1?null:function(t,e,n,i){const r=Math.sin(n);return t*(Math.sin((1-i)*n)/r)+e*(Math.sin(i*n)/r)}(t.a[e],t.b[e],t.angle,M(n,0,1))+t.center[e]}function yl(t){if(t.z<=1)return pl[t.z+2*t.y+t.x];const e=Sl(El(t));return rl.fromPoints(e)}function vl(t,e,n){return Ra(t,t,1-n),Oa(t,t,e,n)}function xl(t,e){const n=Ol(e.zoom);if(0===n)return yl(t);const i=El(t),r=Sl(i),o=$l(i.getWest())*e.worldSize,s=$l(i.getEast())*e.worldSize,a=Hl(i.getNorth())*e.worldSize,l=Hl(i.getSouth())*e.worldSize,c=[o,a,0],u=[s,a,0],h=[o,l,0],d=[s,l,0],p=fa([],e.globeMatrix);return Fa(c,c,p),Fa(u,u,p),Fa(h,h,p),Fa(d,d,p),r[0]=vl(r[0],h,n),r[1]=vl(r[1],d,n),r[2]=vl(r[2],u,n),r[3]=vl(r[3],c,n),rl.fromPoints(r)}function bl(t,e,n){for(const i of t)Fa(i,i,e),Ra(i,i,n)}function Tl(t,e,n){const i=e/t.worldSize,r=t.globeMatrix;if(n.z<=1){const t=yl(n).getCorners();return bl(t,r,i),rl.fromPoints(t)}const o=El(n),s=Sl(o);bl(s,r,i);const a=Number.MAX_VALUE,l=[-a,-a,-a],c=[a,a,a];if(o.contains(t.center)){for(const t of s)Pa(c,c,t),La(l,l,t);l[2]=0;const e=t.point,n=[e.x*i,e.y*i,0];return Pa(c,c,n),La(l,l,n),new rl(c,l)}const u=[r[12]*i,r[13]*i,r[14]*i],h=o.getCenter(),d=M(t.center.lat,-Zl,Zl),p=M(h.lat,-Zl,Zl),f=$l(t.center.lng),m=Hl(d);let g=f-$l(h.lng);const _=m-Hl(p);g>.5?g-=1:g<-.5&&(g+=1);let y=0;Math.abs(g)>Math.abs(_)?y=g>=0?1:3:(y=_>=0?0:2,Oa(u,u,[r[4]*i,r[5]*i,r[6]*i],-Math.sin(b(_>=0?o.getSouth():o.getNorth()))*al));const v=s[y],x=s[(y+1)%4],T=new gl(v,x,u),E=[_l(T,0)||v[0],_l(T,1)||v[1],_l(T,2)||v[2]],S=Ol(t.zoom);if(S>0){const i=function({x:t,y:e,z:n},i,r,o,s){const a=1/(1<<n);let l=t*a,c=l+a,u=e*a,h=u+a,d=0;const p=(l+c)/2-o;return p>.5?d=-1:p<-.5&&(d=1),l=((l+d)*i-(o*=i))*r+o,c=((c+d)*i-o)*r+o,u=(u*i-(s*=i))*r+s,h=(h*i-s)*r+s,[[l,h,0],[c,h,0],[c,u,0],[l,u,0]]}(n,e,t._pixelsPerMercatorPixel,f,m);for(let t=0;t<s.length;t++)vl(s[t],i[t],S);const r=Ma([],i[y],i[(y+1)%4]);Ra(r,r,.5),vl(E,r,S)}for(const t of s)Pa(c,c,t),La(l,l,t);return c[2]=Math.min(v[2],x[2]),Pa(c,c,E),La(l,l,E),new rl(c,l)}function El({x:t,y:e,z:n}){const i=1/(1<<n),r=new Vl(ql(t*i),Xl((e+1)*i)),o=new Vl(ql((t+1)*i),Xl(e*i));return new la(r,o)}function Sl(t){const e=b(t.getNorth()),n=b(t.getSouth()),i=Math.cos(e),r=Math.cos(n),o=Math.sin(e),s=Math.sin(n),a=t.getWest(),l=t.getEast();return[wl(r,s,a),wl(r,s,l),wl(i,o,l),wl(i,o,a)]}function wl(t,e,n,i=al){return n=b(n),[t*Math.sin(n)*i,-e*i,t*Math.cos(n)*i]}function Al(t,e,n){return wl(Math.cos(b(t)),Math.sin(b(t)),e,n)}function Ml(t,e,n,i){const r=1<<n.z,o=(t/aa+n.x)/r;return Al(Xl((e/aa+n.y)/r),ql(o),i)}function Cl({min:t,max:e}){return ll/Math.max(e[0]-t[0],e[1]-t[1],e[2]-t[2])}const Il=new Float64Array(16);function Pl(t){const e=Cl(t),n=xa(Il,[e,e,e]);return ga(n,n,((i=[])[0]=-(r=t.min)[0],i[1]=-r[1],i[2]=-r[2],i));var i,r}function Ll(t){const e=(i=t.min,(n=Il)[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=i[0],n[13]=i[1],n[14]=i[2],n[15]=1,n);var n,i;const r=1/Cl(t);return _a(e,e,[r,r,r])}function Rl(t,e,n,i,r){const o=function(t){const e=aa/(2*Math.PI);return t/(2*Math.PI)/e}(n),s=[t,e,-n/(2*Math.PI)],a=pa(new Float64Array(16));return ga(a,a,s),_a(a,a,[o,o,o]),ya(a,a,b(-r)),va(a,a,b(-i)),a}function Ol(t){return C(ol,sl,t)}function Dl(t,e){const n=Al(e.lat,e.lng),i=function(t){const e=Al(t._center.lat,t._center.lng);let n=Na([],Aa(0,1,0),e);const i=ba([],-t.angle,e);n=Fa(n,n,i),ba(i,-t._pitch,n);const r=Da([],e);return Ra(r,r,fl(t.cameraToCenterDistance/t.pixelsPerMeter)),Fa(r,r,i),Ma([],e,r)}(t);return s=(r=Ca([],i,n))[0],a=r[1],l=r[2],c=(o=n)[0],u=o[1],h=o[2],p=(d=Math.sqrt(s*s+a*a+l*l)*Math.sqrt(c*c+u*u+h*h))&&Ba(r,o)/d,Math.acos(Math.min(Math.max(p,-1),1));var r,o,s,a,l,c,u,h,d,p}function Bl(t,e){return Dl(t,e)>Math.PI/2*1.01}const Nl=b(85),Fl=Math.cos(Nl),Ul=Math.sin(Nl),kl=6371008.8,zl=2*Math.PI*kl;class Gl{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Gl(I(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,n=this.lat*e,i=t.lat*e,r=Math.sin(n)*Math.sin(i)+Math.cos(n)*Math.cos(i)*Math.cos((t.lng-this.lng)*e);return kl*Math.acos(Math.min(r,1))}toBounds(t=0){const e=360*t/40075017,n=e/Math.cos(Math.PI/180*this.lat);return new la(new Gl(this.lng-n,this.lat-e),new Gl(this.lng+n,this.lat+e))}toEcef(t){const e=fl(t);return Al(this.lat,this.lng,al+e)}static convert(t){if(t instanceof Gl)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Gl(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Gl(Number("lng"in t?t.lng:t.lon),Number(t.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>]")}}var Vl=Gl;function jl(t){return zl*Math.cos(t*Math.PI/180)}function $l(t){return(180+t)/360}function Hl(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Wl(t,e){return t/jl(e)}function ql(t){return 360*t-180}function Xl(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Yl(t,e){return t*jl(Xl(e))}const Zl=85.051129;function Jl(t){return 1/Math.cos(t*Math.PI/180)}class Kl{constructor(t,e,n=0){this.x=+t,this.y=+e,this.z=+n}static fromLngLat(t,e=0){const n=Vl.convert(t);return new Kl($l(n.lng),Hl(n.lat),Wl(e,n.lat))}toLngLat(){return new Vl(ql(this.x),Xl(this.y))}toAltitude(){return Yl(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/zl*Jl(Xl(this.y))}}function Ql(t,e,n,i,r,o,s,a,l){const c=(e+i)/2,u=(n+r)/2,h=new y(c,u);a(h),function(t,e,n,i,r,o){const s=n-r,a=i-o;return Math.abs((i-e)*s-(n-t)*a)/Math.hypot(s,a)}(h.x,h.y,o.x,o.y,s.x,s.y)>=l?(Ql(t,e,n,c,u,o,h,a,l),Ql(t,c,u,i,r,h,s,a,l)):t.push(s)}function tc(t,e,n){let i=t[0],r=i.x,o=i.y;e(i);const s=[i];for(let a=1;a<t.length;a++){const l=t[a],{x:c,y:u}=l;e(l),Ql(s,r,o,c,u,i,l,e,n),r=c,o=u,i=l}return s}function ec(t,e,n,i){if(i(e,n)){const r=e.add(n)._mult(.5);ec(t,e,r,i),ec(t,r,n,i)}else t.push(n)}function nc(t,e){let n=t[0];const i=[n];for(let r=1;r<t.length;r++){const o=t[r];ec(i,n,o,e),n=o}return i}const ic=Math.pow(2,14)-1,rc=-ic-1;function oc(t,e){const n=Math.round(t.x*e),i=Math.round(t.y*e);return t.x=M(n,rc,ic),t.y=M(i,rc,ic),(n<t.x||n>t.x+1||i<t.y||i>t.y+1)&&$("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function sc(t,e,n){const i=t.loadGeometry(),r=t.extent,o=aa/r;if(e&&n&&n.projection.isReprojectedInTileSpace){const o=1<<e.z,{scale:s,x:a,y:l,projection:c}=n,u=t=>{const n=ql((e.x+t.x/r)/o),i=Xl((e.y+t.y/r)/o),u=c.project(n,i);t.x=(u.x*s-a)*r,t.y=(u.y*s-l)*r};for(let e=0;e<i.length;e++)if(1!==t.type)i[e]=tc(i[e],u,1);else{const t=[];for(const n of i[e])n.x<0||n.x>=r||n.y<0||n.y>=r||(u(n),t.push(n));i[e]=t}}for(const t of i)for(const e of t)oc(e,o);return i}function ac(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?sc(t):[]}}function lc(t,e,n,i,r){t.emplaceBack(2*e+(i+1)/2,2*n+(r+1)/2)}function cc(t,e,n){const i=16384;t.emplaceBack(e.x,e.y,e.z,n[0]*i,n[1]*i,n[2]*i)}class uc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Go,this.indexArray=new is,this.segments=new sa,this.programConfigurations=new Zs(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,n,i){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ac(e,t);if(!this.layers[0]._featureFilter.filter(new To(this.zoom),c,n))continue;const u=s?s.evaluate(c,{},n):void 0,h={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:sc(e,n,i),patterns:{},sortKey:u};o.push(h)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===i.projection.name&&(this.globeExtVertexArray=new Xo,a=i.projection);for(const i of o){const{geometry:r,index:o,sourceLayerIndex:s}=i,l=t[o].feature;this.addFeature(i,r,o,e.availableImages,n,a),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,n,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,n,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ra.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,oa.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,n,i,r,o){for(const n of e)for(const e of n){const n=e.x,i=e.y;if(n<0||n>=aa||i<0||i>=aa)continue;if(o){const t=o.projectTilePoint(n,i,r),e=o.upVector(r,n,i),s=this.globeExtVertexArray;cc(s,t,e),cc(s,t,e),cc(s,t,e),cc(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;lc(this.layoutVertexArray,n,i,-1,-1),lc(this.layoutVertexArray,n,i,1,-1),lc(this.layoutVertexArray,n,i,1,1),lc(this.layoutVertexArray,n,i,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,{},i,r)}}function hc(t,e){for(let n=0;n<t.length;n++)if(xc(e,t[n]))return!0;for(let n=0;n<e.length;n++)if(xc(t,e[n]))return!0;return!!mc(t,e)}function dc(t,e,n){return!!xc(t,e)||!!_c(e,t,n)}function pc(t,e){if(1===t.length)return vc(e,t[0]);for(let n=0;n<e.length;n++){const i=e[n];for(let e=0;e<i.length;e++)if(xc(t,i[e]))return!0}for(let n=0;n<t.length;n++)if(vc(e,t[n]))return!0;for(let n=0;n<e.length;n++)if(mc(t,e[n]))return!0;return!1}function fc(t,e,n){if(t.length>1){if(mc(t,e))return!0;for(let i=0;i<e.length;i++)if(_c(e[i],t,n))return!0}for(let i=0;i<t.length;i++)if(_c(t[i],e,n))return!0;return!1}function mc(t,e){if(0===t.length||0===e.length)return!1;for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1];for(let t=0;t<e.length-1;t++)if(gc(i,r,e[t],e[t+1]))return!0}return!1}function gc(t,e,n,i){return H(t,n,i)!==H(e,n,i)&&H(t,e,n)!==H(t,e,i)}function _c(t,e,n){const i=n*n;if(1===e.length)return t.distSqr(e[0])<i;for(let n=1;n<e.length;n++)if(yc(t,e[n-1],e[n])<i)return!0;return!1}function yc(t,e,n){const i=e.distSqr(n);if(0===i)return t.distSqr(e);const r=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/i;return t.distSqr(r<0?e:r>1?n:n.sub(e)._mult(r)._add(e))}function vc(t,e){let n,i,r,o=!1;for(let s=0;s<t.length;s++){n=t[s];for(let t=0,s=n.length-1;t<n.length;s=t++)i=n[t],r=n[s],i.y>e.y!=r.y>e.y&&e.x<(r.x-i.x)*(e.y-i.y)/(r.y-i.y)+i.x&&(o=!o)}return o}function xc(t,e){let n=!1;for(let i=0,r=t.length-1;i<t.length;r=i++){const o=t[i],s=t[r];o.y>e.y!=s.y>e.y&&e.x<(s.x-o.x)*(e.y-o.y)/(s.y-o.y)+o.x&&(n=!n)}return n}function bc(t,e,n,i,r){for(const o of t)if(e<=o.x&&n<=o.y&&i>=o.x&&r>=o.y)return!0;const o=[new y(e,n),new y(e,r),new y(i,r),new y(i,n)];if(t.length>2)for(const e of o)if(xc(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Tc(t[e],t[e+1],o))return!0;return!1}function Tc(t,e,n){const i=n[0],r=n[2];if(t.x<i.x&&e.x<i.x||t.x>r.x&&e.x>r.x||t.y<i.y&&e.y<i.y||t.y>r.y&&e.y>r.y)return!1;const o=H(t,e,n[0]);return o!==H(t,e,n[1])||o!==H(t,e,n[2])||o!==H(t,e,n[3])}function Ec(t,e,n){const i=e.paint.get(t).value;return"constant"===i.kind?i.value:n.programConfigurations.get(e.id).getMaxValue(t)}function Sc(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function wc(t,e,n,i,r){if(!e[0]&&!e[1])return t;const o=y.convert(e)._mult(r);"viewport"===n&&o._rotate(-i);const s=[];for(let e=0;e<t.length;e++)s.push(t[e].sub(o));return s}function Ac(t,e,n,i){const r=y.convert(t)._mult(i);return"viewport"===e&&r._rotate(-n),r}Yr(uc,"CircleBucket",{omit:["layers"]});const Mc=new Do({"circle-sort-key":new Ro(te.layout_circle["circle-sort-key"])});var Cc={paint:new Do({"circle-radius":new Ro(te.paint_circle["circle-radius"]),"circle-color":new Ro(te.paint_circle["circle-color"]),"circle-blur":new Ro(te.paint_circle["circle-blur"]),"circle-opacity":new Ro(te.paint_circle["circle-opacity"]),"circle-translate":new Lo(te.paint_circle["circle-translate"]),"circle-translate-anchor":new Lo(te.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Lo(te.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Lo(te.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ro(te.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ro(te.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ro(te.paint_circle["circle-stroke-opacity"])}),layout:Mc};function Ic(t,e,n,i,r,o,s,a,l){if(o&&t.queryGeometry.isAboveHorizon)return!1;o&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,u=n.projection.upVectorScale(c,n.center.lat,n.worldSize).metersToTile;for(const h of e)for(const e of h){const h=e.add(a),d=r&&n.elevation?n.elevation.exaggeration()*r.getElevationAt(h.x,h.y,!0):0,p=n.projection.projectTilePoint(h.x,h.y,c);if(d>0){const t=n.projection.upVector(c,h.x,h.y);p.x+=t[0]*u*d,p.y+=t[1]*u*d,p.z+=t[2]*u*d}const f=o?h:Pc(p.x,p.y,p.z,i),m=o?t.tilespaceRays.map((t=>Oc(t,d))):t.queryGeometry.screenGeometry,g=Ha([],[p.x,p.y,p.z,1],i);if(!s&&o?l*=g[3]/n.cameraToCenterDistance:s&&!o&&(l*=n.cameraToCenterDistance/g[3]),o){const t=Xl((e.y/aa+c.y)/(1<<c.z));l/=n.projection.pixelsPerMeter(t,1)/Wl(1,t)}if(dc(m,f,l))return!0}return!1}function Pc(t,e,n,i){const r=Ha([],[t,e,n,1],i);return new y(r[0]/r[3],r[1]/r[3])}const Lc=Aa(0,0,0),Rc=Aa(0,0,1);function Oc(t,e){const n=Ea();return Lc[2]=e,t.intersectsPlane(Lc,Rc,n),new y(n[0],n[1])}class Dc extends uc{}function Bc(t,{width:e,height:n},i,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==e*n*i)throw new RangeError("mismatched image size")}else r=new Uint8Array(e*n*i);return t.width=e,t.height=n,t.data=r,t}function Nc(t,e,n){const{width:i,height:r}=e;i===t.width&&r===t.height||(Fc(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,i),height:Math.min(t.height,r)},n),t.width=i,t.height=r,t.data=e.data)}function Fc(t,e,n,i,r,o){if(0===r.width||0===r.height)return e;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 source coordinates for image copy");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 destination coordinates for image copy");const s=t.data,a=e.data;for(let l=0;l<r.height;l++){const c=((n.y+l)*t.width+n.x)*o,u=((i.y+l)*e.width+i.x)*o;for(let t=0;t<r.width*o;t++)a[u+t]=s[c+t]}return e}Yr(Dc,"HeatmapBucket",{omit:["layers"]});class Uc{constructor(t,e){Bc(this,t,1,e)}resize(t){Nc(this,new Uc(t),1)}clone(){return new Uc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,n,i,r){Fc(t,e,n,i,r,1)}}class kc{constructor(t,e){Bc(this,t,4,e)}resize(t){Nc(this,new kc(t),4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new kc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,n,i,r){Fc(t,e,n,i,r,4)}}Yr(Uc,"AlphaImage"),Yr(kc,"RGBAImage");var zc={paint:new Do({"heatmap-radius":new Ro(te.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ro(te.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Lo(te.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Oo(te.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Lo(te.paint_heatmap["heatmap-opacity"])})};function Gc(t){const e={},n=t.resolution||256,i=t.clips?t.clips.length:1,r=t.image||new kc({width:n,height:i}),o=(n,i,o)=>{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);r.data[n+i+0]=Math.floor(255*s.r/s.a),r.data[n+i+1]=Math.floor(255*s.g/s.a),r.data[n+i+2]=Math.floor(255*s.b/s.a),r.data[n+i+3]=Math.floor(255*s.a)};if(t.clips)for(let e=0,r=0;e<i;++e,r+=4*n)for(let i=0,s=0;i<n;i++,s+=4){const a=i/(n-1),{start:l,end:c}=t.clips[e];o(r,s,l*(1-a)+c*a)}else for(let t=0,e=0;t<n;t++,e+=4)o(0,e,t/(n-1));return r}var Vc={paint:new Do({"hillshade-illumination-direction":new Lo(te.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Lo(te.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Lo(te.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Lo(te.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Lo(te.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Lo(te.paint_hillshade["hillshade-accent-color"])})};const jc=ko([{name:"a_pos",components:2,type:"Int16"}],4),{members:$c}=jc;var Hc={exports:{}};function Wc(t,e,n){n=n||2;var i,r,o,s,a,l,c,u=e&&e.length,h=u?e[0]*n:t.length,d=qc(t,0,h,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,n,i){var r,o,s,a=[];for(r=0,o=e.length;r<o;r++)(s=qc(t,e[r]*i,r<o-1?e[r+1]*i:t.length,i,!1))===s.next&&(s.steiner=!0),a.push(ru(s));for(a.sort(tu),r=0;r<a.length;r++)n=eu(a[r],n);return n}(t,e,d,n)),t.length>80*n){i=o=t[0],r=s=t[1];for(var f=n;f<h;f+=n)(a=t[f])<i&&(i=a),(l=t[f+1])<r&&(r=l),a>o&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-i,s-r))?32767/c:0}return Yc(d,p,n,i,r,c,0),p}function qc(t,e,n,i,r){var o,s;if(r===_u(t,e,n,i)>0)for(o=e;o<n;o+=i)s=fu(o,t[o],t[o+1],s);else for(o=n-i;o>=e;o-=i)s=fu(o,t[o],t[o+1],s);return s&&lu(s,s.next)&&(mu(s),s=s.next),s}function Xc(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!lu(i,i.next)&&0!==au(i.prev,i,i.next))i=i.next;else{if(mu(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function Yc(t,e,n,i,r,o,s){if(t){!s&&o&&function(t,e,n,i){var r=t;do{0===r.z&&(r.z=iu(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,l,c=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ);e++);for(l=c;a>0||l>0&&i;)0!==a&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(s>1)}(r)}(t,i,r,o);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,o?Jc(t,i,r,o):Zc(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),mu(t),t=l.next,c=l.next;else if((t=l)===c){s?1===s?Yc(t=Kc(Xc(t),e,n),e,n,i,r,o,2):2===s&&Qc(t,e,n,i,r,o):Yc(Xc(t),e,n,i,r,o,1);break}}}function Zc(t){var e=t.prev,n=t,i=t.next;if(au(e,n,i)>=0)return!1;for(var r=e.x,o=n.x,s=i.x,a=e.y,l=n.y,c=i.y,u=r<o?r<s?r:s:o<s?o:s,h=a<l?a<c?a:c:l<c?l:c,d=r>o?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c,f=i.next;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&ou(r,a,o,l,s,c,f.x,f.y)&&au(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Jc(t,e,n,i){var r=t.prev,o=t,s=t.next;if(au(r,o,s)>=0)return!1;for(var a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=a<l?a<c?a:c:l<c?l:c,f=u<h?u<d?u:d:h<d?h:d,m=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,_=iu(p,f,e,n,i),y=iu(m,g,e,n,i),v=t.prevZ,x=t.nextZ;v&&v.z>=_&&x&&x.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&ou(a,u,l,h,c,d,v.x,v.y)&&au(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!==s&&ou(a,u,l,h,c,d,x.x,x.y)&&au(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!==s&&ou(a,u,l,h,c,d,v.x,v.y)&&au(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!==s&&ou(a,u,l,h,c,d,x.x,x.y)&&au(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Kc(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;!lu(r,o)&&cu(r,i,i.next,o)&&du(r,o)&&du(o,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),mu(i),mu(i.next),i=t=o),i=i.next}while(i!==t);return Xc(i)}function Qc(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&su(s,a)){var l=pu(s,a);return s=Xc(s,s.next),l=Xc(l,l.next),Yc(s,e,n,i,r,o,0),void Yc(l,e,n,i,r,o,0)}a=a.next}s=s.next}while(s!==t)}function tu(t,e){return t.x-e.x}function eu(t,e){var n=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==e);if(!n)return null;var l,c=n,u=n.x,h=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=u&&r!==i.x&&ou(o<h?r:s,o,u,h,o<h?s:r,o,i.x,i.y)&&(l=Math.abs(o-i.y)/(r-i.x),du(i,t)&&(l<d||l===d&&(i.x>n.x||i.x===n.x&&nu(n,i)))&&(n=i,d=l)),i=i.next}while(i!==c);return n}(t,e);if(!n)return e;var i=pu(n,t);return Xc(i,i.next),Xc(n,n.next)}function nu(t,e){return au(t.prev,t,e.prev)<0&&au(e.next,t,t.next)<0}function iu(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ru(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function ou(t,e,n,i,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(i-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function su(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&cu(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(du(t,e)&&du(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(au(t.prev,t,e.prev)||au(t,e.prev,e))||lu(t,e)&&au(t.prev,t,t.next)>0&&au(e.prev,e,e.next)>0)}function au(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function lu(t,e){return t.x===e.x&&t.y===e.y}function cu(t,e,n,i){var r=hu(au(t,e,n)),o=hu(au(t,e,i)),s=hu(au(n,i,t)),a=hu(au(n,i,e));return r!==o&&s!==a||!(0!==r||!uu(t,n,e))||!(0!==o||!uu(t,i,e))||!(0!==s||!uu(n,t,i))||!(0!==a||!uu(n,e,i))}function uu(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function hu(t){return t>0?1:t<0?-1:0}function du(t,e){return au(t.prev,t,t.next)<0?au(t,e,t.next)>=0&&au(t,t.prev,e)>=0:au(t,e,t.prev)<0||au(t,t.next,e)<0}function pu(t,e){var n=new gu(t.i,t.x,t.y),i=new gu(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function fu(t,e,n,i){var r=new gu(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function mu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function gu(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function _u(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}Hc.exports=Wc,Hc.exports.default=Wc,Wc.deviation=function(t,e,n,i){var r=e&&e.length,o=Math.abs(_u(t,0,r?e[0]*n:t.length,n));if(r)for(var s=0,a=e.length;s<a;s++)o-=Math.abs(_u(t,e[s]*n,s<a-1?e[s+1]*n:t.length,n));var l=0;for(s=0;s<i.length;s+=3){var c=i[s]*n,u=i[s+1]*n,h=i[s+2]*n;l+=Math.abs((t[c]-t[h])*(t[u+1]-t[c+1])-(t[c]-t[u])*(t[h+1]-t[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},Wc.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);r>0&&n.holes.push(i+=t[r-1].length)}return n};var yu=d(Hc.exports);function vu(t,e,n,i,r){xu(t,e,n,i||t.length-1,r)}function xu(t,e,n,i,r){for(;i>n;){if(i-n>600){var o=i-n+1,s=e-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);xu(t,e,Math.max(n,Math.floor(e-s*l/o+c)),Math.min(i,Math.floor(e+(o-s)*l/o+c)),r)}var u=t[e],h=n,d=i;for(bu(t,n,e),r(t[i],u)>0&&bu(t,n,i);h<d;){for(bu(t,h,d),h++,d--;r(t[h],u)<0;)h++;for(;r(t[d],u)>0;)d--}0===r(t[n],u)?bu(t,n,d):bu(t,++d,i),d<=e&&(n=d+1),e<=d&&(i=d-1)}}function bu(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function Tu(t,e){const n=t.length;if(n<=1)return[t];const i=[];let r,o;for(let e=0;e<n;e++){const n=W(t[e]);0!==n&&(t[e].area=Math.abs(n),void 0===o&&(o=n<0),o===n<0?(r&&i.push(r),r=[t[e]]):r.push(t[e]))}if(r&&i.push(r),e>1)for(let t=0;t<i.length;t++)i[t].length<=e||(vu(i[t],e,1,i[t].length-1,Eu),i[t]=i[t].slice(0,e));return i}function Eu(t,e){return e.area-t.area}function Su(t,e,n){const i=n.patternDependencies;let r=!1;for(const n of e){const e=n.paint.get(`${t}-pattern`);e.isConstant()||(r=!0);const o=e.constantOr(null);o&&(r=!0,i[o]=!0)}return r}function wu(t,e,n,i,r){const o=r.patternDependencies;for(const s of e){const e=s.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:i},n,{},r.availableImages);t=t&&t.name?t.name:t,o[t]=!0,n.patterns[s.id]=t}}return n}class Au{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Go,this.indexArray=new is,this.indexArray2=new cs,this.programConfigurations=new Zs(t.layers,t.zoom),this.segments=new sa,this.segments2=new sa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}populate(t,e,n,i){this.hasPattern=Su("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ac(s,t);if(!this.layers[0]._featureFilter.filter(new To(this.zoom),u,n))continue;const h=r?r.evaluate(u,{},n,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?u.geometry:sc(s,n,i),patterns:{},sortKey:h};o.push(d)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const i of o){const{geometry:r,index:o,sourceLayerIndex:s}=i;if(this.hasPattern){const t=wu("fill",this.layers,i,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(i,r,o,n,{},e.availableImages);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,n,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,n,i)}addFeatures(t,e,n,i,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,n,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,$c),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,n,i,r,o=[]){for(const t of Tu(e,500)){let e=0;for(const n of t)e+=n.length;const n=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),i=n.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const n=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),i=n.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(i+e.length-1,i),r.push(e[0].x),r.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(i+t-1,i+t),r.push(e[t].x),r.push(e[t].y);n.vertexLength+=e.length,n.primitiveLength+=e.length}const s=yu(r,o);for(let t=0;t<s.length;t+=3)this.indexArray.emplaceBack(i+s[t],i+s[t+1],i+s[t+2]);n.vertexLength+=e,n.primitiveLength+=s.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,r,o,i)}}Yr(Au,"FillBucket",{omit:["layers","patternFeatures"]});const Mu=new Do({"fill-sort-key":new Ro(te.layout_fill["fill-sort-key"])});var Cu={paint:new Do({"fill-antialias":new Lo(te.paint_fill["fill-antialias"]),"fill-opacity":new Ro(te.paint_fill["fill-opacity"]),"fill-color":new Ro(te.paint_fill["fill-color"]),"fill-outline-color":new Ro(te.paint_fill["fill-outline-color"]),"fill-translate":new Lo(te.paint_fill["fill-translate"]),"fill-translate-anchor":new Lo(te.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ro(te.paint_fill["fill-pattern"])}),layout:Mu};const Iu=ko([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Pu=ko([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Lu=ko([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Ru}=Iu;var Ou={},Du=g,Bu=Nu;function Nu(t,e,n,i,r){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=r,t.readFields(Fu,this,e)}function Fu(t,e,n){1==t?e.id=n.readVarint():2==t?function(t,e){for(var n=t.readVarint()+t.pos;t.pos<n;){var i=e._keys[t.readVarint()],r=e._values[t.readVarint()];e.properties[i]=r}}(n,e):3==t?e.type=n.readVarint():4==t&&(e._geometry=n.pos)}function Uu(t){for(var e,n,i=0,r=0,o=t.length,s=o-1;r<o;s=r++)i+=((n=t[s]).x-(e=t[r]).x)*(e.y+n.y);return i}Nu.types=["Unknown","Point","LineString","Polygon"],Nu.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,n=t.readVarint()+t.pos,i=1,r=0,o=0,s=0,a=[];t.pos<n;){if(r<=0){var l=t.readVarint();i=7&l,r=l>>3}if(r--,1===i||2===i)o+=t.readSVarint(),s+=t.readSVarint(),1===i&&(e&&a.push(e),e=[]),e.push(new Du(o,s));else{if(7!==i)throw new Error("unknown command "+i);e&&e.push(e[0].clone())}}return e&&a.push(e),a},Nu.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,n=1,i=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos<e;){if(i<=0){var u=t.readVarint();n=7&u,i=u>>3}if(i--,1===n||2===n)(r+=t.readSVarint())<s&&(s=r),r>a&&(a=r),(o+=t.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==n)throw new Error("unknown command "+n)}return[s,l,a,c]},Nu.prototype.toGeoJSON=function(t,e,n){var i,r,o=this.extent*Math.pow(2,n),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=Nu.types[this.type];function u(t){for(var e=0;e<t.length;e++){var n=t[e];t[e]=[360*(n.x+s)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(n.y+a)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(i=0;i<l.length;i++)h[i]=l[i][0];u(l=h);break;case 2:for(i=0;i<l.length;i++)u(l[i]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var n,i,r=[],o=0;o<e;o++){var s=Uu(t[o]);0!==s&&(void 0===i&&(i=s<0),i===s<0?(n&&r.push(n),n=[t[o]]):n.push(t[o]))}return n&&r.push(n),r}(l),i=0;i<l.length;i++)for(r=0;r<l[i].length;r++)u(l[i][r])}1===l.length?l=l[0]:c="Multi"+c;var d={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(d.id=this.id),d};var ku=Bu,zu=Gu;function Gu(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Vu,this,e),this.length=this._features.length}function Vu(t,e,n){15===t?e.version=n.readVarint():1===t?e.name=n.readString():5===t?e.extent=n.readVarint():2===t?e._features.push(n.pos):3===t?e._keys.push(n.readString()):4===t&&e._values.push(function(t){for(var e=null,n=t.readVarint()+t.pos;t.pos<n;){var i=t.readVarint()>>3;e=1===i?t.readString():2===i?t.readFloat():3===i?t.readDouble():4===i?t.readVarint64():5===i?t.readVarint():6===i?t.readSVarint():7===i?t.readBoolean():null}return e}(n))}Gu.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new ku(this._pbf,e,this.extent,this._keys,this._values)};var ju=zu;function $u(t,e,n){if(3===t){var i=new ju(n,n.readVarint()+n.pos);i.length&&(e[i.name]=i)}}var Hu=Ou.VectorTile=function(t,e){this.layers=t.readFields($u,{},e)},Wu=Ou.VectorTileFeature=Bu;function qu(t,e,n,i){const r=[],o=0===i?(t,e,n,i,r,o)=>{t.push(new y(o,n+(o-e)/(i-e)*(r-n)))}:(t,e,n,i,r,o)=>{t.push(new y(e+(o-n)/(r-n)*(i-e),o))};for(const s of t){const t=[];for(const r of s){if(r.length<=2)continue;const s=[];for(let t=0;t<r.length-1;t++){const a=r[t].x,l=r[t].y,c=r[t+1].x,u=r[t+1].y,h=0===i?a:l,d=0===i?c:u;h<e?d>e&&o(s,a,l,c,u,e):h>n?d<n&&o(s,a,l,c,u,n):s.push(r[t]),d<e&&h>=e&&o(s,a,l,c,u,e),d>n&&h<=n&&o(s,a,l,c,u,n)}let a=r[r.length-1];const l=0===i?a.x:a.y;l>=e&&l<=n&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),t.push(s))}t.length&&r.push(t)}return r}Ou.VectorTileLayer=zu;const Xu=Wu.types,Yu=Math.pow(2,13);function Zu(t,e,n,i,r,o,s,a){t.emplaceBack((e<<1)+s,(n<<1)+o,(Math.floor(i*Yu)<<1)+r,Math.round(a))}function Ju(t,e,n){const i=16384;t.emplaceBack(e.x,e.y,e.z,n[0]*i,n[1]*i,n[2]*i)}class Ku{constructor(){this.acc=new y(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new y(t.x,t.y),this.max=new y(t.x,t.y))}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);const n=this.min,i=this.max;t.x<n.x?n.x=t.x:t.x>i.x&&(i.x=t.x),t.y<n.y?n.y=t.y:t.y>i.y&&(i.y=t.y),((0===t.x||t.x===aa)&&t.x===e.x)!=((0===t.y||t.y===aa)&&t.y===e.y)&&this.processBorderOverlap(t,e),e.x<0!=t.x<0&&this.addBorderIntersection(0,Rn(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>aa!=t.x>aa&&this.addBorderIntersection(1,Rn(e.y,t.y,(aa-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,Rn(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>aa!=t.y>aa&&this.addBorderIntersection(3,Rn(e.x,t.x,(aa-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){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 n=this.borders[t];e<n[0]&&(n[0]=e),e>n[1]&&(n[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const n=0===t.x?0:1;this.addBorderIntersection(n,e.y),this.addBorderIntersection(n,t.y)}else{const n=0===t.y?2:3;this.addBorderIntersection(n,e.x),this.addBorderIntersection(n,t.x)}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new y(0,0)}span(){return new y(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class Qu{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.layoutVertexArray=new jo,this.centroidVertexArray=new Ts,this.indexArray=new is,this.programConfigurations=new Zs(t.layers,t.zoom),this.segments=new sa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain}populate(t,e,n,i){this.features=[],this.hasPattern=Su("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<<t.z)*2));return 80150034*e/(e*e+1)/aa/(1<<t.z)}(n),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=ac(r,t);if(!this.layers[0]._featureFilter.filter(new To(this.zoom),l,n))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:sc(r,n,i),properties:r.properties,type:r.type,patterns:{}},u=this.layoutVertexArray.length;this.hasPattern?this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,n,{},e.availableImages,i),e.featureIndex.insert(r,c.geometry,s,a,this.index,u)}this.sortBorders()}addFeatures(t,e,n,i,r){for(const t of this.features){const{geometry:o}=t;this.addFeature(t,o,t.index,e,n,i,r)}this.sortBorders()}update(t,e,n,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,n,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ru),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Lu.members,!0))),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Pu.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,n,i,r,o,s){const a=[new y(0,0),new y(aa,aa)],l=s.projection,c="globe"===l.name,u=this.enableTerrain&&!c?new Ku:null,h="Polygon"===Xu[t.type];c&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Xo);const d=Tu(e,500);for(let t=d.length-1;t>=0;t--){const e=d[t];(0===e.length||(p=e[0]).every((t=>t.x<=0))||p.every((t=>t.x>=aa))||p.every((t=>t.y<=0))||p.every((t=>t.y>=aa)))&&d.splice(t,1)}var p;let f;if(c)f=ah(d,a,i);else{f=[];for(const t of d)f.push({polygon:t,bounds:a})}const m=h?this.edgeRadius:0;for(const{polygon:t,bounds:e}of f){let n=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);if(h){const e=[],r=[];n=o.vertexLength;for(const n of t){let s,a;n.length&&n!==t[0]&&r.push(e.length/2),s=n[1].sub(n[0])._perp()._unit();for(let t=1;t<n.length;t++){const r=n[t],u=n[t===n.length-1?1:t+1];let{x:h,y:d}=r;if(m){a=u.sub(r)._perp()._unit();const t=s.add(a)._unit(),e=m*Math.min(4,1/(s.x*t.x+s.y*t.y));h+=e*t.x,d+=e*t.y,s=a}Zu(this.layoutVertexArray,h,d,0,0,1,1,0),o.vertexLength++,e.push(r.x,r.y),c&&Ju(this.layoutVertexExtArray,l.projectTilePoint(h,d,i),l.upVector(i,h,d))}}const s=yu(e,r);for(let t=0;t<s.length;t+=3)this.indexArray.emplaceBack(n+s[t],n+s[t+2],n+s[t+1]),o.primitiveLength++}for(const r of t){u&&r.length&&u.startRing(r[0]);let t,s,a,d=r.length>4&&rh(r[r.length-2],r[0],r[1]),p=m?eh(r[r.length-2],r[0],r[1],m):0;s=r[1].sub(r[0])._perp()._unit();let f=!0;for(let g=1,_=0;g<r.length;g++){let y=r[g-1],v=r[g];const x=r[g===r.length-1?1:g+1];if(u&&h&&u.currentPolyCount.top++,ih(v,y,e)){m&&(s=x.sub(v)._perp()._unit(),f=!f);continue}u&&u.append(v,y);const b=v.sub(y)._perp(),T=b.x/(Math.abs(b.x)+Math.abs(b.y)),E=b.y>0?1:0,S=y.dist(v);if(_+S>32768&&(_=0),m){a=x.sub(v)._perp()._unit();let t=nh(y,v,x,th(s,a),m);isNaN(t)&&(t=0);const e=v.sub(y)._unit();y=y.add(e.mult(p))._round(),v=v.add(e.mult(-t))._round(),p=t,s=a}const w=o.vertexLength,A=r.length>4&&rh(y,v,x);let M=oh(_,d,f);if(Zu(this.layoutVertexArray,y.x,y.y,T,E,0,0,M),Zu(this.layoutVertexArray,y.x,y.y,T,E,0,1,M),_+=S,M=oh(_,A,!f),d=A,Zu(this.layoutVertexArray,v.x,v.y,T,E,0,0,M),Zu(this.layoutVertexArray,v.x,v.y,T,E,0,1,M),o.vertexLength+=4,this.indexArray.emplaceBack(w+0,w+1,w+2),this.indexArray.emplaceBack(w+1,w+3,w+2),o.primitiveLength+=2,m){const i=n+(1===g?r.length-2:g-2),s=1===g?n:i+1;if(this.indexArray.emplaceBack(w+1,i,w+3),this.indexArray.emplaceBack(i,s,w+3),o.primitiveLength+=2,void 0===t&&(t=w),!ih(x,r[g],e)){const e=g===r.length-1?t:o.vertexLength;this.indexArray.emplaceBack(w+2,w+3,e),this.indexArray.emplaceBack(w+3,e+1,e),this.indexArray.emplaceBack(w+3,s,e+1),o.primitiveLength+=3}f=!f}if(c){const t=this.layoutVertexExtArray,e=l.projectTilePoint(y.x,y.y,i),n=l.projectTilePoint(v.x,v.y,i),r=l.upVector(i,y.x,y.y),o=l.upVector(i,v.x,v.y);Ju(t,e,r),Ju(t,e,r),Ju(t,n,o),Ju(t,n,o)}}h&&(n+=r.length-1)}}if(u&&u.polyCount.length>0){if(u.borders){u.vertexArrayOffset=this.centroidVertexArray.length;const t=u.borders,e=this.featuresOnBorder.push(u)-1;for(let n=0;n<4;n++)t[n][0]!==Number.MAX_VALUE&&this.borders[n].push(e)}this.encodeCentroid(u.borders?void 0:u.centroid(),u)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,r,o,i)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,n)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[n].borders[t][0]))}encodeCentroid(t,e,n=!0){let i,r;if(t)if(0!==t.y){const n=e.span()._mult(this.tileToMeter);i=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(n.x/10)),r=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(n.y/10))}else i=Math.ceil(7*(t.x+450)),r=0;else i=0,r=+n;let o=n?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;e<t.top;e++)this.centroidVertexArray.emplace(o++,i,r);for(let e=0;e<2*t.edges;e++)this.centroidVertexArray.emplace(o++,0,r),this.centroidVertexArray.emplace(o++,i,r)}}}function th(t,e){const n=t.add(e)._unit();return t.x*n.x+t.y*n.y}function eh(t,e,n,i){const r=e.sub(t)._perp()._unit(),o=n.sub(e)._perp()._unit();return nh(t,e,n,th(r,o),i)}function nh(t,e,n,i,r){const o=Math.sqrt(1-i*i);return Math.min(t.dist(e)/3,e.dist(n)/3,r*o/i)}function ih(t,e,n){return t.x<n[0].x&&e.x<n[0].x||t.x>n[1].x&&e.x>n[1].x||t.y<n[0].y&&e.y<n[0].y||t.y>n[1].y&&e.y>n[1].y}function rh(t,e,n){if(t.x<0||t.x>=aa||e.x<0||e.x>=aa||n.x<0||n.x>=aa)return!1;const i=n.sub(e),r=i.perp(),o=t.sub(e);return(i.x*o.x+i.y*o.y)/Math.sqrt((i.x*i.x+i.y*i.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y<0}function oh(t,e,n){const i=e?2|t:-3&t;return n?1|i:-2&i}function sh(){const t=Math.PI/32,e=Math.tan(t),n=kl;return n*Math.sqrt(1+2*e*e)-n}function ah(t,e,n){const i=1<<n.z,r=ql(n.x/i),o=ql((n.x+1)/i),s=Xl(n.y/i),a=Xl((n.y+1)/i);return function(t,e,n,i,r=0,o){const s=[];if(!t.length||!n||!i)return s;const a=(t,e)=>{for(const n of t)s.push({polygon:n,bounds:e})},l=Math.ceil(Math.log2(n)),c=Math.ceil(Math.log2(i)),u=l-c,h=[];for(let t=0;t<Math.abs(u);t++)h.push(u>0?0:1);for(let t=0;t<Math.min(l,c);t++)h.push(0),h.push(1);let d=t;if(d=qu(d,e[0].y-r,e[1].y+r,1),d=qu(d,e[0].x-r,e[1].x+r,0),!d.length)return s;const p=[];for(h.length?p.push({polygons:d,bounds:e,depth:0}):a(d,e);p.length;){const t=p.pop(),e=t.depth,n=h[e],i=t.bounds[0],s=t.bounds[1],l=0===n?i.x:i.y,c=0===n?s.x:s.y,u=o(n,l,c),d=qu(t.polygons,l-r,u+r,n),f=qu(t.polygons,u-r,c+r,n);if(d.length){const t=[i,new y(0===n?u:s.x,1===n?u:s.y)];h.length>e+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new y(0===n?u:i.x,1===n?u:i.y),s];h.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((n.y+e/aa)/i);return(Hl(.5*(Xl((n.y+r/aa)/i)+t))*i-n.y)*aa}}))}Yr(Qu,"FillExtrusionBucket",{omit:["layers","features"]}),Yr(Ku,"PartMetadata");const lh=new Do({"fill-extrusion-edge-radius":new Lo(te["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var ch={paint:new Do({"fill-extrusion-opacity":new Lo(te["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ro(te["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Lo(te["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Lo(te["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ro(te["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ro(te["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ro(te["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Lo(te["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new Lo(te["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new Lo(te["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new Lo(te["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:lh};function uh(t,e,n){var i=2*Math.PI*6378137/256/Math.pow(2,n);return[t*i-2*Math.PI*6378137/2,e*i-2*Math.PI*6378137/2]}class hh{constructor(t,e,n){this.z=t,this.x=e,this.y=n,this.key=fh(0,t,t,e,n)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const n=function(t,e,n){var i=uh(256*t,256*(e=Math.pow(2,n)-e-1),n),r=uh(256*(t+1),256*(e+1),n);return i[0]+","+i[1]+","+r[0]+","+r[1]}(this.x,this.y,this.z),i=function(t,e,n){let i,r="";for(let o=t;o>0;o--)i=1<<o-1,r+=(e&i?1:0)+(n&i?2:0);return r}(this.z,this.x,this.y);return t[(this.x+this.y)%t.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"===e?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",i).replace("{bbox-epsg-3857}",n)}toString(){return`${this.z}/${this.x}/${this.y}`}}class dh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=fh(t,e.z,e.z,e.x,e.y)}}class ph{constructor(t,e,n,i,r){this.overscaledZ=t,this.wrap=e,this.canonical=new hh(n,+i,+r),this.key=0===e&&t===n?this.canonical.key:fh(e,t,n,i,r)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const e=this.canonical.z-t;return t>this.canonical.z?new ph(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ph(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return fh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-t;return fh(this.wrap*+e,t,t,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new ph(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,n=2*this.canonical.x,i=2*this.canonical.y;return[new ph(e,this.wrap,e,n,i),new ph(e,this.wrap,e,n+1,i),new ph(e,this.wrap,e,n,i+1),new ph(e,this.wrap,e,n+1,i+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new ph(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new ph(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new dh(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function fh(t,e,n,i,r){const o=1<<Math.min(n,22);let s=o*(r%o)+i%o;return t&&n<22&&(s+=o*o*((t<0?-2*t-1:2*t)%(1<<2*(22-n)))),16*(32*s+n)+(e-n)}Yr(hh,"CanonicalTileID"),Yr(ph,"OverscaledTileID",{omit:["projMatrix"]});class mh extends y{constructor(t,e,n){super(t,e),this.z=n}}function gh(t,e){return t.x*e.x+t.y*e.y}function _h(t,e){if(1===t.length){let n=0;const i=e[n++];let r;for(;!r||i.equals(r);)if(r=e[n++],!r)return 1/0;for(;n<e.length;n++){const o=e[n],s=t[0],a=r.sub(i),l=o.sub(i),c=s.sub(i),u=gh(a,a),h=gh(a,l),d=gh(l,l),p=gh(c,a),f=gh(c,l),m=u*d-h*h,g=(d*p-h*f)/m,_=(u*f-h*p)/m,y=i.z*(1-g-_)+r.z*g+o.z*_;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const n of e)t=Math.min(t,n.z);return t}}function yh(t,e,n,i,r,o,s,a){const l=s*r.getElevationAt(t,e,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/7-450):s*function(t,e,n){const i=Math.floor(e[0]/8),r=Math.floor(e[1]/8),o=10*(e[0]-8*i),s=10*(e[1]-8*r),a=t.getElevationAt(i,r,!0,!0),l=t.getMeterToDEM(n),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=t.tileCoordToPixel(i,r),d=2*c+1,p=2*u+1,f=function(t,e,n,i,r){return[t.getElevationAtPixel(e,n,!0),t.getElevationAtPixel(e+r,n,!0),t.getElevationAtPixel(e,n+r,!0),t.getElevationAtPixel(e+i,n+r,!0)]}(t,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*o,v*s)}(r,o,a):l;return{base:l+(0===n)?-1:n,top:c?Math.max(u+i,l+n+2):l+i}}const vh=ko([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:xh}=vh,bh=ko([{name:"a_packed",components:4,type:"Float32"}]),{members:Th}=bh,Eh=Wu.types,Sh=Math.cos(Math.PI/180*37.5);class wh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new $o,this.layoutVertexArray2=new Ho,this.indexArray=new is,this.programConfigurations=new Zs(t.layers,t.zoom),this.segments=new sa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,n,i){this.hasPattern=Su("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ac(e,t);if(!this.layers[0]._featureFilter.filter(new To(this.zoom),c,n))continue;const u=r?r.evaluate(c,{},n):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:sc(e,n,i),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:s,featureIndex:a}=e,l=this.addConstantDashes(s);for(const i of o){const{geometry:r,index:o,sourceLayerIndex:c}=i;if(l&&this.addFeatureDashes(i,s),this.hasPattern){const t=wu("line",this.layers,i,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(i,r,o,n,s.positions,e.availableImages);a.insert(t[o].feature,r,o,c,this.index)}}addConstantDashes(t){let e=!1;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,r=n.layout.get("line-cap").value;if("constant"!==i.kind||"constant"!==r.kind)e=!0;else{const e=r.value,n=i.value;if(!n)continue;t.addDash(n,e)}}return e}addFeatureDashes(t,e){const n=this.zoom;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,o=i.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:n},t);a="constant"===o.kind?o.value:o.evaluate({zoom:n},t),e.addDash(s,a),t.patterns[i.id]=e.getKey(s,a)}}update(t,e,n,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,n,i)}addFeatures(t,e,n,i,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,n,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Th)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xh),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,n,i,r,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),l=s.get("line-cap").evaluate(t,{}),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const n of e)this.addLine(n,t,a,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,r,o,i)}addLine(t,e,n,i,r,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const s="Polygon"===Eh[e.type];let a=t.length;for(;a>=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l<a-1&&t[l].equals(t[l+1]);)l++;if(a<(s?3:2))return;"bevel"===n&&(r=1.05);const c=this.overscaling<=16?15*aa/(512*this.overscaling):0,u=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let h,d,p,f,m;this.e1=this.e2=-1,s&&(h=t[a-2],m=t[l].sub(h)._unit()._perp());for(let e=l;e<a;e++){if(p=e===a-1?s?t[l+1]:void 0:t[e+1],p&&t[e].equals(p))continue;m&&(f=m),h&&(d=h),h=t[e],m=p?p.sub(h)._unit()._perp():f,f=f||m;let g=f.add(m);0===g.x&&0===g.y||g._unit();const _=f.x*m.x+f.y*m.y,y=g.x*m.x+g.y*m.y,v=0!==y?1/y:1/0,x=2*Math.sqrt(2-2*y),b=y<Sh&&d&&p,T=f.x*m.y-f.y*m.x>0;if(b&&e>l){const t=h.dist(d);if(t>2*c){const e=h.sub(h.sub(d)._mult(c/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,f,0,0,u),d=e}}const E=d&&p;let S=E?n:s?"butt":i;if(E&&"round"===S&&(v<o?S="miter":v<=2&&(S="fakeround")),"miter"===S&&v>r&&(S="bevel"),"bevel"===S&&(v>2&&(S="flipbevel"),v<r&&(S="miter")),d&&this.updateDistance(d,h),"miter"===S)g._mult(v),this.addCurrentVertex(h,g,0,0,u);else if("flipbevel"===S){if(v>100)g=m.mult(-1);else{const t=v*f.add(m).mag()/f.sub(m).mag();g._perp()._mult(t*(T?-1:1))}this.addCurrentVertex(h,g,0,0,u),this.addCurrentVertex(h,g.mult(-1),0,0,u)}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(v*v-1),e=T?t:0,n=T?0:t;if(d&&this.addCurrentVertex(h,f,e,n,u),"fakeround"===S){const t=Math.round(180*x/Math.PI/20);for(let e=1;e<t;e++){let n=e/t;if(.5!==n){const t=n-.5;n+=n*t*(n-1)*((1.0904+_*(_*(3.55645-1.43519*_)-3.2452))*t*t+(.848013+_*(.215638*_-1.06021)))}const i=m.sub(f)._mult(n)._add(f)._unit()._mult(T?-1:1);this.addHalfVertex(h,i.x,i.y,!1,T,0,u)}}p&&this.addCurrentVertex(h,m,-e,-n,u)}else if("butt"===S)this.addCurrentVertex(h,g,0,0,u);else if("square"===S){const t=d?1:-1;d||this.addCurrentVertex(h,g,t,t,u),this.addCurrentVertex(h,g,0,0,u),d&&this.addCurrentVertex(h,g,t,t,u)}else"round"===S&&(d&&(this.addCurrentVertex(h,f,0,0,u),this.addCurrentVertex(h,f,1,1,u,!0)),p&&(this.addCurrentVertex(h,m,-1,-1,u,!0),this.addCurrentVertex(h,m,0,0,u)));if(b&&e<a-1){const t=h.dist(p);if(t>2*c){const e=h.add(p.sub(h)._mult(c/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,m,0,0,u),h=e}}}}addCurrentVertex(t,e,n,i,r,o=!1){const s=e.y*i-e.x,a=-e.y-e.x*i;this.addHalfVertex(t,e.x+e.y*n,e.y-e.x*n,o,!1,n,r),this.addHalfVertex(t,s,a,o,!0,-i,r)}addHalfVertex({x:t,y:e},n,i,r,o,s,a){this.layoutVertexArray.emplaceBack((t<<1)+(r?1:0),(e<<1)+(o?1:0),Math.round(63*n)+128,Math.round(63*i)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Yr(wh,"LineBucket",{omit:["layers","patternFeatures"]});const Ah=new Do({"line-cap":new Ro(te.layout_line["line-cap"]),"line-join":new Ro(te.layout_line["line-join"]),"line-miter-limit":new Lo(te.layout_line["line-miter-limit"]),"line-round-limit":new Lo(te.layout_line["line-round-limit"]),"line-sort-key":new Ro(te.layout_line["line-sort-key"])});var Mh={paint:new Do({"line-opacity":new Ro(te.paint_line["line-opacity"]),"line-color":new Ro(te.paint_line["line-color"]),"line-translate":new Lo(te.paint_line["line-translate"]),"line-translate-anchor":new Lo(te.paint_line["line-translate-anchor"]),"line-width":new Ro(te.paint_line["line-width"]),"line-gap-width":new Ro(te.paint_line["line-gap-width"]),"line-offset":new Ro(te.paint_line["line-offset"]),"line-blur":new Ro(te.paint_line["line-blur"]),"line-dasharray":new Ro(te.paint_line["line-dasharray"]),"line-pattern":new Ro(te.paint_line["line-pattern"]),"line-gradient":new Oo(te.paint_line["line-gradient"]),"line-trim-offset":new Lo(te.paint_line["line-trim-offset"])}),layout:Ah};const Ch=new class extends Ro{possiblyEvaluate(t,e){return e=new To(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,n,i){return e=R({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,n,i)}}(Mh.paint.properties["line-width"].specification);function Ih(t,e){return e>0?e+2*t:t}Ch.useIntegerZoom=!0;const Ph=ko([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Lh=ko([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Rh=ko([{name:"a_projected_pos",components:4,type:"Float32"}],4);ko([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Oh=ko([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Dh=ko([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);ko([{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 Bh=ko([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Nh=ko([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ko([{name:"triangle",components:3,type:"Uint16"}]),ko([{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"}]),ko([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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"}]),ko([{type:"Float32",name:"offsetX"}]),ko([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Fh=24;const Uh=128;function kh(t,e){const{expression:n}=e;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new To(t+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:i}=n;let r=0;for(;r<e.length&&e[r]<=t;)r++;r=Math.max(0,r-1);let o=r;for(;o<e.length&&e[o]<t+1;)o++;o=Math.min(e.length-1,o);const s=e[r],a=e[o];return"composite"===n.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:i}:{kind:"camera",minZoom:s,maxZoom:a,minSize:n.evaluate(new To(s)),maxSize:n.evaluate(new To(a)),interpolationType:i}}}function zh(t,{uSize:e,uSizeT:n},{lowerSize:i,upperSize:r}){return"source"===t.kind?i/Uh:"composite"===t.kind?Rn(i/Uh,r/Uh,n):e}function Gh(t,e){let n=0,i=0;if("constant"===t.kind)i=t.layoutSize;else if("source"!==t.kind){const{interpolationType:r,minZoom:o,maxZoom:s}=t,a=r?M(ti.interpolationFactor(r,e,o,s),0,1):0;"camera"===t.kind?i=Rn(t.minSize,t.maxSize,a):n=a}return{uSizeT:n,uSize:i}}var Vh=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:Uh,evaluateSizeForFeature:zh,evaluateSizeForZoom:Gh,getSizeData:kh});function jh(t,e,n){return t.sections.forEach((t=>{t.text=function(t,e,n){const i=e.layout.get("text-transform").evaluate(n,{});return"uppercase"===i?t=t.toLocaleUpperCase():"lowercase"===i&&(t=t.toLocaleLowerCase()),bo.applyArabicShaping&&(t=bo.applyArabicShaping(t)),t}(t.text,e,n)})),t}const $h={"!":"︕","#":"＃",$:"＄","%":"％","&":"＆","(":"︵",")":"︶","*":"＊","+":"＋",",":"︐","-":"︲",".":"・","/":"／",":":"︓",";":"︔","<":"︿","=":"＝",">":"﹀","?":"︖","@":"＠","[":"﹇","\\":"＼","]":"﹈","^":"＾",_:"︳","`":"｀","{":"︷","|":"―","}":"︸","~":"～","¢":"￠","£":"￡","¥":"￥","¦":"￤","¬":"￢","¯":"￣","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"￦","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","！":"︕","（":"︵","）":"︶","，":"︐","－":"︲","．":"・","：":"︓","；":"︔","＜":"︿","＞":"﹀","？":"︖","［":"﹇","］":"﹈","＿":"︳","｛":"︷","｜":"―","｝":"︸","｟":"︵","｠":"︶","｡":"︒","｢":"﹁","｣":"﹂","←":"↑","→":"↓"};function Hh(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"｀"===t||"￣"===t||"︑"===t||"︒"===t}function Wh(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var qh=Zh,Xh=function(t,e,n,i,r){var o,s,a=8*r-i-1,l=(1<<a)-1,c=l>>1,u=-7,h=r-1,d=-1,p=t[e+h];for(h+=d,o=p&(1<<-u)-1,p>>=-u,u+=a;u>0;o=256*o+t[e+h],h+=d,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=i;u>0;s=256*s+t[e+h],h+=d,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,i),o-=c}return(p?-1:1)*s*Math.pow(2,o-i)},Yh=function(t,e,n,i,r,o){var s,a,l,c=8*o-r-1,u=(1<<c)-1,h=u>>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=0,f=1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(e*l-1)*Math.pow(2,r),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,r),s=0));r>=8;t[n+p]=255&a,p+=f,a/=256,r-=8);for(s=s<<r|a,c+=r;c>0;t[n+p]=255&s,p+=f,s/=256,c-=8);t[n+p-f]|=128*m};
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function Zh(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Zh.Varint=0,Zh.Fixed64=1,Zh.Bytes=2,Zh.Fixed32=5;var Jh=4294967296,Kh=1/Jh,Qh="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function td(t){return t.type===Zh.Bytes?t.readVarint()+t.pos:t.pos+1}function ed(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function nd(t,e,n){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(i);for(var r=n.pos-1;r>=t;r--)n.buf[r+i]=n.buf[r]}function id(t,e){for(var n=0;n<t.length;n++)e.writeVarint(t[n])}function rd(t,e){for(var n=0;n<t.length;n++)e.writeSVarint(t[n])}function od(t,e){for(var n=0;n<t.length;n++)e.writeFloat(t[n])}function sd(t,e){for(var n=0;n<t.length;n++)e.writeDouble(t[n])}function ad(t,e){for(var n=0;n<t.length;n++)e.writeBoolean(t[n])}function ld(t,e){for(var n=0;n<t.length;n++)e.writeFixed32(t[n])}function cd(t,e){for(var n=0;n<t.length;n++)e.writeSFixed32(t[n])}function ud(t,e){for(var n=0;n<t.length;n++)e.writeFixed64(t[n])}function hd(t,e){for(var n=0;n<t.length;n++)e.writeSFixed64(t[n])}function dd(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function pd(t,e,n){t[n]=e,t[n+1]=e>>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function fd(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Zh.prototype={destroy:function(){this.buf=null},readFields:function(t,e,n){for(n=n||this.length;this.pos<n;){var i=this.readVarint(),r=i>>3,o=this.pos;this.type=7&i,t(r,e,this),this.pos===o&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=dd(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=fd(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=dd(this.buf,this.pos)+dd(this.buf,this.pos+4)*Jh;return this.pos+=8,t},readSFixed64:function(){var t=dd(this.buf,this.pos)+fd(this.buf,this.pos+4)*Jh;return this.pos+=8,t},readFloat:function(){var t=Xh(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Xh(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,n,i=this.buf;return e=127&(n=i[this.pos++]),n<128?e:(e|=(127&(n=i[this.pos++]))<<7,n<128?e:(e|=(127&(n=i[this.pos++]))<<14,n<128?e:(e|=(127&(n=i[this.pos++]))<<21,n<128?e:function(t,e,n){var i,r,o=n.buf;if(i=(112&(r=o[n.pos++]))>>4,r<128)return ed(t,i,e);if(i|=(127&(r=o[n.pos++]))<<3,r<128)return ed(t,i,e);if(i|=(127&(r=o[n.pos++]))<<10,r<128)return ed(t,i,e);if(i|=(127&(r=o[n.pos++]))<<17,r<128)return ed(t,i,e);if(i|=(127&(r=o[n.pos++]))<<24,r<128)return ed(t,i,e);if(i|=(1&(r=o[n.pos++]))<<31,r<128)return ed(t,i,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=i[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Qh?function(t,e,n){return Qh.decode(t.subarray(e,n))}(this.buf,e,t):function(t,e,n){for(var i="",r=e;r<n;){var o,s,a,l=t[r],c=null,u=l>239?4:l>223?3:l>191?2:1;if(r+u>n)break;1===u?l<128&&(c=l):2===u?128==(192&(o=t[r+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(s=t[r+2],128==(192&(o=t[r+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=t[r+2],a=t[r+3],128==(192&(o=t[r+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,i+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),i+=String.fromCharCode(c),r+=u}return i}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Zh.Bytes)return t.push(this.readVarint(e));var n=td(this);for(t=t||[];this.pos<n;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Zh.Bytes)return t.push(this.readSVarint());var e=td(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Zh.Bytes)return t.push(this.readBoolean());var e=td(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Zh.Bytes)return t.push(this.readFloat());var e=td(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Zh.Bytes)return t.push(this.readDouble());var e=td(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Zh.Bytes)return t.push(this.readFixed32());var e=td(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Zh.Bytes)return t.push(this.readSFixed32());var e=td(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Zh.Bytes)return t.push(this.readFixed64());var e=td(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Zh.Bytes)return t.push(this.readSFixed64());var e=td(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Zh.Varint)for(;this.buf[this.pos++]>127;);else if(e===Zh.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Zh.Fixed32)this.pos+=4;else{if(e!==Zh.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var n=new Uint8Array(e);n.set(this.buf),this.buf=n,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),pd(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),pd(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),pd(this.buf,-1&t,this.pos),pd(this.buf,Math.floor(t*Kh),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),pd(this.buf,-1&t,this.pos),pd(this.buf,Math.floor(t*Kh),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var n,i;if(t>=0?(n=t%4294967296|0,i=t/4294967296|0):(i=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,i=i+1|0)),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,n.buf[n.pos]=127&(t>>>=7)}(n,0,e),function(t,e){var n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(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:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,n){for(var i,r,o=0;o<e.length;o++){if((i=e.charCodeAt(o))>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);var n=this.pos-e;n>=128&&nd(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),Yh(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Yh(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var n=0;n<e;n++)this.buf[this.pos++]=t[n]},writeRawMessage:function(t,e){this.pos++;var n=this.pos;t(e,this);var i=this.pos-n;i>=128&&nd(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,n){this.writeTag(t,Zh.Bytes),this.writeRawMessage(e,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,id,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,rd,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,ad,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,od,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,sd,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,ld,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,cd,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,ud,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,hd,e)},writeBytesField:function(t,e){this.writeTag(t,Zh.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Zh.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Zh.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Zh.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Zh.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Zh.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Zh.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Zh.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Zh.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Zh.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var md=d(qh);const gd=3;function _d(t,e,n){e.glyphs=[],1===t&&n.readMessage(yd,e)}function yd(t,e,n){if(3===t){const{id:t,bitmap:i,width:r,height:o,left:s,top:a,advance:l}=n.readMessage(vd,{});e.glyphs.push({id:t,bitmap:new Uc({width:r+2*gd,height:o+2*gd},i),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=n.readSVarint():5===t&&(e.descender=n.readSVarint())}function vd(t,e,n){1===t?e.id=n.readVarint():2===t?e.bitmap=n.readBytes():3===t?e.width=n.readVarint():4===t?e.height=n.readVarint():5===t?e.left=n.readSVarint():6===t?e.top=n.readSVarint():7===t&&(e.advance=n.readVarint())}const xd=gd;function bd(t){let e=0,n=0;for(const i of t)e+=i.w*i.h,n=Math.max(n,i.w);t.sort(((t,e)=>e.h-t.h));const i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),n),h:1/0}];let r=0,o=0;for(const e of t)for(let t=i.length-1;t>=0;t--){const n=i[t];if(!(e.w>n.w||e.h>n.h)){if(e.x=n.x,e.y=n.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===n.w&&e.h===n.h){const e=i.pop();t<i.length&&(i[t]=e)}else e.h===n.h?(n.x+=e.w,n.w-=e.w):e.w===n.w?(n.y+=e.h,n.h-=e.h):(i.push({x:n.x+e.w,y:n.y,w:n.w-e.w,h:e.h}),n.y+=e.h,n.h-=e.h);break}}return{w:r,h:o,fill:e/(r*o)||0}}const Td=1;class Ed{constructor(t,{pixelRatio:e,version:n,stretchX:i,stretchY:r,content:o}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=i,this.stretchY=r,this.content=o,this.version=n}get tl(){return[this.paddedRect.x+Td,this.paddedRect.y+Td]}get br(){return[this.paddedRect.x+this.paddedRect.w-Td,this.paddedRect.y+this.paddedRect.h-Td]}get displaySize(){return[(this.paddedRect.w-2*Td)/this.pixelRatio,(this.paddedRect.h-2*Td)/this.pixelRatio]}}class Sd{constructor(t,e){const n={},i={};this.haveRenderCallbacks=[];const r=[];this.addImages(t,n,r),this.addImages(e,i,r);const{w:o,h:s}=bd(r),a=new kc({width:o||1,height:s||1});for(const e in t){const i=t[e],r=n[e].paddedRect;kc.copy(i.data,a,{x:0,y:0},{x:r.x+Td,y:r.y+Td},i.data)}for(const t in e){const n=e[t],r=i[t].paddedRect,o=r.x+Td,s=r.y+Td,l=n.data.width,c=n.data.height;kc.copy(n.data,a,{x:0,y:0},{x:o,y:s},n.data),kc.copy(n.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),kc.copy(n.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),kc.copy(n.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),kc.copy(n.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=n,this.patternPositions=i}addImages(t,e,n){for(const i in t){const r=t[i],o={x:0,y:0,w:r.data.width+2*Td,h:r.data.height+2*Td};n.push(o),e[i]=new Ed(o,r),r.hasRenderCallback&&this.haveRenderCallbacks.push(i)}}patchUpdatedImages(t,e){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e))),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in t.updatedImages)this.patchUpdatedImage(this.iconPositions[n],t.getImage(n),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n),e)}patchUpdatedImage(t,e,n){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[i,r]=t.tl;n.update(e.data,void 0,{x:i,y:r})}}Yr(Ed,"ImagePosition"),Yr(Sd,"ImageAtlas");const wd={horizontal:1,vertical:2,horizontalOnly:3},Ad=-17;class Md{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const n=new Md;return n.scale=t||1,n.fontStack=e,n}static forImage(t){const e=new Md;return e.imageName=t,e}}class Cd{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const n=new Cd;for(let i=0;i<t.sections.length;i++){const r=t.sections[i];r.image?n.addImageSection(r):n.addTextSection(r,e)}return n}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSections(){return this.sections}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(t){this.text=function(t,e){let n="";for(let i=0;i<t.length;i++){const r=t.charCodeAt(i+1)||null,o=t.charCodeAt(i-1)||null;n+=!e&&(r&&oo(r)&&!$h[t[i+1]]||o&&oo(o)&&!$h[t[i-1]])||!$h[t[i]]?t[i]:$h[t[i]]}return n}(this.text,t)}trim(){let t=0;for(let e=0;e<this.text.length&&Pd[this.text.charCodeAt(e)];e++)t++;let e=this.text.length;for(let n=this.text.length-1;n>=0&&n>=t&&Pd[this.text.charCodeAt(n)];n--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const n=new Cd;return n.text=this.text.substring(t,e),n.sectionIndex=this.sectionIndex.slice(t,e),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Md.forText(t.scale,t.fontStack||e));const n=this.sections.length-1;for(let e=0;e<t.text.length;++e)this.sectionIndex.push(n)}addImageSection(t){const e=t.image?t.image.name:"";if(0===e.length)return void $("Can't add FormattedSection with an empty image.");const n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push(Md.forImage(e)),this.sectionIndex.push(this.sections.length-1)):$("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Id(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f){const m=Cd.fromFeature(t,r);h===wd.vertical&&m.verticalizePunctuation(d);let g=[];const _=function(t,e,n,i,r,o){if(!t)return[];const s=[],a=function(t,e,n,i,r,o){let s=0;for(let n=0;n<t.length();n++){const a=t.getSection(n);s+=Rd(t.getCharCode(n),a,i,r,e,o)}return s/Math.max(1,Math.ceil(s/n))}(t,e,n,i,r,o),l=t.text.indexOf("​")>=0;let c=0;for(let n=0;n<t.length();n++){const h=t.getSection(n),d=t.getCharCode(n);if(Pd[d]||(c+=Rd(d,h,i,r,e,o)),n<t.length()-1){const e=!((u=d)<11904||!(to["Bopomofo Extended"](u)||to.Bopomofo(u)||to["CJK Compatibility Forms"](u)||to["CJK Compatibility Ideographs"](u)||to["CJK Compatibility"](u)||to["CJK Radicals Supplement"](u)||to["CJK Strokes"](u)||to["CJK Symbols and Punctuation"](u)||to["CJK Unified Ideographs Extension A"](u)||to["CJK Unified Ideographs"](u)||to["Enclosed CJK Letters and Months"](u)||to["Halfwidth and Fullwidth Forms"](u)||to.Hiragana(u)||to["Ideographic Description Characters"](u)||to["Kangxi Radicals"](u)||to["Katakana Phonetic Extensions"](u)||to.Katakana(u)||to["Vertical Forms"](u)||to["Yi Radicals"](u)||to["Yi Syllables"](u)));(Ld[d]||e||h.imageName)&&s.push(Bd(n+1,c,a,s,Dd(d,t.getCharCode(n+1),e&&l),!1))}}var u;return Nd(Bd(t.length(),c,a,s,0,!0))}(m,c,o,e,i,p),{processBidirectionalText:y,processStyledBidirectionalText:v}=bo;if(y&&1===m.sections.length){const t=y(m.toString(),_);for(const e of t){const t=new Cd;t.text=e,t.sections=m.sections;for(let n=0;n<e.length;n++)t.sectionIndex.push(0);g.push(t)}}else if(v){const t=v(m.text,m.sectionIndex,_);for(const e of t){const t=new Cd;t.text=e[0],t.sectionIndex=e[1],t.sections=m.sections,g.push(t)}}else g=function(t,e){const n=[],i=t.text;let r=0;for(const i of e)n.push(t.substring(r,i)),r=i;return r<i.length&&n.push(t.substring(r,i.length)),n}(m,_);const x=[],b={positionedLines:x,text:m.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(t,e,n,i,r,o,s,a,l,c,u,h){let d=0,p=0,f=0;const m="right"===a?1:"left"===a?0:.5;let g=!1;for(const t of r){const n=t.getSections();for(const t of n){if(t.imageName)continue;const n=e[t.fontStack];if(n&&(g=void 0!==n.ascender&&void 0!==n.descender,!g))break}if(!g)break}let _=0;for(const s of r){s.trim();const r=s.getMaxScale(),a=(r-1)*Fh,v={positionedGlyphs:[],lineOffset:0};t.positionedLines[_]=v;const x=v.positionedGlyphs;let b=0;if(!s.length()){p+=o,++_;continue}let T=0,E=0;for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCharCode(o);let _=a.scale,v=null,S=null,w=null,A=Fh,M=0;const C=!(l===wd.horizontal||!u&&!ro(m)||u&&(Pd[m]||(y=m,to.Arabic(y)||to["Arabic Supplement"](y)||to["Arabic Extended-A"](y)||to["Arabic Presentation Forms-A"](y)||to["Arabic Presentation Forms-B"](y))));if(a.imageName){const e=i[a.imageName];if(!e)continue;w=a.imageName,t.iconsInText=t.iconsInText||!0,S=e.paddedRect;const n=e.displaySize;_=_*Fh/h,v={width:n[0],height:n[1],left:Td,top:-xd,advance:C?n[1]:n[0],localGlyph:!1},M=g?-v.height*_:Ad+r*Fh-n[1]*_,A=v.advance;const o=(C?n[0]:n[1])*_-Fh*r;o>0&&o>b&&(b=o)}else{const t=n[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const i=e[a.fontStack];if(!i)continue;const o=i.glyphs[m];if(!o)continue;if(v=o.metrics,A=8203!==m?Fh:0,g){const t=void 0!==i.ascender?Math.abs(i.ascender):0,e=void 0!==i.descender?Math.abs(i.descender):0,n=(t+e)*_;T<n&&(T=n,E=(t-e)/2*_),M=-t*_}else M=Ad+(r-_)*Fh}C?(t.verticalizable=!0,x.push({glyph:m,imageName:w,x:d,y:p+M,vertical:C,scale:_,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:S}),d+=A*_+c):(x.push({glyph:m,imageName:w,x:d,y:p+M,vertical:C,scale:_,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:S}),d+=v.advance*_+c)}0!==x.length&&(f=Math.max(d-c,f),g?Ud(x,m,b,E,o*r/2):Ud(x,m,b,0,o/2)),d=0;const S=o*r+b;v.lineOffset=Math.max(b,a),p+=S,++_}var y;const v=p,{horizontalAlign:x,verticalAlign:b}=Fd(s);(function(t,e,n,i,r,o){const s=(e-n)*r,a=-o*i;for(const e of t)for(const t of e.positionedGlyphs)t.x+=s,t.y+=a})(t.positionedLines,m,x,b,f,v),t.top+=-b*v,t.bottom=t.top+v,t.left+=-x*f,t.right=t.left+f,t.hasBaseline=g}(b,e,n,i,g,s,a,l,h,c,d,f),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(x)&&b}const Pd={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Ld={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 Rd(t,e,n,i,r,o){if(e.imageName){const t=i[e.imageName];return t?t.displaySize[0]*e.scale*Fh/o+r:0}{const i=n[e.fontStack],o=i&&i.glyphs[t];return o?o.metrics.advance*e.scale+r:0}}function Od(t,e,n,i){const r=Math.pow(t-e,2);return i?t<e?r/2:2*r:r+Math.abs(n)*n}function Dd(t,e,n){let i=0;return 10===t&&(i-=1e4),n&&(i+=150),40!==t&&65288!==t||(i+=50),41!==e&&65289!==e||(i+=50),i}function Bd(t,e,n,i,r,o){let s=null,a=Od(e,n,r,o);for(const t of i){const i=Od(e-t.x,n,r,o)+t.badness;i<=a&&(s=t,a=i)}return{index:t,x:e,priorBreak:s,badness:a}}function Nd(t){return t?Nd(t.priorBreak).concat(t.index):[]}function Fd(t){let e=.5,n=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":n=1;break;case"top":case"top-right":case"top-left":n=0}return{horizontalAlign:e,verticalAlign:n}}function Ud(t,e,n,i,r){if(!(e||n||i||r))return;const o=t.length-1,s=t[o],a=(s.x+s.metrics.advance*s.scale)*e;for(let e=0;e<=o;e++)t[e].x-=a,t[e].y+=n+i+r}function kd(t,e,n){const{horizontalAlign:i,verticalAlign:r}=Fd(n),o=e[0]-t.displaySize[0]*i,s=e[1]-t.displaySize[1]*r;return{image:t,top:s,bottom:s+t.displaySize[1],left:o,right:o+t.displaySize[0]}}function zd(t,e,n,i,r,o){const s=t.image;let a;if(s.content){const t=s.content,e=s.pixelRatio||1;a=[t[0]/e,t[1]/e,s.displaySize[0]-t[2]/e,s.displaySize[1]-t[3]/e]}const l=e.left*o,c=e.right*o;let u,h,d,p;"width"===n||"both"===n?(p=r[0]+l-i[3],h=r[0]+c+i[1]):(p=r[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=e.top*o,m=e.bottom*o;return"height"===n||"both"===n?(u=r[1]+f-i[0],d=r[1]+m+i[2]):(u=r[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:d,left:p,collisionPadding:a}}class Gd extends y{constructor(t,e,n,i,r){super(t,e),this.angle=i,this.z=n,void 0!==r&&(this.segment=r)}clone(){return new Gd(this.x,this.y,this.z,this.angle,this.segment)}}function Vd(t,e,n,i,r){if(void 0===e.segment)return!0;let o=e,s=e.segment+1,a=0;for(;a>-n/2;){if(s--,s<0)return!1;a-=t[s].dist(o),o=t[s]}a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;a<n/2;){const e=t[s],n=t[s+1];if(!n)return!1;let o=t[s-1].angleTo(e)-e.angleTo(n);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),c+=o;a-l[0].distance>i;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(n)}return!0}function jd(t){let e=0;for(let n=0;n<t.length-1;n++)e+=t[n].dist(t[n+1]);return e}function $d(t,e,n){return t?.6*e*n:0}function Hd(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Wd(t,e,n,i,r,o){const s=$d(n,r,o),a=Hd(n,i)*o;let l=0;const c=jd(t)/2;for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1],o=i.dist(r);if(l+o>c){const u=(c-l)/o,h=Rn(i.x,r.x,u),d=Rn(i.y,r.y,u),p=new Gd(h,d,0,r.angleTo(i),n);return!s||Vd(t,p,a,s,e)?p:void 0}l+=o}}function qd(t,e,n,i,r,o,s,a,l){const c=$d(i,o,s),u=Hd(i,r),h=u*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h<e/4&&(e=h+e/4),Xd(t,d?e/2*a%e:(u/2+2*o)*s*a%e,e,c,n,h,d,!1,l)}function Xd(t,e,n,i,r,o,s,a,l){const c=o/2,u=jd(t);let h=0,d=e-n,p=[];for(let e=0;e<t.length-1;e++){const s=t[e],a=t[e+1],f=s.dist(a),m=a.angleTo(s);for(;d+n<h+f;){d+=n;const g=(d-h)/f,_=Rn(s.x,a.x,g),y=Rn(s.y,a.y,g);if(_>=0&&_<l&&y>=0&&y<l&&d-c>=0&&d+c<=u){const n=new Gd(_,y,0,m,e);n._round(),i&&!Vd(t,n,o,i,r)||p.push(n)}}h+=f}return a||p.length||s||(p=Xd(t,h/2,n,i,r,o,s,!0,l)),p}function Yd(t,e,n,i,r){const o=[];for(let s=0;s<t.length;s++){const a=t[s];let l;for(let t=0;t<a.length-1;t++){let s=a[t],c=a[t+1];s.x<e&&c.x<e||(s.x<e?s=new y(e,s.y+(e-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x<e&&(c=new y(e,s.y+(e-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y<n&&c.y<n||(s.y<n?s=new y(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round():c.y<n&&(c=new y(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round()),s.x>=i&&c.x>=i||(s.x>=i?s=new y(i,s.y+(i-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=i&&(c=new y(i,s.y+(i-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new y(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new y(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}Yr(Gd,"Anchor");const Zd=1e20;function Jd(t,e,n,i,r,o,s,a,l){for(let c=e;c<e+i;c++)Kd(t,n*o+c,o,r,s,a,l);for(let c=n;c<n+r;c++)Kd(t,c*o+e,1,i,s,a,l)}function Kd(t,e,n,i,r,o,s){o[0]=0,s[0]=-Zd,s[1]=Zd,r[0]=t[e];for(let a=1,l=0,c=0;a<i;a++){r[a]=t[e+a*n];const i=a*a;do{const t=o[l];c=(r[a]-r[t]+i-t*t)/(a-t)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=Zd}for(let a=0,l=0;a<i;a++){for(;s[l+1]<a;)l++;const i=o[l],c=a-i;t[e+a*n]=r[i]+c*c}}const Qd=2,tp={none:0,ideographs:1,all:2};class ep{constructor(t,e,n){this.requestManager=t,this.localGlyphMode=e,this.localFontFamily=n,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(t){this.url=t}getGlyphs(t,e){const n=[];for(const e in t)for(const i of t[e])n.push({stack:e,id:i});P(n,(({stack:t,id:e},n)=>{let i=this.entries[t];i||(i=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=i.glyphs[e];if(void 0!==r)return void n(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(i,t,e),r)return i.glyphs[e]=r,void n(null,{stack:t,id:e,glyph:r});const o=Math.floor(e/256);if(256*o>65535)return void n(new Error("glyphs > 65535 not supported"));if(i.ranges[o])return void n(null,{stack:t,id:e,glyph:r});let s=i.requests[o];s||(s=i.requests[o]=[],ep.loadGlyphRange(t,o,this.url,this.requestManager,((t,e)=>{if(e){i.ascender=e.ascender,i.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(i.glyphs[+t]=e.glyphs[+t]);i.ranges[o]=!0}for(const n of s)n(t,e);delete i.requests[o]}))),s.push(((i,r)=>{i?n(i):r&&n(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,n)=>{if(t)e(t);else if(n){const t={};for(const{stack:e,id:i,glyph:r}of n)void 0===t[e]&&(t[e]={}),void 0===t[e].glyphs&&(t[e].glyphs={}),t[e].glyphs[i]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[e].ascender=this.entries[e].ascender,t[e].descender=this.entries[e].descender;e(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==tp.none&&(this.localGlyphMode===tp.all?!!this.localFontFamily:!!this.localFontFamily&&(to["CJK Unified Ideographs"](t)||to["Hangul Syllables"](t)||to.Hiragana(t)||to.Katakana(t)||to["CJK Symbols and Punctuation"](t)))}_tinySDF(t,e,n){const i=this.localFontFamily;if(!i||!this._doesCharSupportLocalGlyph(n))return;let r=t.tinySDF;if(!r){let n="400";/bold/i.test(e)?n="900":/medium/i.test(e)?n="500":/light/i.test(e)&&(n="200"),r=t.tinySDF=new ep.TinySDF({fontFamily:i,fontWeight:n,fontSize:24*Qd,buffer:3*Qd,radius:8*Qd}),r.fontWeight=n}if(this.localGlyphs[r.fontWeight][n])return this.localGlyphs[r.fontWeight][n];const o=String.fromCharCode(n),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][n]={id:n,bitmap:new Uc({width:a,height:l},s),metrics:{width:c/Qd,height:u/Qd,left:h/Qd,top:d/Qd-27,advance:p/Qd,localGlyph:!0}}}}ep.loadGlyphRange=function(t,e,n,i,r){const o=256*e,s=o+255,a=i.transformRequest(i.normalizeGlyphsURL(n).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),lt.Glyphs);dt(a,((t,e)=>{if(t)r(t);else if(e){const t={},n=function(t){return new md(t).readFields(_d,{})}(e);for(const e of n.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:n.ascender,descender:n.descender})}}))},ep.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:n=8,cutoff:i=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=i,this.radius=n;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:i,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(n),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(i)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);_.fill(Zd,0,h),g.fill(0,0,h);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const n=y.data[4*(t*a+e)+3]/255;if(0===n)continue;const i=(t+m)*c+e+m;if(1===n)_[i]=0,g[i]=Zd;else{const t=.5-n;_[i]=t>0?t*t:0,g[i]=t<0?t*t:0}}Jd(_,0,0,c,u,c,this.f,this.v,this.z),Jd(g,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t<h;t++){const e=Math.sqrt(_[t])-Math.sqrt(g[t]);d[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return p}};const np=Td;function ip(t,e,n,i){const r=[],o=t.image,s=o.pixelRatio,a=o.paddedRect.w-2*np,l=o.paddedRect.h-2*np,c=t.right-t.left,u=t.bottom-t.top,h=o.stretchX||[[0,a]],d=o.stretchY||[[0,l]],p=(t,e)=>t+e[1]-e[0],f=h.reduce(p,0),m=d.reduce(p,0),g=a-f,_=l-m;let v=0,x=f,b=0,T=m,E=0,S=g,w=0,A=_;if(o.content&&i){const t=o.content;v=rp(h,0,t[0]),b=rp(d,0,t[1]),x=rp(h,t[0],t[2]),T=rp(d,t[1],t[3]),E=t[0]-v,w=t[1]-b,S=t[2]-t[0]-x,A=t[3]-t[1]-T}const M=(i,r,a,l)=>{const h=sp(i.stretch-v,x,c,t.left),d=ap(i.fixed-E,S,i.stretch,f),p=sp(r.stretch-b,T,u,t.top),g=ap(r.fixed-w,A,r.stretch,m),_=sp(a.stretch-v,x,c,t.left),M=ap(a.fixed-E,S,a.stretch,f),C=sp(l.stretch-b,T,u,t.top),I=ap(l.fixed-w,A,l.stretch,m),P=new y(h,p),L=new y(_,p),R=new y(_,C),O=new y(h,C),D=new y(d/s,g/s),B=new y(M/s,I/s),N=e*Math.PI/180;if(N){const t=Math.sin(N),e=Math.cos(N),n=[e,-t,t,e];P._matMult(n),L._matMult(n),O._matMult(n),R._matMult(n)}const F=i.stretch+i.fixed,U=r.stretch+r.fixed;return{tl:P,tr:L,bl:O,br:R,tex:{x:o.paddedRect.x+np+F,y:o.paddedRect.y+np+U,w:a.stretch+a.fixed-F,h:l.stretch+l.fixed-U},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:B,minFontScaleX:S/s/c,minFontScaleY:A/s/u,isSDF:n}};if(i&&(o.stretchX||o.stretchY)){const t=op(h,g,f),e=op(d,_,m);for(let n=0;n<t.length-1;n++){const i=t[n],o=t[n+1];for(let t=0;t<e.length-1;t++)r.push(M(i,e[t],o,e[t+1]))}}else r.push(M({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:a+1},{fixed:0,stretch:l+1}));return r}function rp(t,e,n){let i=0;for(const r of t)i+=Math.max(e,Math.min(n,r[1]))-Math.max(e,Math.min(n,r[0]));return i}function op(t,e,n){const i=[{fixed:-np,stretch:0}];for(const[e,n]of t){const t=i[i.length-1];i.push({fixed:e-t.stretch,stretch:t.stretch}),i.push({fixed:e-t.stretch,stretch:t.stretch+(n-e)})}return i.push({fixed:e+np,stretch:n}),i}function sp(t,e,n,i){return t/e*n+i}function ap(t,e,n,i){return t-e*n/i}function lp(t,e,n,i){const r=e+t.positionedLines[i].lineOffset;return 0===i?n+r/2:n+(r+(e+t.positionedLines[i-1].lineOffset))/2}class cp{constructor(t=[],e=up){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(n(i,o)>=0)break;e[t]=o,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1),o=e[i];const s=i+1;if(s<this.length&&n(e[s],o)<0&&(i=s,o=e[s]),n(o,r)>=0)break;e[t]=o,t=i}e[t]=r}}function up(t,e){return t<e?-1:t>e?1:0}function hp(t,e=1,n=!1){let i=1/0,r=1/0,o=-1/0,s=-1/0;const a=t[0];for(let t=0;t<a.length;t++){const e=a[t];(!t||e.x<i)&&(i=e.x),(!t||e.y<r)&&(r=e.y),(!t||e.x>o)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-i,s-r);let c=l/2;const u=new cp([],dp);if(0===l)return new y(i,r);for(let e=i;e<o;e+=l)for(let n=r;n<s;n+=l)u.push(new pp(e+c,n+c,c,t));let h=function(t){let e=0,n=0,i=0;const r=t[0];for(let t=0,o=r.length,s=o-1;t<o;s=t++){const o=r[t],a=r[s],l=o.x*a.y-a.x*o.y;n+=(o.x+a.x)*l,i+=(o.y+a.y)*l,e+=3*l}return new pp(n/e,i/e,0,t)}(t),d=u.length;for(;u.length;){const n=u.pop();(n.d>h.d||!h.d)&&(h=n),n.max-h.d<=e||(c=n.h/2,u.push(new pp(n.p.x-c,n.p.y-c,c,t)),u.push(new pp(n.p.x+c,n.p.y-c,c,t)),u.push(new pp(n.p.x-c,n.p.y+c,c,t)),u.push(new pp(n.p.x+c,n.p.y+c,c,t)),d+=4)}return h.p}function dp(t,e){return e.max-t.max}class pp{constructor(t,e,n,i){this.p=new y(t,e),this.h=n,this.d=function(t,e){let n=!1,i=1/0;for(let r=0;r<e.length;r++){const o=e[r];for(let e=0,r=o.length,s=r-1;e<r;s=e++){const r=o[e],a=o[s];r.y>t.y!=a.y>t.y&&t.x<(a.x-r.x)*(t.y-r.y)/(a.y-r.y)+r.x&&(n=!n),i=Math.min(i,yc(t,r,a))}}return(n?1:-1)*Math.sqrt(i)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}}const fp=7,mp=Number.POSITIVE_INFINITY,gp=Math.sqrt(2);function _p(t,[e,n]){let i=0,r=0;if(n===mp){e<0&&(e=0);const n=e/gp;switch(t){case"top-right":case"top-left":r=n-fp;break;case"bottom-right":case"bottom-left":r=-n+fp;break;case"bottom":r=-e+fp;break;case"top":r=e-fp}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}}else{switch(e=Math.abs(e),n=Math.abs(n),t){case"top-right":case"top-left":case"top":r=n-fp;break;case"bottom-right":case"bottom-left":case"bottom":r=-n+fp}switch(t){case"top-right":case"bottom-right":case"right":i=-e;break;case"top-left":case"bottom-left":case"left":i=e}}return[i,r]}function yp(t,e,n,i,r,o,s,a,l,c){t.createArrays(),t.tilePixelRatio=aa/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,d={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:n}=t.textSizeData;d.compositeTextSizes=[h["text-size"].possiblyEvaluate(new To(e),a),h["text-size"].possiblyEvaluate(new To(n),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:n}=t.iconSizeData;d.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new To(e),a),h["icon-size"].possiblyEvaluate(new To(n),a)]}d.layoutTextSize=h["text-size"].possiblyEvaluate(new To(l+1),a),d.layoutIconSize=h["icon-size"].possiblyEvaluate(new To(l+1),a),d.textMaxSize=h["text-size"].possiblyEvaluate(new To(18),a);const p="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),f=u.get("text-size");for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=f.evaluate(o,{},a),m=d.layoutTextSize.evaluate(o,{},a),g=(d.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),_=o.text;let y,v=[0,0];if(_){const i=_.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Fh,c=u.get("text-line-height").evaluate(o,{},a)*Fh,d=no(i)?s:0,f=u.get("text-anchor").evaluate(o,{},a),y=u.get("text-variable-anchor");if(!y){const t=u.get("text-radial-offset").evaluate(o,{},a);v=t?_p(f,[t*Fh,mp]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Fh))}let x=p?"center":u.get("text-justify").evaluate(o,{},a);const b="point"===u.get("symbol-placement"),T=b?u.get("text-max-width").evaluate(o,{},a)*Fh:1/0,E=o=>{t.allowVerticalPlacement&&eo(i)&&(g.vertical=Id(_,e,n,r,l,T,c,f,o,d,v,wd.vertical,!0,m,h))};if(!p&&y){const t="auto"===x?y.map((t=>vp(t))):[x];let i=!1;for(let o=0;o<t.length;o++){const s=t[o];if(!g.horizontal[s])if(i)g.horizontal[s]=g.horizontal[0];else{const t=Id(_,e,n,r,l,T,c,"center",s,d,v,wd.horizontal,!1,m,h);t&&(g.horizontal[s]=t,i=1===t.positionedLines.length)}}E("left")}else{if("auto"===x&&(x=vp(f)),b||u.get("text-writing-mode").indexOf("horizontal")>=0||!eo(i)){const t=Id(_,e,n,r,l,T,c,f,x,d,v,wd.horizontal,!1,m,h);t&&(g.horizontal[x]=t)}E(b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const e=i[o.icon.name];e&&(y=kd(r[o.icon.name],u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),x=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&$("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const b=Sp(g.horizontal)||g.vertical;t.iconsInText||(t.iconsInText=!!b&&b.iconsInText),(b||y)&&xp(t,o,g,y,i,d,m,0,v,x,s,a,c)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function vp(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function xp(t,e,n,i,r,o,s,a,l,c,u,h,d){let p=o.textMaxSize.evaluate(e,{},h);void 0===p&&(p=s);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(e,{},h),g=Sp(n.horizontal)||n.vertical,_="globe"===d.name,y=Fh,v=s/y,x=t.tilePixelRatio*p/y,T=(P=t.overscaling,t.zoom>18&&P>2&&(P>>=1),Math.max(aa/(512*P),1)*f.get("symbol-spacing")),E=f.get("text-padding")*t.tilePixelRatio,S=f.get("icon-padding")*t.tilePixelRatio,w=b(f.get("text-max-angle")),A="map"===f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),M="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),C=f.get("symbol-placement"),I=T/2;var P;const L=f.get("icon-text-fit");let R;i&&"none"!==L&&(t.allowVerticalPlacement&&n.vertical&&(R=zd(i,n.vertical,L,f.get("icon-text-fit-padding"),m,v)),g&&(i=zd(i,g,L,f.get("icon-text-fit-padding"),m,v)));const O=(s,a,p)=>{if(a.x<0||a.x>=aa||a.y<0||a.y>=aa)return;let f=null;if(_){const{x:t,y:e,z:n}=d.projectTilePoint(a.x,a.y,p);f={anchor:new Gd(t,e,n,0,void 0),up:d.upVector(p,a.x,a.y)}}!function(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,T,E,S){const w=t.addToLineVertexArray(e,i);let A,M,C,I,P,L,R,O=0,D=0,B=0,N=0,F=-1,U=-1;const k={};let z=Ls("");const G=n?n.anchor:e;let V=0,j=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[V,j]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Fh)):(V=l.layout.get("text-radial-offset").evaluate(x,{},S)*Fh,j=mp),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)L=Ap(t),a&&(R=Ap(a));else{const n=l.layout.get("text-rotate").evaluate(x,{},S)+90;C=wp(c,G,e,u,h,d,t,p,n,m),a&&(I=wp(c,G,e,u,h,d,a,_,n))}}if(o){const i=l.layout.get("icon-rotate").evaluate(x,{},S),r="none"!==l.layout.get("icon-text-fit"),s=ip(o,i,T,r),p=a?ip(a,i,T,r):void 0;M=wp(c,G,e,u,h,d,o,_,i),O=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Uh*l.layout.get("icon-size").evaluate(x,{},S)],m[0]>Tp&&$(`${t.layerIds[0]}: Value for "icon-size" is >= ${bp}. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Uh*b.compositeIconSizes[0].evaluate(x,{},S),Uh*b.compositeIconSizes[1].evaluate(x,{},S)],(m[0]>Tp||m[1]>Tp)&&$(`${t.layerIds[0]}: Value for "icon-size" is >= ${bp}. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,v,y,x,!1,n,e,w.lineStartIndex,w.lineLength,-1,E,S),F=t.icon.placedSymbolArray.length-1,p&&(D=4*p.length,t.addSymbols(t.icon,p,m,v,y,x,wd.vertical,n,e,w.lineStartIndex,w.lineLength,-1,E,S),U=t.icon.placedSymbolArray.length-1)}for(const i in r.horizontal){const o=r.horizontal[i];A||(z=Ls(o.text),f?P=Ap(o):A=wp(c,G,e,u,h,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(B+=Ep(t,n,e,o,s,l,f,x,m,w,r.vertical?wd.horizontal:wd.horizontalOnly,a?Object.keys(r.horizontal):[i],k,F,b,E,S),a)break}r.vertical&&(N+=Ep(t,n,e,r.vertical,s,l,f,x,m,w,wd.vertical,["vertical"],k,U,b,E,S));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W(P,H),H=W(L,H),H=W(R,H);const q=H>-1?1:0;t.glyphOffsetArray.length>=sf.MAX_GLYPHS&&$("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(G.x,G.y,G.z,e.x,e.y,k.right>=0?k.right:-1,k.center>=0?k.center:-1,k.left>=0?k.left:-1,k.vertical>=0?k.vertical:-1,F,U,z,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==C?C:t.collisionBoxArray.length,void 0!==C?C+1:t.collisionBoxArray.length,void 0!==M?M:t.collisionBoxArray.length,void 0!==M?M+1:t.collisionBoxArray.length,I||t.collisionBoxArray.length,I?I+1:t.collisionBoxArray.length,u,B,N,O,D,q,0,V,j,H)}(t,a,f,s,n,i,r,R,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,E,A,l,0,S,M,m,e,o,c,u,h)};if("line"===C)for(const r of Yd(e.geometry,0,0,aa,aa)){const e=qd(r,T,w,n.vertical||g,i,y,x,t.overscaling,aa);for(const n of e)g&&Mp(t,g.text,I,n)||O(r,n,h)}else if("line-center"===C){for(const t of e.geometry)if(t.length>1){const e=Wd(t,w,n.vertical||g,i,y,x);e&&O(t,e,h)}}else if("Polygon"===e.type)for(const t of Tu(e.geometry,0)){const e=hp(t,16);O(t[0],new Gd(e.x,e.y,0,0,void 0),h)}else if("LineString"===e.type)for(const t of e.geometry)O(t,new Gd(t[0].x,t[0].y,0,0,void 0),h);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)O([e],new Gd(e.x,e.y,0,0,void 0),h)}const bp=255,Tp=bp*Uh;function Ep(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=function(t,e,n,i,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=i.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=function(t){const e=t[0],n=t[1],i=e*n;return i>0?[e,-n]:i<0?[-e,n]:0===e?[n,e]:[n,-e]}(n);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const d=e.positionedLines.length,p=h/d;let f=e.top-n[1];for(let t=0;t<d;++t){const i=e.positionedLines[t];f=lp(e,p,f,t);for(const t of i.positionedGlyphs){if(!t.rect)continue;const i=t.rect||{};let o=xd+1,h=!0,d=1,p=0;if(t.imageName){const e=s[t.imageName];if(!e)continue;if(e.sdf){$("SDF images are not supported in formatted text and will be ignored.");continue}h=!1,d=e.pixelRatio,o=Td/d}const m=(r||a)&&t.vertical,g=t.metrics.advance*t.scale/2,_=t.metrics,v=t.rect;if(null===v)continue;a&&e.verticalizable&&(p=t.imageName?g-t.metrics.width*t.scale/2:0);const x=r?[t.x+g,t.y]:[0,0];let b=[0,0],T=[0,0],E=!1;r||(m?(T=[t.x+g+u[0],t.y+u[1]-p],E=!0):b=[t.x+g+n[0],t.y+n[1]-p]);const S=v.w*t.scale/(d*(t.localGlyph?Qd:1)),w=v.h*t.scale/(d*(t.localGlyph?Qd:1));let A,M,C,I;if(m){const e=t.y-f,n=new y(-g,g-e),i=-Math.PI/2,r=new y(...T);A=new y(-g+b[0],b[1]),A._rotateAround(i,n)._add(r),A.x+=-e+g,A.y-=(_.left-o)*t.scale;const s=t.imageName?_.advance*t.scale:Fh*t.scale,a=String.fromCharCode(t.glyph);Hh(a)?A.x+=(1-o)*t.scale:Wh(a)?A.x+=s-_.height*t.scale+(-o-1)*t.scale:A.x+=t.imageName||_.width+2*o===v.w&&_.height+2*o===v.h?(s-w)/2:(s-(_.height+2*o)*t.scale)/2,M=new y(A.x,A.y-S),C=new y(A.x+w,A.y),I=new y(A.x+w,A.y-S)}else{const e=(_.left-o)*t.scale-g+b[0],n=(-_.top-o)*t.scale+b[1],i=e+S,r=n+w;A=new y(e,n),M=new y(i,n),C=new y(e,r),I=new y(i,r)}if(c){let t;t=r?new y(0,0):E?new y(u[0],u[1]):new y(n[0],n[1]),A._rotateAround(c,t),M._rotateAround(c,t),C._rotateAround(c,t),I._rotateAround(c,t)}const P=new y(0,0),L=new y(0,0);l.push({tl:A,tr:M,bl:C,br:I,tex:i,writingMode:e.writingMode,glyphOffset:x,sectionIndex:t.sectionIndex,isSDF:h,pixelOffsetTL:P,pixelOffsetBR:L,minFontScaleX:0,minFontScaleY:0})}}return l}(0,i,l,o,s,a,r,t.allowVerticalPlacement),v=t.textSizeData;let x=null;"source"===v.kind?(x=[Uh*o.layout.get("text-size").evaluate(a,{},g)],x[0]>Tp&&$(`${t.layerIds[0]}: Value for "text-size" is >= ${bp}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Uh*f.compositeTextSizes[0].evaluate(a,{},g),Uh*f.compositeTextSizes[1].evaluate(a,{},g)],(x[0]>Tp||x[1]>Tp)&&$(`${t.layerIds[0]}: Value for "text-size" is >= ${bp}. Reduce your "text-size".`)),t.addSymbols(t.text,_,x,l,s,a,u,e,n,c.lineStartIndex,c.lineLength,p,m,g);for(const e of h)d[e]=t.text.placedSymbolArray.length-1;return 4*_.length}function Sp(t){for(const e in t)return t[e];return null}function wp(t,e,n,i,r,o,s,a,l,c){let u=s.top,h=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],u-=f[1],p+=f[2],h+=f[3]),l){const t=new y(d,u),e=new y(p,u),n=new y(d,h),i=new y(p,h),r=b(l);let o=new y(0,0);c&&(o=new y(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),n._rotateAround(r,o),i._rotateAround(r,o),d=Math.min(t.x,e.x,n.x,i.x),p=Math.max(t.x,e.x,n.x,i.x),u=Math.min(t.y,e.y,n.y,i.y),h=Math.max(t.y,e.y,n.y,i.y)}return t.emplaceBack(e.x,e.y,e.z,n.x,n.y,d,u,p,h,a,i,r,o),t.length-1}function Ap(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Mp(t,e,n,i){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(i.dist(t[e])<n)return!0}else r[e]=[];return r[e].push(i),!1}function Cp(t,e){const n=t.fovAboveCenter,i=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,r=(t._camera.position[2]*t.worldSize-i)/Math.cos(t._pitch);return Math.sin(n),Math.sin(Math.max(Math.PI/2-t._pitch-n,.01)),Math.sin(t._pitch),Math.max(r*(1/t._horizonShift),r+1e3*t.pixelsPerMeter/Math.cos(t._pitch))}function Ip(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};const n=Math.pow(2,-t.z),i=t.x*n,r=(t.x+1)*n,o=t.y*n,s=(t.y+1)*n,a=ql(i),l=ql(r),c=Xl(o),u=Xl(s),h=e.project(a,c),d=e.project(l,c),p=e.project(l,u),f=e.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=n/16;function x(t,n,i,r,o,s){const a=(i+o)/2,l=(r+s)/2,c=e.project(ql(a),Xl(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(t,c,i,r,a,l),x(c,n,a,l,o,s))}x(h,d,i,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,i,s),x(f,h,i,s,i,o),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:e}}const Pp=pa(new Float32Array(16));class Lp{constructor(t){this.spec=t,this.name=t.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(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new Vl(0,0)}projectTilePoint(t,e,n){return{x:t,y:e,z:0}}locationPoint(t,e,n=!0){return t._coordinatePoint(t.locationCoordinate(e),n)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,n){return 1}farthestPixelDistance(t){return Cp(t,t.pixelsPerMeter)}pointCoordinate(t,e,n,i){const r=t.horizonLineFromTop(!1),o=new y(e,Math.max(r,n));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,i))}pointCoordinate3D(t,e,n){const i=new y(e,n);if(t.elevation)return t.elevation.pointCoordinate(i);{const e=this.pointCoordinate(t,i.x,i.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return!this.pointCoordinate3D(t,e.x,e.y);const n=t.horizonLineFromTop();return e.y<n}createInversionMatrix(t,e){return Pp}createTileMatrix(t,e,n){let i,r,o;const s=n.canonical,a=pa(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=Ip(s,this);i=1,r=l.x+n.wrap*l.scale,o=l.y,_a(a,a,[i/l.scale,i/l.scale,t.pixelsPerMeter/e])}else i=e/t.zoomScale(s.z),r=(s.x+Math.pow(2,s.z)*n.wrap)*i,o=s.y*i;return ga(a,a,[r,o,0]),_a(a,a,[i/aa,i/aa,1]),a}upVector(t,e,n){return[0,0,1]}upVectorScale(t,e,n){return{metersToTile:1}}}class Rp extends Lp{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[e,n]=this.parallels=t.parallels||[29.5,45.5],i=Math.sin(b(e));this.n=(i+Math.sin(b(n)))/2,this.c=1+i*(2*this.n-i),this.r0=Math.sqrt(this.c)/this.n}project(t,e){const{n:n,c:i,r0:r}=this,o=b(t-this.center[0]),s=b(e),a=Math.sqrt(i-2*n*Math.sin(s))/n;return{x:a*Math.sin(o*n),y:a*Math.cos(o*n)-r,z:0}}unproject(t,e){const{n:n,c:i,r0:r}=this,o=r+e;let s=Math.atan2(t,Math.abs(o))*Math.sign(o);o*n<0&&(s-=Math.PI*Math.sign(t)*Math.sign(o));const a=b(this.center[0])*n;s=I(s,-Math.PI-a,Math.PI-a);const l=M(T(s/n)+this.center[0],-180,180),c=Math.asin(M((i-(t*t+o*o)*n*n)/(2*n),-1,1)),u=M(T(c),-Zl,Zl);return new Vl(l,u)}}const Op=1.340264,Dp=-.081106,Bp=893e-6,Np=.003796,Fp=Math.sqrt(3)/2;class Up extends Lp{project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;const n=Math.asin(Fp*Math.sin(e)),i=n*n,r=i*i*i;return{x:.5*(t*Math.cos(n)/(Fp*(Op+3*Dp*i+r*(7*Bp+9*Np*i)))/Math.PI+.5),y:1-.5*(n*(Op+Dp*i+r*(Bp+Np*i))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let n=e=(2*(1-e)-1)*Math.PI,i=n*n,r=i*i*i;for(let t,o,s,a=0;a<12&&(o=n*(Op+Dp*i+r*(Bp+Np*i))-e,s=Op+3*Dp*i+r*(7*Bp+9*Np*i),t=o/s,n=M(n-t,-Math.PI/3,Math.PI/3),i=n*n,r=i*i*i,!(Math.abs(t)<1e-12));++a);const o=Fp*t*(Op+3*Dp*i+r*(7*Bp+9*Np*i))/Math.cos(n),s=Math.asin(Math.sin(n)/Fp),a=M(180*o/Math.PI,-180,180),l=M(180*s/Math.PI,-Zl,Zl);return new Vl(a,l)}}class kp extends Lp{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){return{x:.5+t/360,y:.5-e/360,z:0}}unproject(t,e){const n=360*(t-.5),i=M(360*(.5-e),-Zl,Zl);return new Vl(n,i)}}const zp=Math.PI/2;function Gp(t){return Math.tan((zp+t)/2)}class Vp extends Lp{constructor(t){super(t),this.center=t.center||[0,30];const[e,n]=this.parallels=t.parallels||[30,30];let i=b(e),r=b(n);this.southernCenter=i+r<0,this.southernCenter&&(i=-i,r=-r);const o=Math.cos(i),s=Gp(i);this.n=i===r?Math.sin(i):Math.log(o/Math.cos(r))/Math.log(Gp(r)/s),this.f=o*Math.pow(Gp(i),this.n)/this.n}project(t,e){e=b(e),this.southernCenter&&(e=-e),t=b(t-this.center[0]);const n=1e-6,{n:i,f:r}=this;r>0?e<-zp+n&&(e=-zp+n):e>zp-n&&(e=zp-n);const o=r/Math.pow(Gp(e),i);let s=o*Math.sin(i*t),a=r-o*Math.cos(i*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:n,f:i}=this,r=i-e,o=Math.sign(r),s=Math.sign(n)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*n<0&&(a-=Math.PI*Math.sign(t)*o);const l=M(T(a/n)+this.center[0],-180,180),c=M(T(2*Math.atan(Math.pow(i/s,1/n))-zp),-Zl,Zl);return new Vl(l,this.southernCenter?-c:c)}}class jp extends Lp{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,e){return{x:$l(t),y:Hl(e),z:0}}unproject(t,e){const n=ql(t),i=Xl(e);return new Vl(n,i)}}const $p=b(Zl);class Hp extends Lp{project(t,e){const n=(e=b(e))*e,i=n*n;return{x:.5*((t=b(t))*(.8707-.131979*n+i*(i*(.003971*n-.001529*i)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+n*(.015085+i*(.028874*n-.044475-.005916*i)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let n=e=(2*(1-e)-1)*Math.PI,i=25,r=0,o=n*n;do{o=n*n;const t=o*o;r=(n*(1.007226+o*(.015085+t*(.028874*o-.044475-.005916*t)))-e)/(1.007226+o*(.045255+t*(.259866*o-.311325-.005916*11*t))),n=M(n-r,-$p,$p)}while(Math.abs(r)>1e-6&&--i>0);o=n*n;const s=M(T(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=T(n);return new Vl(s,a)}}const Wp=b(Zl);class qp extends Lp{project(t,e){e=b(e),t=b(t);const n=Math.cos(e),i=2/Math.PI,r=Math.acos(n*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*i+2*n*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let n=t=(2*t-.5)*Math.PI,i=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(i),o=Math.sin(i),l=2*o*r,c=o*o,u=r*r,h=Math.cos(n/2),d=Math.sin(n/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*n/Math.PI)-t,v=.5*(_*o+i)-e,x=.5*g*(u*f+_*r*h*c)+1/Math.PI,b=g*(p*l/4-_*o*d),T=.125*g*(l*d-_*o*u*p),E=.5*g*(c*h+_*f*r)+.5,S=b*T-E*x;s=(v*b-y*E)/S,a=(y*T-v*x)/S,n=M(n-s,-Math.PI,Math.PI),i=M(i-a,-Wp,Wp)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new Vl(T(n),T(i))}}class Xp extends Lp{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(b(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:n,cosPhi:i}=this;return{x:b(t)*i*n+.5,y:-Math.sin(b(e))/i*n+.5,z:0}}unproject(t,e){const{scale:n,cosPhi:i}=this,r=-(e-.5)/n,o=M(T((t-.5)/n)/i,-180,180),s=Math.asin(M(r*i,-1,1)),a=M(T(s),-Zl,Zl);return new Vl(o,a)}}class Yp extends jp{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,n){const i=Ml(t,e,n);return Fa(i,i,Pl(yl(n))),{x:i[0],y:i[1],z:i[2]}}locationPoint(t,e){const n=Al(e.lat,e.lng),i=Da([],n),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;Oa(n,n,i,Wl(1,0)*aa*r);const o=pa(new Float64Array(16));return ma(o,t.pixelMatrix,t.globeMatrix),Fa(n,n,o),new y(n[0],n[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,n){const i=Wl(1,t)*e,r=Rn(Wl(1,45)*e,i,n);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,n){const i=Ll(yl(n.canonical));return ma(new Float64Array(16),t.globeMatrix,i)}createInversionMatrix(t,e){const{center:n}=t,i=Pl(yl(e));return va(i,i,b(n.lng)),ya(i,i,b(n.lat)),_a(i,i,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(i)}pointCoordinate(t,e,n,i){return ml(t,e,n,!0)||new Kl(0,0)}pointCoordinate3D(t,e,n){const i=this.pointCoordinate(t,e,n,0);return[i.x,i.y,i.z]}isPointAboveHorizon(t,e){return!ml(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const n=t.cameraToCenterDistance,i=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=Ma([],Ra([],o,-n),[0,0,i]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,u=Math.tan(t.fovAboveCenter),h=Ra([],r.up(),u),d=Ra([],r.right(),u*c),p=Da([],Ma([],Ma([],o,h),d)),f=[];let m;if(new el(s,p).closestPointOnSphere(l,a,f)){const e=Ma([],f,l),n=za([],e,s);m=Math.cos(t.fovAboveCenter)*wa(n)}else{const t=za([],s,l),e=za([],l,s);Da(e,e);const n=wa(t)-a;m=Math.sqrt(n*(n+2*a));const i=Math.acos(m/(a+n))-Math.acos(Ba(o,e));m*=Math.cos(i)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),n=Ol(t.zoom);if(n>0){const i=Cp(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Rn(e,i+r*(1-Math.cos(o)),Math.pow(n,10))}return e}upVector(t,e,n){return Ml(e,n,t,1)}upVectorScale(t){return{metersToTile:fl(Cl(yl(t)))}}}function Zp(t){const e=t.parallels,n=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new jp(t);case"equirectangular":return new kp(t);case"naturalEarth":return new Hp(t);case"equalEarth":return new Up(t);case"winkelTripel":return new qp(t);case"albers":return n?new Xp(t):new Rp(t);case"lambertConformalConic":return n?new Xp(t):new Vp(t);case"globe":return new Yp(t)}throw new Error(`Invalid projection name: ${t.name}`)}const Jp=Wu.types,Kp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Qp(t,e,n,i,r,o,s,a,l,c,u,h,d){const p=a?Math.min(Tp,Math.round(a[0])):0,f=a?Math.min(Tp,Math.round(a[1])):0;t.emplaceBack(e,n,Math.round(32*i),Math.round(32*r),o,s,(p<<1)+(l?1:0),f,16*c,16*u,256*h,256*d)}function tf(t,e,n,i,r,o,s){t.emplaceBack(e,n,i,r,o,s)}function ef(t,e,n,i,r){t.emplaceBack(e,n,i,r),t.emplaceBack(e,n,i,r),t.emplaceBack(e,n,i,r),t.emplaceBack(e,n,i,r)}function nf(t){for(const e of t.sections)if(lo(e.text))return!0;return!1}class rf{constructor(t){this.layoutVertexArray=new Yo,this.indexArray=new is,this.programConfigurations=t,this.segments=new sa,this.dynamicLayoutVertexArray=new Ho,this.opacityVertexArray=new Jo,this.placedSymbolArray=new ms,this.globeExtVertexArray=new Zo}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,n,i){this.isEmpty()||(n&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ph.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Rh.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Kp,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Lh.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||i)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Yr(rf,"SymbolBuffers");class of{constructor(t,e,n){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new n,this.segments=new sa,this.collisionVertexArray=new es,this.collisionVertexArrayExt=new ns}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Oh.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Dh.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Yr(of,"CollisionBuffers");class sf{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=pa([]),this.placementViewportMatrix=pa([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=kh(this.zoom,e["text-size"]),this.iconSizeData=kh(this.zoom,e["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),r=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==i.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>wd[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new rf(new Zs(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new rf(new Zs(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new ys,this.lineVertexArray=new vs,this.symbolInstances=new _s}calculateGlyphDependencies(t,e,n,i,r){for(let n=0;n<t.length;n++)if(e[t.charCodeAt(n)]=!0,i&&r){const i=$h[t.charAt(n)];i&&(e[i.charCodeAt(0)]=!0)}}populate(t,e,n,i){const r=this.layers[0],o=r.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),u=("constant"!==l.value.kind||l.value.value instanceof De&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,g=new To(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:_}of t){const t=r._featureFilter.needGeometry,y=ac(e,t);if(!r._featureFilter.filter(g,y,n))continue;if(t||(y.geometry=sc(e,n,i)),s&&1!==e.type&&n.z<=5){const t=y.geometry,e=.98078528056,i=(t,i)=>Ba(Ml(t.x,t.y,n,1),Ml(i.x,i.y,n,1))<e;for(let e=0;e<t.length;e++)t[e]=nc(t[e],i)}let v,x;if(u){const t=r.getValueAndResolveTokens("text-field",y,n,m),e=De.factory(t);nf(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===vo()||this.hasRTLText&&bo.isParsed())&&(v=jh(e,r,y))}if(h){const t=r.getValueAndResolveTokens("icon-image",y,n,m);x=t instanceof Be?t:Be.fromString(t)}if(!v&&!x)continue;const b=this.sortFeaturesByKey?d.evaluate(y,{},n):void 0;if(this.features.push({id:l,text:v,icon:x,index:c,sourceLayerIndex:_,geometry:y.geometry,properties:e.properties,type:Jp[e.type],sortKey:b}),x&&(p[x.name]=!0),v){const t=a.evaluate(y,{},n).join(","),e="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(wd.vertical)>=0;for(const n of v.sections)if(n.image)p[n.image.name]=!0;else{const i=eo(v.toString()),r=n.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(n.text,o,e,this.allowVerticalPlacement,i)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},n={},i=[];let r=0;function o(e){i.push(t[e]),r++}function s(t,e,r){const o=n[t];return delete n[t],n[e]=o,i[o].geometry[0].pop(),i[o].geometry[0]=i[o].geometry[0].concat(r[0]),o}function a(t,n,r){const o=e[n];return delete e[n],e[t]=o,i[o].geometry[0].shift(),i[o].geometry[0]=r[0].concat(i[o].geometry[0]),o}function l(t,e,n){const i=n?e[0][e[0].length-1]:e[0][0];return`${t}:${i.x}:${i.y}`}for(let c=0;c<t.length;c++){const u=t[c],h=u.geometry,d=u.text?u.text.toString():null;if(!d){o(c);continue}const p=l(d,h),f=l(d,h,!0);if(p in n&&f in e&&n[p]!==e[f]){const t=a(p,f,h),r=s(p,f,i[t].geometry);delete e[p],delete n[f],n[l(d,i[r].geometry,!0)]=r,i[t].geometry=null}else p in n?s(p,f,h):f in e?a(p,f,h):(o(c),e[p]=r-1,n[f]=r-1)}return i.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,n,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,n,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,n,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Zp(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const n=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:n}of e)this.lineVertexArray.emplaceBack(t,n);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(t,e,n,i,r,o,s,a,l,c,u,h,d,p){const f=t.indexArray,m=t.layoutVertexArray,g=t.globeExtVertexArray,_=t.segments.prepareSegment(4*e.length,m,f,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,v=_.vertexLength,x=this.allowVerticalPlacement&&s===wd.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let i=0;i<e.length;i++){const{tl:r,tr:s,bl:c,br:u,tex:h,pixelOffsetTL:y,pixelOffsetBR:v,minFontScaleX:T,minFontScaleY:E,glyphOffset:S,isSDF:w,sectionIndex:A}=e[i],M=_.vertexLength,C=S[1];if(Qp(m,l.x,l.y,r.x,C+r.y,h.x,h.y,n,w,y.x,y.y,T,E),Qp(m,l.x,l.y,s.x,C+s.y,h.x+h.w,h.y,n,w,v.x,y.y,T,E),Qp(m,l.x,l.y,c.x,C+c.y,h.x,h.y+h.h,n,w,y.x,v.y,T,E),Qp(m,l.x,l.y,u.x,C+u.y,h.x+h.w,h.y+h.h,n,w,v.x,v.y,T,E),a){const{x:e,y:n,z:i}=a.anchor,[r,o,s]=a.up;tf(g,e,n,i,r,o,s),tf(g,e,n,i,r,o,s),tf(g,e,n,i,r,o,s),tf(g,e,n,i,r,o,s),ef(t.dynamicLayoutVertexArray,e,n,i,x)}else ef(t.dynamicLayoutVertexArray,l.x,l.y,l.z,x);f.emplaceBack(M,M+1,M+2),f.emplaceBack(M+1,M+2,M+3),_.vertexLength+=4,_.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(S[0]),i!==e.length-1&&A===e[i+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,o,o.index,{},d,p,b&&b[A])}const T=a?a.anchor:l;t.placedSymbolArray.emplaceBack(T.x,T.y,T.z,l.x,l.y,y,this.glyphOffsetArray.length-y,v,c,u,l.segment,n?n[0]:0,n?n[1]:0,i[0],i[1],s,0,!1,0,h,0)}_commitLayoutVertex(t,e,n,i,r,o,s){t.emplaceBack(e,n,i,r,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(t,e,n,i,r,o,s){const a=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),l=a.vertexLength,c=s.tileAnchorX,u=s.tileAnchorY;for(let t=0;t<4;t++)n.collisionVertexArray.emplaceBack(0,0,0,0);n.collisionVertexArrayExt.emplaceBack(e,-t.padding,-t.padding),n.collisionVertexArrayExt.emplaceBack(e,t.padding,-t.padding),n.collisionVertexArrayExt.emplaceBack(e,t.padding,t.padding),n.collisionVertexArrayExt.emplaceBack(e,-t.padding,t.padding),this._commitLayoutVertex(n.layoutVertexArray,i,r,o,c,u,new y(t.x1,t.y1)),this._commitLayoutVertex(n.layoutVertexArray,i,r,o,c,u,new y(t.x2,t.y1)),this._commitLayoutVertex(n.layoutVertexArray,i,r,o,c,u,new y(t.x2,t.y2)),this._commitLayoutVertex(n.layoutVertexArray,i,r,o,c,u,new y(t.x1,t.y2)),a.vertexLength+=4;const h=n.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(t,e,n,i,r,o){for(let s=i;s<r;s++){const i=n.get(s),r=this.getSymbolInstanceTextSize(t,o,e,s);this._addCollisionDebugVertices(i,r,this.textCollisionBox,i.projectedAnchorX,i.projectedAnchorY,i.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(t,e,n,i,r,o){for(let s=i;s<r;s++){const i=n.get(s),r=this.getSymbolInstanceIconSize(t,e,o.placedIconSymbolIndex);this._addCollisionDebugVertices(i,r,this.iconCollisionBox,i.projectedAnchorX,i.projectedAnchorY,i.projectedAnchorZ,o)}}generateCollisionDebugBuffers(t,e){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new of(Qo,Bh.members,cs),this.iconCollisionBox=new of(Qo,Bh.members,cs);const n=Gh(this.iconSizeData,t),i=Gh(this.textSizeData,t);for(let r=0;r<this.symbolInstances.length;r++){const o=this.symbolInstances.get(r);this._addTextDebugCollisionBoxes(i,t,e,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(i,t,e,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(n,t,e,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(n,t,e,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(t,e,n,i){const r=this.text.placedSymbolArray.get(e.rightJustifiedTextSymbolIndex>=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:i),o=zh(this.textSizeData,t,r)/Fh;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,n){const i=this.icon.placedSymbolArray.get(n),r=zh(this.iconSizeData,t,i);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,n){t.emplaceBack(e,-n,-n),t.emplaceBack(e,n,-n),t.emplaceBack(e,n,n),t.emplaceBack(e,-n,n)}_updateTextDebugCollisionBoxes(t,e,n,i,r,o){for(let s=i;s<r;s++){const i=n.get(s),r=this.getSymbolInstanceTextSize(t,o,e,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,r,i.padding)}}_updateIconDebugCollisionBoxes(t,e,n,i,r,o){for(let s=i;s<r;s++){const i=n.get(s),r=this.getSymbolInstanceIconSize(t,e,o);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,r,i.padding)}}updateCollisionDebugBuffers(t,e){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const n=Gh(this.iconSizeData,t),i=Gh(this.textSizeData,t);for(let r=0;r<this.symbolInstances.length;r++){const o=this.symbolInstances.get(r);this._updateTextDebugCollisionBoxes(i,t,e,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(i,t,e,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(n,t,e,o.iconBoxStartIndex,o.iconBoxEndIndex,o.placedIconSymbolIndex),this._updateIconDebugCollisionBoxes(n,t,e,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o.placedIconSymbolIndex)}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(t,e,n,i,r,o,s,a,l){const c={};if(e<n){const{x1:n,y1:i,x2:r,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=t.get(e);c.textBox={x1:n,y1:i,x2:r,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.textFeatureIndex=p}if(i<r){const{x1:e,y1:n,x2:r,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=t.get(i);c.verticalTextBox={x1:e,y1:n,x2:r,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.verticalTextFeatureIndex=p}if(o<s){const{x1:e,y1:n,x2:i,y2:r,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=t.get(o);c.iconBox={x1:e,y1:n,x2:i,y2:r,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.iconFeatureIndex=p}if(a<l){const{x1:e,y1:n,x2:i,y2:r,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=t.get(a);c.verticalIconBox={x1:e,y1:n,x2:i,y2:r,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.verticalIconFeatureIndex=p}return c}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const n=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.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}addIndicesForPlacedSymbol(t,e){const n=t.placedSymbolArray.get(e),i=n.vertexStartIndex+4*n.numGlyphs;for(let e=n.vertexStartIndex;e<i;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),n=Math.cos(t),i=[],r=[],o=[];for(let t=0;t<this.symbolInstances.length;++t){o.push(t);const s=this.symbolInstances.get(t);i.push(0|Math.round(e*s.tileAnchorX+n*s.tileAnchorY)),r.push(s.featureIndex)}return o.sort(((t,e)=>i[t]-i[e]||r[e]-r[t])),o}addToSortKeyRanges(t,e){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===e?n.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:i,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;n>=0&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&this.addIndicesForPlacedSymbol(this.text,i),r>=0&&r!==i&&r!==n&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),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)}}}Yr(sf,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),sf.MAX_GLYPHS=65535,sf.addDynamicAttributes=ef;const af=new Do({"symbol-placement":new Lo(te.layout_symbol["symbol-placement"]),"symbol-spacing":new Lo(te.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Lo(te.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ro(te.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Lo(te.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Lo(te.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Lo(te.layout_symbol["icon-ignore-placement"]),"icon-optional":new Lo(te.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Lo(te.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ro(te.layout_symbol["icon-size"]),"icon-text-fit":new Lo(te.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Lo(te.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ro(te.layout_symbol["icon-image"]),"icon-rotate":new Ro(te.layout_symbol["icon-rotate"]),"icon-padding":new Lo(te.layout_symbol["icon-padding"]),"icon-keep-upright":new Lo(te.layout_symbol["icon-keep-upright"]),"icon-offset":new Ro(te.layout_symbol["icon-offset"]),"icon-anchor":new Ro(te.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Lo(te.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Lo(te.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Lo(te.layout_symbol["text-rotation-alignment"]),"text-field":new Ro(te.layout_symbol["text-field"]),"text-font":new Ro(te.layout_symbol["text-font"]),"text-size":new Ro(te.layout_symbol["text-size"]),"text-max-width":new Ro(te.layout_symbol["text-max-width"]),"text-line-height":new Ro(te.layout_symbol["text-line-height"]),"text-letter-spacing":new Ro(te.layout_symbol["text-letter-spacing"]),"text-justify":new Ro(te.layout_symbol["text-justify"]),"text-radial-offset":new Ro(te.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Lo(te.layout_symbol["text-variable-anchor"]),"text-anchor":new Ro(te.layout_symbol["text-anchor"]),"text-max-angle":new Lo(te.layout_symbol["text-max-angle"]),"text-writing-mode":new Lo(te.layout_symbol["text-writing-mode"]),"text-rotate":new Ro(te.layout_symbol["text-rotate"]),"text-padding":new Lo(te.layout_symbol["text-padding"]),"text-keep-upright":new Lo(te.layout_symbol["text-keep-upright"]),"text-transform":new Ro(te.layout_symbol["text-transform"]),"text-offset":new Ro(te.layout_symbol["text-offset"]),"text-allow-overlap":new Lo(te.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Lo(te.layout_symbol["text-ignore-placement"]),"text-optional":new Lo(te.layout_symbol["text-optional"])});var lf={paint:new Do({"icon-opacity":new Ro(te.paint_symbol["icon-opacity"]),"icon-color":new Ro(te.paint_symbol["icon-color"]),"icon-halo-color":new Ro(te.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ro(te.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ro(te.paint_symbol["icon-halo-blur"]),"icon-translate":new Lo(te.paint_symbol["icon-translate"]),"icon-translate-anchor":new Lo(te.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ro(te.paint_symbol["text-opacity"]),"text-color":new Ro(te.paint_symbol["text-color"],{runtimeType:de,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Ro(te.paint_symbol["text-halo-color"]),"text-halo-width":new Ro(te.paint_symbol["text-halo-width"]),"text-halo-blur":new Ro(te.paint_symbol["text-halo-blur"]),"text-translate":new Lo(te.paint_symbol["text-translate"]),"text-translate-anchor":new Lo(te.paint_symbol["text-translate-anchor"])}),layout:af};class cf{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:le,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Yr(cf,"FormatSectionOverride",{omit:["defaultValue"]});class uf extends ia{constructor(t){super(t,lf)}recalculate(t,e){super.recalculate(t,e),"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 n=this.layout.get("text-writing-mode");if(n){const t=[];for(const e of n)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,e,n,i){const r=this.layout.get(t).evaluate(e,{},n,i),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||Yi(o.value)||!r?r:function(t,e){return e.replace(/{([^{}]+)}/g,((e,n)=>n in t?String(t[n]):""))}(e.properties,r)}createBucket(t){return new sf(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of lf.paint.overridableProperties){if(!uf.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),n=new cf(e),i=new Xi(n,e.property.specification);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Ji("source",i):new Ki("composite",i,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Io(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,n){return!(!this.layout||e.isDataDriven()||n.isDataDriven())&&uf.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const n=t.get("text-field"),i=lf.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(i.overrides&&i.overrides.hasOverride(e))return void(r=!0)};if("constant"===n.value.kind&&n.value.value instanceof De)o(n.value.value.sections);else if("source"===n.value.kind){const t=e=>{r||(e instanceof Ge&&Ue(e.value)===ge?o(e.value.sections):e instanceof We?o(e.sections):e.eachChild(t))},e=n.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramConfiguration(t){return new Ys(this,t)}}var hf={paint:new Do({"background-color":new Lo(te.paint_background["background-color"]),"background-pattern":new Lo(te.paint_background["background-pattern"]),"background-opacity":new Lo(te.paint_background["background-opacity"])})},df={paint:new Do({"raster-opacity":new Lo(te.paint_raster["raster-opacity"]),"raster-hue-rotate":new Lo(te.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Lo(te.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Lo(te.paint_raster["raster-brightness-max"]),"raster-saturation":new Lo(te.paint_raster["raster-saturation"]),"raster-contrast":new Lo(te.paint_raster["raster-contrast"]),"raster-resampling":new Lo(te.paint_raster["raster-resampling"]),"raster-fade-duration":new Lo(te.paint_raster["raster-fade-duration"])})};class pf extends ia{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var ff={paint:new Do({"sky-type":new Lo(te.paint_sky["sky-type"]),"sky-atmosphere-sun":new Lo(te.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Lo(te.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Lo(te.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Lo(te.paint_sky["sky-gradient-radius"]),"sky-gradient":new Oo(te.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Lo(te.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Lo(te.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Lo(te.paint_sky["sky-opacity"])})};function mf(t,e,n){const i=[0,0,1],r=qa([]);return Ya(r,r,n?-b(t)+Math.PI:b(t)),Xa(r,r,-b(e)),Ua(i,i,r),Da(i,i)}const gf={circle:class extends ia{constructor(t){super(t,Cc)}createBucket(t){return new uc(t)}queryRadius(t){const e=t;return Ec("circle-radius",this,e)+Ec("circle-stroke-width",this,e)+Sc(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,n,i,r,o,s,a){const l=Ac(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,n)+this.paint.get("circle-stroke-width").evaluate(e,n);return Ic(t,i,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new Ys(this,t)}},heatmap:class extends ia{createBucket(t){return new Dc(t)}constructor(t){super(t,zc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Gc({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)}queryRadius(t){return Ec("heatmap-radius",this,t)}queryIntersectsFeature(t,e,n,i,r,o,s,a){const l=this.paint.get("heatmap-radius").evaluate(e,n);return Ic(t,i,o,s,a,!0,!0,new y(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new Ys(this,t)}},hillshade:class extends ia{constructor(t){super(t,Vc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends ia{constructor(t){super(t,Cu)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),n=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(t){return new Ys(this,t)}recalculate(t,e){super.recalculate(t,e);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Au(t)}queryRadius(){return Sc(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,n,i,r,o){return!t.queryGeometry.isAboveHorizon&&pc(wc(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),i)}isTileClipped(){return!0}},"fill-extrusion":class extends ia{constructor(t){super(t,ch)}createBucket(t){return new Qu(t)}queryRadius(){return Sc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new Ys(this,t)}queryIntersectsFeature(t,e,n,i,r,o,s,a,l){const c=Ac(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(e,n),h=this.paint.get("fill-extrusion-base").evaluate(e,n),d=[0,0],p=a&&o.elevation,f=o.elevation?o.elevation.exaggeration():1,m=t.tile.getBucket(this);if(p&&m instanceof Qu){const t=m.centroidVertexArray,e=l+1;e<t.length&&(d[0]=t.geta_centroid_pos0(e),d[1]=t.geta_centroid_pos1(e))}if(0===d[0]&&1===d[1])return!1;"globe"===o.projection.name&&(i=ah([i],[new y(0,0),new y(aa,aa)],t.tileID.canonical).map((t=>t.polygon)).flat());const g=p?a:null,[_,v]=function(t,e,n,i,r,o,s,a,l,c,u){return"globe"===t.projection.name?function(t,e,n,i,r,o,s,a,l,c,u){const h=[],d=[],p=t.projection.upVectorScale(u,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],g=(t,e,n,i)=>{t[0]=e,t[1]=n,t[2]=i,t[3]=1},_=sh();n>0&&(n+=_),i+=_;for(const _ of e){const e=[],y=[];for(const h of _){const d=h.x+r.x,_=h.y+r.y,v=t.projection.projectTilePoint(d,_,u),x=t.projection.upVector(u,h.x,h.y);let b=n,T=i;if(s){const t=yh(d,_,n,i,s,a,l,c);b+=t.base,T+=t.top}0!==n?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*T,v.y+x[1]*p*T,v.z+x[2]*p*T),Fa(f,f,o),Fa(m,m,o),e.push(new mh(f[0],f[1],f[2])),y.push(new mh(m[0],m[1],m[2]))}h.push(e),d.push(y)}return[h,d]}(t,e,n,i,r,o,s,a,l,c,u):s?function(t,e,n,i,r,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const u=c.x+i.x,d=c.y+i.y,f=yh(u,d,e,n,o,s,a,l);h[0]=u,h[1]=d,h[2]=f.base,h[3]=1,Ha(h,h,r),h[3]=Math.max(h[3],1e-5);const m=new mh(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,Ha(h,h,r),h[3]=Math.max(h[3],1e-5);const g=new mh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);t.push(m),p.push(g)}c.push(t),u.push(p)}return[c,u]}(e,n,i,r,o,s,a,l,c):function(t,e,n,i,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,u=r[11]*e,h=r[8]*n,d=r[9]*n,p=r[10]*n,f=r[11]*n;for(const e of t){const t=[],n=[];for(const o of e){const e=o.x+i.x,s=o.y+i.y,m=r[0]*e+r[4]*s+r[12],g=r[1]*e+r[5]*s+r[13],_=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=g+l,b=_+c,T=Math.max(y+u,1e-5),E=m+h,S=g+d,w=_+p,A=Math.max(y+f,1e-5);t.push(new mh(v/T,x/T,b/T)),n.push(new mh(E/A,S/A,w/A))}o.push(t),s.push(n)}return[o,s]}(e,n,i,r,o)}(o,i,h,u,c,s,g,d,f,o.center.lat,t.tileID.canonical),x=t.queryGeometry;return function(t,e,n){let i=1/0;pc(n,e)&&(i=_h(n,e[0]));for(let r=0;r<e.length;r++){const o=e[r],s=t[r];for(let t=0;t<o.length-1;t++){const e=o[t],r=[e,o[t+1],s[t+1],s[t],e];hc(n,r)&&(i=Math.min(i,_h(n,r)))}}return i!==1/0&&i}(_,v,x.isPointQuery()?x.screenBounds:x.screenGeometry)}},line:class extends ia{constructor(t){super(t,Mh),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof Ln,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}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Ch.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new wh(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(t){return new Ys(this,t)}queryRadius(t){const e=t,n=Ih(Ec("line-width",this,e),Ec("line-gap-width",this,e)),i=Ec("line-offset",this,e);return n/2+Math.abs(i)+Sc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,n,i,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=wc(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*Ih(this.paint.get("line-width").evaluate(e,n),this.paint.get("line-gap-width").evaluate(e,n)),l=this.paint.get("line-offset").evaluate(e,n);return l&&(i=function(t,e){const n=[],i=new y(0,0);for(let r=0;r<t.length;r++){const o=t[r],s=[];for(let t=0;t<o.length;t++){const n=o[t],r=o[t+1],a=0===t?i:n.sub(o[t-1])._unit()._perp(),l=t===o.length-1?i:r.sub(n)._unit()._perp(),c=a._add(l)._unit();c._mult(1/(c.x*l.x+c.y*l.y)),s.push(c._mult(e)._add(n))}n.push(s)}return n}(i,l*t.pixelToTileUnitsFactor)),function(t,e,n){for(let i=0;i<e.length;i++){const r=e[i];if(t.length>=3)for(let e=0;e<r.length;e++)if(xc(t,r[e]))return!0;if(fc(t,r,n))return!0}return!1}(s,i,a)}isTileClipped(){return!0}},symbol:uf,background:class extends ia{constructor(t){super(t,hf)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends ia{constructor(t){super(t,df)}getProgramIds(){return["raster"]}},sky:class extends ia{constructor(t){super(t,ff),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Gc({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(t,e){if("atmosphere"===this.paint.get("sky-type")){const n=this.paint.get("sky-atmosphere-sun"),i=!n,r=t.style.light,o=r.properties.get("position");return i&&"viewport"===r.properties.get("anchor")&&$("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),i?mf(o.azimuthal,90-o.polar,e):mf(n[0],90-n[1],e)}const n=this.paint.get("sky-gradient-center");return mf(n[0],90-n[1],e)}is3D(){return!1}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return"atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}}};class _f{constructor(t,e,n,i){this.context=t,this.format=n,this.texture=t.gl.createTexture(),this.update(e,i)}update(t,n,i){const{width:r,height:o}=t,{context:s}=this,{gl:a}=s,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:u,ImageData:h,ImageBitmap:d}=e;if(a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!n||!1!==n.premultiply)),i||this.size&&this.size[0]===r&&this.size[1]===o){const{x:e,y:n}=i||{x:0,y:0};t instanceof l||t instanceof c||t instanceof u||t instanceof h||d&&t instanceof d?a.texSubImage2D(a.TEXTURE_2D,0,e,n,a.RGBA,a.UNSIGNED_BYTE,t):a.texSubImage2D(a.TEXTURE_2D,0,e,n,r,o,a.RGBA,a.UNSIGNED_BYTE,t.data)}else this.size=[r,o],t instanceof l||t instanceof c||t instanceof u||t instanceof h||d&&t instanceof d?a.texImage2D(a.TEXTURE_2D,0,this.format,this.format,a.UNSIGNED_BYTE,t):a.texImage2D(a.TEXTURE_2D,0,this.format,r,o,0,this.format,a.UNSIGNED_BYTE,t.data);this.useMipmap=Boolean(n&&n.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}bind(t,e){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),t!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap?t===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_NEAREST:t),this.filter=t),e!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class yf{constructor(t){this._callback=t,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 vf{constructor(){this.tasks={},this.taskQueue=[],U(["process"],this),this.invoker=new yf(this.process),this.nextId=0}add(t,e){const n=this.nextId++,i=function({type:t,isSymbolTile:e,zoom:n}){return n=n||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-n:"maybePrepare"===t&&e?400-n:500:200-n:100-n}(e);if(0===i){q();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:t,metadata:e,priority:i,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){q();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let n=0;n<this.taskQueue.length;n++){const i=this.tasks[this.taskQueue[n]];i.priority<e&&(e=i.priority,t=n)}if(null===t)return null;const n=this.taskQueue[t];return this.taskQueue.splice(t,1),n}remove(){this.invoker.remove()}}class xf{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const n=t[e];this._stringToNumber[n]=e,this._numberToString[e]=n}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}const bf=["tile","layer","source","sourceLayer","state"];class Tf{constructor(t,e,n,i,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=n,this._y=i,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};void 0!==this.id&&(t.id=this.id);for(const e of bf)void 0!==this[e]&&(t[e]=this[e]);return t}}const Ef=32,Sf=33,wf=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,n=0,i=0,r=0,o=0,s=0,a=0;for(1&e?r=o=s=Ef:n=i=a=Ef;(e>>=1)>1;){const t=n+r>>1,l=i+o>>1;1&e?(r=n,o=i,n=s,i=a):(n=r,i=o,r=s,o=a),s=t,a=l}const l=4*t;wf[l+0]=n,wf[l+1]=i,wf[l+2]=r,wf[l+3]=o}const Af=new Uint16Array(2178),Mf=new Uint8Array(1089),Cf=new Uint16Array(1089);function If(t){return 0===t?-.03125:32===t?.03125:0}var Pf=ko([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Lf={type:2,extent:aa,loadGeometry:()=>[[new y(0,0),new y(aa+1,0),new y(aa+1,aa+1),new y(0,aa+1),new y(0,0)]]};class Rf{constructor(t,e,n,i,r){this.tileID=t,this.uid=D(),this.uses=0,this.tileSize=e,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,this.expiredRequestCount=0,this.state="loading",i&&i.transform&&(this.projection=i.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;e<Xt.now()||this.fadeEndTime&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=Ip(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,e,n){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const n={};if(!e)return n;for(const i of t){const t=i.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){i.layers=t,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)n[e.id]=i}}return n}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof sf){if(this.hasSymbolBuckets=!0,!n)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof sf&&e.hasRTLText){this.hasRTLText=!0,bo.isLoading()||bo.isLoaded()||"deferred"!==vo()||xo();break}}this.queryPadding=0;for(const t in this.buckets){const n=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(n))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new ps}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),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"}}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const n=this.buckets[e];n.uploadPending()&&n.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new _f(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new _f(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new _f(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,n,i,r,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:i,pixelPosMatrix:s,transform:o,params:r,tileTransform:this.tileTransform},t,e,n):{}}querySourceFeatures(t,e){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const i=n.loadVTLayers(),r=e?e.sourceLayer:"",o=i._geojsonTileLayer||i[r];if(!o)return;const s=hr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let e=0;e<o.length;e++){const i=o.feature(e);if(s.needGeometry){const t=ac(i,!0);if(!s.filter(new To(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!s.filter(new To(this.tileID.overscaledZ),i))continue;const h=n.getId(i,r),d=new Tf(i,a,l,c,h);d.tile=u,t.push(d)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const e=this.expirationTime;if(t.cacheControl){const e=X(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let n=!1;if(this.expirationTime>t)n=!1;else if(e)if(this.expirationTime<e)n=!0;else{const i=this.expirationTime-e;i?this.expirationTime=t+Math.max(i,3e4):n=!0}else n=!0;n?(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-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(t,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length||!e)return;const n=this.latestFeatureIndex.loadVTLayers(),i=e.style.listImages();for(const r in this.buckets){if(!e.style.hasLayer(r))continue;const o=this.buckets[r],s=o.layers[0].sourceLayer||"_geojsonTileLayer",a=n[s],l=t[s];if(!a||!l||0===Object.keys(l).length)continue;if(o.update(l,a,i,this.imageAtlas&&this.imageAtlas.patternPositions||{}),o instanceof wh||o instanceof Au){const t=e.style._getSourceCache(o.layers[0].source);e._terrain&&e._terrain.enabled&&t&&o.programConfigurations.needsUpload&&e._terrain._clearRenderCacheForTile(t.id,this.tileID)}const c=e&&e.style&&e.style.getLayer(r);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(o)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Xt.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=Xt.now()+t}setTexture(t,e){const n=e.context,i=n.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture?this.texture.update(t,{useMipmap:!0}):(this.texture=new _f(n,t,i.RGBA,{useMipmap:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE))}setDependencies(t,e){const n={};for(const t of e)n[t]=!0;this.dependencies[t]=n}hasDependency(t,e){for(const n of t){const t=this.dependencies[n];if(t)for(const n of e)if(t[n])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,e){if(!e||"mercator"===e.name||this._tileDebugBuffer)return;const n=sc(Lf,this.tileID.canonical,this.tileTransform)[0],i=new Go,r=new us;for(let t=0;t<n.length;t++){const{x:e,y:o}=n[t];i.emplaceBack(e,o),r.emplaceBack(t)}r.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(r),this._tileDebugBuffer=t.createVertexBuffer(i,tl.members),this._tileDebugSegments=sa.simpleSegment(0,0,i.length,r.length)}_makeTileBoundsBuffers(t,e){if(this._tileBoundsBuffer||!e||"mercator"===e.name)return;const n=sc(Lf,this.tileID.canonical,this.tileTransform)[0];let i,r;if(this.isRaster){const t=function(t,e){const n=Ip(t,e),i=Math.pow(2,t.z);for(let r=0;r<Sf;r++)for(let o=0;o<Sf;o++){const s=ql((t.x+(o+If(o))/Ef)/i),a=Xl((t.y+(r+If(r))/Ef)/i),l=e.project(s,a),c=r*Sf+o;Af[2*c+0]=Math.round((l.x*n.scale-n.x)*aa),Af[2*c+1]=Math.round((l.y*n.scale-n.y)*aa)}Mf.fill(0),Cf.fill(0);for(let t=2045;t>=0;t--){const e=4*t,n=wf[e+0],i=wf[e+1],r=wf[e+2],o=wf[e+3],s=n+r>>1,a=i+o>>1,l=s+a-i,c=a+n-s,u=i*Sf+n,h=o*Sf+r,d=a*Sf+s,p=Math.hypot((Af[2*u+0]+Af[2*h+0])/2-Af[2*d+0],(Af[2*u+1]+Af[2*h+1])/2-Af[2*d+1])>=16;Mf[d]=Mf[d]||(p?1:0),t<1022&&(Mf[d]=Mf[d]||Mf[(i+c>>1)*Sf+(n+l>>1)]||Mf[(o+c>>1)*Sf+(r+l>>1)])}const r=new jo,o=new is;let s=0;function a(t,e){const n=e*Sf+t;return 0===Cf[n]&&(r.emplaceBack(Af[2*n+0],Af[2*n+1],t*aa/Ef,e*aa/Ef),Cf[n]=++s),Cf[n]-1}function l(t,e,n,i,r,s){const c=t+n>>1,u=e+i>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Mf[u*Sf+c])l(r,s,t,e,c,u),l(n,i,r,s,c,u);else{const l=a(t,e),c=a(n,i),u=a(r,s);o.emplaceBack(l,c,u)}}return l(0,0,Ef,Ef,Ef,0),l(Ef,Ef,0,0,0,Ef),{vertices:r,indices:o}}(this.tileID.canonical,e);i=t.vertices,r=t.indices}else{i=new jo,r=new is;for(const{x:t,y:e}of n)i.emplaceBack(t,e,0,0);const t=yu(i.int16,void 0,4);for(let e=0;e<t.length;e+=3)r.emplaceBack(t[e],t[e+1],t[e+2])}this._tileBoundsBuffer=t.createVertexBuffer(i,Pf.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(r),this._tileBoundsSegments=sa.simpleSegment(0,0,i.length,r.length)}_makeGlobeTileDebugBuffers(t,e){const n=e.projection;if(!n||"globe"!==n.name||e.freezeTileCoverage)return;const i=this.tileID.canonical,r=Pl(xl(i,e)),o=Ol(e.zoom);let s;o>0&&(s=fa(new Float64Array(16),e.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,i,e,r,s,o),this._makeGlobeTileDebugTextBuffer(t,i,e,r,s,o)}_globePoint(t,e,n,i,r,o,s){let a=Ml(t,e,n);if(o){const r=1<<n.z,l=$l(i.center.lng),c=Hl(i.center.lat),u=(n.x+.5)/r-l;let h=0;u>.5?h=-1:u<-.5&&(h=1);let d=(t/aa+n.x)/r+h,p=(e/aa+n.y)/r;d=(d-l)*i._pixelsPerMercatorPixel+l,p=(p-c)*i._pixelsPerMercatorPixel+c;const f=[d*i.worldSize,p*i.worldSize,0];Fa(f,f,o),a=vl(a,f,s)}return Fa(a,a,r)}_makeGlobeTileDebugBorderBuffer(t,e,n,i,r,o){const s=new Go,a=new us,l=new Vo,c=(t,c,u,h,d)=>{const p=(u-t)/(d-1),f=(h-c)/(d-1),m=s.length;for(let u=0;u<d;u++){const h=t+u*p,d=c+u*f;s.emplaceBack(h,d);const g=this._globePoint(h,d,e,n,i,r,o);l.emplaceBack(g[0],g[1],g[2]),a.emplaceBack(m+u)}},u=aa;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=t.createIndexBuffer(a),this._tileDebugBuffer=t.createVertexBuffer(s,tl.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(l,Qa.members),this._tileDebugSegments=sa.simpleSegment(0,0,s.length,a.length)}_makeGlobeTileDebugTextBuffer(t,e,n,i,r,o){const s=aa/4,a=new Go,l=new is,c=new Vo,u=25;l.reserve(32),a.reserve(u),c.reserve(u);const h=(t,e)=>u*t+e;for(let t=0;t<u;t++){const l=t*s;for(let t=0;t<u;t++){const u=t*s;a.emplaceBack(u,l);const h=this._globePoint(u,l,e,n,i,r,o);c.emplaceBack(h[0],h[1],h[2])}}for(let t=0;t<4;t++)for(let e=0;e<4;e++){const n=h(t,e),i=h(t,e+1),r=h(t+1,e),o=h(t+1,e+1);l.emplaceBack(n,i,r),l.emplaceBack(r,i,o)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(l),this._tileDebugTextBuffer=t.createVertexBuffer(a,tl.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(c,Qa.members),this._tileDebugTextSegments=sa.simpleSegment(0,0,u,32)}}class Of{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,n){const i=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][i]=this.stateChanges[t][i]||{},R(this.stateChanges[t][i],n),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==i&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][i]){this.deletedStates[t][i]={};for(const e in this.state[t][i])n[e]||(this.deletedStates[t][i][e]=null)}else for(const e in n)this.deletedStates[t]&&this.deletedStates[t][i]&&null===this.deletedStates[t][i][e]&&delete this.deletedStates[t][i][e]}removeFeatureState(t,e,n){if(null===this.deletedStates[t])return;const i=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},n&&void 0!==e)null!==this.deletedStates[t][i]&&(this.deletedStates[t][i]=this.deletedStates[t][i]||{},this.deletedStates[t][i][n]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][i])for(n in this.deletedStates[t][i]={},this.stateChanges[t][i])this.deletedStates[t][i][n]=null;else this.deletedStates[t][i]=null;else this.deletedStates[t]=null}getState(t,e){const n=String(e),i=R({},(this.state[t]||{})[n],(this.stateChanges[t]||{})[n]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const n=this.deletedStates[t][e];if(null===n)return{};for(const t in n)delete i[t]}return i}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const n={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const n in this.stateChanges[t])this.state[t][n]||(this.state[t][n]={}),R(this.state[t][n],this.stateChanges[t][n]),e[n]=this.state[t][n];n[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const n in this.state[t])e[n]={},this.state[t][n]={};else for(const n in this.deletedStates[t]){if(null===this.deletedStates[t][n])this.state[t][n]={};else if(this.state[t][n])for(const e of Object.keys(this.deletedStates[t][n]))delete this.state[t][n][e];e[n]=this.state[t][n]}n[t]=n[t]||{},R(n[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const i in t)t[i].setFeatureState(n,e)}}class Df{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const n=this.toIdx(t,e);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function Bf(t,e,n,i){let r=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(i[s])<1e-15){if(n[s]<t[s]||n[s]>e[s])return null}else{const a=1/i[s];let l=(t[s]-n[s])*a,c=(e[s]-n[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),c<o&&(o=c),r>o)return null}return r}function Nf(t,e,n,i,r,o,s,a,l,c,u){const h=i-t,d=r-e,p=o-n,f=s-t,m=a-e,g=l-n,_=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,T=c[0]-t,E=c[1]-e,S=c[2]-n,w=(T*_+E*y+S*v)*b;if(w<0||w>1)return null;const A=E*p-S*d,M=S*h-T*p,C=T*d-E*h,I=(u[0]*A+u[1]*M+u[2]*C)*b;return I<0||w+I>1?null:(f*A+m*M+g*C)*b}function Ff(t,e,n){return(t-e)/(n-e)}function Uf(t,e,n,i,r,o,s,a,l){const c=1<<n,u=o-i,h=s-r,d=(t+1)/c*u+i,p=(e+0)/c*h+r,f=(e+1)/c*h+r;a[0]=(t+0)/c*u+i,a[1]=p,l[0]=d,l[1]=f}class kf{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const e=function(t){const e=Math.ceil(Math.log2(t.dim/8)),n=[];let i=Math.ceil(Math.pow(2,e));const r=1/i,o=(t,e,n,i,r)=>{const o=i?1:0,s=(t+1)*n-o,a=e*n,l=(e+1)*n-o;r[0]=t*n,r[1]=a,r[2]=s,r[3]=l};let s=new Df(i);const a=[];for(let e=0;e<i*i;e++){o(e%i,Math.floor(e/i),r,!1,a);const n=Gf(a[0],a[1],t),l=Gf(a[2],a[1],t),c=Gf(a[2],a[3],t),u=Gf(a[0],a[3],t);s.minimums.push(Math.min(n,l,c,u)),s.maximums.push(Math.max(n,l,c,u)),s.leaves.push(1)}for(n.push(s),i/=2;i>=1;i/=2){const t=n[n.length-1];s=new Df(i);for(let e=0;e<i*i;e++){o(e%i,Math.floor(e/i),2,!0,a);const n=t.getElevation(a[0],a[1]),r=t.getElevation(a[2],a[1]),l=t.getElevation(a[2],a[3]),c=t.getElevation(a[0],a[3]),u=t.isLeaf(a[0],a[1]),h=t.isLeaf(a[2],a[1]),d=t.isLeaf(a[2],a[3]),p=t.isLeaf(a[0],a[3]),f=Math.min(n.min,r.min,l.min,c.min),m=Math.max(n.max,r.max,l.max,c.max),g=u&&h&&d&&p;s.maximums.push(m),s.minimums.push(f),s.leaves.push(m-f<=5&&g?1:0)}n.push(s)}return n}(this.dem),n=e.length-1,i=e[n];this._addNode(i.minimums[0],i.maximums[0],i.leaves[0]),this._construct(e,0,0,n,0)}raycastRoot(t,e,n,i,r,o,s=1){return Bf([t,e,-100],[n,i,this.maximums[0]*s],r,o)}raycast(t,e,n,i,r,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(t,e,n,i,r,o,s);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]){Uf(f,m,g,t,e,n,i,u,h);const a=1<<g,l=(f+0)/a,c=(f+1)/a,d=(m+0)/a,_=(m+1)/a,y=Gf(l,d,this.dem)*s,v=Gf(c,d,this.dem)*s,x=Gf(c,_,this.dem)*s,b=Gf(l,_,this.dem)*s,T=Nf(u[0],u[1],y,h[0],u[1],v,h[0],h[1],x,r,o),E=Nf(h[0],h[1],x,u[0],h[1],b,u[0],u[1],y,r,o),S=Math.min(null!==T?T:Number.MAX_VALUE,null!==E?E:Number.MAX_VALUE);if(S!==Number.MAX_VALUE)return S;{const t=Oa([],r,o,p);if(zf(y,v,b,x,Ff(t[0],u[0],h[0]),Ff(t[1],u[1],h[1]))>=t[2])return p}continue}let _=0;for(let d=0;d<this._siblingOffset.length;d++){Uf((f<<1)+this._siblingOffset[d][0],(m<<1)+this._siblingOffset[d][1],g+1,t,e,n,i,u,h),u[2]=-100,h[2]=this.maximums[this.childOffsets[a]+d]*s;const p=Bf(u,h,r,o);if(null!=p){const t=p;l[d]=t;let e=!1;for(let n=0;n<_&&!e;n++)t>=l[c[n]]&&(c.splice(n,0,d),e=!0);e||(c[_]=d),_++}}for(let t=0;t<_;t++){const e=c[t];d.push({idx:this.childOffsets[a]+e,t:l[e],nodex:(f<<1)+this._siblingOffset[e][0],nodey:(m<<1)+this._siblingOffset[e][1],depth:g+1})}}return null}_addNode(t,e,n){return this.minimums.push(t),this.maximums.push(e),this.leaves.push(n),this.childOffsets.push(0),this.nodeCount++}_construct(t,e,n,i,r){if(1===t[i].isLeaf(e,n))return;this.childOffsets[r]||(this.childOffsets[r]=this.nodeCount);const o=i-1,s=t[o];let a=0,l=0;for(let t=0;t<this._siblingOffset.length;t++){const i=2*e+this._siblingOffset[t][0],r=2*n+this._siblingOffset[t][1],o=s.getElevation(i,r),c=s.isLeaf(i,r),u=this._addNode(o.min,o.max,c);c&&(a|=1<<t),l||(l=u)}for(let i=0;i<this._siblingOffset.length;i++)a&1<<i||this._construct(t,2*e+this._siblingOffset[i][0],2*n+this._siblingOffset[i][1],o,l+i)}}function zf(t,e,n,i,r,o){return Rn(Rn(t,n,o),Rn(e,i,o),r)}function Gf(t,e,n){const i=n.dim,r=M(t*i-.5,0,i-1),o=M(e*i-.5,0,i-1),s=Math.floor(r),a=Math.floor(o),l=Math.min(s+1,i-1),c=Math.min(a+1,i-1);return zf(n.get(s,a),n.get(l,a),n.get(s,c),n.get(l,c),r-s,o-a)}const Vf={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function jf(t,e,n){return(256*t*256+256*e+n)/10-1e4}function $f(t,e,n){return 256*t+e+n/256-32768}class Hf{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,e,n,i=!1,r=!1){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(n&&"mapbox"!==n&&"terrarium"!==n)return $(`"${n}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const o=this.dim=e.height-2,s=new Uint32Array(e.data.buffer);if(this.pixels=new Uint8Array(e.data.buffer),this.encoding=n||"mapbox",this.borderReady=i,!i){for(let t=0;t<o;t++)s[this._idx(-1,t)]=s[this._idx(0,t)],s[this._idx(o,t)]=s[this._idx(o-1,t)],s[this._idx(t,-1)]=s[this._idx(t,0)],s[this._idx(t,o)]=s[this._idx(t,o-1)];s[this._idx(-1,-1)]=s[this._idx(0,0)],s[this._idx(o,-1)]=s[this._idx(o-1,0)],s[this._idx(-1,o)]=s[this._idx(0,o-1)],s[this._idx(o,o)]=s[this._idx(o-1,o-1)],r&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new kf(this)}get(t,e,n=!1){n&&(t=M(t,-1,this.dim),e=M(e,-1,this.dim));const i=4*this._idx(t,e);return("terrarium"===this.encoding?$f:jf)(this.pixels[i],this.pixels[i+1],this.pixels[i+2])}static getUnpackVector(t){return Vf[t]}get unpackVector(){return Vf[this.encoding]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const n=[0,0,0,0],i=Hf.getUnpackVector(e);let r=Math.floor((t+i[3])/i[2]);return n[2]=r%256,r=Math.floor(r/256),n[1]=r%256,r=Math.floor(r/256),n[0]=r,n}getPixels(){return new kc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,n){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let i=e*this.dim,r=e*this.dim+this.dim,o=n*this.dim,s=n*this.dim+this.dim;switch(e){case-1:i=r-1;break;case 1:r=i+1}switch(n){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-n*this.dim;for(let e=o;e<s;e++)for(let n=i;n<r;n++){const i=4*this._idx(n,e),r=4*this._idx(n+a,e+l);this.pixels[i+0]=t.pixels[r+0],this.pixels[i+1]=t.pixels[r+1],this.pixels[i+2]=t.pixels[r+2],this.pixels[i+3]=t.pixels[r+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Yr(Hf,"DEMData"),Yr(kf,"DemMinMaxQuadTree",{omit:["dem"]});class Wf{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,n){const i=t.wrapped().key;void 0===this.data[i]&&(this.data[i]=[]);const r={value:e,timeout:void 0};if(void 0!==n&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),n)),this.data[i].push(r),this.order.push(i),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const n=t.wrapped().key,i=void 0===e?0:this.data[n].indexOf(e),r=this.data[n][i];return this.data[n].splice(i,1),r.timeout&&clearTimeout(r.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(r.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const n in this.data)for(const i of this.data[n])t(i.value)||e.push(i);for(const t of e)this.remove(t.value.tileID,t)}}class qf{constructor(t,e,n){this.func=t,this.mask=e,this.range=n}}qf.ReadOnly=!1,qf.ReadWrite=!0,qf.disabled=new qf(519,qf.ReadOnly,[0,1]);const Xf=7680;class Yf{constructor(t,e,n,i,r,o){this.test=t,this.ref=e,this.mask=n,this.fail=i,this.depthFail=r,this.pass=o}}Yf.disabled=new Yf({func:519,mask:0},0,0,Xf,Xf,Xf);class Zf{constructor(t,e,n){this.blendFunction=t,this.blendColor=e,this.mask=n}}Zf.Replace=[1,0],Zf.disabled=new Zf(Zf.Replace,Le.transparent,[!1,!1,!1,!1]),Zf.unblended=new Zf(Zf.Replace,Le.transparent,[!0,!0,!0,!0]),Zf.alphaBlended=new Zf([1,771],Le.transparent,[!0,!0,!0,!0]);const Jf=1029,Kf=2305;class Qf{constructor(t,e,n){this.enable=t,this.mode=e,this.frontFace=n}}Qf.disabled=new Qf(!1,Jf,Kf),Qf.backCCW=new Qf(!0,Jf,Kf),Qf.backCW=new Qf(!0,Jf,2304),Qf.frontCW=new Qf(!0,1028,2304),Qf.frontCCW=new Qf(!0,1028,Kf);class tm extends Qt{constructor(t,e,n){super(),this.id=t,this._onlySymbols=n,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Wf(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Of,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const n=this._tiles[e];n.upload(t),n.prepare(this.map.style.imageManager)}}getIds(){return L(this._tiles).map((t=>t.tileID)).sort(em).map((t=>t.key))}getRenderableIds(t){const e=[];for(const n in this._tiles)this._isIdRenderable(+n,t)&&e.push(this._tiles[n]);return t?e.sort(((t,e)=>{const n=t.tileID,i=e.tileID,r=new y(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),o=new y(i.canonical.x,i.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-i.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(em).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const n=this._tiles[t];n&&("loading"!==n.state&&(n.state=e),this._loadTile(n,this._tileLoaded.bind(this,n,t,e)))}_tileLoaded(t,e,n,i){if(i)if(t.state="errored",404!==i.status)this._source.fire(new Kt(i,{tile:t}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=Xt.now(),"expired"===n&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Jt("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let i=0;i<e.length;i++){const r=e[i];if(t.neighboringTiles&&t.neighboringTiles[r]){const e=this.getTileByID(r);n(t,e),n(e,t)}}function n(t,e){if(!t.dem||t.dem.borderReady)return;t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0;let n=e.tileID.canonical.x-t.tileID.canonical.x;const i=e.tileID.canonical.y-t.tileID.canonical.y,r=Math.pow(2,t.tileID.canonical.z),o=e.tileID.key;0===n&&0===i||Math.abs(i)>1||(Math.abs(n)>1&&(1===Math.abs(n+r)?n+=r:1===Math.abs(n-r)&&(n-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,n,i),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,n,i){for(const r in this._tiles){let o=this._tiles[r];if(i[r]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>n)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){i[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const n=this._loadedParentTiles[t.key];return n&&n.tileID.overscaledZ>=e?n:null}for(let n=t.overscaledZ-1;n>=e;n--){const e=t.scaledTo(n),i=this._getLoadedTile(e);if(i)return i}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const n=Math.ceil(t.width/e)+1,i=Math.ceil(t.height/e)+1,r=Math.floor(n*i*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const n in this._tiles){const i=this._tiles[n];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),t[i.tileID.key]=i}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;let i;this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new ph(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(i=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(i=i.filter((t=>this._source.hasTile(t))))):i=[];const r=this._updateRetainedTiles(i);if(nm(this._source.type)&&0!==i.length){const t={},e={},n=Object.keys(r);for(const i of n){const n=r[i],o=this._tiles[i];if(!o||o.fadeEndTime&&o.fadeEndTime<=Xt.now())continue;const s=this.findLoadedParent(n,Math.max(n.overscaledZ-tm.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),e[i]=n}const o=i[i.length-1].overscaledZ;for(const t in this._tiles){const n=this._tiles[t];if(r[t]||!n.hasData())continue;let i=n.tileID;for(;i.overscaledZ>o;){i=i.scaledTo(i.overscaledZ-1);const o=this._tiles[i.key];if(o&&o.hasData()&&e[i.key]){r[t]=n.tileID;break}}}for(const e in t)r[e]||(this._coveredTiles[e]=!0,r[e]=t[e])}for(const t in r)this._tiles[t].clearFadeHold();const o=function(t,e){const n=[];for(const i in t)i in e||n.push(i);return n}(this._tiles,r);for(const t of o){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const n={},i=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-tm.maxOverzooming,this._source.minzoom),s=Math.max(r+tm.maxUnderzooming,this._source.minzoom),a={};for(const n of t){const t=this._addTile(n);e[n.key]=n,t.hasData()||i<this._source.maxzoom&&(a[n.key]=n)}this._retainLoadedChildren(a,i,s,e);for(const i of t){let t=this._tiles[i.key];if(t.hasData())continue;if(i.canonical.z>=this._source.maxzoom){const t=i.children(this._source.maxzoom)[0],n=this.getTile(t);if(n&&n.hasData()){e[t.key]=t;continue}}else{const t=i.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=i.overscaledZ-1;s>=o;--s){const o=i.scaledTo(s);if(n[o.key])break;if(n[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let n,i=this._tiles[t].tileID;for(;i.overscaledZ>0;){if(i.key in this._loadedParentTiles){n=this._loadedParentTiles[i.key];break}e.push(i.key);const t=i.scaledTo(i.overscaledZ-1);if(n=this._getLoadedTile(t),n)break;i=t}for(const t of e)this._loadedParentTiles[t]=n}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const n=Boolean(e);if(!n){const n=this.map?this.map.painter:null;e=new Rf(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,n,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,n||this._source.fire(new Jt("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const n=e.getExpiryTimeout();n&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),n))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);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,e,n){const i=[],r=this.transform;if(!r)return i;const o="globe"===r.projection.name,s=$l(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(M(s,...im(t,-1))-s),Math.abs(M(s,...im(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(M(s,...im(t,-1))-s),Math.abs(M(s,...im(t,0))-s),Math.abs(M(s,...im(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const n of c){const o=t.containsTile(l,r,e,n);o&&i.push(o)}}return i}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(nm(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=Xt.now())return!0}return!1}setFeatureState(t,e,n){this._state.updateState(t=t||"_geojsonTileLayer",e,n)}removeFeatureState(t,e,n){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,n)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,n){const i=this._tiles[t];i&&i.setDependencies(e,n)}reloadTilesForDependencies(t,e){for(const n in this._tiles)this._tiles[n].hasDependency(t,e)&&this._reloadTile(+n,"reloading");this._cache.filter((n=>!n.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const n=()=>{this._sourceLoaded&&(this._source.off("data",n),this._preloadTiles(t,e))};return void this._source.on("data",n)}const n=new Map,i=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of i){const e=t.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 t of e)n.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}P(Array.from(n.values()),((t,e)=>{const n=new Rf(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(n,(t=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),e(t,n)}))}),e)}}function em(t,e){const n=Math.abs(2*t.wrap)-+(t.wrap<0),i=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||i-n||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function nm(t){return"raster"===t||"image"===t||"video"===t||"custom"===t}function im(t,e){const n=1<<t.z;return[t.x/n+e,(t.x+1)/n+e]}tm.maxOverzooming=10,tm.maxUnderzooming=3;class rm{constructor(t,e,n){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=n}static create(t,e,n){const i=n||t.findDEMTileFor(e);if(!i||!i.dem)return;const r=i.dem,o=i.tileID,s=1<<e.canonical.z-o.canonical.z;return new rm(i,i.tileSize/aa/s,[(e.canonical.x/s-o.canonical.x)*r.dim,(e.canonical.y/s-o.canonical.y)*r.dim])}tileCoordToPixel(t,e){const n=e*this._scale+this._offset[1],i=Math.floor(t*this._scale+this._offset[0]),r=Math.floor(n);return new y(i,r)}getElevationAt(t,e,n,i){const r=t*this._scale+this._offset[0],o=e*this._scale+this._offset[1],s=Math.floor(r),a=Math.floor(o),l=this._dem;return i=!!i,n?Rn(Rn(l.get(s,a,i),l.get(s,a+1,i),o-a),Rn(l.get(s+1,a,i),l.get(s+1,a+1,i),o-a),r-s):l.get(s,a,i)}getElevationAtPixel(t,e,n){return this._dem.get(t,e,!!n)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*Wl(1,t)*this._dem.stride}}class om{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new qr(aa,16,0),this.featureIndexArray=new bs,this.promoteId=e}insert(t,e,n,i,r,o=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,i,r,o);const a=this.grid;for(let t=0;t<e.length;t++){const n=e[t],i=[1/0,1/0,-1/0,-1/0];for(let t=0;t<n.length;t++){const e=n[t];i[0]=Math.min(i[0],e.x),i[1]=Math.min(i[1],e.y),i[2]=Math.max(i[2],e.x),i[3]=Math.max(i[3],e.y)}i[0]<aa&&i[1]<aa&&i[2]>=0&&i[3]>=0&&a.insert(s,i[0],i[1],i[2],i[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Hu(new md(this.rawTileData)).layers,this.sourceLayerCoder=new xf(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,n,i){this.loadVTLayers();const r=t.params||{},o=hr(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,n,i)=>bc(s.bufferedTilespaceGeometry,t,e,n,i)));c.sort(am);let u=null;a.elevation&&c.length>0&&(u=rm.create(a.elevation,this.tileID));const h={};let d;for(let a=0;a<c.length;a++){const l=c[a];if(l===d)continue;d=l;const p=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(h,p,o,r.layers,r.availableImages,e,n,i,((e,n,i,r=0)=>(f||(f=sc(e,this.tileID.canonical,t.tileTransform)),n.queryIntersectsFeature(s,e,i,f,this.z,t.transform,t.pixelPosMatrix,u,r))))}return h}loadMatchingFeature(t,e,n,i,r,o,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[u];if(i&&!function(t,e){for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>=0)return!0;return!1}(i,p))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(n.needGeometry){const t=ac(m,!0);if(!n.filter(new To(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!n.filter(new To(this.tileID.overscaledZ),m))return;const g=this.getId(m,f);for(let e=0;e<p.length;e++){const n=p[e];if(i&&i.indexOf(n)<0)continue;const u=o[n];if(!u)continue;let h={};void 0!==g&&a&&(h=a.getState(u.sourceLayer||"_geojsonTileLayer",g));const f=R({},s[n]);f.paint=sm(f.paint,u.paint,m,h,r),f.layout=sm(f.layout,u.layout,m,h,r);const _=!l||l(m,u,h,d);if(!_)continue;const y=new Tf(m,this.z,this.x,this.y,g);y.layer=f;let v=t[n];void 0===v&&(v=t[n]=[]),v.push({featureIndex:c,feature:y,intersectionZ:_})}}lookupSymbolFeatures(t,e,n,i,r,o,s,a){const l={};this.loadVTLayers();const c=hr(r);for(const r of t)this.loadMatchingFeature(l,{bucketIndex:n,sourceLayerIndex:i,featureIndex:r,layoutVertexArrayOffset:0},c,o,s,a,e);return l}loadFeature(t){const{featureIndex:e,sourceLayerIndex:n}=t;this.loadVTLayers();const i=this.sourceLayerCoder.decode(n),r=this.vtFeatures[i];if(r[e])return r[e];const o=this.vtLayers[i].feature(e);return r[e]=o,o}hasLayer(t){for(const e of this.bucketLayerIDs)for(const n of e)if(t===n)return!0;return!1}getId(t,e){let n=t.id;if(this.promoteId){const i="string"==typeof this.promoteId?this.promoteId:this.promoteId[e];null!=i&&(n=t.properties[i]),"boolean"==typeof n&&(n=Number(n))}return n}}function sm(t,e,n,i,r){return z(t,((t,o)=>{const s=e instanceof Po?e.get(o):null;return s&&s.evaluate?s.evaluate(n,i,r):s}))}function am(t,e){return e-t}Yr(om,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class lm{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new Uc({width:t,height:e}),this.positions={},this.uploaded=!1}getDash(t,e){const n=this.getKey(t,e);return this.positions[n]}trim(){const t=this.width,e=this.height=N(this.nextRow);this.image.resize({width:t,height:e})}getKey(t,e){return t.join(",")+e}getDashRanges(t,e,n){const i=[];let r=t.length%2==1?-t[t.length-1]*n:0,o=t[0]*n,s=!0;i.push({left:r,right:o,isDash:s,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){s=!s;const l=t[e];r=a*n,a+=l,o=a*n,i.push({left:r,right:o,isDash:s,zeroLength:0===l})}return i}addRoundDash(t,e,n){const i=e/2;for(let e=-n;e<=n;e++){const r=this.width*(this.nextRow+n+e);let o=0,s=t[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=e/n*(i+1);if(s.isDash){const t=i-Math.abs(d);h=Math.sqrt(u*u+t*t)}else h=i-Math.sqrt(u*u+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const n=t[e],i=t[e+1];n.zeroLength?t.splice(e,1):i&&i.isDash===n.isDash&&(i.left=n.left,t.splice(e,1))}const n=t[0],i=t[t.length-1];n.isDash===i.isDash&&(n.left=i.left-this.width,i.right=n.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let n=0;n<this.width;n++){n/s.right>1&&(s=t[++o]);const i=Math.abs(n-s.left),a=Math.abs(n-s.right),l=Math.min(i,a);this.image.data[r+n]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const n=this.getKey(t,e);if(this.positions[n])return this.positions[n];const i="round"===e,r=i?7:0,o=2*r+1;if(this.nextRow+o>this.height)return $("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e<t.length;e++)t[e]<0&&($("Negative value is found in line dasharray, replacing values with 0"),t[e]=0),s+=t[e];if(0!==s){const n=this.width/s,o=this.getDashRanges(t,this.width,n);i?this.addRoundDash(o,n,r):this.addRegularDash(o,"square"===e?.5*n:0)}const a=this.nextRow+r;this.nextRow+=o;const l={tl:[a,r],br:[s,0]};return this.positions[n]=l,l}}Yr(lm,"LineAtlas");const cm=1*Qd;class um{constructor(t){const e={},n=[];for(const i in t){const r=t[i],o=e[i]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?cm:1,s={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(s),o[t]=s}}const{w:i,h:r}=bd(n),o=new Uc({width:i||1,height:r||1});for(const n in t){const i=t[n];for(const t in i.glyphs){const r=i.glyphs[+t];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const s=e[n][t],a=r.metrics.localGlyph?cm:1;Uc.copy(r.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},r.bitmap)}}this.image=o,this.positions=e}}Yr(um,"GlyphAtlas");class hm{constructor(t){this.tileID=new ph(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=Ip(t.tileID.canonical,t.projection),this.projection=t.projection}parse(t,e,n,i,r){this.status="parsing",this.data=t,this.collisionBoxArray=new ps;const o=new xf(Object.keys(t.layers).sort()),s=new om(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new lm(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:n},u=e.familiesBySource[this.source];for(const e in u){const i=t.layers[e];if(!i)continue;let r=!1,l=!1;for(const t of u[e])"symbol"===t[0].type?r=!0:l=!0;if(!0===this.isSymbolTile&&!r)continue;if(!1===this.isSymbolTile&&!l)continue;1===i.version&&$(`Vector tile source "${this.source}" layer "${e}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=o.encode(e),d=[];for(let t=0;t<i.length;t++){const n=i.feature(t),r=s.getId(n,e);d.push({feature:n,id:r,index:t,sourceLayerIndex:h})}for(const t of u[e]){const e=t[0];void 0!==this.isSymbolTile&&"symbol"===e.type!==this.isSymbolTile||e.minzoom&&this.zoom<Math.floor(e.minzoom)||e.maxzoom&&this.zoom>=e.maxzoom||"none"!==e.visibility&&(dm(t,this.zoom,n),(a[e.id]=e.createBucket({index:s.bucketLayerIDs.length,layers:t,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:n})).populate(d,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(t.map((t=>t.id))))}}let h,d,p,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},g=()=>{if(h)return r(h);if(d&&p&&f){const t=new um(d),e=new Sd(p,f);for(const i in a){const r=a[i];r instanceof sf?(dm(r.layers,this.zoom,n),yp(r,d,t.positions,p,e.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):r.hasPattern&&(r instanceof wh||r instanceof Au||r instanceof Qu)&&(dm(r.layers,this.zoom,n),r.addFeatures(c,this.tileID.canonical,e.patternPositions,n,this.tileTransform))}this.status="done",r(null,{buckets:L(a).filter((t=>!t.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?d:null,iconMap:this.returnDependencies?p:null,glyphPositions:this.returnDependencies?t.positions:null})}},_=z(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(_).length?i.send("getGlyphs",{uid:this.uid,stacks:_},((t,e)=>{h||(h=t,d=e,g())}),void 0,!1,m):d={};const y=Object.keys(c.iconDependencies);y.length?i.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{h||(h=t,p=e,g())}),void 0,!1,m):p={};const v=Object.keys(c.patternDependencies);v.length?i.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{h||(h=t,f=e,g())}),void 0,!1,m):f={},g()}}function dm(t,e,n){const i=new To(e);for(const e of t)e.recalculate(i,n)}class pm{constructor(t){this.entries={},this.scheduler=t}request(t,e,n,i){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,n]=r.result;return this.scheduler?this.scheduler.add((()=>{i(t,n)}),e):i(t,n),()=>{}}return r.callbacks.push(i),r.cancel||(r.cancel=n(((n,i)=>{r.result=[n,i];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(n,i)}),e):t(n,i);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==i)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}}function fm(t,e,n){const i=JSON.stringify(t.request);return t.data&&(this.deduped.entries[i]={result:[null,t.data]}),this.deduped.request(i,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const i=dt(t.request,((t,i,r,o)=>{t?e(t):i&&e(null,{vectorTile:n?void 0:new Hu(new md(i)),rawData:i,cacheControl:r,expires:o})}));return()=>{i.cancel(),e()}}),e)}const mm=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class gm{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,n]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const i=n>>4;if(1!==i)throw new Error(`Got v${i} data when expected v1.`);const r=mm[15&n];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new gm(s,o,r,t)}constructor(t,e=64,n=Float64Array,i){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=n,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const r=mm.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${n}.`);i&&i instanceof ArrayBuffer?(this.data=i,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+r]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=t,this.coords[this._pos++]=e,n}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return _m(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,n,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=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<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=t&&a<=n&&c>=e&&c<=i&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=t&&p<=n&&f>=e&&f<=i&&l.push(r[d]),(0===c?t<=p:e<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?n>=p:i>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(t,e,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:r,nodeSize:o}=this,s=[0,i.length-1,0],a=[],l=n*n;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let n=h;n<=u;n++)bm(r[2*n],r[2*n+1],t,e)<=l&&a.push(i[n]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];bm(p,f,t,e)<=l&&a.push(i[d]),(0===c?t-n<=p:e-n<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?t+n>=p:e+n>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function _m(t,e,n,i,r,o){if(r-i<=n)return;const s=i+r>>1;ym(t,e,s,i,r,o),_m(t,e,n,i,s-1,1-o),_m(t,e,n,s+1,r,1-o)}function ym(t,e,n,i,r,o){for(;r>i;){if(r-i>600){const s=r-i+1,a=n-i+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);ym(t,e,n,Math.max(i,Math.floor(n-a*c/s+u)),Math.min(r,Math.floor(n+(s-a)*c/s+u)),o)}const s=e[2*n+o];let a=i,l=r;for(vm(t,e,i,n),e[2*r+o]>s&&vm(t,e,i,r);a<l;){for(vm(t,e,a,l),a++,l--;e[2*a+o]<s;)a++;for(;e[2*l+o]>s;)l--}e[2*i+o]===s?vm(t,e,i,l):(l++,vm(t,e,l,r)),l<=n&&(i=l+1),n<=l&&(r=l-1)}}function vm(t,e,n,i){xm(t,n,i),xm(e,2*n,2*i),xm(e,2*n+1,2*i+1)}function xm(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function bm(t,e,n,i){const r=t-n,o=e-i;return r*r+o*o}t.ARRAY_TYPE=ua,t.AUTH_ERR_MSG=yt,t.Aabb=rl,t.Actor=class{constructor(t,n,i){this.target=t,this.parent=n,this.mapId=i,this.callbacks={},this.cancelCallbacks={},U(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=q()?t:e,this.scheduler=new vf}send(t,e,n,i,r=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=o,this.callbacks[s]=n);const a=Z(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:t,hasCallback:!!n,targetMapId:i,mustQueue:r,sourceMapId:this.mapId,data:Kr(e,a)},a),{cancel:()=>{n&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:i,sourceMapId:this.mapId})}}}receive(t){const e=t.data,n=e.id;if(n&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){const t=this.cancelCallbacks[n];delete this.cancelCallbacks[n],t&&t.cancel()}else if(e.mustQueue||q()){const t=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add((()=>this.processTask(n,e)),t&&t.metadata||{type:"message"})}else this.processTask(n,e)}processTask(t,e){if("<response>"===e.type){const n=this.callbacks[t];delete this.callbacks[t],n&&(e.error?n(Qr(e.error)):n(null,Qr(e.data)))}else{const n=Z(this.globalScope)?void 0:[],i=e.hasCallback?(e,i)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?Kr(e):null,data:Kr(i,n)},n)}:t=>{},r=Qr(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,i);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source)[t[1]](r,i)}else i(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.CanonicalTileID=hh,t.Color=Le,t.ColorMode=Zf,t.CullFaceMode=Qf,t.DEMData=Hf,t.DataConstantProperty=Lo,t.DedupedRequest=pm,t.DepthMode=qf,t.EXTENT=aa,t.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return!1;const n=e.getSource().maxzoom,i=1<<n,r=Math.floor(t.x),o=Math.floor((t.x-r)*i),s=Math.floor(t.y*i),a=this.findDEMTileFor(new ph(n,r,n,o,s));return!(!a||!a.dem)}getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,n=!0){if(this.isUsingMockSource())return null;null==e&&(e=null);const i=this._source();if(!i)return e;if(t.y<0||t.y>1)return e;const r=i.getSource().maxzoom,o=1<<r,s=Math.floor(t.x),a=t.x-s,l=new ph(r,s,r,Math.floor(a*o),Math.floor(t.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return e;const u=c.dem,h=1<<c.tileID.canonical.z,d=(a*h-c.tileID.canonical.x)*u.dim,p=(t.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(d),m=Math.floor(p);return(n?this.exaggeration():1)*Rn(Rn(u.get(f,m),u.get(f,m+1),p-m),Rn(u.get(f+1,m),u.get(f+1,m+1),p-m),d-f)}getAtTileOffset(t,e,n){const i=1<<t.canonical.z;return this.getAtPointOrZero(new Kl(t.wrap+(t.canonical.x+e/aa)/i,(t.canonical.y+n/aa)/i))}getAtTileOffsetFunc(t,e,n,i){return r=>{const o=this.getAtTileOffset(t,r.x,r.y),s=i.upVector(t.canonical,r.x,r.y);return Ra(s,s,o*i.upVectorScale(t.canonical,e,n).metersToTile),s}}getForTilePoints(t,e,n,i){if(this.isUsingMockSource())return!1;const r=rm.create(this,t,i);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],n)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const n=e.dem.tree,i=e.tileID,r=1<<t.canonical.z-i.canonical.z;let o=t.canonical.x/r-i.canonical.x,s=t.canonical.y/r-i.canonical.y,a=0;for(let e=0;e<t.canonical.z-i.canonical.z&&!n.leaves[a];e++){o*=2,s*=2;const t=2*Math.floor(s)+Math.floor(o);a=n.childOffsets[a]+t,o%=1,s%=1}return{min:this.exaggeration()*n.minimums[a],max:this.exaggeration()*n.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,n){throw new Error("Pure virtual method called.")}pointCoordinate(t){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(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},t.ErrorEvent=Kt,t.EvaluationParameters=To,t.Event=Jt,t.Evented=Qt,t.FillExtrusionBucket=Qu,t.Frustum=il,t.FrustumCorners=nl,t.GLOBE_RADIUS=al,t.GLOBE_SCALE_MATCH_LATITUDE=45,t.GLOBE_ZOOM_THRESHOLD_MAX=sl,t.GLOBE_ZOOM_THRESHOLD_MIN=ol,t.GlobeSharedBuffers=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const t of this._wireframeSegments)t.destroy()}}_fillGridMeshWithLods(t,e){const n=new Go,i=new is,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,n)=>{let i=t===o-1?t-2:0===t?t:t-1;return i+=n?24575:0,[i,e]};for(let t=0;t<o;++t)n.emplaceBack(...l(t,0,!0));for(let t=0;t<s;++t)for(let e=0;e<o;++e)n.emplaceBack(...l(e,t,(0===e||e===o-1)&&!0));for(let t=0;t<e.length;++t){const i=e[t];for(let t=0;t<o;++t)n.emplaceBack(...l(t,i,!0))}for(let t=0;t<e.length;++t){const s=i.length,l=e[t]+1+2,c=new is;for(let n=0;n<l-1;n++){const r=n===l-2,s=r?o*(a-e.length+t-n):o;for(let t=0;t<o-1;t++){const e=n*o+t;0===n||r||0===t||t===o-2?(c.emplaceBack(e+1,e,e+s),c.emplaceBack(e+s,e+s+1,e+1)):(i.emplaceBack(e+1,e,e+s),i.emplaceBack(e+s,e+s+1,e+1))}}const u=sa.simpleSegment(0,s,n.length,i.length-s);for(let t=0;t<c.uint16.length;t+=3)i.emplaceBack(c.uint16[t],c.uint16[t+1],c.uint16[t+2]);const h=sa.simpleSegment(0,s,n.length,i.length-s);r.push({withoutSkirts:u,withSkirts:h})}return{vertices:n,indices:i,segments:r}}_createGrid(t){const e=this._fillGridMeshWithLods(cl,ul);this._gridSegments=e.segments,this._gridBuffer=t.createVertexBuffer(e.vertices,tl.members),this._gridIndexBuffer=t.createIndexBuffer(e.indices,!0)}_createPoles(t){const e=new is;for(let t=0;t<=cl;t++)e.emplaceBack(0,t+1,t+2);this._poleIndexBuffer=t.createIndexBuffer(e,!0);const n=new as,i=new as;this._poleSegments=[];for(let t=0,e=0;t<ol;t++){const r=360/(1<<t);n.emplaceBack(0,-al,0,.5,0),i.emplaceBack(0,-al,0,.5,1);for(let t=0;t<=cl;t++){const e=t/cl,o=Rn(0,r,e),[s,a,l]=wl(Fl,Ul,o,al);n.emplaceBack(s,a,l,e,0),i.emplaceBack(s,a,l,e,1)}this._poleSegments.push(sa.simpleSegment(e,0,66,64)),e+=66}this._poleNorthVertexBuffer=t.createVertexBuffer(n,Ka,!1),this._poleSouthVertexBuffer=t.createVertexBuffer(i,Ka,!1)}getGridBuffers(t,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[t].withSkirts:this._gridSegments[t].withoutSkirts]}getPoleBuffers(t){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[t]]}getWirefameBuffers(t,e){if(!this._wireframeSegments){const e=new cs,n=cl,i=n+1+2,r=1;this._wireframeSegments=[];for(let t=0,o=0;t<ul.length;t++){const s=ul[t];for(let t=r;t<s+r;t++)for(let o=r;o<n+r;o++){const n=t*i+o;e.emplaceBack(n,n+1),e.emplaceBack(n,n+i),e.emplaceBack(n,n+i+1)}const a=s*n*3;this._wireframeSegments.push(sa.simpleSegment(0,o,(s+1)*i,a)),o+=a}this._wireframeIndexBuffer=t.createIndexBuffer(e)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[e]]}},t.GlyphManager=ep,t.ImagePosition=Ed,t.KDBush=gm,t.LivePerformanceUtils=zt,t.LngLat=Vl,t.LngLatBounds=la,t.LocalGlyphMode=tp,t.MAX_MERCATOR_LATITUDE=Zl,t.MercatorCoordinate=Kl,t.ONE_EM=Fh,t.OverscaledTileID=ph,t.PerformanceMarkers=kt,t.Point=y,t.Properties=Do,t.RGBAImage=kc,t.Ray=el,t.RequestManager=class{constructor(t,e,n){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",h,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!vt(t))return t;const n=wt(t);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!vt(t))return t;const n=wt(t);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||e)}normalizeSourceURL(t,e,n,i){if(!vt(t))return t;const r=wt(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),n&&r.params.push(`language=${n}`),i&&r.params.push(`worldview=${i}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,n,i){const r=wt(t);return vt(t)?(r.path=`/styles/v1${r.path}/sprite${e}${n}`,this._makeAPIURL(r,this._customAccessToken||i)):(r.path+=`${e}${n}`,At(r))}normalizeTileURL(t,e,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!vt(t))return t;const i=wt(t);i.path=i.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||n&&"raster"!==i.authority&&512===n?"@2x":""}${o.supported?".webp":"$1"}`),"raster"===i.authority?i.path=`/${r.RASTER_URL_PREFIX}${i.path}`:(i.path=i.path.replace(/^.+\/v4\//,"/"),i.path=`/${r.TILE_URL_VERSION}${i.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(i.params)||r.ACCESS_TOKEN;return r.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&i.params.push(`sku=${this._skuToken}`),this._makeAPIURL(i,s)}canonicalizeTileURL(t,e){const n=wt(t);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return t;let i="mapbox://";n.path.match(/^\/raster\/v1\//)?i+=`raster/${n.path.replace(`/${r.RASTER_URL_PREFIX}/`,"")}`:i+=`tiles/${n.path.replace(`/${r.TILE_URL_VERSION}/`,"")}`;let o=n.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(i+=`?${o.join("&")}`),i}canonicalizeTileset(t,e){const n=!!e&&vt(e),i=[];for(const e of t.tiles||[])xt(e)?i.push(this.canonicalizeTileURL(e,n)):i.push(e);return i}_makeAPIURL(t,e){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",i=wt(r.API_URL);if(t.protocol=i.protocol,t.authority=i.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==i.path&&(t.path=`${i.path}${t.path}`),!r.REQUIRE_ACCESS_TOKEN)return At(t);if(e=e||r.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===e[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((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),At(t)}},t.ResourceType=lt,t.SegmentVector=sa,t.SourceCache=tm,t.StencilMode=Yf,t.StructArrayLayout1ui2=us,t.StructArrayLayout2f1f2i16=ts,t.StructArrayLayout2i4=Go,t.StructArrayLayout2ui4=cs,t.StructArrayLayout3f12=ns,t.StructArrayLayout3ui6=is,t.StructArrayLayout4i8=jo,t.StructArrayLayout5f20=as,t.Texture=_f,t.Tile=Rf,t.Transitionable=wo,t.Uniform1f=Fs,t.Uniform1i=class extends Ns{constructor(t){super(t),this.current=0}set(t,e,n){this.fetchUniformLocation(t,e)&&this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}},t.Uniform2f=class extends Ns{constructor(t){super(t),this.current=[0,0]}set(t,e,n){this.fetchUniformLocation(t,e)&&(n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1])))}},t.Uniform3f=class extends Ns{constructor(t){super(t),this.current=[0,0,0]}set(t,e,n){this.fetchUniformLocation(t,e)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2])))}},t.Uniform4f=Us,t.UniformColor=ks,t.UniformMatrix2f=class extends Ns{constructor(t){super(t),this.current=Vs}set(t,e,n){if(this.fetchUniformLocation(t,e))for(let t=0;t<4;t++)if(n[t]!==this.current[t]){this.current=n,this.gl.uniformMatrix2fv(this.location,!1,n);break}}},t.UniformMatrix3f=class extends Ns{constructor(t){super(t),this.current=Gs}set(t,e,n){if(this.fetchUniformLocation(t,e))for(let t=0;t<9;t++)if(n[t]!==this.current[t]){this.current=n,this.gl.uniformMatrix3fv(this.location,!1,n);break}}},t.UniformMatrix4f=class extends Ns{constructor(t){super(t),this.current=zs}set(t,e,n){if(this.fetchUniformLocation(t,e)){if(n[12]!==this.current[12]||n[0]!==this.current[0])return this.current=n,void this.gl.uniformMatrix4fv(this.location,!1,n);for(let t=1;t<16;t++)if(n[t]!==this.current[t]){this.current=n,this.gl.uniformMatrix4fv(this.location,!1,n);break}}}},t.UnwrappedTileID=dh,t.ValidationError=nr,t.VectorTileFeature=Wu,t.VectorTileWorkerSource=class extends Qt{constructor(t,e,n,i,r){super(),this.actor=t,this.layerIndex=e,this.availableImages=n,this.loadVectorData=r||fm,this.loading={},this.loaded={},this.deduped=new pm(t.scheduler),this.isSpriteLoaded=i,this.scheduler=t.scheduler}loadTile(t,e){const n=t.uid,i=t&&t.request,r=i&&i.collectResourceTiming,o=this.loading[n]=new hm(t);o.abort=this.loadVectorData(t,((s,a)=>{const l=!this.loading[n];if(delete this.loading[n],l||s||!a)return o.status="done",l||(this.loaded[n]=o),e(s);const c=a.rawData,u={};a.expires&&(u.expires=a.expires),a.cacheControl&&(u.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new Hu(new md(c));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,n)=>{if(t||!n)return e(t);const o={};if(r){const t=jt(i);t.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,R({rawTileData:c.slice(0)},n,u,o))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[n]=o}))}reloadTile(t,e){const n=this.loaded,i=t.uid,r=this;if(n&&n[i]){const o=n[i];o.showCollisionBoxes=t.showCollisionBoxes,o.enableTerrain=!!t.enableTerrain,o.projection=t.projection,o.tileTransform=Ip(t.tileID.canonical,t.projection);const s=(t,n)=>{const i=o.reloadCallback;i&&(delete o.reloadCallback,o.parse(o.vectorTile,r.layerIndex,this.availableImages,r.actor,i)),e(t,n)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(t,e){const n=t.uid,i=this.loading[n];i&&(i.abort&&i.abort(),delete this.loading[n]),e()}removeTile(t,e){const n=this.loaded,i=t.uid;n&&n[i]&&delete n[i],e()}},t.WritingMode=wd,t.ZoomDependentExpression=Ki,t.add=Ma,t.addDynamicAttributes=ef,t.adjoint=function(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t[0]=s*u-a*c,t[1]=r*c-i*u,t[2]=i*a-r*s,t[3]=a*l-o*u,t[4]=n*u-r*l,t[5]=r*o-n*a,t[6]=o*c-s*l,t[7]=i*l-n*c,t[8]=n*s-i*o,t},t.asyncAll=P,t.bezier=w,t.bindAll=U,t.boundsAttributes=Pf,t.bufferConvexPolygon=function(t,e){const n=[];for(let i=0;i<t.length;i++){const r=I(i-1,-1,t.length-1),o=I(i+1,-1,t.length-1),s=t[i],a=t[o],l=t[r].sub(s).unit(),c=a.sub(s).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*e/Math.sin(u/2));n.push(s.add(h))}return n},t.cacheEntryPossiblyAdded=function(t){at++,at>it&&(t.getActor().send("enforceCacheSizeLimit",nt),at=0)},t.calculateGlobeLabelMatrix=function(t,e){const{x:n,y:i}=t.point,r=Rl(n,i,t.worldSize/t._pixelsPerMercatorPixel,0,0);return ma(r,r,Ll(yl(e)))},t.calculateGlobeMatrix=function(t){const{x:e,y:n}=t.point,{lng:i,lat:r}=t._center;return Rl(e,n,t.worldSize,i,r)},t.calculateGlobeMercatorMatrix=function(t){const e=t.pixelsPerMeter,n=e/Wl(1,t.center.lat),i=pa(new Float64Array(16));return ga(i,i,[t.point.x,t.point.y,0]),_a(i,i,[n,n,e]),Float32Array.from(i)},t.circumferenceAtLatitude=jl,t.clamp=M,t.clearTileCache=function(t){if(!rt())return;const n=e.caches.delete(Q);t&&n.catch(t).then((()=>t()))},t.clipLine=Yd,t.clone=function(t){var e=new ua(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=V,t.collisionCircleLayout=Nh,t.config=r,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.create=function(){var t=new ua(16);return ua!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=ha,t.createExpression=Zi,t.createLayout=ko,t.createStyleLayer=function(t){return"custom"===t.type?new pf(t):new gf[t.type](t)},t.cross=Na,t.degToRad=b,t.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},t.div=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t},t.dot=Ba,t.earthRadius=kl,t.ease=A,t.easeCubicInOut=S,t.ecefToLatLng=function([t,e,n]){const i=Math.hypot(t,e,n),r=Math.atan2(t,n),o=.5*Math.PI-Math.acos(-e/i);return new Vl(T(r),T(o))},t.emitValidationErrors=jr,t.endsWith=k,t.enforceCacheSizeLimit=function(t){ot(),tt&&tt.then((e=>{e.keys().then((n=>{for(let i=0;i<n.length-t;i++)e.delete(n[i])}))}))},t.evaluateSizeForFeature=zh,t.evaluateSizeForZoom=Gh,t.evaluateVariableOffset=_p,t.evented=yo,t.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},t.exactEquals$1=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},t.exported=Xt,t.exported$1=o,t.extend=R,t.extend$1=ee,t.fillExtrusionHeightLift=sh,t.filterObject=G,t.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},t.fromQuat=function(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n+n,a=i+i,l=r+r,c=n*s,u=i*s,h=i*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;return t[0]=1-h-f,t[1]=u+_,t[2]=d-g,t[3]=0,t[4]=u-_,t[5]=1-c-f,t[6]=p+m,t[7]=0,t[8]=d+g,t[9]=p-m,t[10]=1-c-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.fromRotation=function(t,e){var n=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=n,t[2]=0,t[3]=-n,t[4]=i,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.fromScaling=xa,t.furthestTileCorner=function(t){const e=Math.round((t+45+360)%360/90)%4;return E[e]},t.getAABBPointSquareDist=function(t,e,n){let i=0;for(let r=0;r<2;++r){const o=n?n[r]:0;t[r]>o&&(i+=(t[r]-o)*(t[r]-o)),e[r]<o&&(i+=(o-e[r])*(o-e[r]))}return i},t.getAnchorAlignment=Fd,t.getAnchorJustification=vp,t.getBounds=function(t){let e=1/0,n=1/0,i=-1/0,r=-1/0;for(const o of t)e=Math.min(e,o.x),n=Math.min(n,o.y),i=Math.max(i,o.x),r=Math.max(r,o.y);return{min:new y(e,n),max:new y(i,r)}},t.getColumn=K,t.getDefaultExportFromCjs=d,t.getGridMatrix=function(t,e,n,i){const r=e.getNorth(),o=e.getSouth(),s=e.getWest(),a=e.getEast(),l=1<<t.z,c=a-s,u=r-o,h=c/cl,d=-u/ul[n],p=[0,h,0,d,0,0,r,s,0];if(t.z>0){const t=180/i;da(p,p,[t/c+1,0,0,0,t/u+1,0,-.5*t/h,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.getImage=_t,t.getJSON=function(t,e){return ht(R(t,{type:"json"}),e)},t.getLatitudinalLod=function(t){const e=Zl-5;t=M(t,-e,e)/e*90;const n=Math.pow(Math.abs(Math.sin(b(t))),3);return Math.round(n*(ul.length-1))},t.getMapSessionAPI=Ft,t.getPerformanceMeasurement=jt,t.getProjection=Zp,t.getRTLTextPluginStatus=vo,t.getReferrer=ut,t.getTilePoint=function(t,{x:e,y:n},i=0){return new y(((e-i)*t.scale-t.x)*aa,(n*t.scale-t.y)*aa)},t.getTileVec3=function(t,e,n=0){return Aa(((e.x-n)*t.scale-t.x)*aa,(e.y*t.scale-t.y)*aa,Yl(e.z,e.y))},t.getVideo=function(t,n){const i=e.document.createElement("video");i.muted=!0,i.onloadstart=function(){n(null,i)};for(let n=0;n<t.length;n++){const r=e.document.createElement("source");pt(t[n])||(i.crossOrigin="Anonymous"),r.src=t[n],i.appendChild(r)}return{cancel:()=>{}}},t.globeCenterToScreenPoint=function(t){const e=[0,0,0],n=pa(new Float64Array(16));return ma(n,t.pixelMatrix,t.globeMatrix),Fa(e,e,n),new y(e[0],e[1])},t.globeDenormalizeECEF=Ll,t.globeECEFOrigin=function(t,e){const n=[0,0,0];return Fa(n,n,Pl(yl(e.canonical))),Fa(n,n,t),n},t.globeMetersToEcef=fl,t.globeNormalizeECEF=Pl,t.globePixelsToTileUnits=function(t,e){return aa/(512*Math.pow(2,t))*Cl(yl(e))},t.globePoleMatrixForTile=function(t,e,n){const i=pa(new Float64Array(16)),r=(e/(1<<t)-.5)*Math.PI*2;return va(i,n.globeMatrix,r),Float32Array.from(i)},t.globeTileBounds=yl,t.globeTiltAtLngLat=Dl,t.globeToMercatorTransition=Ol,t.globeUseCustomAntiAliasing=function(t,e,n){const i=Ol(n.zoom),r=t.style.map._antialias,o=!!e.extStandardDerivatives,s=e.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===i&&!r&&!s&&o},t.identity=pa,t.identity$1=qa,t.invert=fa,t.isFullscreen=function(){return!!e.document.fullscreenElement||!!e.document.webkitFullscreenElement},t.isLngLatBehindGlobe=Bl,t.isMapAuthenticated=function(t){return Ut.has(t)},t.isMapboxURL=vt,t.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!Z(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.latFromMercatorY=Xl,t.latLngToECEF=Al,t.len=Va,t.length=wa,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.lngFromMercatorX=ql,t.loadVectorTile=fm,t.makeRequest=ht,t.mapValue=function(t,e,n,i,r){return M((t-e)/(n-e)*(r-i)+i,i,r)},t.mercatorScale=Jl,t.mercatorXfromLng=$l,t.mercatorYfromLat=Hl,t.mercatorZfromAltitude=Wl,t.mul=Ta,t.mul$1=Ga,t.multiply=ma,t.multiply$1=da,t.multiply$2=Ia,t.nextPowerOfTwo=N,t.normalize=Da,t.normalize$1=Za,t.normalize$2=$a,t.number=Rn,t.ortho=function(t,e,n,i,r,o,s){var a=1/(e-n),l=1/(i-r),c=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*a,t[13]=(r+i)*l,t[14]=(s+o)*c,t[15]=1,t},t.pbf=qh,t.perspective=function(t,e,n,i,r){var o,s=1/Math.tan(e/2);return t[0]=s/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=r&&r!==1/0?(t[10]=(r+i)*(o=1/(i-r)),t[14]=2*r*i*o):(t[10]=-1,t[14]=-2*i),t},t.pick=function(t,e){const n={};for(let i=0;i<e.length;i++){const r=e[i];r in t&&(n[r]=t[r])}return n},t.plugin=bo,t.pointGeometry=g,t.polesInViewport=function(t){const e=pa(new Float64Array(16));ma(e,t.pixelMatrix,t.globeMatrix);const n=[0,hl,0],i=[0,dl,0];return Fa(n,n,e),Fa(i,i,e),[n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!Bl(t,new Vl(t.center.lat,90)),i[0]>0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!Bl(t,new Vl(t.center.lat,-90))]},t.polygonContainsPoint=xc,t.polygonIntersectsBox=bc,t.polygonIntersectsPolygon=hc,t.polygonizeBounds=function(t,e,n=0,i=!0){const r=new y(n,n),o=t.sub(r),s=e.add(r),a=[o,new y(s.x,o.y),s,new y(o.x,s.y)];return i&&a.push(o.clone()),a},t.posAttributes=tl,t.postMapLoadEvent=Ot,t.postPerformanceEvent=Bt,t.postTurnstileEvent=Lt,t.potpack=bd,t.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},t.radToDeg=T,t.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.registerForPluginStateChange=function(t){return t({pluginStatus:fo,pluginURL:mo}),yo.on("pluginStateChange",t),t},t.removeAuthState=function(t){Ut.delete(t)},t.renderColorRamp=Gc,t.resample=tc,t.rotateX=ya,t.rotateX$1=Xa,t.rotateY=va,t.rotateY$1=Ya,t.rotateZ=function(t,e,n){var i=Math.sin(n),r=Math.cos(n),o=e[0],s=e[1],a=e[2],l=e[3],c=e[4],u=e[5],h=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r+c*i,t[1]=s*r+u*i,t[2]=a*r+h*i,t[3]=l*r+d*i,t[4]=c*r-o*i,t[5]=u*r-s*i,t[6]=h*r-a*i,t[7]=d*r-l*i,t},t.rotateZ$1=function(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),l=Math.cos(n);return t[0]=i*l+r*a,t[1]=r*l-i*a,t[2]=o*l+s*a,t[3]=s*l-o*a,t},t.scale=_a,t.scale$1=ja,t.scale$2=Ra,t.scaleAndAdd=Oa,t.set=function(t,e,n,i){return t[0]=e,t[1]=n,t[2]=i,t},t.setCacheLimits=function(t,e){nt=t,it=e},t.setColumn=function(t,e,n){t[4*e+0]=n[0],t[4*e+1]=n[1],t[4*e+2]=n[2],t[4*e+3]=n[3]},t.setRTLTextPlugin=function(t,e,n=!1){if(fo===co||fo===uo||fo===ho)throw new Error("setRTLTextPlugin cannot be called multiple times.");mo=Xt.resolveURL(t),fo=co,po=e,_o(),n||xo()},t.smoothstep=C,t.spec=te,t.squaredLength=function(t){var e=t[0],n=t[1],i=t[2];return e*e+n*n+i*i},t.storeAuthState=function(t,e){e?Ut.add(t):Ut.delete(t)},t.sub=za,t.subtract=Ca,t.symbolSize=Vh,t.tileAABB=function(t,e,n,i,r,o,s,a,l){if("globe"===l.name)return Tl(t,e,new hh(n,i,r));const c=Ip({z:n,x:i,y:r},l);return new rl([(o+c.x/c.scale)*e,e*(c.y/c.scale),s],[(o+c.x2/c.scale)*e,e*(c.y2/c.scale),a])},t.tileCornersToBounds=El,t.tileTransform=Ip,t.transformMat3=function(t,e,n){var i=e[0],r=e[1],o=e[2];return t[0]=i*n[0]+r*n[3]+o*n[6],t[1]=i*n[1]+r*n[4]+o*n[7],t[2]=i*n[2]+r*n[5]+o*n[8],t},t.transformMat4=Fa,t.transformMat4$1=Ha,t.transformQuat=Ua,t.transitionTileAABBinECEF=xl,t.translate=ga,t.transpose=function(t,e){if(t===e){var n=e[1],i=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=n,t[5]=e[7],t[6]=i,t[7]=r}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},t.triggerPluginCompletionEvent=go,t.uniqueId=D,t.updateGlobeVertexNormal=function(t,e,n,i,r){const o=5*e+2;t.float32[o+0]=n,t.float32[o+1]=i,t.float32[o+2]=r},t.validateCustomStyleLayer=function(t){const e=[],n=t.id;return void 0===n&&e.push({message:`layers.${n}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${n}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${n}: property "renderingMode" must be either "2d" or "3d"`}),e},t.validateFilter=t=>Vr(Er(t)),t.validateFog=t=>Vr(Br(t)),t.validateLayer=t=>Vr(Cr(t)),t.validateLight=t=>Vr(Or(t)),t.validateSource=t=>Vr(Lr(t)),t.validateStyle=kr,t.validateTerrain=t=>Vr(Dr(t)),t.values=L,t.vectorTile=Ou,t.version=n,t.warnOnce=$,t.window=e,t.wrap=I})),i(["./shared"],(function(t){function e(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let n="[";for(const i of t)n+=`${e(i)},`;return`${n}]`}let n="{";for(const i of Object.keys(t).sort())n+=`${i}:${e(t[i])},`;return`${n}}`}function n(n){let i="";for(const r of t.refProperties)i+=`/${e(n[r])}`;return i}class i{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,i){for(const n of e)this._layerConfigs[n.id]=n,(this._layers[n.id]=t.createStyleLayer(n)).compileFilter(),this.keyCache[n.id]&&delete this.keyCache[n.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const r=function(t,e){const i={};for(let r=0;r<t.length;r++){const o=e&&e[t[r].id]||n(t[r]);e&&(e[t[r].id]=o);let s=i[o];s||(s=i[o]=[]),s.push(t[r])}const r=[];for(const t in i)r.push(i[t]);return r}(t.values(this._layerConfigs),this.keyCache);for(const t of r){const e=t.map((t=>this._layers[t.id])),n=e[0];if("none"===n.visibility)continue;const i=n.source||"";let r=this.familiesBySource[i];r||(r=this.familiesBySource[i]={});const o=n.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}class r{loadTile(e,n){const{uid:i,encoding:r,rawImageData:o,padding:s,buildQuadTree:a}=e,l=t.window.ImageBitmap&&o instanceof t.window.ImageBitmap?this.getImageData(o,s):o;n(null,new t.DEMData(i,l,r,s<1,a))}getImageData(t,e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(t.width,t.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=t.width,this.offscreenCanvas.height=t.height,this.offscreenCanvasContext.drawImage(t,0,0,t.width,t.height);const n=this.offscreenCanvasContext.getImageData(-e,-e,t.width+2*e,t.height+2*e);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),n}}function o(t,e){if(0!==t.length){s(t[0],e);for(var n=1;n<t.length;n++)s(t[n],!e)}}function s(t,e){for(var n=0,i=0,r=0,o=t.length,s=o-1;r<o;s=r++){var a=(t[r][0]-t[s][0])*(t[s][1]+t[r][1]),l=n+a;i+=Math.abs(n)>=Math.abs(a)?n-l+a:a-l+n,n=l}n+i>=0!=!!e&&t.reverse()}var a=t.getDefaultExportFromCjs((function t(e,n){var i,r=e&&e.type;if("FeatureCollection"===r)for(i=0;i<e.features.length;i++)t(e.features[i],n);else if("GeometryCollection"===r)for(i=0;i<e.geometries.length;i++)t(e.geometries[i],n);else if("Feature"===r)t(e.geometry,n);else if("Polygon"===r)o(e.coordinates,n);else if("MultiPolygon"===r)for(i=0;i<e.coordinates.length;i++)o(e.coordinates[i],n);return e}));const l=t.VectorTileFeature.prototype.toGeoJSON;var c={exports:{}},u=t.pointGeometry,h=t.vectorTile.VectorTileFeature,d=p;function p(t,e){this.options=e||{},this.features=t,this.length=t.length}function f(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}p.prototype.feature=function(t){return new f(this.features[t],this.options.extent)},f.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var e=0;e<t.length;e++){for(var n=t[e],i=[],r=0;r<n.length;r++)i.push(new u(n[r][0],n[r][1]));this.geometry.push(i)}return this.geometry},f.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var t=this.geometry,e=1/0,n=-1/0,i=1/0,r=-1/0,o=0;o<t.length;o++)for(var s=t[o],a=0;a<s.length;a++){var l=s[a];e=Math.min(e,l.x),n=Math.max(n,l.x),i=Math.min(i,l.y),r=Math.max(r,l.y)}return[e,i,n,r]},f.prototype.toGeoJSON=h.prototype.toGeoJSON;var m=t.pbf,g=d;function _(t){var e=new m;return function(t,e){for(var n in t.layers)e.writeMessage(3,y,t.layers[n])}(t,e),e.finish()}function y(t,e){var n;e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);var i={keys:[],values:[],keycache:{},valuecache:{}};for(n=0;n<t.length;n++)i.feature=t.feature(n),e.writeMessage(2,v,i);var r=i.keys;for(n=0;n<r.length;n++)e.writeStringField(3,r[n]);var o=i.values;for(n=0;n<o.length;n++)e.writeMessage(4,S,o[n])}function v(t,e){var n=t.feature;void 0!==n.id&&e.writeVarintField(1,n.id),e.writeMessage(2,x,t),e.writeVarintField(3,n.type),e.writeMessage(4,E,n)}function x(t,e){var n=t.feature,i=t.keys,r=t.values,o=t.keycache,s=t.valuecache;for(var a in n.properties){var l=n.properties[a],c=o[a];if(null!==l){void 0===c&&(i.push(a),o[a]=c=i.length-1),e.writeVarint(c);var u=typeof l;"string"!==u&&"boolean"!==u&&"number"!==u&&(l=JSON.stringify(l));var h=u+":"+l,d=s[h];void 0===d&&(r.push(l),s[h]=d=r.length-1),e.writeVarint(d)}}}function b(t,e){return(e<<3)+(7&t)}function T(t){return t<<1^t>>31}function E(t,e){for(var n=t.loadGeometry(),i=t.type,r=0,o=0,s=n.length,a=0;a<s;a++){var l=n[a],c=1;1===i&&(c=l.length),e.writeVarint(b(1,c));for(var u=3===i?l.length-1:l.length,h=0;h<u;h++){1===h&&1!==i&&e.writeVarint(b(2,u-1));var d=l[h].x-r,p=l[h].y-o;e.writeVarint(T(d)),e.writeVarint(T(p)),r+=d,o+=p}3===i&&e.writeVarint(b(7,1))}}function S(t,e){var n=typeof t;"string"===n?e.writeStringField(1,t):"boolean"===n?e.writeBooleanField(7,t):"number"===n&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}c.exports=_,c.exports.fromVectorTileJs=_,c.exports.fromGeojsonVt=function(t,e){e=e||{};var n={};for(var i in t)n[i]=new g(t[i].features,e),n[i].name=i,n[i].version=e.version,n[i].extent=e.extent;return _({layers:n})},c.exports.GeoJSONWrapper=g;var w=t.getDefaultExportFromCjs(c.exports);const A={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},M=Math.fround||(C=new Float32Array(1),t=>(C[0]=+t,C[0]));var C;const I=3,P=5,L=6;class R{constructor(t){this.options=Object.assign(Object.create(A),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{minZoom:e,maxZoom:n}=this.options;this.points=t;const i=[];for(let e=0;e<t.length;e++){const n=t[e];if(!n.geometry)continue;const[r,o]=n.geometry.coordinates,s=M(B(r)),a=M(N(o));i.push(s,a,1/0,e,-1,1),this.options.reduce&&i.push(0)}let r=this.trees[n+1]=this._createTree(i);for(let t=n;t>=e;t--)r=this.trees[t]=this._createTree(this._cluster(r,t));return this}getClusters(t,e){let n=((t[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)n=-180,r=180;else if(n>r){const t=this.getClusters([n,i,180,o],e),s=this.getClusters([-180,i,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(B(n),N(o),B(r),N(i)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+P]>1?O(l,e,this.clusterProps):this.points[l[e+I]])}return c}getChildren(t){const e=this._getOriginId(t),n=this._getOriginZoom(t),i="No cluster with the specified id.",r=this.trees[n];if(!r)throw new Error(i);const o=r.data;if(e*this.stride>=o.length)throw new Error(i);const s=this.options.radius/(this.options.extent*Math.pow(2,n-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const n=e*this.stride;o[n+4]===t&&l.push(o[n+P]>1?O(o,n,this.clusterProps):this.points[o[n+I]])}if(0===l.length)throw new Error(i);return l}getLeaves(t,e,n){const i=[];return this._appendLeaves(i,t,e=e||10,n=n||0,0),i}getTile(t,e,n){const i=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(n-a)/r,c=(n+1+a)/r,u={features:[]};return this._addTileFeatures(i.range((e-a)/r,l,(e+1+a)/r,c),i.data,e,n,r,u),0===e&&this._addTileFeatures(i.range(1-a/r,l,1,c),i.data,r,n,r,u),e===r-1&&this._addTileFeatures(i.range(0,l,a/r,c),i.data,-1,n,r,u),u.features.length?u:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const n=this.getChildren(t);if(e++,1!==n.length)break;t=n[0].properties.cluster_id}return e}_appendLeaves(t,e,n,i,r){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?r+o.point_count<=i?r+=o.point_count:r=this._appendLeaves(t,o.cluster_id,n,i,r):r<i?r++:t.push(e),t.length===n)break}return r}_createTree(e){const n=new t.KDBush(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let t=0;t<e.length;t+=this.stride)n.add(e[t],e[t+1]);return n.finish(),n.data=e,n}_addTileFeatures(t,e,n,i,r,o){for(const s of t){const t=s*this.stride,a=e[t+P]>1;let l,c,u;if(a)l=D(e,t,this.clusterProps),c=e[t],u=e[t+1];else{const n=this.points[e[t+I]];l=n.properties;const[i,r]=n.geometry.coordinates;c=B(i),u=N(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-n)),Math.round(this.options.extent*(u*r-i))]],tags:l};let d;d=a||this.options.generateId?e[t+I]:this.points[e[t+I]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:n,extent:i,reduce:r,minPoints:o}=this.options,s=n/(i*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let n=0;n<a.length;n+=c){if(a[n+2]<=e)continue;a[n+2]=e;const i=a[n],u=a[n+1],h=t.within(a[n],a[n+1],s),d=a[n+P];let p=d;for(const t of h){const n=t*c;a[n+2]>e&&(p+=a[n+P])}if(p>d&&p>=o){let t,o=i*d,s=u*d,f=-1;const m=(n/c<<5)+(e+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=e)continue;a[l+2]=e;const u=a[l+P];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(t||(t=this._map(a,n,!0),f=this.clusterProps.length,this.clusterProps.push(t)),r(t,this._map(a,l)))}a[n+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let t=0;t<c;t++)l.push(a[n+t]);if(p>1)for(const t of h){const n=t*c;if(!(a[n+2]<=e)){a[n+2]=e;for(let t=0;t<c;t++)l.push(a[n+t])}}}}return l}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,n){if(t[e+P]>1){const i=this.clusterProps[t[e+L]];return n?Object.assign({},i):i}const i=this.points[t[e+I]].properties,r=this.options.map(i);return n&&r===i?Object.assign({},r):r}}function O(t,e,n){return{type:"Feature",id:t[e+I],properties:D(t,e,n),geometry:{type:"Point",coordinates:[(i=t[e],360*(i-.5)),F(t[e+1])]}};var i}function D(t,e,n){const i=t[e+P],r=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,o=t[e+L],s=-1===o?{}:Object.assign({},n[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+I],point_count:i,point_count_abbreviated:r})}function B(t){return t/360+.5}function N(t){const e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function F(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function U(t,e,n,i){for(var r,o=i,s=n-e>>1,a=n-e,l=t[e],c=t[e+1],u=t[n],h=t[n+1],d=e+3;d<n;d+=3){var p=k(t[d],t[d+1],l,c,u,h);if(p>o)r=d,o=p;else if(p===o){var f=Math.abs(d-s);f<a&&(r=d,a=f)}}o>i&&(r-e>3&&U(t,e,r,i),t[r+2]=o,n-r>3&&U(t,r,n,i))}function k(t,e,n,i,r,o){var s=r-n,a=o-i;if(0!==s||0!==a){var l=((t-n)*s+(e-i)*a)/(s*s+a*a);l>1?(n=r,i=o):l>0&&(n+=s*l,i+=a*l)}return(s=t-n)*s+(a=e-i)*a}function z(t,e,n,i){var r={id:void 0===t?null:t,type:e,geometry:n,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,n=t.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)G(t,e);else if("Polygon"===n||"MultiLineString"===n)for(var i=0;i<e.length;i++)G(t,e[i]);else if("MultiPolygon"===n)for(i=0;i<e.length;i++)for(var r=0;r<e[i].length;r++)G(t,e[i][r])}(r),r}function G(t,e){for(var n=0;n<e.length;n+=3)t.minX=Math.min(t.minX,e[n]),t.minY=Math.min(t.minY,e[n+1]),t.maxX=Math.max(t.maxX,e[n]),t.maxY=Math.max(t.maxY,e[n+1])}function V(t,e,n,i){if(e.geometry){var r=e.geometry.coordinates,o=e.geometry.type,s=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2),a=[],l=e.id;if(n.promoteId?l=e.properties[n.promoteId]:n.generateId&&(l=i||0),"Point"===o)j(r,a);else if("MultiPoint"===o)for(var c=0;c<r.length;c++)j(r[c],a);else if("LineString"===o)$(r,a,s,!1);else if("MultiLineString"===o){if(n.lineMetrics){for(c=0;c<r.length;c++)$(r[c],a=[],s,!1),t.push(z(l,"LineString",a,e.properties));return}H(r,a,s,!1)}else if("Polygon"===o)H(r,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(c=0;c<e.geometry.geometries.length;c++)V(t,{id:l,geometry:e.geometry.geometries[c],properties:e.properties},n,i);return}throw new Error("Input data is not a valid GeoJSON object.")}for(c=0;c<r.length;c++){var u=[];H(r[c],u,s,!0),a.push(u)}}t.push(z(l,o,a,e.properties))}}function j(t,e){e.push(W(t[0])),e.push(q(t[1])),e.push(0)}function $(t,e,n,i){for(var r,o,s=0,a=0;a<t.length;a++){var l=W(t[a][0]),c=q(t[a][1]);e.push(l),e.push(c),e.push(0),a>0&&(s+=i?(r*c-l*o)/2:Math.sqrt(Math.pow(l-r,2)+Math.pow(c-o,2))),r=l,o=c}var u=e.length-3;e[2]=1,U(e,0,u,n),e[u+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function H(t,e,n,i){for(var r=0;r<t.length;r++){var o=[];$(t[r],o,n,i),e.push(o)}}function W(t){return t/360+.5}function q(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function X(t,e,n,i,r,o,s,a){if(i/=e,o>=(n/=e)&&s<i)return t;if(s<n||o>=i)return null;for(var l=[],c=0;c<t.length;c++){var u=t[c],h=u.geometry,d=u.type,p=0===r?u.minX:u.minY,f=0===r?u.maxX:u.maxY;if(p>=n&&f<i)l.push(u);else if(!(f<n||p>=i)){var m=[];if("Point"===d||"MultiPoint"===d)Y(h,m,n,i,r);else if("LineString"===d)Z(h,m,n,i,r,!1,a.lineMetrics);else if("MultiLineString"===d)K(h,m,n,i,r,!1);else if("Polygon"===d)K(h,m,n,i,r,!0);else if("MultiPolygon"===d)for(var g=0;g<h.length;g++){var _=[];K(h[g],_,n,i,r,!0),_.length&&m.push(_)}if(m.length){if(a.lineMetrics&&"LineString"===d){for(g=0;g<m.length;g++)l.push(z(u.id,d,m[g],u.tags));continue}"LineString"!==d&&"MultiLineString"!==d||(1===m.length?(d="LineString",m=m[0]):d="MultiLineString"),"Point"!==d&&"MultiPoint"!==d||(d=3===m.length?"Point":"MultiPoint"),l.push(z(u.id,d,m,u.tags))}}}return l.length?l:null}function Y(t,e,n,i,r){for(var o=0;o<t.length;o+=3){var s=t[o+r];s>=n&&s<=i&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function Z(t,e,n,i,r,o,s){for(var a,l,c=J(t),u=0===r?tt:et,h=t.start,d=0;d<t.length-3;d+=3){var p=t[d],f=t[d+1],m=t[d+2],g=t[d+3],_=t[d+4],y=0===r?p:f,v=0===r?g:_,x=!1;s&&(a=Math.sqrt(Math.pow(p-g,2)+Math.pow(f-_,2))),y<n?v>n&&(l=u(c,p,f,g,_,n),s&&(c.start=h+a*l)):y>i?v<i&&(l=u(c,p,f,g,_,i),s&&(c.start=h+a*l)):Q(c,p,f,m),v<n&&y>=n&&(l=u(c,p,f,g,_,n),x=!0),v>i&&y<=i&&(l=u(c,p,f,g,_,i),x=!0),!o&&x&&(s&&(c.end=h+a*l),e.push(c),c=J(t)),s&&(h+=a)}var b=t.length-3;p=t[b],f=t[b+1],m=t[b+2],(y=0===r?p:f)>=n&&y<=i&&Q(c,p,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&Q(c,c[0],c[1],c[2]),c.length&&e.push(c)}function J(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function K(t,e,n,i,r,o){for(var s=0;s<t.length;s++)Z(t[s],e,n,i,r,o,!1)}function Q(t,e,n,i){t.push(e),t.push(n),t.push(i)}function tt(t,e,n,i,r,o){var s=(o-e)/(i-e);return t.push(o),t.push(n+(r-n)*s),t.push(1),s}function et(t,e,n,i,r,o){var s=(o-n)/(r-n);return t.push(e+(i-e)*s),t.push(o),t.push(1),s}function nt(t,e){for(var n=[],i=0;i<t.length;i++){var r,o=t[i],s=o.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)r=it(o.geometry,e);else if("MultiLineString"===s||"Polygon"===s){r=[];for(var a=0;a<o.geometry.length;a++)r.push(it(o.geometry[a],e))}else if("MultiPolygon"===s)for(r=[],a=0;a<o.geometry.length;a++){for(var l=[],c=0;c<o.geometry[a].length;c++)l.push(it(o.geometry[a][c],e));r.push(l)}n.push(z(o.id,s,r,o.tags))}return n}function it(t,e){var n=[];n.size=t.size,void 0!==t.start&&(n.start=t.start,n.end=t.end);for(var i=0;i<t.length;i+=3)n.push(t[i]+e,t[i+1],t[i+2]);return n}function rt(t,e){if(t.transformed)return t;var n,i,r,o=1<<t.z,s=t.x,a=t.y;for(n=0;n<t.features.length;n++){var l=t.features[n],c=l.geometry,u=l.type;if(l.geometry=[],1===u)for(i=0;i<c.length;i+=2)l.geometry.push(ot(c[i],c[i+1],e,o,s,a));else for(i=0;i<c.length;i++){var h=[];for(r=0;r<c[i].length;r+=2)h.push(ot(c[i][r],c[i][r+1],e,o,s,a));l.geometry.push(h)}}return t.transformed=!0,t}function ot(t,e,n,i,r,o){return[Math.round(n*(t*i-r)),Math.round(n*(e*i-o))]}function st(t,e,n,i,r){for(var o=e===r.maxZoom?0:r.tolerance/((1<<e)*r.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:n,y:i,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<t.length;a++){s.numFeatures++,at(s,t[a],o,r);var l=t[a].minX,c=t[a].minY,u=t[a].maxX,h=t[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),u>s.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function at(t,e,n,i){var r=e.geometry,o=e.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<r.length;a+=3)s.push(r[a]),s.push(r[a+1]),t.numPoints++,t.numSimplified++;else if("LineString"===o)lt(s,r,t,n,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<r.length;a++)lt(s,r[a],t,n,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<r.length;l++){var c=r[l];for(a=0;a<c.length;a++)lt(s,c[a],t,n,!0,0===a)}if(s.length){var u=e.tags||null;if("LineString"===o&&i.lineMetrics){for(var h in u={},e.tags)u[h]=e.tags[h];u.mapbox_clip_start=r.start/r.size,u.mapbox_clip_end=r.end/r.size}var d={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:u};null!==e.id&&(d.id=e.id),t.features.push(d)}}function lt(t,e,n,i,r,o){var s=i*i;if(i>0&&e.size<(r?s:i))n.numPoints+=e.length/3;else{for(var a=[],l=0;l<e.length;l+=3)(0===i||e[l+2]>s)&&(n.numSimplified++,a.push(e[l]),a.push(e[l+1])),n.numPoints++;r&&function(t,e){for(var n=0,i=0,r=t.length,o=r-2;i<r;o=i,i+=2)n+=(t[i]-t[o])*(t[i+1]+t[o+1]);if(n>0===e)for(i=0,r=t.length;i<r/2;i+=2){var s=t[i],a=t[i+1];t[i]=t[r-2-i],t[i+1]=t[r-1-i],t[r-2-i]=s,t[r-1-i]=a}}(a,o),t.push(a)}}function ct(t,e){var n=(e=this.options=function(t,e){for(var n in e)t[n]=e[n];return t}(Object.create(this.options),e)).debug;if(e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var i=function(t,e){var n=[];if("FeatureCollection"===t.type)for(var i=0;i<t.features.length;i++)V(n,t.features[i],e,i);else V(n,"Feature"===t.type?t:{geometry:t},e);return n}(t,e);this.tiles={},this.tileCoords=[],n&&(this.stats={},this.total=0),i=function(t,e){var n=e.buffer/e.extent,i=t,r=X(t,1,-1-n,n,0,-1,2,e),o=X(t,1,1-n,2+n,0,-1,2,e);return(r||o)&&(i=X(t,1,-n,1+n,0,-1,2,e)||[],r&&(i=nt(r,1).concat(i)),o&&(i=i.concat(nt(o,-1)))),i}(i,e),i.length&&this.splitTile(i,0,0,0)}function ut(t,e,n){return 32*((1<<t)*n+e)+t}function ht(e,n){const i=e.tileID.canonical;if(!this._geoJSONIndex)return n(null,null);const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return n(null,null);const o=new class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e}feature(e){return new class{constructor(e){this._feature=e,this.extent=t.EXTENT,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 n of this._feature.geometry)e.push([new t.Point(n[0],n[1])]);return e}{const e=[];for(const n of this._feature.geometry){const i=[];for(const e of n)i.push(new t.Point(e[0],e[1]));e.push(i)}return e}}toGeoJSON(t,e,n){return l.call(this,t,e,n)}}(this._features[e])}}(r.features);let s=w(o);0===s.byteOffset&&s.byteLength===s.buffer.byteLength||(s=new Uint8Array(s)),n(null,{vectorTile:o,rawData:s.buffer})}ct.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},ct.prototype.splitTile=function(t,e,n,i,r,o,s){for(var a=[t,e,n,i],l=this.options,c=l.debug;a.length;){i=a.pop(),n=a.pop(),e=a.pop(),t=a.pop();var u=1<<e,h=ut(e,n,i),d=this.tiles[h];if(!d&&(d=this.tiles[h]=st(t,e,n,i,l),this.tileCoords.push({z:e,x:n,y:i}),c)){var p="z"+e;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(d.source=t,r){if(e===l.maxZoom||e===r)continue;var f=1<<r-e;if(n!==Math.floor(o/f)||i!==Math.floor(s/f))continue}else if(e===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue;if(d.source=null,0!==t.length){var m,g,_,y,v,x,b=.5*l.buffer/l.extent,T=.5-b,E=.5+b,S=1+b;m=g=_=y=null,v=X(t,u,n-b,n+E,0,d.minX,d.maxX,l),x=X(t,u,n+T,n+S,0,d.minX,d.maxX,l),t=null,v&&(m=X(v,u,i-b,i+E,1,d.minY,d.maxY,l),g=X(v,u,i+T,i+S,1,d.minY,d.maxY,l),v=null),x&&(_=X(x,u,i-b,i+E,1,d.minY,d.maxY,l),y=X(x,u,i+T,i+S,1,d.minY,d.maxY,l),x=null),a.push(m||[],e+1,2*n,2*i),a.push(g||[],e+1,2*n,2*i+1),a.push(_||[],e+1,2*n+1,2*i),a.push(y||[],e+1,2*n+1,2*i+1)}}},ct.prototype.getTile=function(t,e,n){var i=this.options,r=i.extent;if(t<0||t>24)return null;var o=1<<t,s=ut(t,e=(e%o+o)%o,n);if(this.tiles[s])return rt(this.tiles[s],r);for(var a,l=t,c=e,u=n;!a&&l>0;)l--,c=Math.floor(c/2),u=Math.floor(u/2),a=this.tiles[ut(l,c,u)];return a&&a.source?(this.splitTile(a.source,l,c,u,t,e,n),this.tiles[s]?rt(this.tiles[s],r):null):null};class dt extends t.VectorTileWorkerSource{constructor(t,e,n,i,r){super(t,e,n,i,ht),r&&(this.loadGeoJSON=r)}loadData(e,n){const i=e&&e.request,r=i&&i.collectResourceTiming;this.loadGeoJSON(e,((o,s)=>{if(o||!s)return n(o);if("object"!=typeof s)return n(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{a(s,!0);try{if(e.filter){const n=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===n.result)throw new Error(n.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const i=s.features.filter((t=>n.value.evaluate({zoom:0},t)));s={type:"FeatureCollection",features:i}}this._geoJSONIndex=e.cluster?new R(function({superclusterOptions:e,clusterProperties:n}){if(!n||!e)return e;const i={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(n);for(const e of a){const[o,s]=n[e],a=t.createExpression(s),l=t.createExpression("string"==typeof o?[o,["accumulated"],["get",e]]:o);i[e]=a.value,r[e]=l.value}return e.map=t=>{s.properties=t;const e={};for(const t of a)e[t]=i[t].evaluate(o,s);return e},e.reduce=(t,e)=>{s.properties=e;for(const e of a)o.accumulated=t[e],t[e]=r[e].evaluate(o,s)},e}(e)).load(s.features):function(t,e){return new ct(t,e)}(s,e.geojsonVtOptions)}catch(o){return n(o)}this.loaded={};const l={};if(r){const n=t.getPerformanceMeasurement(i);n&&(l.resourceTiming={},l.resourceTiming[e.source]=JSON.parse(JSON.stringify(n)))}n(null,l)}}))}reloadTile(t,e){const n=this.loaded;return n&&n[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,n){if(e.request)t.getJSON(e.request,n);else{if("string"!=typeof e.data)return n(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(e.data))}catch(t){return n(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class pt{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=t.getProjection({name:"mercator"}),this.workerSourceTypes={vector:t.VectorTileWorkerSource,geojson:dt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=e=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}clearCaches(t,e,n){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],n()}checkIfReady(t,e,n){n()}setReferrer(t,e){this.referrer=e}spriteLoaded(e,n){this.isSpriteLoaded[e]=n;for(const i in this.workerSources[e]){const r=this.workerSources[e][i];for(const e in r)r[e]instanceof t.VectorTileWorkerSource&&(r[e].isSpriteLoaded=n,r[e].fire(new t.Event("isSpriteLoaded")))}}setImages(t,e,n){this.availableImages[t]=e;for(const n in this.workerSources[t]){const i=this.workerSources[t][n];for(const t in i)i[t].availableImages=e}n()}enableTerrain(t,e,n){this.terrain=e,n()}setProjection(e,n){this.projections[e]=t.getProjection(n)}setLayers(t,e,n){this.getLayerIndex(t).replace(e),n()}updateLayers(t,e,n){this.getLayerIndex(t).update(e.layers,e.removedIds),n()}loadTile(e,n,i){const r=this.enableTerrain?t.extend({enableTerrain:this.terrain},n):n;r.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,n.type,n.source).loadTile(r,i)}loadDEMTile(e,n,i){const r=this.enableTerrain?t.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(e,n.source).loadTile(r,i)}reloadTile(e,n,i){const r=this.enableTerrain?t.extend({enableTerrain:this.terrain},n):n;r.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,n.type,n.source).reloadTile(r,i)}abortTile(t,e,n){this.getWorkerSource(t,e.type,e.source).abortTile(e,n)}removeTile(t,e,n){this.getWorkerSource(t,e.type,e.source).removeTile(e,n)}removeSource(t,e,n){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const i=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==i.removeSource?i.removeSource(e,n):n()}loadWorkerSource(t,e,n){try{this.self.importScripts(e.url),n()}catch(t){n(t.toString())}}syncRTLPluginState(e,n,i){try{t.plugin.setState(n);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const n=t.plugin.isParsed();i(n?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),n)}}catch(t){i(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new i),e}getWorkerSource(t,e,n){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][n]){const i={send:(e,n,i,r,o,s)=>{this.actor.send(e,n,i,t,o,s)},scheduler:this.actor.scheduler};this.workerSources[t][e][n]=new this.workerSourceTypes[e](i,this.getLayerIndex(t),this.getAvailableImages(t),this.isSpriteLoaded[t])}return this.workerSources[t][e][n]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new r),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,n){t.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(t,e,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new pt(self)),pt})),i(["./shared"],(function(t){function e(t,n){if(Array.isArray(t)){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let i=0;i<t.length;i++)if(!e(t[i],n[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==n){if("object"!=typeof n)return!1;if(Object.keys(t).length!==Object.keys(n).length)return!1;for(const i in t)if(!e(t[i],n[i]))return!1;return!0}return t===n}var n=i;function i(t){return!function(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,n=new Blob([""],{type:"text/javascript"}),i=URL.createObjectURL(n);try{e=new Worker(i),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(i),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var n=e.getImageData(0,0,1,1);return n&&n.width===t.width}()?(void 0===r[e=t&&t.failIfMajorPerformanceCaveat]&&(r[e]=function(t){var e,n=function(t){var e=document.createElement("canvas"),n=Object.create(i.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=t,e.getContext("webgl",n)||e.getContext("experimental-webgl",n)}(t);if(!n)return!1;try{e=n.createShader(n.VERTEX_SHADER)}catch(t){return!1}return!(!e||n.isContextLost())&&(n.shaderSource(e,"void main() {}"),n.compileShader(e),!0===n.getShaderParameter(e,n.COMPILE_STATUS))}(e)),r[e]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var e}(t)}var r={};function o(e,n,i){const r=t.window.document.createElement(e);return void 0!==n&&(r.className=n),i&&i.appendChild(r),r}function s(e,n,i){const r=t.window.document.createElementNS("http://www.w3.org/2000/svg",e);for(const t of Object.keys(n))r.setAttributeNS(null,t,n[t]);return i&&i.appendChild(r),r}i.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const a=t.window.document&&t.window.document.documentElement.style,l=a&&void 0!==a.userSelect?"userSelect":"WebkitUserSelect";let c;function u(){a&&l&&(c=a[l],a[l]="none")}function h(){a&&l&&(a[l]=c)}function d(e){e.preventDefault(),e.stopPropagation(),t.window.removeEventListener("click",d,!0)}function p(){t.window.addEventListener("click",d,!0),t.window.setTimeout((()=>{t.window.removeEventListener("click",d,!0)}),0)}function f(t,e){const n=t.getBoundingClientRect();return _(t,n,e)}function m(t,e){const n=t.getBoundingClientRect(),i=[];for(let r=0;r<e.length;r++)i.push(_(t,n,e[r]));return i}function g(e){return void 0!==t.window.InstallTrigger&&2===e.button&&e.ctrlKey&&t.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button}function _(e,n,i){const r=e.offsetWidth===n.width?1:e.offsetWidth/n.width;return new t.Point((i.clientX-n.left)*r,(i.clientY-n.top)*r)}function y(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n*o-r*i;return s?(t[0]=o*(s=1/s),t[1]=-i*s,t[2]=-r*s,t[3]=n*s,t):null}function v(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class x extends t.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}hasImage(t){return!!this.getImage(t)}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(e,n){let i=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(n.content,n)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(t,e){if(!t)return!0;let n=0;for(const i of t){if(i[0]<n||i[1]<i[0]||e<i[1])return!1;n=i[1]}return!0}_validateContent(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,e){e.version=this.images[t].version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,e){let n=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(n=!1);this.isLoaded()||n?this._notify(t,e):this.requestors.push({ids:t,callback:e})}_notify(e,n){const i={};for(const n of e){this.images[n]||this.fire(new t.Event("styleimagemissing",{id:n}));const e=this.images[n];e?i[n]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.warnOnce(`Image "${n}" 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.`)}n(null,i)}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(e){const n=this.patterns[e],i=this.getImage(e);if(!i)return null;if(n&&n.position.version===i.version)return n.position;if(n)n.position.version=i.version;else{const n={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new t.ImagePosition(n,i);this.patterns[e]={bin:n,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.Texture(e,this.atlasImage,n.RGBA),this.atlasTexture&&this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:n,h:i}=t.potpack(e),r=this.atlasImage;r.resize({width:n||1,height:i||1});for(const e in this.patterns){const{bin:n}=this.patterns[e],i=n.x+1,o=n.y+1,s=this.images[e].data,a=s.width,l=s.height;t.RGBAImage.copy(s,r,{x:0,y:0},{x:i,y:o},{width:a,height:l}),t.RGBAImage.copy(s,r,{x:0,y:l-1},{x:i,y:o-1},{width:a,height:1}),t.RGBAImage.copy(s,r,{x:0,y:0},{x:i,y:o+l},{width:a,height:1}),t.RGBAImage.copy(s,r,{x:a-1,y:0},{x:i-1,y:o},{width:1,height:l}),t.RGBAImage.copy(s,r,{x:0,y:0},{x:i+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const e of t){if(this.callbackDispatchedThisFrame[e])continue;this.callbackDispatchedThisFrame[e]=!0;const t=this.images[e];v(t)&&this.updateImage(e,t)}}}const b=new t.Properties({anchor:new t.DataConstantProperty(t.spec.light.anchor),position:new class{constructor(){this.specification=t.spec.light.position}possiblyEvaluate(e,n){return function([e,n,i]){const r=t.degToRad(n+90),o=t.degToRad(i);return{x:e*Math.cos(r)*Math.sin(o),y:e*Math.sin(r)*Math.sin(o),z:e*Math.cos(o),azimuthal:n,polar:i}}(e.expression.evaluate(n))}interpolate(e,n,i){return{x:t.number(e.x,n.x,i),y:t.number(e.y,n.y,i),z:t.number(e.z,n.z,i),azimuthal:t.number(e.azimuthal,n.azimuthal,i),polar:t.number(e.polar,n.polar,i)}}},color:new t.DataConstantProperty(t.spec.light.color),intensity:new t.DataConstantProperty(t.spec.light.intensity)});class T extends t.Evented{constructor(e){super(),this._transitionable=new t.Transitionable(b),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(t.validateLight,e,n))for(const n in e){const i=e[n];t.endsWith(n,"-transition")?this._transitionable.setTransition(n.slice(0,-11),i):this._transitionable.setValue(n,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(e,n,i){return(!i||!1!==i.validate)&&t.emitValidationErrors(this,e.call(t.validateStyle,t.extend({value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}const E=new t.Properties({source:new t.DataConstantProperty(t.spec.terrain.source),exaggeration:new t.DataConstantProperty(t.spec.terrain.exaggeration)});let S=class extends t.Evented{constructor(e,n){super(),this._transitionable=new t.Transitionable(E),this.set(e),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=n}get(){return this._transitionable.serialize()}set(e){for(const n in e){const i=e[n];t.endsWith(n,"-transition")?this._transitionable.setTransition(n.slice(0,-11),i):this._transitionable.setValue(n,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}};function w(e,n,i,r){const o=t.smoothstep(45,65,i),[s,a]=A(e,r),l=t.length(n);let c=1-Math.min(1,Math.exp((l-s)/(a-s)*-6));return c*=c*c,c=Math.min(1,1.00747*c),c*o*e.alpha}function A(t,e){const n=.5/Math.tan(.5*e);return[t.range[0]+n,t.range[1]+n]}const M=new t.Properties({range:new t.DataConstantProperty(t.spec.fog.range),color:new t.DataConstantProperty(t.spec.fog.color),"high-color":new t.DataConstantProperty(t.spec.fog["high-color"]),"space-color":new t.DataConstantProperty(t.spec.fog["space-color"]),"horizon-blend":new t.DataConstantProperty(t.spec.fog["horizon-blend"]),"star-intensity":new t.DataConstantProperty(t.spec.fog["star-intensity"])});class C extends t.Evented{constructor(e,n){super(),this._transitionable=new t.Transitionable(M),this.set(e),this._transitioning=this._transitionable.untransitioned(),this._transform=n}get state(){const e=this._transform,n="globe"===e.projection.name,i=t.globeToMercatorTransition(e.zoom),r=this.properties.get("range"),o=[.5,3];return{range:n?[t.number(o[0],r[0],i),t.number(o[1],r[1],i)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,n={}){if(!this._validate(t.validateFog,e,n)){for(const n of Object.keys(t.spec.fog))e&&void 0===e[n]&&(e[n]=t.spec.fog[n].default);for(const n in e){const i=e[n];t.endsWith(n,"-transition")?this._transitionable.setTransition(n.slice(0,-11),i):this._transitionable.setValue(n,i)}}}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const n=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:t.smoothstep(45,65,e))*n.a}getOpacityAtLatLng(e,n){return this._transform.projection.supportsFog?function(e,n,i){const r=t.MercatorCoordinate.fromLngLat(n),o=i.elevation?i.elevation.getAtPointOrZero(r):0,s=[r.x,r.y,o];return t.transformMat4(s,s,i.mercatorFogMatrix),w(e,s,i.pitch,i._fov)}(this.state,e,n):0}getFovAdjustedRange(t){return this._transform.projection.supportsFog?A(this.state,t):[0,1]}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(e,n,i){return(!i||!1!==i.validate)&&t.emitValidationErrors(this,e.call(t.validateStyle,t.extend({value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}class I{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t.uniqueId();const i=this.workerPool.acquire(this.id);for(let t=0;t<i.length;t++){const e=new I.Actor(i[t],n,this.id);e.name=`Worker ${t}`,this.actors.push(e)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(e,n,i){t.asyncAll(this.actors,((t,i)=>{t.send(e,n,i)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function P(e,n,i){return n*(t.EXTENT/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}I.Actor=t.Actor;class L{constructor(t,e,n,i){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=n,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i)}static createFromScreenPoints(e,n){let i,r;if(e instanceof t.Point||"number"==typeof e[0]){const o=t.Point.convert(e);i=[o],r=n.isPointAboveHorizon(o)}else{const o=t.Point.convert(e[0]),s=t.Point.convert(e[1]);i=[o,s],r=t.polygonizeBounds(o,s).every((t=>n.isPointAboveHorizon(t)))}return new L(i,n.getCameraPoint(),r,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return t.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const n=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new t.Point(1,1)):this.screenBounds[1],r=t.polygonizeBounds(n,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x<i.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?r[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(r[3]=this.cameraPoint)),t.bufferConvexPolygon(r,e)}bufferedCameraGeometryGlobe(e){const n=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new t.Point(1,1)):this.screenBounds[1],r=t.polygonizeBounds(n,i,e),o=this.cameraPoint.clone();switch(3*((o.y>n.y)+(o.y>i.y))+((o.x>n.x)+(o.x>i.x))){case 0:r[0]=o,r[4]=o.clone();break;case 1:r.splice(1,0,o);break;case 2:r[1]=o;break;case 3:r.splice(4,0,o);break;case 5:r.splice(2,0,o);break;case 6:r[3]=o;break;case 7:r.splice(3,0,o);break;case 8:r[2]=o}return r}containsTile(e,n,i,r=0){const o=e.queryPadding/n._pixelsPerMercatorPixel+1,s=i?this._bufferedCameraMercator(o,n):this._bufferedScreenMercator(o,n);let a=e.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map((n=>t.getTilePoint(e.tileTransform,n,a)));if(!t.polygonIntersectsBox(l,0,0,t.EXTENT,t.EXTENT))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((n=>t.getTileVec3(e.tileTransform,n,a))),u=c.map((e=>new t.Point(e[0],e[1]))),h=n.getFreeCameraOptions().position||new t.MercatorCoordinate(0,0,0),d=t.getTileVec3(e.tileTransform,h,a),p=c.map((e=>{const n=t.sub(e,e,d);return t.normalize(n,n),new t.Ray(d,n)})),f=P(e,1,n.zoom)*n._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=t.getBounds(l),m.min.x=t.clamp(m.min.x,0,t.EXTENT),m.min.y=t.clamp(m.min.y,0,t.EXTENT),m.max.x=t.clamp(m.max.x,0,t.EXTENT),m.max.y=t.clamp(m.max.y,0,t.EXTENT),m),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(t,e){const n=D(t);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{let i;return i="globe"===e.projection.name?this._projectAndResample(this.bufferedScreenGeometry(t),e):{polygon:this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._screenRaycastCache[n]=i,i}}_bufferedCameraMercator(t,e){const n=D(t);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{let i;return i="globe"===e.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),e):{polygon:this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._cameraRaycastCache[n]=i,i}}_projectAndResample(e,n){const i=function(e,n){const i=t.multiply([],n.pixelMatrix,n.globeMatrix),r=[0,-t.GLOBE_RADIUS,0,1],o=[0,t.GLOBE_RADIUS,0,1],s=[0,0,0,1];t.transformMat4$1(r,r,i),t.transformMat4$1(o,o,i),t.transformMat4$1(s,s,i);const a=new t.Point(r[0]/r[3],r[1]/r[3]),l=new t.Point(o[0]/o[3],o[1]/o[3]),c=t.polygonContainsPoint(e,a)&&r[3]<s[3],u=t.polygonContainsPoint(e,l)&&o[3]<s[3];if(!c&&!u)return null;const h=function(t,e,n){for(let i=1;i<t.length;i++){const r=O(e.pointCoordinate3D(t[i-1]).x),o=O(e.pointCoordinate3D(t[i]).x);if(n<0){if(r<o)return{idx:i,t:-r/(o-1-r)}}else if(o<r)return{idx:i,t:(1-r)/(o+1-r)}}return null}(e,n,c?-1:1);if(!h)return null;const{idx:d,t:p}=h;let f=d>1?R(e.slice(0,d),n):[],m=d<e.length?R(e.slice(d),n):[];f=f.map((e=>new t.Point(O(e.x),e.y))),m=m.map((e=>new t.Point(O(e.x),e.y)));const g=[...f];0===g.length&&g.push(m[m.length-1]);const _=t.number(g[g.length-1].y,(0===m.length?f[0]:m[0]).y,p);let y;return y=c?[new t.Point(0,_),new t.Point(0,0),new t.Point(1,0),new t.Point(1,_)]:[new t.Point(1,_),new t.Point(1,1),new t.Point(0,1),new t.Point(0,_)],g.push(...y),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:!1}}(e,n);if(i)return i;const r=function(e,n){let i=!1,r=-1/0,o=0;for(let t=0;t<e.length-1;t++)e[t].x>r&&(r=e[t].x,o=t);for(let t=0;t<e.length-1;t++){const n=(o+t)%(e.length-1),r=e[n],s=e[n+1];Math.abs(r.x-s.x)>.5&&(r.x<s.x?(r.x+=1,0===n&&(e[e.length-1].x+=1)):(s.x+=1,n+1===e.length-1&&(e[0].x+=1)),i=!0)}const s=t.mercatorXfromLng(n.center.lng);return i&&s<Math.abs(s-1)&&e.forEach((t=>{t.x-=1})),{polygon:e,unwrapped:i}}(R(e,n).map((e=>new t.Point(O(e.x),e.y))),n);return{polygon:r.polygon.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:r.unwrapped}}}function R(e,n){return t.resample(e,(t=>{const e=n.pointCoordinate3D(t);t.x=e.x,t.y=e.y}),1/256)}function O(t){return t<0?1+t%1:t%1}function D(t){return 100*t|0}function B(e,n,i,r,o){const s=function(i,r){if(i)return o(i);if(r){e.url&&r.tiles&&e.tiles&&delete e.tiles;const i=t.pick(t.extend(r,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(i.vectorLayers=r.vector_layers,i.vectorLayerIds=i.vectorLayers.map((t=>t.id))),i.tiles=n.canonicalizeTileset(i,e.url),o(null,i)}};return e.url?t.getJSON(n.transformRequest(n.normalizeSourceURL(e.url,null,i,r),t.ResourceType.Source),s):t.exported.frame((()=>s(null,e)))}class N{constructor(e,n,i){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(e){const n=Math.pow(2,e.z),i=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*n),r=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*n),o=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*n),s=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*n);return e.x>=i&&e.x<o&&e.y>=r&&e.y<s}}class F{constructor(t,e,n){this.context=t;const i=t.gl;this.buffer=i.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||e.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const U={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class k{constructor(t,e,n,i){this.length=e.length,this.attributes=n,this.itemSize=e.bytesPerElement,this.dynamicDraw=i,this.context=t;const r=t.gl;this.buffer=r.createBuffer(),t.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||e.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let n=0;n<this.attributes.length;n++){const i=e.attributes[this.attributes[n].name];void 0!==i&&t.enableVertexAttribArray(i)}}setVertexAttribPointers(t,e,n){for(let i=0;i<this.attributes.length;i++){const r=this.attributes[i],o=e.attributes[r.name];void 0!==o&&t.vertexAttribPointer(o,r.components,t[U[r.type]],!1,this.itemSize,r.offset+this.itemSize*(n||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class z{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class G extends z{getDefault(){return t.Color.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class V extends z{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class j extends z{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class $ extends z{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class H extends z{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class W extends z{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class q extends z{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class X extends z{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Y extends z{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class Z extends z{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class J extends z{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class K extends z{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Q extends z{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class tt extends z{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class et extends z{getDefault(){return t.Color.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class nt extends z{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class it extends z{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class rt extends z{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class ot extends z{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}let st,at=class extends z{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}};class lt extends z{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class ct extends z{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class ut extends z{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class ht extends z{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class dt extends z{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class pt extends z{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ft extends z{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class mt extends z{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class gt extends z{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class _t extends z{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class yt extends z{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class vt extends z{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class xt extends vt{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class bt extends vt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,this.attachment(),e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Tt extends bt{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Et{constructor(t,e,n,i){this.context=t,this.width=e,this.height=n;const r=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new xt(t,r),i&&(this.depthAttachment=new bt(t,r))}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class St{constructor(t,e=!1){if(this.gl=t,this.isWebGL2=e,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),e){const e=t;this.extVertexArrayObject={createVertexArrayOES:e.createVertexArray.bind(t),deleteVertexArrayOES:e.deleteVertexArray.bind(t),bindVertexArrayOES:e.bindVertexArray.bind(t)}}this.clearColor=new G(this),this.clearDepth=new V(this),this.clearStencil=new j(this),this.colorMask=new $(this),this.depthMask=new H(this),this.stencilMask=new W(this),this.stencilFunc=new q(this),this.stencilOp=new X(this),this.stencilTest=new Y(this),this.depthRange=new Z(this),this.depthTest=new J(this),this.depthFunc=new K(this),this.blend=new Q(this),this.blendFunc=new tt(this),this.blendColor=new et(this),this.blendEquation=new nt(this),this.cullFace=new it(this),this.cullFaceSide=new rt(this),this.frontFace=new ot(this),this.program=new at(this),this.activeTexture=new lt(this),this.viewport=new ct(this),this.bindFramebuffer=new ut(this),this.bindRenderbuffer=new ht(this),this.bindTexture=new dt(this),this.bindVertexBuffer=new pt(this),this.bindElementBuffer=new ft(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new mt(this),this.pixelStoreUnpack=new gt(this),this.pixelStoreUnpackPremultiplyAlpha=new _t(this),this.pixelStoreUnpackFlipY=new yt(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extDebugRendererInfo=t.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=t.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=t.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),e||(this.extTextureHalfFloat=t.getExtension("OES_texture_half_float")),(e||this.extTextureHalfFloat&&t.getExtension("OES_texture_half_float_linear"))&&(this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=e||t.getExtension("OES_standard_derivatives"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)}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.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new F(this,t,e)}createVertexBuffer(t,e,n){return new k(this,t,e,n)}createRenderbuffer(t,e,n){const i=this.gl,r=i.createRenderbuffer();return this.bindRenderbuffer.set(r),i.renderbufferStorage(i.RENDERBUFFER,t,e,n),this.bindRenderbuffer.set(null),r}createFramebuffer(t,e,n){return new Et(this,t,e,n)}clear({color:t,depth:e,stencil:n}){const i=this.gl;let r=0;t&&(r|=i.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(r|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==n&&(r|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),i.clear(r)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(n){e(n.blendFunction,t.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(n.blendFunction),this.blendColor.set(n.blendColor)),this.colorMask.set(n.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class wt extends t.Evented{constructor(e,n,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.extend(this,t.pick(n,["url","scheme","tileSize","promoteId"])),this._options=t.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new t.DedupedRequest}load(e){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"}));const n=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=B(this._options,this.map._requestManager,n,i,((n,i)=>{this._tileJSONRequest=null,this._loaded=!0,n?this.fire(new t.ErrorEvent(n)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new N(i.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(i.tiles,this.map._requestManager._customAccessToken),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(n)}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest(),this.load((()=>this.map.style._clearSource(this.id)))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return t.extend({},this._options)}loadTile(e,n){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,t.ResourceType.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=n:e.request=e.actor.send("reloadTile",r,o.bind(this));else if(e.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",r,o.bind(this),void 0,!0);else{const n=t.loadVectorTile.call({deduped:this._deduped},r,((t,n)=>{t||!n?o.call(this,t):(r.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},e.actor&&e.actor.send("loadTile",r,o.bind(this),void 0,!0))}),!0);e.request={cancel:n}}function o(i,r){return delete e.request,e.aborted?n(null):i&&404!==i.status?n(i):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class At extends t.Evented{constructor(e,n,i,r){super(),this.id=e,this.dispatcher=i,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=t.extend({type:"raster"},n),t.extend(this,t.pick(n,["url","scheme","tileSize"]))}load(e){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=B(this._options,this.map._requestManager,null,null,((n,i)=>{this._tileJSONRequest=null,this._loaded=!0,n?this.fire(new t.ErrorEvent(n)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new N(i.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(i.tiles),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(n)}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest(),this.load((()=>this.map.style._clearSource(this.id)))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return t.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,n){const i=t.exported.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),((i,r,o,s)=>(delete e.request,e.aborted?(e.state="unloaded",n(null)):i?(e.state="errored",n(i)):r?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:o,expires:s}),e.setTexture(r,this.map.painter),e.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),void n(null)):n(null))))}static loadTileData(t,e,n){t.setTexture(e,n)}static unloadTileData(t,e){t.texture&&e.saveTileTexture(t.texture)}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Mt(e,n,i,r,o,s,a,l){const c=[e,i,o,n,r,s,1,1,1],u=[a,l,1],h=t.adjoint([],c),[d,p,f]=t.transformMat3(u,u,t.transpose(h,h));return t.multiply$1(c,[d,0,0,0,p,0,0,0,f],c)}class Ct extends t.Evented{constructor(t,e,n,i){super(),this.id=t,this.dispatcher=n,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=e,this._dirty=!1}load(e,n){this._loaded=n||!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),((n,i)=>{if(this._imageRequest=null,this._loaded=!0,n)this.fire(new t.ErrorEvent(n));else if(i){const{HTMLImageElement:n}=t.window;this.image=i instanceof n?t.exported.getImageData(i):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(t){return this.image&&t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(e){this.coordinates=e,this._boundsArray=void 0;const n=e.map(t.MercatorCoordinate.fromLngLat);return this.tileID=function(e){let n=1/0,i=1/0,r=-1/0,o=-1/0;for(const t of e)n=Math.min(n,t.x),i=Math.min(i,t.y),r=Math.max(r,t.x),o=Math.max(o,t.y);const s=Math.max(r-n,o-i),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new t.CanonicalTileID(a,Math.floor((n+r)/2*l),Math.floor((i+o)/2*l))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray)return;const n=t.tileTransform(this.tileID,this.map.transform.projection),[i,r,o,s]=this.coordinates.map((e=>{const i=n.projection.project(e[0],e[1]);return t.getTilePoint(n,i)._round()}));this.perspectiveTransform=function(e,n,i,r,o,s,a,l,c,u){const h=Mt(0,0,e,0,0,n,e,n),d=Mt(i,r,o,s,a,l,c,u);return t.multiply$1(d,t.adjoint(h,h),d),[d[6]/d[8]*e/t.EXTENT,d[7]/d[8]*n/t.EXTENT]}(this.width,this.height,i.x,i.y,r.x,r.y,s.x,s.y,o.x,o.y);const a=this._boundsArray=new t.StructArrayLayout4i8;a.emplaceBack(i.x,i.y,0,0),a.emplaceBack(r.x,r.y,t.EXTENT,0),a.emplaceBack(s.x,s.y,0,t.EXTENT),a.emplaceBack(o.x,o.y,t.EXTENT,t.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,t.boundsAttributes.members),this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,n=e.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new t.Texture(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(e)}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const It={vector:wt,raster:At,"raster-dem":class extends At{constructor(e,n,i,r){super(e,n,i,r),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(e,n){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(t,i){t&&(e.state="errored",n(t)),i&&(e.dem=i,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",n(null))}e.request=t.getImage(this.map._requestManager.transformRequest(i,t.ResourceType.Tile),function(i,o,s,a){if(delete e.request,e.aborted)e.state="unloaded",n(null);else if(i)e.state="errored",n(i);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:s,expires:a});const n=t.window.ImageBitmap&&o instanceof t.window.ImageBitmap&&(null==st&&(st=t.window.OffscreenCanvas&&new t.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof t.window.createImageBitmap),st),i=1-(o.width-t.prevPowerOfTwo(o.width))/2;i<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const l=n?o:t.exported.getImageData(o,i),c={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:i};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",c,r.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(e){const n=e.canonical,i=Math.pow(2,n.z),r=(n.x-1+i)%i,o=0===n.x?e.wrap-1:e.wrap,s=(n.x+1+i)%i,a=n.x+1===i?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,o,n.z,r,n.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},n.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,o,n.z,r,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1}),n.y+1<i&&(l[new t.OverscaledTileID(e.overscaledZ,o,n.z,r,n.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,n.z,s,n.y+1).key]={backfilled:!1}),l}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded"}},geojson:class extends t.Evented{constructor(e,n,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(r),this._data=n.data,this._options=t.extend({},n),this._collectResourceTiming=n.collectResourceTiming,void 0!==n.maxzoom&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;const o=t.EXTENT/this.tileSize;this.workerOptions=t.extend({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(void 0!==n.buffer?n.buffer:128)*o,tolerance:(void 0!==n.tolerance?n.tolerance:.375)*o,extent:t.EXTENT,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:void 0!==n.clusterMaxZoom?n.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,n.clusterMinPoints||2),extent:t.EXTENT,radius:(void 0!==n.clusterRadius?n.clusterRadius:50)*o,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions)}onAdd(t){this.map=t,this.setData(this._data)}setData(t){return this._data=t,this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,n,i){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:n},i),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new t.Event("dataloading",{dataType:"source"})),this._loaded=!1;const e=t.extend({},this.workerOptions),n=this._data;"string"==typeof n?(e.request=this.map._requestManager.transformRequest(t.exported.resolveURL(n),t.ResourceType.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(n),this._pendingLoad=this.actor.send(`${this.type}.loadData`,e,((e,n)=>{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new t.ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(e.resourceTiming=n.resourceTiming[this.id]),this.fire(new t.Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(e,n){const i=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(i,{type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((t,r)=>(delete e.request,e.unloadVectorData(),e.aborted?n(null):t?n(t):(e.loadVectorData(r,this.map.painter,"reloadTile"===i),n(null)))),void 0,"loadTile"===i)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ct{constructor(t,e,n,i){super(t,e,n,i),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,t.ResourceType.Source).url);t.getVideo(this.urls,((e,n)=>{this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):n&&(this.video=n,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(e){if(this.video){const n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,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 e=this.map.painter.context,n=e.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ct,canvas:class extends Ct{constructor(e,n,i,r){super(e,n,i,r),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,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 t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(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(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const n=this.map.painter.context;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(n,this.canvas,n.gl.RGBA,{premultiply:!0}),this._prepareData(n)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}},custom:class extends t.Evented{constructor(e,n,i,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=n,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 t.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new t.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new N(this._implementation.bounds,this.minzoom,this.maxzoom)),n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),t.extend(this,t.pick(n,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return t.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(t){this._implementation.onRemove&&this._implementation.onRemove(t)}hasTile(t){if(this._implementation.hasTile){const{x:e,y:n,z:i}=t.canonical;return this._implementation.hasTile({x:e,y:n,z:i})}return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,n){const{x:i,y:r,z:o}=e.tileID.canonical,s=new t.window.AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:r,z:o},{signal:s.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",n(null)):void 0===i?(e.state="errored",n(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",n(null)):function(e){return e instanceof t.window.ImageData||e instanceof t.window.HTMLCanvasElement||e instanceof t.window.ImageBitmap||e instanceof t.window.HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void n(null)):(e.state="errored",n(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((t=>{20!==t.code&&(e.state="errored",n(t))})),e.request.cancel=()=>s.abort()}loadTileData(t,e){At.loadTileData(t,e,this._map.painter)}unloadTileData(t){At.unloadTileData(t,this._map.painter)}unloadTile(t,e){if(this.unloadTileData(t),this._implementation.unloadTile){const{x:e,y:n,z:i}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:n,z:i})}e()}abortTile(t,e){t.request&&t.request.cancel&&(t.request.cancel(),delete t.request),e()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((t=>({x:t.canonical.x,y:t.canonical.y,z:t.canonical.z})))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Pt=function(e,n,i,r){const o=new It[n.type](e,n,i,r);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return t.bindAll(["load","abort","unload","serialize","prepare"],o),o};function Lt(e,n){const i=t.identity([]);return t.scale(i,i,[.5*e.width,.5*-e.height,1]),t.translate(i,i,[1,-1,0]),t.multiply(i,i,e.calculateProjMatrix(n.toUnwrapped())),Float32Array.from(i)}function Rt(t,e,n,i,r,o,s,a=!1){const l=t.tilesIn(i,s,a);l.sort(Dt);const c=[];for(const i of l)c.push({wrappedTileID:i.tile.tileID.wrapped().key,queryResults:i.tile.queryRenderedFeatures(e,n,t._state,i,r,o,Lt(t.transform,i.tile.tileID),a)});const u=function(t){const e={},n={};for(const i of t){const t=i.queryResults,r=i.wrappedTileID,o=n[r]=n[r]||{};for(const n in t){const i=t[n],r=o[n]=o[n]||{},s=e[n]=e[n]||[];for(const t of i)r[t.featureIndex]||(r[t.featureIndex]=!0,s.push(t))}}return e}(c);for(const e in u)u[e].forEach((e=>{const n=e.feature,i=n.layer;i&&"background"!==i.type&&"sky"!==i.type&&(n.source=i.source,i["source-layer"]&&(n.sourceLayer=i["source-layer"]),n.state=void 0!==n.id?t.getFeatureState(i["source-layer"],n.id):{})}));return u}function Ot(t,e){const n=t.getRenderableIds().map((e=>t.getTileByID(e))),i=[],r={};for(let t=0;t<n.length;t++){const o=n[t],s=o.tileID.canonical.key;r[s]||(r[s]=!0,o.querySourceFeatures(i,e))}return i}function Dt(t,e){const n=t.tileID,i=e.tileID;return n.overscaledZ-i.overscaledZ||n.canonical.y-i.canonical.y||n.wrap-i.wrap||n.canonical.x-i.canonical.x}function Bt(){return null!=po.workerClass?new po.workerClass:new t.window.Worker(po.workerUrl)}const Nt="mapboxgl_preloaded_worker_pool";class Ft{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Ft.workerCount;)this.workers.push(new Bt);return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Nt]}numActive(){return Object.keys(this.active).length}}let Ut;function kt(){return Ut||(Ut=new Ft),Ut}function zt(e,n){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return t.refProperties.forEach((t=>{t in n&&(i[t]=n[t])})),i}function Gt(t){t=t.slice();const e=Object.create(null);for(let n=0;n<t.length;n++)e[t[n].id]=t[n];for(let n=0;n<t.length;n++)"ref"in t[n]&&(t[n]=zt(t[n],e[t[n].ref]));return t}Ft.workerCount=2;const Vt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",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",setProjection:"setProjection"};function jt(t,e,n){n.push({command:Vt.addSource,args:[t,e[t]]})}function $t(t,e,n){e.push({command:Vt.removeSource,args:[t]}),n[t]=!0}function Ht(t,e,n,i){$t(t,n,i),jt(t,e,n)}function Wt(t,n,i){let r;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!e(t[i][r],n[i][r]))return!1;for(r in n[i])if(n[i].hasOwnProperty(r)&&"data"!==r&&!e(t[i][r],n[i][r]))return!1;return!0}function qt(t,n,i,r,o,s){let a;for(a in n=n||{},t=t||{})t.hasOwnProperty(a)&&(e(t[a],n[a])||i.push({command:s,args:[r,a,n[a],o]}));for(a in n)n.hasOwnProperty(a)&&!t.hasOwnProperty(a)&&(e(t[a],n[a])||i.push({command:s,args:[r,a,n[a],o]}))}function Xt(t){return t.id}function Yt(t,e){return t[e.id]=e,t}class Zt{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=t.clamp(e,0,1);let n=1,i=this._distances[n];const r=e*this.paddedLength+this.padding;for(;i<r&&n<this._distances.length;)i=this._distances[++n];const o=n-1,s=this._distances[o],a=i-s,l=a>0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))}}class Jt{constructor(t,e,n){const i=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(t/n),this.yCellCount=Math.ceil(e/n);for(let t=0;t<this.xCellCount*this.yCellCount;t++)i.push([]),r.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,n,i,r){this._forEachCell(e,n,i,r,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(n),this.bboxes.push(i),this.bboxes.push(r)}insertCircle(t,e,n,i){this._forEachCell(e-i,n-i,e+i,n+i,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(n),this.circles.push(i)}_insertBoxCell(t,e,n,i,r,o){this.boxCells[r].push(o)}_insertCircleCell(t,e,n,i,r,o){this.circleCells[r].push(o)}_query(t,e,n,i,r,o){if(n<0||t>this.width||i<0||e>this.height)return!r&&[];const s=[];if(t<=0&&e<=0&&this.width<=n&&this.height<=i){if(r)return!0;for(let t=0;t<this.boxKeys.length;t++)s.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],n=this.circles[3*t+1],i=this.circles[3*t+2];s.push({key:this.circleKeys[t],x1:e-i,y1:n-i,x2:e+i,y2:n+i})}return o?s.filter(o):s}return this._forEachCell(t,e,n,i,this._queryCell,s,{hitTest:r,seenUids:{box:{},circle:{}}},o),r?s.length>0:s}_queryCircle(t,e,n,i,r){const o=t-n,s=t+n,a=e-n,l=e+n;if(s<0||o>this.width||l<0||a>this.height)return!i&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:i,circle:{x:t,y:e,radius:n},seenUids:{box:{},circle:{}}},r),i?c.length>0:c}query(t,e,n,i,r){return this._query(t,e,n,i,!1,r)}hitTest(t,e,n,i,r){return this._query(t,e,n,i,!0,r)}hitTestCircle(t,e,n,i){return this._queryCircle(t,e,n,!0,i)}_queryCell(t,e,n,i,r,o,s,a){const l=s.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(t<=r[c+2]&&e<=r[c+3]&&n>=r[c+0]&&i>=r[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]})}}}const u=this.circleCells[r];if(null!==u){const r=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(r[u],r[u+1],r[u+2],t,e,n,i)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const t=r[u],e=r[u+1],n=r[u+2];o.push({key:this.circleKeys[c],x1:t-n,y1:e-n,x2:t+n,y2:e+n})}}}}}_queryCellCircle(t,e,n,i,r,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[r];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const n=4*e;if(this._circleAndRectCollide(l.x,l.y,l.radius,t[n+0],t[n+1],t[n+2],t[n+3])&&(!a||a(this.boxKeys[e])))return o.push(!0),!0}}const h=this.circleCells[r];if(null!==h){const t=this.circles;for(const e of h)if(!c.circle[e]){c.circle[e]=!0;const n=3*e;if(this._circlesCollide(t[n],t[n+1],t[n+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[e])))return o.push(!0),!0}}}_forEachCell(t,e,n,i,r,o,s,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),u=this._convertToXCellCoord(n),h=this._convertToYCellCoord(i);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,t,e,n,i,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,n,i,r,o){const s=i-t,a=r-e,l=n+o;return l*l>s*s+a*a}_circleAndRectCollide(t,e,n,i,r,o,s){const a=(o-i)/2,l=Math.abs(t-(i+a));if(l>a+n)return!1;const c=(s-r)/2,u=Math.abs(e-(r+c));if(u>c+n)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=n*n}}const Kt={unknown:0,flipRequired:1,flipNotRequired:2},Qt=Math.tan(85*Math.PI/180);function te(e,n,i,r,o,s,a){const l=t.create();if(i)if("globe"===s.name){const e=t.calculateGlobeLabelMatrix(o,n);t.multiply(l,l,e)}else{const e=y([],a);l[0]=e[0],l[1]=e[1],l[4]=e[2],l[5]=e[3],r||t.rotateZ(l,l,o.angle)}else t.multiply(l,o.labelPlaneMatrix,e);return l}function ee(t,e,n,i,r,o,s){const a=te(t,e,n,i,r,o,s);return"globe"===o.name&&n||(a[2]=a[6]=a[10]=a[14]=0),a}function ne(e,n,i,r,o,s,a){if(i){if("globe"===s.name){const l=te(e,n,i,r,o,s,a);return t.invert(l,l),t.multiply(l,e,l),l}{const n=t.clone(e),i=t.identity([]);return i[0]=a[0],i[1]=a[1],i[4]=a[2],i[5]=a[3],t.multiply(n,n,i),r||t.rotateZ(n,n,-o.angle),n}}return o.glCoordMatrix}function ie(e,n,i,r){const o=[e,n,i,1];i?t.transformMat4$1(o,o,r):fe(o,o,r);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function re(t,e){return Math.min(.5+t/e*.5,1.5)}function oe(t,e){const n=t[0]/t[3],i=t[1]/t[3];return n>=-e[0]&&n<=e[0]&&i>=-e[1]&&i<=e[1]}function se(e,n,i,r,o,s,a,l,c,u){const h=i.transform,d=r?e.textSizeData:e.iconSizeData,p=t.evaluateSizeForZoom(d,i.transform.zoom),f="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let _=null;f&&(_=r?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const y=e.lineVertexArray,v=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=i.transform.width/i.transform.height;let b,T=!1;for(let r=0;r<v.length;r++){const f=v.get(r),{numGlyphs:E,writingMode:S}=f;if(S!==t.WritingMode.vertical||T||b===t.WritingMode.horizontal||(T=!0),b=S,(f.hidden||S===t.WritingMode.vertical)&&!T){pe(E,g);continue}T=!1;const w=new t.Point(f.tileAnchorX,f.tileAnchorY);let{x:A,y:M,z:C}=h.projection.projectTilePoint(w.x,w.y,u.canonical);if(c){const[t,e,n]=c(w);A+=t,M+=e,C+=n}const I=[A,M,C,1];if(t.transformMat4$1(I,I,n),!oe(I,m)){pe(E,g);continue}const P=re(i.transform.cameraToCenterDistance,I[3]),L=t.evaluateSizeForFeature(d,p,f),R=a?L/P:L*P,O=ie(A,M,C,o);if(O[3]<=0){pe(E,g);continue}let D={};const B=a?null:c,N=ce(f,R,!1,l,n,o,s,e.glyphOffsetArray,y,g,_,O,w,D,x,B,h.projection,u,a);T=N.useVertical,B&&N.needsFlipping&&(D={}),(N.notEnoughRoom||T||N.needsFlipping&&ce(f,R,!0,l,n,o,s,e.glyphOffsetArray,y,g,_,O,w,D,x,B,h.projection,u,a).notEnoughRoom)&&pe(E,g)}r?(e.text.dynamicLayoutVertexBuffer.updateData(g),_&&e.text.globeExtVertexBuffer.updateData(_)):(e.icon.dynamicLayoutVertexBuffer.updateData(g),_&&e.icon.globeExtVertexBuffer.updateData(_))}function ae(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m){const{lineStartIndex:g,glyphStartIndex:_,segment:y}=a,v=_+a.numGlyphs,x=g+a.lineLength,b=e.getoffsetX(_),T=e.getoffsetX(v-1),E=de(t*b,n,i,r,o,s,y,g,x,l,c,u,h,d,!0,p,f,m);if(!E)return null;const S=de(t*T,n,i,r,o,s,y,g,x,l,c,u,h,d,!0,p,f,m);return S?{first:E,last:S}:null}function le(e,n,i,r){return e===t.WritingMode.horizontal&&Math.abs(r)>Math.abs(i)?{useVertical:!0}:e===t.WritingMode.vertical?r>0?{needsFlipping:!0}:null:n!==Kt.unknown&&function(t,e){return 0===t||Math.abs(e/t)>Qt}(i,r)?n===Kt.flipRequired?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function ce(e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v){const x=n/24,b=e.lineOffsetX*x,T=e.lineOffsetY*x,{lineStartIndex:E,glyphStartIndex:S,numGlyphs:w,segment:A,writingMode:M,flipState:C}=e,I=E+e.lineLength,P=e=>{if(h){const[n,i,r]=e.up,o=u.length;t.updateGlobeVertexNormal(h,o+0,n,i,r),t.updateGlobeVertexNormal(h,o+1,n,i,r),t.updateGlobeVertexNormal(h,o+2,n,i,r),t.updateGlobeVertexNormal(h,o+3,n,i,r)}const[n,i,r]=e.point;t.addDynamicAttributes(u,n,i,r,e.angle)};if(w>1){const t=ae(x,l,b,T,i,d,p,e,c,s,f,g,!1,_,y,v);if(!t)return{notEnoughRoom:!0};if(r&&!i){let[n,i,r]=t.first.point,[o,s,l]=t.last.point;[n,i]=ie(n,i,r,a),[o,s]=ie(o,s,l,a);const c=le(M,C,(o-n)*m,s-i);if(e.flipState=c&&c.needsFlipping?Kt.flipRequired:Kt.flipNotRequired,c)return c}P(t.first);for(let t=S+1;t<S+w-1;t++){const e=de(x*l.getoffsetX(t),b,T,i,d,p,A,E,I,c,s,f,g,!1,!1,_,y,v);if(!e)return u.length-=4*(t-S),{notEnoughRoom:!0};P(e)}P(t.last)}else{if(r&&!i){const n=ie(p.x,p.y,0,o),i=E+A+1,r=new t.Point(c.getx(i),c.gety(i)),s=ie(r.x,r.y,0,o),a=s[3]>0?s:he(p,r,n,1,o,void 0,_,y.canonical),l=le(M,C,(a[0]-n[0])*m,a[1]-n[1]);if(e.flipState=l&&l.needsFlipping?Kt.flipRequired:Kt.flipNotRequired,l)return l}const n=de(x*l.getoffsetX(S),b,T,i,d,p,A,E,I,c,s,f,g,!1,!1,_,y,v);if(!n)return{notEnoughRoom:!0};P(n)}return{}}function ue(t,e,n,i,r){const{x:o,y:s,z:a}=i.projectTilePoint(t.x,t.y,e);if(!r)return ie(o,s,a,n);const[l,c,u]=r(t);return ie(o+l,s+c,a+u,n)}function he(e,n,i,r,o,s,a,l){const c=ue(e.sub(n)._unit()._add(e),l,o,a,s);return t.sub(c,i,c),t.normalize(c,c),t.scaleAndAdd(c,i,c,r)}function de(e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y){const v=r?e-n:e+n;let x=v>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let T=l+a+(x>0?0:1)|0,E=o,S=o,w=0,A=0;const M=Math.abs(v),C=[],I=[];let P=s,L=P;const R=()=>he(L,P,S,M-w+1,h,p,g,_.canonical);for(;w+A<=M;){if(T+=x,T<l||T>=c)return null;if(S=E,L=P,C.push(S),f&&I.push(L),P=new t.Point(u.getx(T),u.gety(T)),E=d[T],!E){const t=ue(P,_.canonical,h,g,p);E=t[3]>0?d[T]=t:R()}w+=A,A=t.distance(S,E)}m&&p&&(d[T]&&(E=R(),A=t.distance(S,E)),d[T]=E);const O=(M-w)/A,D=P.sub(L)._mult(O)._add(L),B=t.sub([],E,S),N=t.scaleAndAdd([],S,B,O);let F=[0,0,1],U=B[0],k=B[1];if(y&&(F=g.upVector(_.canonical,D.x,D.y),0!==F[0]||0!==F[1]||1!==F[2])){const e=[F[2],0,-F[0]],n=t.cross([],F,e);t.normalize(e,e),t.normalize(n,n),U=t.dot(B,e),k=t.dot(B,n)}if(i){const e=t.cross([],F,B);t.normalize(e,e),t.scaleAndAdd(N,N,e,i*x)}const z=b+Math.atan2(k,U);return C.push(N),f&&I.push(D),{point:N,angle:z,path:C,tilePath:I,up:F}}function pe(t,e){const n=e.length,i=n+4*t;e.resize(i),e.float32.fill(-1/0,4*n,4*i)}function fe(t,e,n){const i=e[0],r=e[1];return t[0]=n[0]*i+n[4]*r+n[12],t[1]=n[1]*i+n[5]*r+n[13],t[3]=n[3]*i+n[7]*r+n[15],t}const me=100;class ge{constructor(t,e,n=new Jt(t.width+200,t.height+200,25),i=new Jt(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=i,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+me,this.screenBottomBoundary=t.height+me,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=e}placeCollisionBox(t,e,n,i,r,o,s,a){let l=n.projectedAnchorX,c=n.projectedAnchorY,u=n.projectedAnchorZ;const h=n.elevation,d=n.tileID,p=t.getProjection();if(h&&d){const[t,e,i]=p.upVector(d.canonical,n.tileAnchorX,n.tileAnchorY),r=p.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=t*h*r,c+=e*h*r,u+=i*h*r}const f=this.projectAndGetPerspectiveRatio(s,l,c,u,n.tileID,"globe"===p.name||!!h||this.transform.pitch>0,p),m=o*f.perspectiveRatio,g=(n.x1*e+i.x-n.padding)*m+f.point.x,_=(n.y1*e+i.y-n.padding)*m+f.point.y,y=(n.x2*e+i.x+n.padding)*m+f.point.x,v=(n.y2*e+i.y+n.padding)*m+f.point.y,x=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(g,_,y,v)||!r&&this.grid.hitTest(g,_,y,v,a)||x?{box:[],offscreen:!1,occluded:f.occluded}:{box:[g,_,y,v],offscreen:this.isOffscreen(g,_,y,v),occluded:!1}}placeCollisionCircles(e,n,i,r,o,s,a,l,c,u,h,d,p,f,m){const g=[],_=this.transform.elevation,y=e.getProjection(),v=_?_.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,x=new t.Point(i.tileAnchorX,i.tileAnchorY);let{x:b,y:T,z:E}=y.projectTilePoint(x.x,x.y,m.canonical);if(v){const[t,e,n]=v(x);b+=t,T+=e,E+=n}const S="globe"===y.name,w=this.projectAndGetPerspectiveRatio(a,b,T,E,m,S||!!_||this.transform.pitch>0,y),{perspectiveRatio:A}=w,M=(h?s/A:s*A)/t.ONE_EM,C=ie(b,T,E,l),I=w.signedDistanceFromCamera>0?ae(M,o,i.lineOffsetX*M,i.lineOffsetY*M,!1,C,x,i,r,l,{},_&&!h?v:null,h&&!!_,y,m,h):null;let P=!1,L=!1,R=!0;if(I&&!w.occluded){const e=.5*p*A+f,i=new t.Point(-100,-100),r=new t.Point(this.screenRightBoundary,this.screenBottomBoundary),o=new Zt,{first:s,last:a}=I,l=s.path.length;let h=[];for(let t=l-1;t>=1;t--)h.push(s.path[t]);for(let t=1;t<a.path.length;t++)h.push(a.path[t]);const m=2.5*e;c&&(h=h.map((([t,e,n],i)=>(v&&!S&&(n=v(i<l-1?s.tilePath[l-1-i]:a.tilePath[i-l+2])[2]),ie(t,e,n,c)))),h.some((t=>t[3]<=0))&&(h=[]));let _=[];if(h.length>0){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const t of h)e=Math.min(e,t[0]),o=Math.min(o,t[1]),n=Math.max(n,t[0]),s=Math.max(s,t[1]);n>=i.x&&e<=r.x&&s>=i.y&&o<=r.y&&(_=[h.map((e=>new t.Point(e[0],e[1])))],(e<i.x||n>r.x||o<i.y||s>r.y)&&(_=t.clipLine(_,i.x,i.y,r.x,r.y)))}for(const t of _){o.reset(t,.25*e);let i=0;i=o.length<=.5*e?1:Math.ceil(o.paddedLength/m)+1;for(let t=0;t<i;t++){const r=t/Math.max(i-1,1),s=o.lerp(r),a=s.x+me,l=s.y+me;g.push(a,l,e,0);const c=a-e,h=l-e,p=a+e,f=l+e;if(R=R&&this.isOffscreen(c,h,p,f),L=L||this.isInsideGrid(c,h,p,f),!n&&this.grid.hitTestCircle(a,l,e,d)&&(P=!0,!u))return{circles:[],offscreen:!1,collisionDetected:P,occluded:!1}}}}return{circles:!u&&P||!L?[]:g,offscreen:R,collisionDetected:P,occluded:w.occluded}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const n=[];let i=1/0,r=1/0,o=-1/0,s=-1/0;for(const a of e){const e=new t.Point(a.x+me,a.y+me);i=Math.min(i,e.x),r=Math.min(r,e.y),o=Math.max(o,e.x),s=Math.max(s,e.y),n.push(e)}const a=this.grid.query(i,r,o,s).concat(this.ignoredGrid.query(i,r,o,s)),l={},c={};for(const e of a){const i=e.key;if(void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex])continue;const r=[new t.Point(e.x1,e.y1),new t.Point(e.x2,e.y1),new t.Point(e.x2,e.y2),new t.Point(e.x1,e.y2)];t.polygonIntersectsPolygon(n,r)&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]=[]),c[i.bucketInstanceId].push(i.featureIndex))}return c}insertCollisionBox(t,e,n,i,r){(e?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:i,collisionGroupID:r},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,n,i,r){const o=e?this.ignoredGrid:this.grid,s={bucketInstanceId:n,featureIndex:i,collisionGroupID:r};for(let e=0;e<t.length;e+=4)o.insertCircle(s,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(e,n,i,r,o,s,a){const l=[n,i,r,1];let c=!1;if(r||this.transform.pitch>0){if(t.transformMat4$1(l,l,e),this.fogState&&o&&"globe"!==a.name){const e=function(e,n,i,r,o,s){const a=s.calculateFogTileMatrix(o),l=[n,i,r];return t.transformMat4(l,l,a),w(e,l,s.pitch,s._fov)}(this.fogState,n,i,r,o.toUnwrapped(),this.transform);c=e>.9}}else fe(l,l,e);const u=l[3];return{point:new t.Point((l[0]/u+1)/2*this.transform.width+me,(-l[1]/u+1)/2*this.transform.height+me),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(t,e,n,i){return n<me||t>=this.screenRightBoundary||i<me||e>this.screenBottomBoundary}isInsideGrid(t,e,n,i){return n>=0&&t<this.gridRightBoundary&&i>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const e=t.identity([]);return t.translate(e,e,[-100,-100,0]),e}}function _e(e,n,i){const r=n.createTileMatrix(e,e.worldSize,i.toUnwrapped());return t.multiply(new Float32Array(16),e.projMatrix,r)}function ye(t,e,n){if(e.projection.name===n.projection.name)return t.projMatrix;const i=n.clone();return i.setProjection(e.projection),_e(i,e.getProjection(),t)}function ve(t,e,n){return e.name===n.projection.name?t.projMatrix:_e(n,e,t)}class xe{constructor(t,e,n,i){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):i&&n?1:0,this.placed=n}isHidden(){return 0===this.opacity&&!this.placed}}class be{constructor(t,e,n,i,r,o=!1){this.text=new xe(t?t.text:null,e,n,r),this.icon=new xe(t?t.icon:null,e,i,r),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Te{constructor(t,e,n,i=!1){this.text=t,this.icon=e,this.skipFade=n,this.clipped=i}}class Ee{constructor(){this.invProjMatrix=t.create(),this.viewportMatrix=t.create(),this.circles=[]}}class Se{constructor(t,e,n,i,r){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=n,this.bucketIndex=i,this.tileID=r}}class we{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function Ae(e,n,i,r,o){const{horizontalAlign:s,verticalAlign:a}=t.getAnchorAlignment(e),l=-(s-.5)*n,c=-(a-.5)*i,u=t.evaluateVariableOffset(e,r);return new t.Point(l+u[0]*o,c+u[1]*o)}function Me(e,n,i,r,o){const s=new t.Point(e,n);return i&&s._rotate(r?o:-o),s}class Ce{constructor(t,e,n,i,r){this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new ge(this.transform,r),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new we(n),this.collisionCircleArrays={},this.prevPlacement=i,i&&(i.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,n,i,r){const o=i.getBucket(n),s=i.latestFeatureIndex;if(!o||!s||n.id!==o.layerIds[0])return;const a=o.layers[0].layout,l=i.collisionBoxArray,c=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/t.EXTENT,h=i.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(p=i.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(p.toUnwrapped()):_e(m,f,p));var p,f,m;const g="map"===a.get("text-pitch-alignment"),_="map"===a.get("text-rotation-alignment");n.compileFilter();const y=n.dynamicFilter(),v=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),b=ee(d,i.tileID.canonical,g,_,this.transform,o.getProjection(),x);let T=null;if(g){const e=ne(d,i.tileID.canonical,g,_,this.transform,o.getProjection(),x);T=t.multiply([],this.transform.labelPlaneMatrix,e)}let E=null;y&&i.latestFeatureIndex&&(E={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new Se(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,i.tileID);const S={bucket:o,layout:a,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:T,clippingData:E,scale:c,textPixelRatio:u,holdingForFade:i.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:t.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const t of o.sortKeyRanges){const{sortKey:n,symbolInstanceStart:i,symbolInstanceEnd:r}=t;e.push({sortKey:n,symbolInstanceStart:i,symbolInstanceEnd:r,parameters:S})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:S})}attemptAnchorPlacement(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_){const{textOffset0:y,textOffset1:v,crossTileID:x}=h,b=[y,v],T=Ae(t,n,i,b,r),E=this.collisionIndex.placeCollisionBox(p,r,e,Me(T.x,T.y,o,s,this.transform.angle),u,a,l,c.predicate);if(m){const t=p.getSymbolInstanceIconSize(_,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(p,t,m,Me(T.x,T.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)return}if(E.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(e=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:b,width:n,height:i,anchor:t,textScale:r,prevAnchor:e},this.markUsedJustification(p,t,h,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,h),this.placedOrientations[x]=f),{shift:T,placedGlyphBoxes:E}}}placeLayerBucketPart(e,n,i,r){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:d,collisionBoxArray:p,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:g}=e.parameters,_=s.get("text-optional"),y=s.get("icon-optional"),v=s.get("text-allow-overlap"),x=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),T="map"===s.get("text-pitch-alignment"),E="none"!==s.get("icon-text-fit"),S="viewport-y"===s.get("symbol-z-order");this.transform.setProjection(o.projection);let w=v&&(x||!o.hasIconData()||y),A=x&&(v||!o.hasTextData()||_);!o.collisionArrays&&p&&o.deserializeCollisionBoxes(p),i&&r&&o.updateCollisionDebugBuffers(this.transform.zoom,p);const M=(e,r,p)=>{const{crossTileID:S,numVerticalGlyphVertices:M}=e;if(u){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[o.bucketInstanceId];r=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(i,r,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new t.Point(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[S]=new Te(!1,!1,!1,!0),void n.add(S)}if(n.has(S))return;if(d)return void(this.placements[S]=new Te(!1,!1,!1));let C=!1,I=!1,P=!0,L=!1,R=!1,O=null,D={box:null,offscreen:null,occluded:null},B={box:null,offscreen:null,occluded:null},N=null,F=null,U=null,k=0,z=0,G=0;p.textFeatureIndex?k=p.textFeatureIndex:e.useRuntimeCollisionCircles&&(k=e.featureIndex),p.verticalTextFeatureIndex&&(z=p.verticalTextFeatureIndex);const V=t=>{t.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const e=this.transform.elevation;(e||t.elevation)&&(t.elevation=e?e.getAtTileOffset(t.tileID,t.tileAnchorX,t.tileAnchorY):0)},j=p.textBox;if(j){V(j);const n=n=>{let i=t.WritingMode.horizontal;if(o.allowVerticalPlacement&&!n&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[S];t&&(this.placedOrientations[S]=t,i=t,this.markUsedOrientation(o,i,e))}return i},i=(e,n)=>{if(o.allowVerticalPlacement&&M>0&&p.verticalTextBox){for(const i of o.writingModes)if(i===t.WritingMode.vertical?(D=n(),B=D):D=e(),D&&D.box&&D.box.length)break}else D=e()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[S]){const t=this.prevPlacement.variableOffsets[S];l.indexOf(t.anchor)>0&&(l=l.filter((e=>e!==t.anchor)),l.unshift(t.anchor))}const c=(t,n,i)=>{const s=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,r),c=(t.x2-t.x1)*s+2*t.padding,u=(t.y2-t.y1)*s+2*t.padding,d=E&&!x?n:null;d&&V(d);let p={box:[],offscreen:!1,occluded:!1};const _=v?2*l.length:l.length;for(let n=0;n<_;++n){const _=this.attemptAnchorPlacement(l[n%l.length],t,c,u,s,b,T,h,a,g,n>=l.length,e,r,o,i,d,f,m);if(_&&(p=_.placedGlyphBoxes,p&&p.box&&p.box.length)){C=!0,O=_.shift;break}}return p};i((()=>c(j,p.iconBox,t.WritingMode.horizontal)),(()=>{const e=p.verticalTextBox;return e&&V(e),o.allowVerticalPlacement&&!(D&&D.box&&D.box.length)&&M>0&&e?c(e,p.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),D&&(C=D.box,P=D.offscreen,L=D.occluded);const u=n(!(!D||!D.box));if(!C&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[S];t&&(this.variableOffsets[S]=t,this.markUsedJustification(o,t.anchor,e,u))}}else{const s=(n,i)=>{const s=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(o,s,n,new t.Point(0,0),v,h,a,g.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,i,e),this.placedOrientations[S]=i),l};i((()=>s(j,t.WritingMode.horizontal)),(()=>{const e=p.verticalTextBox;return o.allowVerticalPlacement&&M>0&&e?(V(e),s(e,t.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),n(!!(D&&D.box&&D.box.length))}}if(N=D,C=N&&N.box&&N.box.length>0,P=N&&N.offscreen,L=N&&N.occluded,e.useRuntimeCollisionCircles){const n=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),r=t.evaluateSizeForFeature(o.textSizeData,f,n),u=s.get("text-padding");F=this.collisionIndex.placeCollisionCircles(o,v,n,o.lineVertexArray,o.glyphOffsetArray,r,a,l,c,i,T,g.predicate,e.collisionCircleDiameter*r/t.ONE_EM,u,this.retainedQueryData[o.bucketInstanceId].tileID),C=v||F.circles.length>0&&!F.collisionDetected,P=P&&F.offscreen,L=F.occluded}if(p.iconFeatureIndex&&(G=p.iconFeatureIndex),p.iconBox){const n=n=>{V(n);const i=E&&O?Me(O.x,O.y,b,T,this.transform.angle):new t.Point(0,0),r=o.getSymbolInstanceIconSize(m,this.transform.zoom,e.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,r,n,i,x,h,a,g.predicate)};B&&B.box&&B.box.length&&p.verticalIconBox?(U=n(p.verticalIconBox),I=U.box.length>0):(U=n(p.iconBox),I=U.box.length>0),P=P&&U.offscreen,R=U.occluded}const $=_||0===e.numHorizontalGlyphVertices&&0===M,H=y||0===e.numIconVertices;if($||H?H?$||(I=I&&C):C=I&&C:I=C=I&&C,C&&N&&N.box&&this.collisionIndex.insertCollisionBox(N.box,s.get("text-ignore-placement"),o.bucketInstanceId,B&&B.box&&z?z:k,g.ID),I&&U&&this.collisionIndex.insertCollisionBox(U.box,s.get("icon-ignore-placement"),o.bucketInstanceId,G,g.ID),F&&(C&&this.collisionIndex.insertCollisionCircles(F.circles,s.get("text-ignore-placement"),o.bucketInstanceId,k,g.ID),i)){const t=o.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Ee);for(let t=0;t<F.circles.length;t+=4)e.circles.push(F.circles[t+0]),e.circles.push(F.circles[t+1]),e.circles.push(F.circles[t+2]),e.circles.push(F.collisionDetected?1:0)}const W="globe"!==o.projection.name;w=w&&(W||!L),A=A&&(W||!R),this.placements[S]=new Te(C||w,I||A,P||o.justReloaded),n.add(S)};if(S){const t=o.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const n=t[e];M(o.symbolInstances.get(n),n,o.collisionArrays[n])}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)M(o.symbolInstances.get(t),t,o.collisionArrays[t]);if(i&&o.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[o.bucketInstanceId];t.invert(e.invProjMatrix,a),e.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(e,n,i,r){const{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=i,u=t.getAnchorJustification(n),h=r===t.WritingMode.vertical?l:"left"===u?o:"center"===u?s:"right"===u?a:-1;o>=0&&(e.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(e.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(e,n,i){const r=n===t.WritingMode.horizontal||n===t.WritingMode.horizontalOnly?n:0,o=n===t.WritingMode.vertical?n:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=i,u=e.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=r),a>=0&&(u.get(a).placedOrientation=r),l>=0&&(u.get(l).placedOrientation=r),c>=0&&(u.get(c).placedOrientation=o)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let n=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const i=e?e.symbolFadeChange(t):1,r=e?e.opacities:{},o=e?e.variableOffsets:{},s=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],o=r[t];o?(this.opacities[t]=new be(o,i,e.text,e.icon,null,e.clipped),n=n||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new be(null,i,e.text,e.icon,e.skipFade,e.clipped),n=n||e.text||e.icon)}for(const t in r){const e=r[t];if(!this.opacities[t]){const r=new be(e,i,!1,!1);r.isHidden()||(this.opacities[t]=r,n=n||e.text.placed||e.icon.placed)}}for(const t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(const t in s)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=s[t]);n?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const n=new Set;for(const i of e){const e=i.getBucket(t);e&&i.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,n,i.collisionBoxArray)}}updateBucketOpacities(e,n,i){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const r=e.layers[0].layout,o=!!e.layers[0].dynamicFilter(),s=new be(null,0,!1,!1,!0),a=r.get("text-allow-overlap"),l=r.get("icon-allow-overlap"),c=r.get("text-variable-anchor"),u="map"===r.get("text-rotation-alignment"),h="map"===r.get("text-pitch-alignment"),d="none"!==r.get("icon-text-fit"),p=new be(null,0,a&&(l||!e.hasIconData()||r.get("icon-optional")),l&&(a||!e.hasTextData()||r.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);const f=(t,e,n)=>{for(let i=0;i<e/4;i++)t.opacityVertexArray.emplaceBack(n)};let m=0;for(let i=0;i<e.symbolInstances.length;i++){const r=e.symbolInstances.get(i),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:g,numIconVertices:_}=r,y=n.has(g);let v=this.opacities[g];y?v=s:v||(v=p,this.opacities[g]=v),n.add(g);const x=a>0||l>0,b=_>0,T=this.placedOrientations[g],E=T===t.WritingMode.vertical,S=T===t.WritingMode.horizontal||T===t.WritingMode.horizontalOnly;if(!x&&!b||v.isHidden()||m++,x){const t=Fe(v.text);f(e.text,a,E?Ue:t),f(e.text,l,S?Ue:t);const n=v.text.isHidden(),{leftJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:c}=r,u=e.text.placedSymbolArray,h=n||E?1:0;i>=0&&(u.get(i).hidden=h),o>=0&&(u.get(o).hidden=h),s>=0&&(u.get(s).hidden=h),c>=0&&(u.get(c).hidden=n||S?1:0);const d=this.variableOffsets[g];d&&this.markUsedJustification(e,d.anchor,r,T);const p=this.placedOrientations[g];p&&(this.markUsedJustification(e,"left",r,p),this.markUsedOrientation(e,p,r))}if(b){const t=Fe(v.icon),{placedIconSymbolIndex:n,verticalPlacedIconSymbolIndex:i}=r,o=e.icon.placedSymbolArray,s=v.icon.isHidden()?1:0;n>=0&&(f(e.icon,_,E?Ue:t),o.get(n).hidden=s),i>=0&&(f(e.icon,r.numVerticalIconVertices,S?Ue:t),o.get(i).hidden=s)}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const n=e.collisionArrays[i];if(n){let i=new t.Point(0,0),r=!0;if(n.textBox||n.verticalTextBox){if(c){const t=this.variableOffsets[g];t?(i=Ae(t.anchor,t.width,t.height,t.textOffset,t.textScale),u&&i._rotate(h?this.transform.angle:-this.transform.angle)):r=!1}o&&(r=!v.clipped),n.textBox&&Ie(e.textCollisionBox.collisionVertexArray,v.text.placed,!r||E,i.x,i.y),n.verticalTextBox&&Ie(e.textCollisionBox.collisionVertexArray,v.text.placed,!r||S,i.x,i.y)}const s=r&&Boolean(!S&&n.verticalIconBox);n.iconBox&&Ie(e.iconCollisionBox.collisionVertexArray,v.icon.placed,s,d?i.x:0,d?i.y:0),n.verticalIconBox&&Ie(e.iconCollisionBox.collisionVertexArray,v.icon.placed,!s,d?i.x:0,d?i.y:0)}}}if(e.fullyClipped=0===m,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const n=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*n>t}setStale(){this.stale=!0}}function Ie(t,e,n,i,r){t.emplaceBack(e?1:0,n?1:0,i||0,r||0),t.emplaceBack(e?1:0,n?1:0,i||0,r||0),t.emplaceBack(e?1:0,n?1:0,i||0,r||0),t.emplaceBack(e?1:0,n?1:0,i||0,r||0)}const Pe=Math.pow(2,25),Le=Math.pow(2,24),Re=Math.pow(2,17),Oe=Math.pow(2,16),De=Math.pow(2,9),Be=Math.pow(2,8),Ne=Math.pow(2,1);function Fe(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,n=Math.floor(127*t.opacity);return n*Pe+e*Le+n*Re+e*Oe+n*De+e*Be+n*Ne+e}const Ue=0;class ke{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(t,e,n,i,r){const o=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(o,i,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,r())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<o.length;){const t=o[this._currentPartIndex];if(e.placeLayerBucketPart(t,this._seenCrossTileIDs,n,0===t.symbolInstanceStart),this._currentPartIndex++,r())return!0}return!1}}class ze{constructor(t,e,n,i,r,o,s,a){this.placement=new Ce(t,r,o,s,a),this._currentPlacementIndex=e.length-1,this._forceFullPlacement=n,this._showCollisionBoxes=i,this._done=!1}isDone(){return this._done}continuePlacement(e,n,i){const r=t.exported.now(),o=()=>{const e=t.exported.now()-r;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const t=n[e[this._currentPlacementIndex]],r=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=r)&&(!t.maxzoom||t.maxzoom>r)){if(this._inProgressLayer||(this._inProgressLayer=new ke(t)),this._inProgressLayer.continuePlacement(i[t.source],this.placement,this._showCollisionBoxes,t,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Ge=512/t.EXTENT/2;class Ve{constructor(e,n,i){this.tileID=e,this.bucketInstanceId=i,this.index=new t.KDBush(n.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=e.canonical.x*t.EXTENT,o=e.canonical.y*t.EXTENT;for(let t=0;t<n.length;t++){const{key:e,crossTileID:i,tileAnchorX:s,tileAnchorY:a}=n.get(t),l=Math.floor((r+s)*Ge),c=Math.floor((o+a)*Ge);this.index.add(l,c),this.keys.push(e),this.crossTileIDs.push(i)}this.index.finish()}findMatches(e,n,i){const r=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z),o=Ge/Math.pow(2,n.canonical.z-this.tileID.canonical.z),s=n.canonical.x*t.EXTENT,a=n.canonical.y*t.EXTENT;for(let t=0;t<e.length;t++){const n=e.get(t);if(n.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:u}=n,h=Math.floor((s+c)*o),d=Math.floor((a+u)*o),p=this.index.range(h-r,d-r,h+r,d+r);for(const t of p){const e=this.crossTileIDs[t];if(this.keys[t]===l&&!i.has(e)){i.add(e),n.crossTileID=e;break}}}}}class je{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class $e{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const n=this.indexes[t],i={};for(const t in n){const r=n[t];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),i[r.tileID.key]=r}this.indexes[t]=i}this.lng=t}addBucket(t,e,n){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]=new Set);const i=this.usedCrossTileIDs[t.overscaledZ];for(const n in this.indexes){const r=this.indexes[n];if(Number(n)>t.overscaledZ)for(const n in r){const o=r[n];o.tileID.isChildOf(t)&&o.findMatches(e.symbolInstances,t,i)}else{const o=r[t.scaledTo(Number(n)).key];o&&o.findMatches(e.symbolInstances,t,i)}}for(let t=0;t<e.symbolInstances.length;t++){const r=e.symbolInstances.get(t);r.crossTileID||(r.crossTileID=n.generate(),i.add(r.crossTileID))}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Ve(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const n of e.crossTileIDs)this.usedCrossTileIDs[t].delete(n)}removeStaleBuckets(t){let e=!1;for(const n in this.indexes){const i=this.indexes[n];for(const r in i)t[i[r].bucketInstanceId]||(this.removeBucketCrossTileIDs(n,i[r]),delete i[r],e=!0)}return e}}class He{constructor(){this.layerIndexes={},this.crossTileIDs=new je,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,n,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new $e);let o=!1;const s={};"globe"!==i.name&&r.handleWrapJump(n);for(const n of e){const e=n.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(n.tileID,e,this.crossTileIDs)&&(o=!0),s[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const We=(e,n)=>t.emitValidationErrors(e,n&&n.filter((t=>"source.canvas"!==t.identifier))),qe=t.pick(Vt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Xe=t.pick(Vt,["setCenter","setZoom","setBearing","setPitch"]),Ye={version:8,layers:[],sources:{}},Ze={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Je extends t.Evented{constructor(e,n={}){super(),this.map=e,this.dispatcher=new I(kt(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new t.GlyphManager(e._requestManager,n.localFontFamily?t.LocalGlyphMode.all:n.localIdeographFontFamily?t.LocalGlyphMode.ideographs:t.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.crossTileSymbolIndex=new He,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const i=this;this._rtlTextPluginCallback=Je.registerForPluginStateChange((e=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,n)=>{if(t.triggerPluginCompletionEvent(e),n&&n.every((t=>t)))for(const t in i._sourceCaches){const e=i._sourceCaches[t],n=e.getSource().type;"vector"!==n&&"geojson"!==n||e.reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.getSource(t.sourceId);if(e&&e.vectorLayerIds)for(const t in this._layers){const n=this._layers[t];n.source===e.id&&this._validateLayer(n)}}))}loadURL(e,n={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const i="boolean"==typeof n.validate?n.validate:!t.isMapboxURL(e);e=this.map._requestManager.normalizeStyleURL(e,n.accessToken);const r=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(r,((e,n)=>{this._request=null,e?this.fire(new t.ErrorEvent(e)):n&&this._load(n,i)}))}loadJSON(e,n={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame((()=>{this._request=null,this._load(e,!1!==n.validate)}))}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(Ye,!1)}_updateLayerCount(t,e){const n=e?1:-1;t.is3D()&&(this._num3DLayers+=n),"circle"===t.type&&(this._numCircleLayers+=n),"symbol"===t.type&&(this._numSymbolLayers+=n)}_load(e,n){if(n&&We(this,t.validateStyle(e)))return;this._loaded=!0,this.stylesheet=t.clone$1(e),this._updateMapProjection();for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const i=Gt(this.stylesheet.layers);this._order=i.map((t=>t.id)),this._layers={},this._serializedLayers={};for(const e of i){const n=t.createStyleLayer(e);n.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=n,this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new T(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(e){this._spriteRequest=function(e,n,i){let r,o,s;const a=t.exported.devicePixelRatio>1?"@2x":"";let l=t.getJSON(n.transformRequest(n.normalizeSpriteURL(e,a,".json"),t.ResourceType.SpriteJSON),((t,e)=>{l=null,s||(s=t,r=e,u())})),c=t.getImage(n.transformRequest(n.normalizeSpriteURL(e,a,".png"),t.ResourceType.SpriteImage),((t,e)=>{c=null,s||(s=t,o=e,u())}));function u(){if(s)i(s);else if(r&&o){const e=t.exported.getImageData(o),n={};for(const i in r){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=r[i],f=new t.RGBAImage({width:o,height:s});t.RGBAImage.copy(e,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),n[i]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p}}i(null,n)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(e,this.map._requestManager,((e,n)=>{if(this._spriteRequest=null,e)this.fire(new t.ErrorEvent(e));else if(n)for(const t in n)this.imageManager.addImage(t,n[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new t.Event("data",{dataType:"style"}))}))}_validateLayer(e){const n=this.getSource(e.source);if(!n)return;const i=e.sourceLayer;i&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(i))&&this.fire(new t.ErrorEvent(new Error(`Source layer "${i}" does not exist on source "${n.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const n of t){const t=this._layers[n];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&("function"==typeof t.isLayerDraped?t.isLayerDraped():Ze[t.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const n=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(t.length||n.length)&&this._updateWorkerLayers(t,n);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const i={};for(const t in this._sourceCaches){const e=this._sourceCaches[t];i[t]=e.used,e.used=!1}for(const t of this._order){const n=this._layers[t];if(n.recalculate(e,this._availableImages),!n.isHidden(e.zoom)){const t=this._getLayerSourceCache(n);t&&(t.used=!0)}const i=this.map.painter;if(i){const t=n.getProgramIds();if(!t)continue;const r=n.getProgramConfiguration(e.zoom);for(const e of t)i.useProgram(e,r)}}for(const e in i){const n=this._sourceCaches[e];i[e]!==n.used&&n.getSource().fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:n.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this._sourceCaches)this._sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(n){if(this._checkLoaded(),We(this,t.validateStyle(n)))return!1;(n=t.clone$1(n)).layers=Gt(n.layers);const i=function(t,n){if(!t)return[{command:Vt.setStyle,args:[n]}];let i=[];try{if(!e(t.version,n.version))return[{command:Vt.setStyle,args:[n]}];e(t.center,n.center)||i.push({command:Vt.setCenter,args:[n.center]}),e(t.zoom,n.zoom)||i.push({command:Vt.setZoom,args:[n.zoom]}),e(t.bearing,n.bearing)||i.push({command:Vt.setBearing,args:[n.bearing]}),e(t.pitch,n.pitch)||i.push({command:Vt.setPitch,args:[n.pitch]}),e(t.sprite,n.sprite)||i.push({command:Vt.setSprite,args:[n.sprite]}),e(t.glyphs,n.glyphs)||i.push({command:Vt.setGlyphs,args:[n.glyphs]}),e(t.transition,n.transition)||i.push({command:Vt.setTransition,args:[n.transition]}),e(t.light,n.light)||i.push({command:Vt.setLight,args:[n.light]}),e(t.fog,n.fog)||i.push({command:Vt.setFog,args:[n.fog]}),e(t.projection,n.projection)||i.push({command:Vt.setProjection,args:[n.projection]});const r={},o=[];!function(t,n,i,r){let o;for(o in n=n||{},t=t||{})t.hasOwnProperty(o)&&(n.hasOwnProperty(o)||$t(o,i,r));for(o in n){if(!n.hasOwnProperty(o))continue;const s=n[o];t.hasOwnProperty(o)?e(t[o],s)||("geojson"===t[o].type&&"geojson"===s.type&&Wt(t,n,o)?i.push({command:Vt.setGeoJSONSourceData,args:[o,s.data]}):Ht(o,n,i,r)):jt(o,n,i)}}(t.sources,n.sources,o,r);const s=[];t.layers&&t.layers.forEach((t=>{t.source&&r[t.source]?i.push({command:Vt.removeLayer,args:[t.id]}):s.push(t)}));let a=t.terrain;a&&r[a.source]&&(i.push({command:Vt.setTerrain,args:[void 0]}),a=void 0),i=i.concat(o),e(a,n.terrain)||i.push({command:Vt.setTerrain,args:[n.terrain]}),function(t,n,i){n=n||[];const r=(t=t||[]).map(Xt),o=n.map(Xt),s=t.reduce(Yt,{}),a=n.reduce(Yt,{}),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],a.hasOwnProperty(d)?h++:(i.push({command:Vt.removeLayer,args:[d]}),l.splice(l.indexOf(d,h),1));for(u=0,h=0;u<o.length;u++)d=o[o.length-1-u],l[l.length-1-u]!==d&&(s.hasOwnProperty(d)?(i.push({command:Vt.removeLayer,args:[d]}),l.splice(l.lastIndexOf(d,l.length-h),1)):h++,m=l[l.length-u],i.push({command:Vt.addLayer,args:[a[d],m]}),l.splice(l.length-u,0,d),c[d]=!0);for(u=0;u<o.length;u++)if(d=o[u],p=s[d],f=a[d],!c[d]&&!e(p,f))if(e(p.source,f.source)&&e(p["source-layer"],f["source-layer"])&&e(p.type,f.type)){for(g in qt(p.layout,f.layout,i,d,null,Vt.setLayoutProperty),qt(p.paint,f.paint,i,d,null,Vt.setPaintProperty),e(p.filter,f.filter)||i.push({command:Vt.setFilter,args:[d,f.filter]}),e(p.minzoom,f.minzoom)&&e(p.maxzoom,f.maxzoom)||i.push({command:Vt.setLayerZoomRange,args:[d,f.minzoom,f.maxzoom]}),p)p.hasOwnProperty(g)&&"layout"!==g&&"paint"!==g&&"filter"!==g&&"metadata"!==g&&"minzoom"!==g&&"maxzoom"!==g&&(0===g.indexOf("paint.")?qt(p[g],f[g],i,d,g.slice(6),Vt.setPaintProperty):e(p[g],f[g])||i.push({command:Vt.setLayerProperty,args:[d,g,f[g]]}));for(g in f)f.hasOwnProperty(g)&&!p.hasOwnProperty(g)&&"layout"!==g&&"paint"!==g&&"filter"!==g&&"metadata"!==g&&"minzoom"!==g&&"maxzoom"!==g&&(0===g.indexOf("paint.")?qt(p[g],f[g],i,d,g.slice(6),Vt.setPaintProperty):e(p[g],f[g])||i.push({command:Vt.setLayerProperty,args:[d,g,f[g]]}))}else i.push({command:Vt.removeLayer,args:[d]}),m=l[l.lastIndexOf(d)+1],i.push({command:Vt.addLayer,args:[f,m]})}(s,n.layers,i)}catch(t){i=[{command:Vt.setStyle,args:[n]}]}return i}(this.serialize(),n).filter((t=>!(t.command in Xe)));if(0===i.length)return!1;const r=i.filter((t=>!(t.command in qe)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((t=>t.command)).join(", ")}.`);return i.forEach((t=>{"setTransition"!==t.command&&"setProjection"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=n,this._updateMapProjection(),!0}addImage(e,n){return this.getImage(e)?this.fire(new t.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,n),this._afterImageUpdated(e),this)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e),this):this.fire(new t.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(e,n,i={}){if(this._checkLoaded(),void 0!==this.getSource(e))throw new Error("There is already a source with this ID");if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(t.validateSource,`sources.${e}`,n,null,i))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const r=Pt(e,n,this.dispatcher,this);r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(e),source:r.serialize(),sourceId:e})));const o=n=>{const i=(n?"symbol:":"other:")+e,o=this._sourceCaches[i]=new t.SourceCache(i,r,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[e]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==n.type&&"geojson"!==n.type||o(!0),r.onAdd&&r.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const n=this.getSource(e);if(!n)throw new Error("There is no source with this ID");for(const n in this._layers)if(this._layers[n].source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${n}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const i=this._getSourceCaches(e);for(const e of i)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(t,e){this._checkLoaded(),this.getSource(t).setData(e),this._changed=!0}getSource(t){const e=this._getSourceCache(t);return e&&e.getSource()}_getSources(){const t=[];for(const e in this._otherSourceCaches){const n=this._getSourceCache(e);n&&t.push(n.getSource())}return t}addLayer(e,n,i={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${r}" already exists on this map`)));let o;if("custom"===e.type){if(We(this,t.validateCustomStyleLayer(e)))return;o=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(r,e.source),e=t.clone$1(e),e=t.extend(e,{source:r})),this._validate(t.validateLayer,`layers.${r}`,e,{arrayIndex:-1},i))return;o=t.createStyleLayer(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const s=n?this._order.indexOf(n):this._order.length;if(n&&-1===s)return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o;const a=this._getLayerSourceCache(o);if(this._removedLayers[r]&&o.source&&a&&"custom"!==o.type){const t=this._removedLayers[r];delete this._removedLayers[r],t.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;const i=this._order.indexOf(e);this._order.splice(i,1);const r=n?this._order.indexOf(n):this._order.length;n&&-1===r?this.fire(new t.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const n=this._layers[e];if(!n)return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(const e in this._layers)if(this._layers[e].type===t)return!0;return!1}setLayerZoomRange(e,n,i){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===n&&r.maxzoom===i||(null!=n&&(r.minzoom=n),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(n,i,r={}){this._checkLoaded();const o=this.getLayer(n);if(o){if(!e(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.validateFilter,`layers.${o.id}.filter`,i,{layerType:o.type},r)||(o.filter=t.clone$1(i),this._updateLayer(o)))}else this.fire(new t.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){const n=this.getLayer(e);return n&&t.clone$1(n.filter)}setLayoutProperty(n,i,r,o={}){this._checkLoaded();const s=this.getLayer(n);s?e(s.getLayoutProperty(i),r)||(s.setLayoutProperty(i,r,o),this._updateLayer(s)):this.fire(new t.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,n){const i=this.getLayer(e);if(i)return i.getLayoutProperty(n);this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(n,i,r,o={}){this._checkLoaded();const s=this.getLayer(n);s?e(s.getPaintProperty(i),r)||(s.setPaintProperty(i,r,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new t.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,e){const n=this.getLayer(t);return n&&n.getPaintProperty(e)}setFeatureState(e,n){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.getSource(i);if(!o)return void this.fire(new t.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const s=o.type;if("geojson"===s&&r)return void this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(i);for(const t of a)t.setFeatureState(r,e.id,n)}removeFeatureState(e,n){this._checkLoaded();const i=e.source,r=this.getSource(i);if(!r)return void this.fire(new t.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const o=r.type,s="vector"===o?e.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(i);for(const t of a)t.removeFeatureState(s,e.id,n)}getFeatureState(e){this._checkLoaded();const n=e.source,i=e.sourceLayer,r=this.getSource(n);if(r){if("vector"!==r.type||i)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(i,e.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const t in this._sourceCaches){const n=this._sourceCaches[t].getSource();e[n.id]||(e[n.id]=n.serialize())}return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,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:e,layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0;const e=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&e&&"raster"!==e.getSource().type&&(this._updatedSources[t.source]="reload",e.pause()),this._changed=!0,t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,n={},i=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(e(o)){n[o]=r;for(const e of t){const t=e[o];if(t)for(const e of t)i.push(e)}}}i.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(e(s))for(let t=i.length-1;t>=0;t--){const e=i[t].feature;if(n[e.layer.id]<o)break;r.push(e),i.pop()}else for(const e of t){const t=e[s];if(t)for(const e of t)r.push(e.feature)}}return r}queryRenderedFeatures(e,n,i){n&&n.filter&&this._validate(t.validateFilter,"queryRenderedFeatures.filter",n.filter,null,n);const r={};if(n&&n.layers){if(!Array.isArray(n.layers))return this.fire(new t.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const e of n.layers){const n=this._layers[e];if(!n)return this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[n.source]=!0}}const o=[];n.availableImages=this._availableImages;const s=n&&n.layers?n.layers.some((t=>{const e=this.getLayer(t);return e&&e.is3D()})):this.has3DLayers(),a=L.createFromScreenPoints(e,i);for(const t in this._sourceCaches){const e=this._sourceCaches[t].getSource().id;n.layers&&!r[e]||o.push(Rt(this._sourceCaches[t],this._layers,this._serializedLayers,a,n,i,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(t,e,n,i,r,o,s){const a={},l=o.queryRenderedSymbols(i),c=[];for(const t of Object.keys(l).map(Number))c.push(s[t]);c.sort(Dt);for(const n of c){const i=n.featureIndex.lookupSymbolFeatures(l[n.bucketInstanceId],e,n.bucketIndex,n.sourceLayerIndex,r.filter,r.layers,r.availableImages,t);for(const t in i){const e=a[t]=a[t]||[],r=i[t];r.sort(((t,e)=>{const i=n.featureSortOrder;if(i){const n=i.indexOf(t.featureIndex);return i.indexOf(e.featureIndex)-n}return e.featureIndex-t.featureIndex}));for(const t of r)e.push(t)}}for(const e in a)a[e].forEach((i=>{const r=i.feature,o=n(t[e]);if(!o)return;const s=o.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=s}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,n){n&&n.filter&&this._validate(t.validateFilter,"querySourceFeatures.filter",n.filter,null,n);const i=this._getSourceCaches(e);let r=[];for(const t of i)r=r.concat(Ot(t,n));return r}addSourceType(t,e,n){return Je.getSourceType(t)?n(new Error(`A source type called "${t}" already exists.`)):(Je.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},n):n(null,null))}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const n in t)if(!e(t[n],i[n])){r=!0;break}if(!r)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(t,n),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(n,i=1){if(this._checkLoaded(),!n)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let r=n;if(1===i){if("object"==typeof r.source){const e="terrain-dem-src";this.addSource(e,r.source),r=t.clone$1(r),r=t.extend(r,{source:e})}if(this._validate(t.validateTerrain,"terrain",r))return}if(!this.terrain||this.terrain&&i!==this.terrain.drapeRenderMode){if(!r)return;this._createTerrain(r,i)}else{const n=this.terrain,i=n.get();for(const e of Object.keys(t.spec.terrain))!r.hasOwnProperty(e)&&t.spec.terrain[e].default&&(r[e]=t.spec.terrain[e].default);for(const t in r)if(!e(r[t],i[t])){n.set(r),this.stylesheet.terrain=r;const t=this._setTransitionParameters({duration:0});n.updateTransitions(t);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const e=this.fog=new C(t,this.map.transform);this.stylesheet.fog=t;const n=this._setTransitionParameters({duration:0});e.updateTransitions(n)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const t of this.map._markers)t._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,i=n.get();0===Object.keys(t).length&&n.set(t);for(const r in t)if(!e(t[r],i[r])){n.set(t),this.stylesheet.fog=t;const e=this._setTransitionParameters({duration:0});n.updateTransitions(e);break}}else this._createFog(t);this._markersNeedUpdate=!0}_setTransitionParameters(e){return{now:t.exported.now(),transition:t.extend(e,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const t=this._order.filter((t=>this.isLayerDraped(this._layers[t]))),e=this._order.filter((t=>!this.isLayerDraped(this._layers[t])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...e)}_createTerrain(t,e){const n=this.terrain=new S(t,e);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const i=this._setTransitionParameters({duration:0});n.updateTransitions(i)}_force3DLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"fill-extrusion"===e.type&&this._updateLayer(e)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"symbol"===e.type&&this._updateLayer(e)}}_validate(e,n,i,r,o={}){return(!o||!1!==o.validate)&&We(this,e.call(t.validateStyle,t.extend({key:n,style:this.serialize(),value:i,styleSpec:t.spec},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){const e=this._getSourceCaches(t);for(const t of e)t.clearTiles()}_reloadSource(t){const e=this._getSourceCaches(t);for(const t of e)t.resume(),t.reload()}_reloadSources(){for(const t of this._getSources())t.reload&&t.reload()}_updateSources(t){for(const e in this._sourceCaches)this._sourceCaches[e].update(t)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const e=this._sourceCaches[t];e.resume(),e.reload()}}_updatePlacement(e,n,i,r,o=!1){let s=!1,a=!1;const l={};for(const t of this._order){const n=this._layers[t];if("symbol"!==n.type)continue;if(!l[n.source]){const t=this._getLayerSourceCache(n);if(!t)continue;l[n.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const i=this.crossTileSymbolIndex.addLayer(n,l[n.source],e.center.lng,e.projection);s=s||i}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new t.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),e.zoom))&&(this.pauseablePlacement=new ze(e,this._order,o,n,i,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,n){this.imageManager.getImages(e.icons,n),this._updateTilesForChangedImages();const i=t=>{t&&t.setDependencies(e.tileID.key,e.type,e.icons)};i(this._otherSourceCaches[e.source]),i(this._symbolSourceCaches[e.source])}getGlyphs(t,e,n){this.glyphManager.getGlyphs(e.stacks,n)}getResource(e,n,i){return t.makeRequest(n,i)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){const e=[];return this._otherSourceCaches[t]&&e.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&e.push(this._symbolSourceCaches[t]),e}_isSourceCacheLoaded(e){const n=this._getSourceCaches(e);return 0===n.length?(this.fire(new t.ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):n.every((t=>t.loaded()))}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Je.getSourceType=function(t){return It[t]},Je.setSourceType=function(t,e){It[t]=e},Je.registerForPluginStateChange=t.registerForPluginStateChange;var Ke="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.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",Qe="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying 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;}",tn="\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\nconst float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;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;uniform sampler2D u_depth;uniform vec2 u_depth_size_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 decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}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*texture2D(u_dem,pos).a;\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=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));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*texture2D(u_dem_prev,pos).a;\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=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));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\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;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn 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; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",en="#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;varying 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",nn="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying 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;highp 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 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,opacity);}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;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif";let rn={},on={};const sn=[];hn(Ke,sn),hn(tn,sn),hn(en,sn),hn(nn,sn),rn=dn("",tn),on=dn(nn,en);const an=dn("\n#if __VERSION__ >=300\n#define varying in\n#define gl_FragColor glFragColor\n#define texture2D texture\n#define textureCube texture\nout vec4 glFragColor;\n#endif\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp 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#if __VERSION__ >=300\n#define attribute in\n#define varying out\n#define texture2D texture\n#endif\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);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}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 float tile_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 (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),ln=Ke,cn="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var un={background:dn("uniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nvarying vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\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\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform vec4 u_color;varying vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(u_color);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:dn("uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:dn("varying vec3 v_data;varying 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\nvoid 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 extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);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(out_color);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\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;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 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\nvarying vec3 v_data;varying 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,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),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(void) {\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=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;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(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);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);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\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:dn("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:dn("uniform highp float u_intensity;varying 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);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 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\nvarying 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(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(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(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=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=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:dn("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:dn("varying float v_placed;varying 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);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_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+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:dn("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying 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);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying 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;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));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=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:dn("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:dn("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:dn("varying vec2 v_pos;\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;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\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\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:dn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform 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;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);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,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:dn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:dn("varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\nvoid main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvec3 normal=v_normal;\n#endif\nfloat z;vec4 color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);\n#else\ncolor=v_color;\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;\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);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef ZERO_ROOF_RADIUS\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#endif\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform 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;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 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\nvarying vec4 v_color;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nv_normal=normal;\n#endif\nbase=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=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=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 hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\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);\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)));}v_color=vec4(0.0,0.0,0.0,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.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_color=apply_lighting(color,NdotL);\n#else\nv_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_color*=u_opacity;\n#ifdef ZERO_ROOF_RADIUS\nv_roof_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef LIGHTING_3D_MODE\nv_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));\n#else\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.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:dn("uniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,v_NdotL)*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\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform 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 vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 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\nvarying vec2 v_pos;varying vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=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.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : 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(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=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\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.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.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_NdotL=NdotL;\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}"),hillshadePrepare:dn("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}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));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying 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=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:dn("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(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);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\ngl_FragColor=apply_lighting(gl_FragColor);\n#endif\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:dn("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nuniform float u_border_width;uniform vec4 u_border_color;float 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 lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\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 lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(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);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);\n#ifdef RENDER_LINE_BORDER_AUTO\nfloat 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);}\n#else\nout_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);\n#endif\n}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute 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;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 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\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;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);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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\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=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\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=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:dn("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(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);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;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);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\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=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:dn("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 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(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:dn("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\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 highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\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\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],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;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 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\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\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\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\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);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:dn("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\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\nvoid main() {\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\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;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;\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\nvarying vec2 v_data0;varying vec3 v_data1;\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\nvoid main() {\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],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;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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 fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 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\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\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*fontScale+a_pxoffset);\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\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\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);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:dn("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\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\nvoid main() {\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\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;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;\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\nvarying vec4 v_data0;varying vec4 v_data1;\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\nvoid main() {\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],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;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\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*font_scale);\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\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\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);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:dn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\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\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nconst float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=wireframeOffset;\n#endif\nv_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.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:dn("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:dn("\nvarying 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=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Qe),skyboxGradient:dn("varying 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=texture2D(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;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Qe),skyboxCapture:dn("\nvarying 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;\n#ifdef GL_ES\nprecision highp float;\n#endif\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;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying 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:dn("uniform sampler2D u_image0;varying 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\nvec2 uv=gl_FragCoord.xy/u_viewport;highp 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);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\ncolor=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform 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\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+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);}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);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_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:dn("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}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) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);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_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 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 =mix(color_stop_2,c2,t);float 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);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute 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;varying highp vec3 v_ray_dir;varying 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);}")};function hn(t,e){const n=t.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let t of n)if(t=t.trim(),"#"===t[0]&&t.includes("if")&&!t.includes("endif")){t=t.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const n=t.split(" ");for(const t of n)e.includes(t)||e.push(t)}}function dn(t,e){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,i=e.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),r={},o=[...sn];return hn(t,o),hn(e,o),{fragmentSource:t=t.replace(n,((t,e,n,i,o)=>(r[o]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${n} ${i} ${o};\n#else\nuniform ${n} ${i} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n    ${n} ${i} ${o} = u_${o};\n#endif\n`))),vertexSource:e=e.replace(n,((t,e,n,i,o)=>{const s="float"===i?"vec2":"vec4",a=o.match(/color/)?"color":s;return r[o]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${s} a_${o};\nvarying ${n} ${i} ${o};\n#else\nuniform ${n} ${i} u_${o};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${o}\n    ${o} = a_${o};\n#else\n    ${n} ${i} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n    ${o} = unpack_mix_${a}(a_${o}, u_${o}_t);\n#else\n    ${n} ${i} ${o} = u_${o};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${s} a_${o};\n#else\nuniform ${n} ${i} u_${o};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${o}\n    ${n} ${i} ${o} = a_${o};\n#else\n    ${n} ${i} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n    ${n} ${i} ${o} = unpack_mix_${a}(a_${o}, u_${o}_t);\n#else\n    ${n} ${i} ${o} = u_${o};\n#endif\n`})),staticAttributes:i,usedDefines:o}}class pn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(t,e,n,i,r,o,s){this.context=t;let a=this.boundPaintVertexBuffers.length!==i.length;for(let t=0;!a&&t<i.length;t++)this.boundPaintVertexBuffers[t]!==i[t]&&(a=!0);let l=this.boundDynamicVertexBuffers.length!==s.length;for(let t=0;!l&&t<s.length;t++)this.boundDynamicVertexBuffers[t]!==s[t]&&(l=!0);if(!t.extVertexArrayObject||!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==n||a||l||this.boundIndexBuffer!==r||this.boundVertexOffset!==o)this.freshBind(e,n,i,r,o,s);else{t.bindVertexArrayOES.set(this.vao);for(const t of s)t&&t.bind();r&&r.dynamicDraw&&r.bind()}}freshBind(t,e,n,i,r,o){let s;const a=t.numAttributes,l=this.context,c=l.gl;if(l.extVertexArrayObject)this.vao&&this.destroy(),this.vao=l.extVertexArrayObject.createVertexArrayOES(),l.bindVertexArrayOES.set(this.vao),s=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=n,this.boundIndexBuffer=i,this.boundVertexOffset=r,this.boundDynamicVertexBuffers=o;else{s=l.currentNumAttributes||0;for(let t=a;t<s;t++)c.disableVertexAttribArray(t)}e.enableAttributes(c,t),e.bind(),e.setVertexAttribPointers(c,t,r);for(const e of n)e.enableAttributes(c,t),e.bind(),e.setVertexAttribPointers(c,t,r);for(const e of o)e&&(e.enableAttributes(c,t),e.bind(),e.setVertexAttribPointers(c,t,r));i&&i.bind(),l.currentNumAttributes=a}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function fn(e,n){const i=Math.pow(2,n.canonical.z),r=n.canonical.y;return[new t.MercatorCoordinate(0,r/i).toLngLat().lat,new t.MercatorCoordinate(0,(r+1)/i).toLngLat().lat]}function mn(e,n,i,r,o,s,a){const l=e.context,c=l.gl,u=i.fbo;if(!u)return;e.prepareDrawTile();const h=e.useProgram("hillshade");l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get());const d=((t,e,n,i)=>{const r=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),s=n.paint.get("hillshade-accent-color");let a=n.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===n.paint.get("hillshade-illumination-anchor")&&(a-=t.transform.angle);const l=!t.options.moving;return{u_matrix:i||t.transform.calculateProjMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:fn(0,e.tileID),u_light:[n.paint.get("hillshade-exaggeration"),a],u_shadow:r,u_highlight:o,u_accent:s}})(e,i,r,e.terrain?n.projMatrix:null);e.prepareDrawProgram(l,h,n.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=e.getTileBoundsBuffers(i);h.draw(l,c.TRIANGLES,o,s,a,t.CullFaceMode.disabled,d,r.id,p,f,m)}function gn(e,n,i){if(!n.needsDEMTextureUpload)return;const r=e.context,o=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||e.getTileTexture(i.stride);const s=i.getPixels();n.demTexture?n.demTexture.update(s,{premultiply:!1}):n.demTexture=new t.Texture(r,s,o.RGBA,{premultiply:!1}),n.needsDEMTextureUpload=!1}function _n(e,n,i,r,o,s){const a=e.context,l=a.gl;if(!n.dem)return;const c=n.dem;if(a.activeTexture.set(l.TEXTURE1),gn(e,n,c),!n.demTexture)return;n.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const u=c.dim;a.activeTexture.set(l.TEXTURE0);let h=n.fbo;if(!h){const e=new t.Texture(a,{width:u,height:u,data:null},l.RGBA);e.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=n.fbo=a.createFramebuffer(u,u,!0),h.colorAttachment.set(e.texture)}a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,u,u]);const{tileBoundsBuffer:d,tileBoundsIndexBuffer:p,tileBoundsSegments:f}=e.getMercatorTileBoundsBuffers();e.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,r,o,s,t.CullFaceMode.disabled,((e,n)=>{const i=n.stride,r=t.create();return t.ortho(r,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(r,r,[0,-t.EXTENT,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:n.unpackVector}})(n.tileID,c),i.id,d,p,f),n.needsHillshadePrepare=!1}const yn=e=>({u_matrix:new t.UniformMatrix4f(e),u_image0:new t.Uniform1i(e),u_skirt_height:new t.Uniform1f(e)}),vn=(t,e)=>({u_matrix:t,u_image0:0,u_skirt_height:e}),xn=(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f)=>({u_proj_matrix:Float32Array.from(t),u_globe_matrix:e,u_normalize_matrix:Float32Array.from(i),u_merc_matrix:n,u_zoom_transition:r,u_merc_center:o,u_image0:0,u_frustum_tl:s,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:f?Float32Array.from(f):new Float32Array(9),u_skirt_height:p});function bn(t,e){return null!=t&&null!=e&&!(!t.hasData()||!e.hasData())&&null!=t.demTexture&&null!=e.demTexture&&t.tileID.key!==e.tileID.key}const Tn=new class{constructor(){this.operations={}}newMorphing(t,e,n,i,r){if(t in this.operations){const e=this.operations[t];e.to.tileID.key!==n.tileID.key&&(e.queued=n)}else this.operations[t]={startTime:i,phase:0,duration:r,from:e,to:n,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;const e=this.operations[t];return{from:e.from,to:e.to,phase:e.phase}}update(t){for(const e in this.operations){const n=this.operations[e];for(n.phase=(t-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,t)){delete this.operations[e];break}}}_nextOp(t,e){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=e,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}},En={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Sn(t){return 6*Math.pow(1.5,22-t)}function wn(t,e){const n=1<<t.z;return!e&&(0===t.x||t.x===n-1)||0===t.y||t.y===n-1}const An=t=>({u_matrix:t});function Mn(e,n,i,r,o){if(o>0){const s=t.exported.now(),a=(s-e.timeAdded)/o,l=n?(s-n.timeAdded)/o:-1,c=i.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),d=h&&e.refreshedUponExpiration?1:t.clamp(h?a:1-l,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class Cn extends t.SourceCache{constructor(t){const e={type:"raster-dem",maxzoom:t.transform.maxZoom},n=new I(kt(),null),i=Pt("mock-dem",e,n,t.style);super("mock-dem",i,!1),i.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,e){t.state="loaded",e(null)}}class In extends t.SourceCache{constructor(t){const e=Pt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new I(kt(),null),t.style);super("proxy",e,!1),e.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,n,i){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((n,i)=>{if(n[i.key]="",!this._tiles[i.key]){const n=new t.Tile(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);n.state="loaded",this._tiles[i.key]=n}return n}),{});for(const t in this._tiles)t in r||(this.freeFBO(t),this._tiles[t].unloadVectorData(),delete this._tiles[t])}freeFBO(t){const e=this.proxyCachedFBO[t];if(void 0!==e){const n=Object.values(e);this.renderCachePool.push(...n),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach((t=>t.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Pn extends t.OverscaledTileID{constructor(t,e,n){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=e,this.projMatrix=n}}class Ln extends t.Elevation{constructor(e,n){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,o]=function(){const e=new t.StructArrayLayout2i4,n=new t.StructArrayLayout3ui6,i=131;e.reserve(17161),n.reserve(33800);const r=t.EXTENT/128,o=t.EXTENT+r/2,s=o+r;for(let n=-r;n<s;n+=r)for(let i=-r;i<s;i+=r){const r=i<0||i>o||n<0||n>o?24575:0,s=t.clamp(Math.round(i),0,t.EXTENT),a=t.clamp(Math.round(n),0,t.EXTENT);e.emplaceBack(s+r,a)}const a=(t,e)=>{const r=e*i+t;n.emplaceBack(r+1,r,r+i),n.emplaceBack(r+i,r+i+1,r+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)a(e,t);return[0,129].forEach((t=>{for(let e=0;e<130;e++)a(e,t),a(t,e)})),[e,n,32768]}(),s=e.context;this.gridBuffer=s.createVertexBuffer(i,t.posAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=t.SegmentVector.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=t.SegmentVector.simpleSegment(0,0,i.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new In(n.map),this.orthoMatrix=t.create(),t.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,t.EXTENT,0,t.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new t.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Cn(n.map)}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(e,n,i){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const r=e.terrain.properties;this.sourceCache=0===e.terrain.drapeRenderMode?this._mockSourceCache:e._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const o=()=>{this.sourceCache.used&&t.warnOnce(`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 e=this.getScaledDemTileSize();this.sourceCache.update(n,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),n.updateElevation(!0,i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&t.warnOnce(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n                may be affected negatively, consider placing all background, fill and line layers before layer\n                with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((t=>t.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=n.getIds().map((t=>{const e=n.getTileByID(t).tileID;return e.projMatrix=i.calculateProjMatrix(e.toUnwrapped()),e}));!function(e,n){const i=n.transform.pointCoordinate(n.transform.getCameraPoint()),r=new t.Point(i.x,i.y);e.sort(((e,n)=>{if(n.overscaledZ-e.overscaledZ)return n.overscaledZ-e.overscaledZ;const i=new t.Point(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),o=new t.Point(n.canonical.x+(1<<n.canonical.z)*n.wrap,n.canonical.y),s=r.mult(1<<e.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(i)-s.distSqr(o)}))}(r,this.painter),this._previousZoom=i.zoom;const o=this.proxyToSource||{};this.proxyToSource={},r.forEach((t=>{this.proxyToSource[t.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const t in s){const n=s[t];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,e[t],o),n.usedForTerrain)continue;const i=e[t];n.getSource().reparseOverscaled&&this._assignTerrainTiles(i)}this.proxiedCoords[n.id]=r.map((t=>new Pn(t,t.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=t.exported.now();const a={};this._visibleDemTiles=[];for(const t of this.proxyCoords){const e=this.terrainTileForTile[t.key];if(!e)continue;const n=e.tileID.key;n in a||(this._visibleDemTiles.push(e),a[n]=n)}}_assignTerrainTiles(t){this._initializing||t.forEach((t=>{if(this.terrainTileForTile[t.key])return;const e=this._findTileCoveringTileID(t,this.sourceCache);e&&(this.terrainTileForTile[t.key]=e)}))}_prepareDEMTextures(){const t=this.painter.context,e=t.gl;for(const n in this.terrainTileForTile){const i=this.terrainTileForTile[n],r=i.dem;!r||i.demTexture&&!i.needsDEMTextureUpload||(t.activeTexture.set(e.TEXTURE1),gn(this.painter,i,r))}}_prepareDemTileUniforms(t,e,n,i){if(!e||null==e.demTexture)return!1;const r=t.tileID.canonical,o=Math.pow(2,e.tileID.canonical.z-r.z),s=i||"";return n[`u_dem_tl${s}`]=[r.x*o%1,r.y*o%1],n[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,n=e.gl;if(!this._emptyDepthBufferTexture){const i=new t.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new t.Texture(e,i,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let t=0;const e=this._visibleDemTiles.reduce(((e,n)=>{if(!n.dem)return e;const i=n.dem.tree.minimums[0];return i>0&&t++,e+i}),0);return t?e/t:0}_updateEmptyDEMTexture(){const e=this.painter.context,n=e.gl;e.activeTexture.set(n.TEXTURE2);const i=this._getLoadedAreaMinimum(),r=new t.RGBAImage({width:1,height:1},new Uint8Array(t.DEMData.pack(i,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(r,{premultiply:!1}):o=this._emptyDEMTexture=new t.Texture(e,r,n.RGBA,{premultiply:!1}),o}setupElevationDraw(e,n,i){const r=this.painter.context,o=r.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:t.DEMData.getUnpackVector(a),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_exaggeration:0});var a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();let l=null,c=null,u=1;if(i&&i.morphing&&this._useVertexMorphing){const t=i.morphing.srcDemTile,n=i.morphing.dstDemTile;u=i.morphing.phase,t&&n&&(this._prepareDemTileUniforms(e,t,s,"_prev")&&(c=t),this._prepareDemTileUniforms(e,n,s)&&(l=n))}if(c&&l?(r.activeTexture.set(o.TEXTURE2),l.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),r.activeTexture.set(o.TEXTURE4),c.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_dem_lerp=u):(l=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(e,l,s)?l.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),r.activeTexture.set(o.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&l){const e=(1<<l.tileID.canonical.z)*t.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=e}if(i&&i.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),n.setTerrainUniformValues(r,s),"globe"===this.painter.transform.projection.name){const t=this.globeUniformValues(this.painter.transform,e.tileID.canonical,i&&i.useDenormalizedUpVectorScale);n.setGlobeUniformValues(r,t)}}globeUniformValues(e,n,i){const r=e.projection;return{u_tile_tl_up:r.upVector(n,0,0),u_tile_tr_up:r.upVector(n,t.EXTENT,0),u_tile_br_up:r.upVector(n,t.EXTENT,t.EXTENT),u_tile_bl_up:r.upVector(n,0,t.EXTENT),u_tile_up_scale:i?t.globeMetersToEcef(1):r.upVectorScale(n,e.center.lat,e.worldSize).metersToTile}}renderToBackBuffer(e){const n=this.painter,i=this.painter.context;0!==e.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,n.width,n.height]),n.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(e,n,i,r,o){if("globe"===e.transform.projection.name)!function(e,n,i,r,o){const s=e.context,a=s.gl;let l,c;const u=e.options.showTerrainWireframe?2:0,h=e.transform,d=t.globeUseCustomAntiAliasing(e,s,h),p=(t,n)=>{if(c===t)return;const i=[En[t],"PROJECTION_GLOBE_VIEW"];d&&i.push("CUSTOM_ANTIALIASING"),n&&i.push(En[u]),l=e.useProgram("globeRaster",null,i),c=t},f=e.colorModeForRenderPass(),m=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);Tn.update(o);const g=t.calculateGlobeMercatorMatrix(h),_=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],y=u?[!1,!0]:[!1],v=e.globeSharedBuffers,x=[h.width*t.exported.devicePixelRatio,h.height*t.exported.devicePixelRatio],b=Float32Array.from(h.globeMatrix),T={useDenormalizedUpVectorScale:!0};if(y.forEach((u=>{const h=e.transform,d=Sn(h.zoom)*n.exaggeration();c=-1;const y=u?a.LINES:a.TRIANGLES;for(const c of r){const r=i.getTile(c),E=t.StencilMode.disabled,S=n.prevTerrainTileForTile[c.key],w=n.terrainTileForTile[c.key];bn(S,w)&&Tn.newMorphing(c.key,S,w,o,250),s.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const A=Tn.getMorphValuesForProxy(c.key),M=A?1:0;A&&t.extend$1(T,{morphing:{srcDemTile:A.from,dstDemTile:A.to,phase:t.easeCubicInOut(A.phase)}});const C=t.tileCornersToBounds(c.canonical),I=t.getLatitudinalLod(C.getCenter().lat),P=t.getGridMatrix(c.canonical,C,I,h.worldSize/h._pixelsPerMercatorPixel),L=t.globeNormalizeECEF(t.globeTileBounds(c.canonical)),R=xn(h.projMatrix,b,g,L,t.globeToMercatorTransition(h.zoom),_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,d,P);if(p(M,u),n.setupElevationDraw(r,l,T),e.prepareDrawProgram(s,l,c.toUnwrapped()),v){const[n,i,r]=u?v.getWirefameBuffers(e.context,I):v.getGridBuffers(I,0!==d);l.draw(s,y,m,E,f,t.CullFaceMode.backCCW,R,"globe_raster",n,i,r)}}})),v){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&o.push("CUSTOM_ANTIALIASING"),l=e.useProgram("globeRaster",null,o);for(const o of r){const{x:r,y:c,z:u}=o.canonical,d=0===c,p=c===(1<<u)-1,[g,y,b,E]=v.getPoleBuffers(u);if(E&&(d||p)){const c=i.getTile(o);s.activeTexture.set(a.TEXTURE0),c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let v=t.globePoleMatrixForTile(u,r,h);const S=t.globeNormalizeECEF(t.globeTileBounds(o.canonical)),w=(e,n)=>e.draw(s,a.TRIANGLES,m,t.StencilMode.disabled,f,t.CullFaceMode.disabled,xn(h.projMatrix,v,v,S,0,_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,0),"globe_pole_raster",n,b,E);n.setupElevationDraw(c,l,T),e.prepareDrawProgram(s,l,o.toUnwrapped()),d&&w(l,g),p&&(v=t.scale(t.create(),v,[1,-1,1]),w(l,y))}}}}(e,n,i,r,o);else{const s=e.context,a=s.gl;let l,c;const u=e.options.showTerrainWireframe?2:0,h=(t,n)=>{if(c===t)return;const i=[En[t]];n&&i.push(En[u]),l=e.useProgram("terrainRaster",null,i),c=t},d=e.colorModeForRenderPass(),p=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);Tn.update(o);const f=e.transform,m=Sn(f.zoom)*n.exaggeration();(u?[!1,!0]:[!1]).forEach((u=>{c=-1;const g=u?a.LINES:a.TRIANGLES,[_,y]=u?n.getWirefameBuffer():[n.gridIndexBuffer,n.gridSegments];for(const c of r){const r=i.getTile(c),v=t.StencilMode.disabled,x=n.prevTerrainTileForTile[c.key],b=n.terrainTileForTile[c.key];bn(x,b)&&Tn.newMorphing(c.key,x,b,o,250),s.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const T=Tn.getMorphValuesForProxy(c.key),E=T?1:0;let S;T&&(S={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:t.easeCubicInOut(T.phase)}});const w=vn(c.projMatrix,wn(c.canonical,f.renderWorldCopies)?m/10:m);h(E,u),n.setupElevationDraw(r,l,S),e.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,g,p,v,d,t.CullFaceMode.backCCW,w,"terrain_raster",n.gridBuffer,_,y)}}))}}(n,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,n.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const n=this.painter,i=this.painter.context,r=this.proxySourceCache,o=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=[],l=n.style.order;let c=0;for(const u of o){const o=r.getTileByID(u.proxyTileKey),h=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][e]:void 0,d=void 0!==h?r.renderCache[h]:this.pool[c++],p=void 0!==h;if(o.texture=d.tex,p&&!d.dirty){a.push(o.tileID);continue}let f;i.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(i.clear({color:t.Color.transparent,stencil:0}),d.dirty=!1);for(let t=s.start;t<=s.end;++t){const e=n.style._layers[l[t]];if(e.isHidden(n.transform.zoom))continue;const r=n.style._getLayerSourceCache(e),o=r?this.proxyToSource[u.key][r.id]:[u];if(!o)continue;const s=o;i.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(d,o,e,r),f=r?r.id:null),n.renderLayer(n,r,e,s)}this.renderedToTile?(d.dirty=!0,a.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,n.width,n.height]),s.end+1}postRender(){}renderCacheEfficiency(t){const e=t.order.length;if(0===e)return{efficiency:100};let n,i=0,r=0,o=!1;for(let s=0;s<e;++s){const e=t._layers[t.order[s]];this._style.isLayerDraped(e)?(o&&++i,++r):o||(o=!0,n=e.id)}return 0===r?{efficiency:100}:{efficiency:100*(1-i/r),firstUndrapedLayer:n}}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter((t=>t.dem)).forEach((e=>{t=Math.min(t,e.dem.tree.minimums[0])})),0===t?t:(t-30)*this._exaggeration}raycast(t,e,n){if(!this._visibleDemTiles)return null;const i=this._visibleDemTiles.filter((t=>t.dem)).map((i=>{const r=i.tileID,o=1<<r.overscaledZ,{x:s,y:a}=r.canonical,l=s/o,c=(s+1)/o,u=a/o,h=(a+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:i.dem.tree.raycastRoot(l,u,c,h,t,e,n),tile:i}}));i.sort(((t,e)=>(null!==t.t?t.t:Number.MAX_VALUE)-(null!==e.t?e.t:Number.MAX_VALUE)));for(const r of i){if(null==r.t)return null;const i=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,t,e,n);if(null!=i)return i}return null}_createFBO(){const e=this.painter.context,n=e.gl,i=this.drapeBufferSize;e.activeTexture.set(n.TEXTURE0);const r=new t.Texture(e,{width:i[0],height:i[1],data:null},n.RGBA);r.bind(n.LINEAR,n.CLAMP_TO_EDGE);const o=e.createFramebuffer(i[0],i[1],!1);return o.colorAttachment.set(r.texture),o.depthAttachment=new Tt(e,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&n.texParameterf(n.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:o,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t].hasTransition())return!0;return this._style.order.some((t=>{const e=this._style._layers[t],n=e.isHidden(this.painter.transform.zoom);return"custom"===e.type?!n&&e.shouldRedrape():!n&&e.hasTransition()}))}_clearLineLayersFromRenderCache(){let e=!1;for(const t of this._style._getSources())if(t instanceof wt){e=!0;break}if(!e)return;const n={};for(let e=0;e<this._style.order.length;++e){const i=this._style._layers[this._style.order[e]],r=this._style._getLayerSourceCache(i);if(r&&!n[r.id]&&!i.isHidden(this.painter.transform.zoom)&&"line"===i.type&&i.widthExpression()instanceof t.ZoomDependentExpression){n[r.id]=!0;for(const t of this.proxyCoords){const e=this.proxyToSource[t.key][r.id];if(e)for(const t of e)this._clearRenderCacheForTile(r.id,t)}}}}_clearRasterLayersFromRenderCache(){let t=!1;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e]._source instanceof At){t=!0;break}if(!t)return;const e={};for(let t=0;t<this._style.order.length;++t){const n=this._style._layers[this._style.order[t]],i=this._style._getLayerSourceCache(n);if(!i||e[i.id])continue;if(n.isHidden(this.painter.transform.zoom)||"raster"!==n.type)continue;const r=n.paint.get("raster-fade-duration");for(const t of this.proxyCoords){const e=this.proxyToSource[t.key][i.id];if(e)for(const t of e){const e=Mn(i.getTile(t),i.findLoadedParent(t,0),i,this.painter.transform,r);(1!==e.opacity||0!==e.mix)&&this._clearRenderCacheForTile(i.id,t)}}}}_setupDrapedRenderBatches(){const t=this._style.order,e=t.length;if(0===e)return;const n=[];let i,r=0,o=this._style._layers[t[r]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++r<e;)o=this._style._layers[t[r]];for(;r<e;++r){const e=this._style._layers[t[r]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===i&&(i=r):void 0!==i&&(n.push({start:i,end:r-1}),i=void 0))}void 0!==i&&n.push({start:i,end:r-1}),this._drapedRenderBatches=n}_setupRenderCache(t){const e=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,e.renderCache.length>e.renderCachePool.length){const t=Object.values(e.proxyCachedFBO);e.proxyCachedFBO={};for(let n=0;n<t.length;++n){const i=Object.values(t[n]);e.renderCachePool.push(...i)}}return}this._clearRasterLayersFromRenderCache();const n=this.proxyCoords,i=this._tilesDirty;for(let r=n.length-1;r>=0;r--){const o=n[r];if(e.getTileByID(o.key),void 0!==e.proxyCachedFBO[o.key]){const n=t[o.key],r=this.proxyToSource[o.key];let s=0;for(const t in r){const e=r[t],o=n[t];if(!o||o.length!==e.length||e.some(((e,n)=>e!==o[n]||i[t]&&i[t].hasOwnProperty(e.key)))){s=-1;break}++s}for(const t in e.proxyCachedFBO[o.key])e.renderCache[e.proxyCachedFBO[o.key][t]].dirty=s<0||s!==Object.values(n).length}}const r=[...this._drapedRenderBatches];r.sort(((t,e)=>e.end-e.start-(t.end-t.start)));for(const t of r)for(const i of n){if(e.proxyCachedFBO[i.key])continue;let n=e.renderCachePool.pop();void 0===n&&e.renderCache.length<50&&(n=e.renderCache.length,e.renderCache.push(this._createFBO())),void 0!==n&&(e.proxyCachedFBO[i.key]={},e.proxyCachedFBO[i.key][t.start]=n,e.renderCache[n].dirty=!0)}this._tilesDirty={}}_setupStencil(t,e,n,i){if(!i||!this._sourceTilesOverlap[i.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,o=r.gl;if(e.length<=1)return void(this._overlapStencilType=!1);let s;if(n.isTileClipped())s=e.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(e[0].overscaledZ>e[e.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(e,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):t.StencilMode.disabled}_renderTileClippingMasks(e,n){const i=this.painter,r=this.painter.context,o=r.gl;i._tileClippingMaskIDs={},r.setColorMode(t.ColorMode.disabled),r.setDepthMode(t.DepthMode.disabled);const s=i.useProgram("clippingMask");for(const a of e){const e=i._tileClippingMaskIDs[a.key]=--n;s.draw(r,o.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:o.ALWAYS,mask:0},e,255,o.KEEP,o.KEEP,o.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,An(a.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(e){const n=this.painter.transform;if(e.x<0||e.x>n.width||e.y<0||e.y>n.height)return null;const i=[e.x,e.y,1,1];t.transformMat4$1(i,i,n.pixelMatrixInverse),t.scale$1(i,i,1/i[3]),i[0]/=n.worldSize,i[1]/=n.worldSize;const r=n._camera.position,o=t.mercatorZfromAltitude(1,n.center.lat),s=[r[0],r[1],r[2]/o,0],a=t.subtract([],i.slice(0,3),s);t.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(t.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const e=this.painter,n=e.context,i=this.proxySourceCache,r=Math.ceil(e.width),o=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=n.gl,i=n.createFramebuffer(r,o,!0);n.activeTexture.set(e.TEXTURE0);const s=new t.Texture(n,{width:r,height:o,data:null},e.RGBA);s.bind(e.NEAREST,e.CLAMP_TO_EDGE),i.colorAttachment.set(s.texture);const a=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,r,o);i.depthAttachment.set(a),this._depthFBO=i,this._depthTexture=s}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,r,o]),function(e,n,i,r){if("globe"===e.transform.projection.name)return;const o=e.context,s=o.gl;o.clear({depth:1});const a=e.useProgram("terrainDepth"),l=new t.DepthMode(s.LESS,t.DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of r){const r=i.getTile(e),c=vn(e.projMatrix,0);n.setupElevationDraw(r,a),a.draw(o,s.TRIANGLES,l,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.backCCW,c,"terrain_depth",n.gridBuffer,n.gridIndexBuffer,n.gridNoSkirtSegments)}}(e,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,e,n){if(t.getSource()instanceof Ct)return this._setupProxiedCoordsForImageSource(t,e,n);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const i=this.proxiedCoords[t.id]=[],r=this.proxyCoords;for(let e=0;e<r.length;e++){const o=r[e],s=this._findTileCoveringTileID(o,t);if(s){const e=this._createProxiedId(o,s,n[o.key]&&n[o.key][t.id]);i.push(e),this.proxyToSource[o.key][t.id]=[e]}}let o=!1;for(let r=0;r<e.length;r++){const s=t.getTile(e[r]);if(!s||!s.hasData())continue;const a=this._findTileCoveringTileID(s.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==s.tileID.canonical.z){const e=this.proxyToSource[a.tileID.key][t.id],r=this._createProxiedId(a.tileID,s,n[a.tileID.key]&&n[a.tileID.key][t.id]);e?e.splice(e.length-1,0,r):this.proxyToSource[a.tileID.key][t.id]=[r],i.push(r),o=!0}}this._sourceTilesOverlap[t.id]=o}_setupProxiedCoordsForImageSource(e,n,i){if(!e.getSource().loaded())return;const r=this.proxiedCoords[e.id]=[],o=this.proxyCoords,s=e.getSource(),a=new t.Point(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(t.MercatorCoordinate.fromLngLat).reduce(((t,e)=>(t.min.x=Math.min(t.min.x,e.x-a.x),t.min.y=Math.min(t.min.y,e.y-a.y),t.max.x=Math.max(t.max.x,e.x-a.x),t.max.y=Math.max(t.max.y,e.y-a.y),t)),{min:new t.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new t.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,n)=>{const i=e.wrap+e.canonical.x/(1<<e.canonical.z),r=e.canonical.y/(1<<e.canonical.z),o=t.EXTENT/(1<<e.canonical.z),s=n.wrap+n.canonical.x/(1<<n.canonical.z),a=n.canonical.y/(1<<n.canonical.z);return i+o<s+l.min.x||i>s+l.max.x||r+o<a+l.min.y||r>a+l.max.y};for(let t=0;t<o.length;t++){const s=o[t];for(let t=0;t<n.length;t++){const o=e.getTile(n[t]);if(!o||!o.hasData())continue;if(c(s,o.tileID))continue;const a=this._createProxiedId(s,o,i[s.key]&&i[s.key][e.id]),l=this.proxyToSource[s.key][e.id];l?l.push(a):this.proxyToSource[s.key][e.id]=[a],r.push(a)}}}_createProxiedId(e,n,i){let r=this.orthoMatrix;if(i){const t=i.find((t=>t.key===n.tileID.key));if(t)return t}if(n.tileID.key!==e.key){const i=e.canonical.z-n.tileID.canonical.z;let o,s,a;r=t.create();const l=n.tileID.wrap-e.wrap<<e.overscaledZ;i>0?(o=t.EXTENT>>i,s=o*((n.tileID.canonical.x<<i)-e.canonical.x+l),a=o*((n.tileID.canonical.y<<i)-e.canonical.y)):(o=t.EXTENT<<-i,s=t.EXTENT*(n.tileID.canonical.x-(e.canonical.x+l<<-i)),a=t.EXTENT*(n.tileID.canonical.y-(e.canonical.y<<-i))),t.ortho(r,0,o,0,o,0,1),t.translate(r,r,[s,a,0])}return new Pn(n.tileID,e.key,r)}_findTileCoveringTileID(e,n){let i=n.getTile(e);if(i&&i.hasData())return i;const r=this._findCoveringTileCache[n.id],o=r[e.key];if(i=o?n.getTileByID(o):null,i&&i.hasData()||null===o)return i;let s=i?i.tileID:e,a=s.overscaledZ;const l=n.getSource().minzoom,c=[];if(!o){const r=n.getSource().maxzoom;if(e.canonical.z>=r){const i=e.canonical.z-r;n.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,n.transform.tileZoom),s=new t.OverscaledTileID(a,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i)):0!==i&&(a=r,s=new t.OverscaledTileID(a,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i))}s.key!==e.key&&(c.push(s.key),i=n.getTile(s))}const u=t=>{c.forEach((e=>{r[e]=t})),c.length=0};for(a-=1;a>=l&&(!i||!i.hasData());a--){i&&u(i.tileID.key);const t=s.calculateScaledKey(a);if(i=n.getTileByID(t),i&&i.hasData())break;const e=r[t];if(null===e)break;void 0===e?c.push(t):i=n.getTileByID(e)}return u(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,e){let n=this._tilesDirty[t];n||(n=this._tilesDirty[t]={}),n[e.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(){let e=0;const n=new t.StructArrayLayout2ui4,i=131;for(let t=1;t<129;t++){for(let r=1;r<129;r++)e=t*i+r,n.emplaceBack(e,e+1),n.emplaceBack(e,e+i),n.emplaceBack(e+1,e+i),128===t&&n.emplaceBack(e+i,e+i+1);n.emplaceBack(e+1,e+1+i)}return n}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=t.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Rn{static cacheKey(t,e,n,i){let r=`${e}${i?i.cacheKey:""}`;for(const e of n)t.usedDefines.includes(e)&&(r+=`/${e}`);return r}constructor(e,n,i,r,o,s){const a=e.gl;this.program=a.createProgram();const l=function(t){const e=[];for(let n=0;n<t.length;n++){if(null===t[n])continue;const i=t[n].split(" ");e.push(i.pop())}return e}(i.staticAttributes),c=r?r.getBinderAttributes():[],u=l.concat(c);let h=r?r.defines():[];h=h.concat(s.map((t=>`#define ${t}`)));const d=e.isWebGL2?"#version 300 es\n":"",p=d+h.concat(e.extStandardDerivatives&&0===d.length?"#extension GL_OES_standard_derivatives : enable\n".concat(cn):cn,cn,ln,an.fragmentSource,on.fragmentSource,i.fragmentSource).join("\n"),f=d+h.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",ln,an.vertexSource,on.vertexSource,rn.vertexSource,i.vertexSource).join("\n"),m=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(m,p),a.compileShader(m),a.attachShader(this.program,m);const g=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(g,f),a.compileShader(g),a.attachShader(this.program,g),this.attributes={},this.numAttributes=u.length;for(let t=0;t<this.numAttributes;t++)u[t]&&(a.bindAttribLocation(this.program,t,u[t]),this.attributes[u[t]]=t);a.linkProgram(this.program),a.deleteShader(g),a.deleteShader(m),this.fixedUniforms=o(e),this.binderUniforms=r?r.getUniforms(e):[],s.includes("TERRAIN")&&(this.terrainUniforms=(e=>({u_dem:new t.Uniform1i(e),u_dem_prev:new t.Uniform1i(e),u_dem_unpack:new t.Uniform4f(e),u_dem_tl:new t.Uniform2f(e),u_dem_scale:new t.Uniform1f(e),u_dem_tl_prev:new t.Uniform2f(e),u_dem_scale_prev:new t.Uniform1f(e),u_dem_size:new t.Uniform1f(e),u_dem_lerp:new t.Uniform1f(e),u_exaggeration:new t.Uniform1f(e),u_depth:new t.Uniform1i(e),u_depth_size_inv:new t.Uniform2f(e),u_meter_to_dem:new t.Uniform1f(e),u_label_plane_matrix_inv:new t.UniformMatrix4f(e)}))(e)),s.includes("GLOBE")&&(this.globeUniforms=(e=>({u_tile_tl_up:new t.Uniform3f(e),u_tile_tr_up:new t.Uniform3f(e),u_tile_br_up:new t.Uniform3f(e),u_tile_bl_up:new t.Uniform3f(e),u_tile_up_scale:new t.Uniform1f(e)}))(e)),s.includes("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new t.UniformMatrix4f(e),u_fog_range:new t.Uniform2f(e),u_fog_color:new t.Uniform4f(e),u_fog_horizon_blend:new t.Uniform1f(e),u_fog_temporal_offset:new t.Uniform1f(e),u_frustum_tl:new t.Uniform3f(e),u_frustum_tr:new t.Uniform3f(e),u_frustum_br:new t.Uniform3f(e),u_frustum_bl:new t.Uniform3f(e),u_globe_pos:new t.Uniform3f(e),u_globe_radius:new t.Uniform1f(e),u_globe_transition:new t.Uniform1f(e),u_is_globe:new t.Uniform1i(e),u_viewport:new t.Uniform2f(e)}))(e))}}setTerrainUniformValues(t,e){if(!this.terrainUniforms)return;const n=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)n[t]&&n[t].set(this.program,t,e[t])}}setGlobeUniformValues(t,e){if(!this.globeUniforms)return;const n=this.globeUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)n[t]&&n[t].set(this.program,t,e[t])}}setFogUniformValues(t,e){if(!this.fogUniforms)return;const n=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)n[t].set(this.program,t,e[t])}}draw(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f){const m=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(n),t.setStencilMode(i),t.setColorMode(r),t.setCullFace(o);for(const t of Object.keys(this.fixedUniforms))this.fixedUniforms[t].set(this.program,t,s[t]);p&&p.setUniforms(this.program,t,this.binderUniforms,h,{zoom:d});const g={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[e];for(const n of u.get()){const i=n.vaos||(n.vaos={});(i[a]||(i[a]=new pn)).bind(t,this,l,p?p.getPaintVertexBuffers():[],c,n.vertexOffset,f||[]),m.drawElements(e,n.primitiveLength*g,m.UNSIGNED_SHORT,n.primitiveOffset*g*2)}}}function On(t,e){const n=Math.pow(2,e.tileID.overscaledZ),i=e.tileSize*Math.pow(2,t.transform.tileZoom)/n,r=i*(e.tileID.canonical.x+e.tileID.wrap*n),o=i*e.tileID.canonical.y;return{u_image:0,u_texsize:e.imageAtlasTexture.size,u_tile_units_to_pixels:1/P(e,1,t.transform.tileZoom),u_pixel_coord_upper:[r>>16,o>>16],u_pixel_coord_lower:[65535&r,65535&o]}}const Dn=t.create(),Bn=(e,n,i,r,o,s,a,l,c,u,h)=>{const d=n.style.light,p=d.properties.get("position"),f=[p.x,p.y,p.z],m=t.create$1();"viewport"===d.properties.get("anchor")&&(t.fromRotation(m,-n.transform.angle),t.transformMat3(f,f,m));const g=d.properties.get("color"),_=n.transform,y={u_matrix:e,u_lightpos:f,u_lightintensity:d.properties.get("intensity"),u_lightcolor:[g.r,g.g,g.b],u_vertical_gradient:+i,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Dn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:s};return"globe"===_.projection.name&&(y.u_tile_id=[a.canonical.x,a.canonical.y,1<<a.canonical.z],y.u_zoom_transition=c,y.u_inv_rot_matrix=h,y.u_merc_center=u,y.u_up_dir=_.projection.upVector(new t.CanonicalTileID(0,0,0),u[0]*t.EXTENT,u[1]*t.EXTENT),y.u_height_lift=l),y},Nn=(e,n,i,r,o,s,a,l,c,u,h,d)=>{const p=Bn(e,n,i,r,o,s,a,c,u,h,d),f={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return t.extend(p,On(n,l),f)},Fn=t=>({u_matrix:t}),Un=(e,n,i)=>t.extend(Fn(e),On(n,i)),kn=(t,e)=>({u_matrix:t,u_world:e}),zn=(e,n,i,r)=>t.extend(Un(e,n,i),{u_world:r}),Gn=t.create(),Vn=(e,n,i,r,o,s)=>{const a=e.transform,l="globe"===a.projection.name;let c;if("map"===s.paint.get("circle-pitch-alignment"))if(l){const e=t.globePixelsToTileUnits(a.zoom,n.canonical)*a._pixelsPerMercatorPixel;c=Float32Array.from([e,0,0,e])}else c=a.calculatePixelsToTileUnitsMatrix(i);else c=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:e.translatePosMatrix(n.projMatrix,i,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:t.exported.devicePixelRatio,u_extrude_scale:c,u_inv_rot_matrix:Gn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=r,u.u_merc_center=o,u.u_tile_id=[n.canonical.x,n.canonical.y,1<<n.canonical.z],u.u_zoom_transition=t.globeToMercatorTransition(a.zoom);const e=o[0]*t.EXTENT,i=o[1]*t.EXTENT;u.u_up_dir=a.projection.upVector(new t.CanonicalTileID(0,0,0),e,i)}return u},jn=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e},$n=(e,n,i,r)=>{const o=t.EXTENT/i.tileSize;return{u_matrix:e,u_camera_to_center_distance:n.getCameraToCenterDistance(r),u_extrude_scale:[n.pixelsToGLUnits[0]/o,n.pixelsToGLUnits[1]/o]}},Hn=(t,e,n=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:n}),Wn=t.create(),qn=(e,n,i,r,o,s,a)=>{const l=e.transform,c="globe"===l.projection.name,u=c?t.globePixelsToTileUnits(l.zoom,n.canonical)*l._pixelsPerMercatorPixel:P(i,1,s),h={u_matrix:n.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:Wn,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=o,h.u_tile_id=[n.canonical.x,n.canonical.y,1<<n.canonical.z],h.u_zoom_transition=t.globeToMercatorTransition(l.zoom);const e=o[0]*t.EXTENT,i=o[1]*t.EXTENT;h.u_up_dir=l.projection.upVector(new t.CanonicalTileID(0,0,0),e,i)}return h},Xn=(t,e,n,i,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:Jn(t,e,n,i),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:Kn(n)?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Zn(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s}},Yn=(t,e,n,i,r)=>{const o=t.transform;return{u_matrix:Jn(t,e,n,i),u_texsize:e.imageAtlasTexture.size,u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:Zn(e,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Zn(t,e){return 1/P(t,1,e.tileZoom)}function Jn(t,e,n,i){return t.translatePosMatrix(i||e.tileID.projMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}function Kn(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const Qn=(t,e,n,i,r,o)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:n,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(a=r.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=r.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:ti(r.paint.get("raster-hue-rotate")),u_perspective_transform:o};var s,a};function ti(t){t*=Math.PI/180;const e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const ei=t.create(),ni=(e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g)=>{const _=o.transform,y={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+r,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ei,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:ei,u_up_vector:[0,-1,0]};return"globe"===g.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],y.u_zoom_transition=d,y.u_inv_rot_matrix=f,y.u_merc_center=p,y.u_camera_forward=_._camera.forward(),y.u_ecef_origin=t.globeECEFOrigin(_.globeMatrix,h.toUnwrapped()),y.u_tile_matrix=Float32Array.from(_.globeMatrix),y.u_up_vector=m),y},ii=(e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_)=>t.extend(ni(e,n,i,r,o,s,a,l,c,u,d,p,f,m,g,_),{u_gamma_scale:r?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:t.exported.devicePixelRatio,u_is_halo:+h}),ri=(e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g)=>t.extend(ii(e,n,i,r,o,s,a,l,!0,c,!0,h,d,p,f,m,g),{u_texsize_icon:u,u_texture_icon:1}),oi=(t,e,n)=>({u_matrix:t,u_opacity:e,u_color:n}),si=(e,n,i,r,o)=>t.extend(function(t,e,n){const i=e.imageManager.getPattern(t.toString()),{width:r,height:o}=e.imageManager.getPixelSize(),s=Math.pow(2,n.tileID.overscaledZ),a=n.tileSize*Math.pow(2,e.transform.tileZoom)/s,l=a*(n.tileID.canonical.x+n.tileID.wrap*s),c=a*n.tileID.canonical.y;return{u_image:0,u_pattern_tl:i.tl,u_pattern_br:i.br,u_texsize:[r,o],u_pattern_size:i.displaySize,u_tile_units_to_pixels:1/P(n,1,e.transform.tileZoom),u_pixel_coord_upper:[l>>16,c>>16],u_pixel_coord_lower:[65535&l,65535&c]}}(r,i,o),{u_matrix:e,u_opacity:n}),ai={fillExtrusion:e=>({u_matrix:new t.UniformMatrix4f(e),u_lightpos:new t.Uniform3f(e),u_lightintensity:new t.Uniform1f(e),u_lightcolor:new t.Uniform3f(e),u_vertical_gradient:new t.Uniform1f(e),u_opacity:new t.Uniform1f(e),u_edge_radius:new t.Uniform1f(e),u_ao:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_up_dir:new t.Uniform3f(e),u_height_lift:new t.Uniform1f(e)}),fillExtrusionPattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_lightpos:new t.Uniform3f(e),u_lightintensity:new t.Uniform1f(e),u_lightcolor:new t.Uniform3f(e),u_vertical_gradient:new t.Uniform1f(e),u_height_factor:new t.Uniform1f(e),u_edge_radius:new t.Uniform1f(e),u_ao:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_up_dir:new t.Uniform3f(e),u_height_lift:new t.Uniform1f(e),u_image:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_pixel_coord_upper:new t.Uniform2f(e),u_pixel_coord_lower:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e),u_opacity:new t.Uniform1f(e)}),fill:e=>({u_matrix:new t.UniformMatrix4f(e)}),fillPattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_image:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_pixel_coord_upper:new t.Uniform2f(e),u_pixel_coord_lower:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e)}),fillOutline:e=>({u_matrix:new t.UniformMatrix4f(e),u_world:new t.Uniform2f(e)}),fillOutlinePattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_world:new t.Uniform2f(e),u_image:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_pixel_coord_upper:new t.Uniform2f(e),u_pixel_coord_lower:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e)}),circle:e=>({u_camera_to_center_distance:new t.Uniform1f(e),u_extrude_scale:new t.UniformMatrix2f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_up_dir:new t.Uniform3f(e)}),collisionBox:e=>({u_matrix:new t.UniformMatrix4f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_extrude_scale:new t.Uniform2f(e)}),collisionCircle:e=>({u_matrix:new t.UniformMatrix4f(e),u_inv_matrix:new t.UniformMatrix4f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_viewport_size:new t.Uniform2f(e)}),debug:e=>({u_color:new t.UniformColor(e),u_matrix:new t.UniformMatrix4f(e),u_overlay:new t.Uniform1i(e),u_overlay_scale:new t.Uniform1f(e)}),clippingMask:e=>({u_matrix:new t.UniformMatrix4f(e)}),heatmap:e=>({u_extrude_scale:new t.Uniform1f(e),u_intensity:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_up_dir:new t.Uniform3f(e)}),heatmapTexture:e=>({u_image:new t.Uniform1i(e),u_color_ramp:new t.Uniform1i(e),u_opacity:new t.Uniform1f(e)}),hillshade:e=>({u_matrix:new t.UniformMatrix4f(e),u_image:new t.Uniform1i(e),u_latrange:new t.Uniform2f(e),u_light:new t.Uniform2f(e),u_shadow:new t.UniformColor(e),u_highlight:new t.UniformColor(e),u_accent:new t.UniformColor(e)}),hillshadePrepare:e=>({u_matrix:new t.UniformMatrix4f(e),u_image:new t.Uniform1i(e),u_dimension:new t.Uniform2f(e),u_zoom:new t.Uniform1f(e),u_unpack:new t.Uniform4f(e)}),line:e=>({u_matrix:new t.UniformMatrix4f(e),u_pixels_to_tile_units:new t.UniformMatrix2f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_units_to_pixels:new t.Uniform2f(e),u_dash_image:new t.Uniform1i(e),u_gradient_image:new t.Uniform1i(e),u_image_height:new t.Uniform1f(e),u_texsize:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e),u_alpha_discard_threshold:new t.Uniform1f(e),u_trim_offset:new t.Uniform2f(e)}),linePattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_texsize:new t.Uniform2f(e),u_pixels_to_tile_units:new t.UniformMatrix2f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_image:new t.Uniform1i(e),u_units_to_pixels:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e),u_alpha_discard_threshold:new t.Uniform1f(e)}),raster:e=>({u_matrix:new t.UniformMatrix4f(e),u_tl_parent:new t.Uniform2f(e),u_scale_parent:new t.Uniform1f(e),u_fade_t:new t.Uniform1f(e),u_opacity:new t.Uniform1f(e),u_image0:new t.Uniform1i(e),u_image1:new t.Uniform1i(e),u_brightness_low:new t.Uniform1f(e),u_brightness_high:new t.Uniform1f(e),u_saturation_factor:new t.Uniform1f(e),u_contrast_factor:new t.Uniform1f(e),u_spin_weights:new t.Uniform3f(e),u_perspective_transform:new t.Uniform2f(e)}),symbolIcon:e=>({u_is_size_zoom_constant:new t.Uniform1i(e),u_is_size_feature_constant:new t.Uniform1i(e),u_size_t:new t.Uniform1f(e),u_size:new t.Uniform1f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_rotate_symbol:new t.Uniform1i(e),u_aspect_ratio:new t.Uniform1f(e),u_fade_change:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_label_plane_matrix:new t.UniformMatrix4f(e),u_coord_matrix:new t.UniformMatrix4f(e),u_is_text:new t.Uniform1i(e),u_pitch_with_map:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_camera_forward:new t.Uniform3f(e),u_tile_matrix:new t.UniformMatrix4f(e),u_up_vector:new t.Uniform3f(e),u_ecef_origin:new t.Uniform3f(e),u_texture:new t.Uniform1i(e)}),symbolSDF:e=>({u_is_size_zoom_constant:new t.Uniform1i(e),u_is_size_feature_constant:new t.Uniform1i(e),u_size_t:new t.Uniform1f(e),u_size:new t.Uniform1f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_rotate_symbol:new t.Uniform1i(e),u_aspect_ratio:new t.Uniform1f(e),u_fade_change:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_label_plane_matrix:new t.UniformMatrix4f(e),u_coord_matrix:new t.UniformMatrix4f(e),u_is_text:new t.Uniform1i(e),u_pitch_with_map:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_texture:new t.Uniform1i(e),u_gamma_scale:new t.Uniform1f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_camera_forward:new t.Uniform3f(e),u_tile_matrix:new t.UniformMatrix4f(e),u_up_vector:new t.Uniform3f(e),u_ecef_origin:new t.Uniform3f(e),u_is_halo:new t.Uniform1i(e)}),symbolTextAndIcon:e=>({u_is_size_zoom_constant:new t.Uniform1i(e),u_is_size_feature_constant:new t.Uniform1i(e),u_size_t:new t.Uniform1f(e),u_size:new t.Uniform1f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_rotate_symbol:new t.Uniform1i(e),u_aspect_ratio:new t.Uniform1f(e),u_fade_change:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_label_plane_matrix:new t.UniformMatrix4f(e),u_coord_matrix:new t.UniformMatrix4f(e),u_is_text:new t.Uniform1i(e),u_pitch_with_map:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_texsize_icon:new t.Uniform2f(e),u_texture:new t.Uniform1i(e),u_texture_icon:new t.Uniform1i(e),u_gamma_scale:new t.Uniform1f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_is_halo:new t.Uniform1i(e)}),background:e=>({u_matrix:new t.UniformMatrix4f(e),u_opacity:new t.Uniform1f(e),u_color:new t.UniformColor(e)}),backgroundPattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_opacity:new t.Uniform1f(e),u_image:new t.Uniform1i(e),u_pattern_tl:new t.Uniform2f(e),u_pattern_br:new t.Uniform2f(e),u_texsize:new t.Uniform2f(e),u_pattern_size:new t.Uniform2f(e),u_pixel_coord_upper:new t.Uniform2f(e),u_pixel_coord_lower:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e)}),terrainRaster:yn,terrainDepth:yn,skybox:e=>({u_matrix:new t.UniformMatrix4f(e),u_sun_direction:new t.Uniform3f(e),u_cubemap:new t.Uniform1i(e),u_opacity:new t.Uniform1f(e),u_temporal_offset:new t.Uniform1f(e)}),skyboxGradient:e=>({u_matrix:new t.UniformMatrix4f(e),u_color_ramp:new t.Uniform1i(e),u_center_direction:new t.Uniform3f(e),u_radius:new t.Uniform1f(e),u_opacity:new t.Uniform1f(e),u_temporal_offset:new t.Uniform1f(e)}),skyboxCapture:e=>({u_matrix_3f:new t.UniformMatrix3f(e),u_sun_direction:new t.Uniform3f(e),u_sun_intensity:new t.Uniform1f(e),u_color_tint_r:new t.Uniform4f(e),u_color_tint_m:new t.Uniform4f(e),u_luminance:new t.Uniform1f(e)}),globeRaster:e=>({u_proj_matrix:new t.UniformMatrix4f(e),u_globe_matrix:new t.UniformMatrix4f(e),u_normalize_matrix:new t.UniformMatrix4f(e),u_merc_matrix:new t.UniformMatrix4f(e),u_zoom_transition:new t.Uniform1f(e),u_merc_center:new t.Uniform2f(e),u_image0:new t.Uniform1i(e),u_grid_matrix:new t.UniformMatrix3f(e),u_skirt_height:new t.Uniform1f(e),u_frustum_tl:new t.Uniform3f(e),u_frustum_tr:new t.Uniform3f(e),u_frustum_br:new t.Uniform3f(e),u_frustum_bl:new t.Uniform3f(e),u_globe_pos:new t.Uniform3f(e),u_globe_radius:new t.Uniform1f(e),u_viewport:new t.Uniform2f(e)}),globeAtmosphere:e=>({u_frustum_tl:new t.Uniform3f(e),u_frustum_tr:new t.Uniform3f(e),u_frustum_br:new t.Uniform3f(e),u_frustum_bl:new t.Uniform3f(e),u_horizon:new t.Uniform1f(e),u_transition:new t.Uniform1f(e),u_fadeout_range:new t.Uniform1f(e),u_color:new t.Uniform4f(e),u_high_color:new t.Uniform4f(e),u_space_color:new t.Uniform4f(e),u_star_intensity:new t.Uniform1f(e),u_star_density:new t.Uniform1f(e),u_star_size:new t.Uniform1f(e),u_temporal_offset:new t.Uniform1f(e),u_horizon_angle:new t.Uniform1f(e),u_rotation_matrix:new t.UniformMatrix4f(e)})};let li;function ci(e,n,i,r,o,s,a){const l=e.context,c=l.gl,u=e.transform,h=e.useProgram("collisionBox"),d=[];let p=0,f=0;for(let m=0;m<r.length;m++){const g=r[m],_=n.getTile(g),y=_.getBucket(i);if(!y)continue;const v=ye(g,y,u);let x=v;0===o[0]&&0===o[1]||(x=e.translatePosMatrix(v,_,o,s));const b=a?y.textCollisionBox:y.iconCollisionBox,T=y.collisionCircleArray;if(T.length>0){const e=t.create(),n=x;t.mul(e,y.placementInvProjMatrix,u.glCoordMatrix),t.mul(e,e,y.placementViewportMatrix),d.push({circleArray:T,circleOffset:f,transform:n,invTransform:e,projection:y.getProjection()}),p+=T.length/4,f=p}b&&(e.terrain&&e.terrain.setupElevationDraw(_,h),h.draw(l,c.LINES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,$n(x,u,_,y.getProjection()),i.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,u.zoom,null,[b.collisionVertexBuffer,b.collisionVertexBufferExt]))}if(!a||!d.length)return;const m=e.useProgram("collisionCircle"),g=new t.StructArrayLayout2f1f2i16;g.resize(4*p),g._trim();let _=0;for(const t of d)for(let e=0;e<t.circleArray.length/4;e++){const n=4*e,i=t.circleArray[n+0],r=t.circleArray[n+1],o=t.circleArray[n+2],s=t.circleArray[n+3];g.emplace(_++,i,r,o,s,0),g.emplace(_++,i,r,o,s,1),g.emplace(_++,i,r,o,s,2),g.emplace(_++,i,r,o,s,3)}(!li||li.length<2*p)&&(li=function(e){const n=2*e,i=new t.StructArrayLayout3ui6;i.resize(n),i._trim();for(let t=0;t<n;t++){const e=6*t;i.uint16[e+0]=4*t+0,i.uint16[e+1]=4*t+1,i.uint16[e+2]=4*t+2,i.uint16[e+3]=4*t+2,i.uint16[e+4]=4*t+3,i.uint16[e+5]=4*t+0}return i}(p));const y=l.createIndexBuffer(li,!0),v=l.createVertexBuffer(g,t.collisionCircleLayout.members,!0);for(const n of d){const r={u_matrix:n.transform,u_inv_matrix:n.invTransform,u_camera_to_center_distance:(x=u).getCameraToCenterDistance(n.projection),u_viewport_size:[x.width,x.height]};m.draw(l,c.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,r,i.id,v,y,t.SegmentVector.simpleSegment(0,2*n.circleOffset,n.circleArray.length,n.circleArray.length/2),null,u.zoom)}var x;v.destroy(),y.destroy()}const ui=t.create();function hi({width:e,height:n,anchor:i,textOffset:r,textScale:o},s){const{horizontalAlign:a,verticalAlign:l}=t.getAnchorAlignment(i),c=-(a-.5)*e,u=-(l-.5)*n,h=t.evaluateVariableOffset(i,r);return new t.Point((c/o+h[0])*s,(u/o+h[1])*s)}function di(e,n,i,r,o,s,a,l,c,u,h){const d=e.text.placedSymbolArray,p=e.text.dynamicLayoutVertexArray,f=e.icon.dynamicLayoutVertexArray,m={},g=e.getProjection(),_=ve(l,g,s),y=s.elevation,v=g.upVectorScale(l.canonical,s.center.lat,s.worldSize).metersToTile;p.clear();for(let f=0;f<d.length;f++){const x=d.get(f),{tileAnchorX:b,tileAnchorY:T,numGlyphs:E}=x,S=x.hidden||!x.crossTileID||e.allowVerticalPlacement&&!x.placedOrientation?null:r[x.crossTileID];if(S){let r=0,d=0,f=0;if(y){const t=y?y.getAtTileOffset(l,b,T):0,[e,n,i]=g.upVector(l.canonical,b,T);r=t*e*v,d=t*n*v,f=t*i*v}let[w,A,M,C]=ie(x.projectedAnchorX+r,x.projectedAnchorY+d,x.projectedAnchorZ+f,i?_:a);const I=re(s.getCameraToCenterDistance(g),C);let P=o.evaluateSizeForFeature(e.textSizeData,u,x)*I/t.ONE_EM;i&&(P*=e.tilePixelRatio/c);const L=hi(S,P);i?(({x:w,y:A,z:M}=g.projectTilePoint(b+L.x,T+L.y,l.canonical)),[w,A,M]=ie(w+r,A+d,M+f,a)):(n&&L._rotate(-s.angle),w+=L.x,A+=L.y,M=0);const R=e.allowVerticalPlacement&&x.placedOrientation===t.WritingMode.vertical?Math.PI/2:0;for(let e=0;e<E;e++)t.addDynamicAttributes(p,w,A,M,R);h&&x.associatedIconIndex>=0&&(m[x.associatedIconIndex]={x:w,y:A,z:M,angle:R})}else pe(E,p)}if(h){f.clear();const n=e.icon.placedSymbolArray;for(let e=0;e<n.length;e++){const i=n.get(e),{numGlyphs:r}=i,o=m[e];if(i.hidden||!o)pe(r,f);else{const{x:e,y:n,z:i,angle:s}=o;for(let o=0;o<r;o++)t.addDynamicAttributes(f,e,n,i,s)}}e.icon.dynamicLayoutVertexBuffer.updateData(f)}e.text.dynamicLayoutVertexBuffer.updateData(p)}function pi(t,e,n){return n.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function fi(e,n,i,r,o,s,a,l,c,u,h,d){const p=e.context,f=p.gl,m=e.transform,g="map"===l,_="map"===c,y=g&&"point"!==i.layout.get("symbol-placement"),v=g&&!_&&!y,x=void 0!==i.layout.get("symbol-sort-key").constantOr(1);let b=!1;const T=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),E=[t.mercatorXfromLng(m.center.lng),t.mercatorYfromLat(m.center.lat)],S=i.layout.get("text-variable-anchor"),w="globe"===m.projection.name,A=[],M=[0,-1,0];let C=M;!w&&!m.mercatorFromTransition||g||(C=function(e){const n=e._camera.getWorldToCamera(e.worldSize,1),i=t.multiply([],n,e.globeMatrix);t.invert(i,i);const r=[0,0,0],o=[0,1,0,0];return t.transformMat4$1(o,o,i),r[0]=o[0],r[1]=o[1],r[2]=o[2],t.normalize(r,r),r}(m));for(const l of r){const r=n.getTile(l),c=r.getBucket(i);if(!c)continue;if("mercator"===c.projection.name&&w)continue;const h=o?c.text:c.icon;if(!h||c.fullyClipped||!h.segments.get().length)continue;const d=h.programConfigurations.get(i.id),p=o||c.sdfIcons,T=o?c.textSizeData:c.iconSizeData,I=_||0!==m.pitch,P=t.evaluateSizeForZoom(T,m.zoom);let L,R,O,D,B=[0,0],N=null;if(o)R=r.glyphAtlasTexture,O=f.LINEAR,L=r.glyphAtlasTexture.size,c.iconsInText&&(B=r.imageAtlasTexture.size,N=r.imageAtlasTexture,D=I||e.options.rotating||e.options.zooming||"composite"===T.kind||"camera"===T.kind?f.LINEAR:f.NEAREST);else{const t=1!==i.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;R=r.imageAtlasTexture,O=p||e.options.rotating||e.options.zooming||t||I?f.LINEAR:f.NEAREST,L=r.imageAtlasTexture.size}const F="globe"===c.projection.name,U=F?C:M,k=F?t.globeToMercatorTransition(m.zoom):0,z=ve(l,c.getProjection(),m),G=m.calculatePixelsToTileUnitsMatrix(r),V=te(z,r.tileID.canonical,_,g,m,c.getProjection(),G),j=e.terrain&&_&&y?t.invert(t.create(),V):ui,$=ne(z,r.tileID.canonical,_,g,m,c.getProjection(),G),H=S&&c.hasTextData(),W="none"!==i.layout.get("icon-text-fit")&&H&&c.hasIconData();if(y){const t=m.elevation,n=t?t.getAtTileOffsetFunc(l,m.center.lat,m.worldSize,c.getProjection()):null,i=ee(z,r.tileID.canonical,_,g,m,c.getProjection(),G);se(c,z,e,o,i,$,_,u,n,l)}const q=y||o&&S||W,X=e.translatePosMatrix(z,r,s,a),Y=q?ui:V,Z=e.translatePosMatrix($,r,s,a,!0),J=c.getProjection().createInversionMatrix(m,l.canonical),K=[];e.terrainRenderModeElevated()&&_&&K.push("PITCH_WITH_MAP_TERRAIN"),F&&K.push("PROJECTION_GLOBE_VIEW"),q&&K.push("PROJECTED_POS_ON_VIEWPORT");const Q=p&&0!==i.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let tt;tt=p?c.iconsInText?ri(T.kind,P,v,_,e,X,Y,Z,L,B,l,k,E,J,U,c.getProjection()):ii(T.kind,P,v,_,e,X,Y,Z,o,L,!0,l,k,E,J,U,c.getProjection()):ni(T.kind,P,v,_,e,X,Y,Z,o,L,l,k,E,J,U,c.getProjection());const et={program:e.useProgram(pi(p,o,c),d,K),buffers:h,uniformValues:tt,atlasTexture:R,atlasTextureIcon:N,atlasInterpolation:O,atlasInterpolationIcon:D,isSDF:p,hasHalo:Q,tile:r,labelPlaneMatrixInv:j};if(x&&c.canOverlap){b=!0;const e=h.segments.get();for(const n of e)A.push({segments:new t.SegmentVector([n]),sortKey:n.sortKey,state:et})}else A.push({segments:h.segments,sortKey:0,state:et})}b&&A.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of A){const n=t.state;if(e.terrain&&e.terrain.setupElevationDraw(n.tile,n.program,{useDepthForOcclusion:!w,labelPlaneMatrixInv:n.labelPlaneMatrixInv}),p.activeTexture.set(f.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,f.CLAMP_TO_EDGE),n.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),n.isSDF){const r=n.uniformValues;n.hasHalo&&(r.u_is_halo=1,mi(n.buffers,t.segments,i,e,n.program,T,h,d,r)),r.u_is_halo=0}mi(n.buffers,t.segments,i,e,n.program,T,h,d,n.uniformValues)}}function mi(e,n,i,r,o,s,a,l,c){const u=r.context,h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.globeExtVertexBuffer];o.draw(u,u.gl.TRIANGLES,s,a,l,t.CullFaceMode.disabled,c,i.id,e.layoutVertexBuffer,e.indexBuffer,n,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),h)}function gi(e,n,i,r,o,s,a){const l=e.context.gl,c=i.paint.get("fill-pattern"),u=c&&c.constantOr(1);let h,d,p,f,m;a?(d=u&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=l.LINES):(d=u?"fillPattern":"fill",h=l.TRIANGLES);for(const g of r){const r=n.getTile(g);if(u&&!r.patternsLoaded())continue;const _=r.getBucket(i);if(!_)continue;e.prepareDrawTile();const y=_.programConfigurations.get(i.id),v=e.useProgram(d,y);u&&(e.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),y.updatePaintBuffers());const x=c.constantOr(null);if(x&&r.imageAtlas){const t=r.imageAtlas.patternPositions[x.toString()];t&&y.setConstantPatternPositions(t)}const b=e.translatePosMatrix(g.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){f=_.indexBuffer2,m=_.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];p="fillOutlinePattern"===d&&u?zn(b,e,r,t):kn(b,t)}else f=_.indexBuffer,m=_.segments,p=u?Un(b,e,r):Fn(b);e.prepareDrawProgram(e.context,v,g.toUnwrapped()),v.draw(e.context,h,o,e.stencilModeForClipping(g),s,t.CullFaceMode.disabled,p,i.id,_.layoutVertexBuffer,f,m,i.paint,e.transform.zoom,y)}}function _i(e,n,i,r,o,s,a){const l=e.context,c=l.gl,u=e.transform,h=i.paint.get("fill-extrusion-pattern"),d=h.constantOr(1),p=i.paint.get("fill-extrusion-opacity"),f=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),i.paint.get("fill-extrusion-ambient-occlusion-radius")],m=i.layout.get("fill-extrusion-edge-radius"),g=m>0&&!i.paint.get("fill-extrusion-rounded-roof"),_=g?0:m,y="globe"===u.projection.name?t.fillExtrusionHeightLift():0,v="globe"===u.projection.name,x=v?t.globeToMercatorTransition(u.zoom):0,b=[t.mercatorXfromLng(u.center.lng),t.mercatorYfromLat(u.center.lat)],T=[];v&&T.push("PROJECTION_GLOBE_VIEW"),f[0]>0&&T.push("FAUX_AO"),g&&T.push("ZERO_ROOF_RADIUS");for(const m of r){const r=n.getTile(m),g=r.getBucket(i);if(!g||g.projection.name!==u.projection.name)continue;const E=g.programConfigurations.get(i.id),S=e.useProgram(d?"fillExtrusionPattern":"fillExtrusion",E,T);if(e.terrain){const t=e.terrain;if(e.style.terrainSetForDrapingOnly())t.setupElevationDraw(r,S,{useMeterToDem:!0});else{if(!g.enableTerrain)continue;if(t.setupElevationDraw(r,S,{useMeterToDem:!0}),yi(l,n,m,g,i,t),!g.centroidVertexBuffer){const t=S.attributes.a_centroid_pos;void 0!==t&&c.vertexAttrib2f(t,0,0)}}}d&&(e.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),E.updatePaintBuffers());const w=h.constantOr(null);if(w&&r.imageAtlas){const t=r.imageAtlas.patternPositions[w.toString()];t&&E.setConstantPatternPositions(t)}const A=e.translatePosMatrix(m.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),M=u.projection.createInversionMatrix(u,m.canonical),C=i.paint.get("fill-extrusion-vertical-gradient"),I=d?Nn(A,e,C,p,f,_,m,r,y,x,b,M):Bn(A,e,C,p,f,_,m,y,x,b,M);e.prepareDrawProgram(l,S,m.toUnwrapped());const P=[];e.terrain&&P.push(g.centroidVertexBuffer),v&&P.push(g.layoutVertexExtBuffer),S.draw(l,l.gl.TRIANGLES,o,s,a,t.CullFaceMode.backCCW,I,i.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,i.paint,e.transform.zoom,E,P)}}function yi(e,n,i,r,o,s){const a=[e=>{let n=e.canonical.x-1,i=e.wrap;return n<0&&(n=(1<<e.canonical.z)-1,i--),new t.OverscaledTileID(e.overscaledZ,i,e.canonical.z,n,e.canonical.y)},e=>{let n=e.canonical.x+1,i=e.wrap;return n===1<<e.canonical.z&&(n=0,i++),new t.OverscaledTileID(e.overscaledZ,i,e.canonical.z,n,e.canonical.y)},e=>new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)],l=t=>{const e=n.getSource().minzoom,i=t=>{const e=n.getTileByID(t);if(e&&e.hasData())return e.getBucket(o)},r=[0,-1,1];for(const n of r){if(t.overscaledZ+n<e)continue;const r=i(t.calculateScaledKey(t.overscaledZ+n));if(r)return r}},c=[0,0,0],u=(e,n)=>(c[0]=Math.min(e.min.y,n.min.y),c[1]=Math.max(e.max.y,n.max.y),c[2]=t.EXTENT-n.min.x>e.max.x?n.min.x-t.EXTENT:e.max.x,c),h=(e,n)=>(c[0]=Math.min(e.min.x,n.min.x),c[1]=Math.max(e.max.x,n.max.x),c[2]=t.EXTENT-n.min.y>e.max.y?n.min.y-t.EXTENT:e.max.y,c),d=[(t,e)=>u(t,e),(t,e)=>u(e,t),(t,e)=>h(t,e),(t,e)=>h(e,t)],p=new t.Point(0,0);let f,m,g;const _=(e,n,r,o,a)=>{const l=[[o?r:e,o?e:r,0],[o?r:n,o?n:r,0]],c=a<0?t.EXTENT+a:a,u=[o?c:(e+n)/2,o?(e+n)/2:c,0];return 0===r&&a<0||0!==r&&a>0?s.getForTilePoints(g,[u],!0,m):l.push(u),s.getForTilePoints(i,l,!0,f),Math.max(l[0][2],l[1][2],u[2])/s.exaggeration()};for(let e=0;e<4;e++){const n=(e<2?1:5)-e,o=r.borders[e];if(0===o.length)continue;const c=g=a[e](i),u=l(c);if(!(u&&u instanceof t.FillExtrusionBucket&&u.enableTerrain))continue;if(r.borderDoneWithNeighborZ[e]===u.canonical.z&&u.borderDoneWithNeighborZ[n]===r.canonical.z)continue;if(m=s.findDEMTileFor(c),!m||!m.dem)continue;if(!f){const t=s.findDEMTileFor(i);if(!t||!t.dem)return;f=t}const h=u.borders[n];let y=0;const v=u.borderDoneWithNeighborZ[n]!==r.canonical.z;if(r.canonical.z===u.canonical.z){for(let i=0;i<o.length;i++){const s=r.featuresOnBorder[o[i]],a=s.borders[e];let l;for(;y<h.length&&(l=u.featuresOnBorder[h[y]],!(l.borders[n][1]>a[0]+3));)v&&u.encodeCentroid(void 0,l,!1),y++;if(l&&y<h.length){const i=y;let o=0;for(;!(l.borders[n][0]>a[1]-3)&&(o++,++y!==h.length);)l=u.featuresOnBorder[h[y]];if(l=u.featuresOnBorder[h[i]],s.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=i),r.encodeCentroid(void 0,s,!1),v&&u.encodeCentroid(void 0,l,!1);continue}const c=d[e](s,l),f=e%2?t.EXTENT-1:0;p.x=_(c[0],Math.min(t.EXTENT-1,c[1]),f,e<2,c[2]),p.y=0,r.encodeCentroid(p,s,!1),v&&u.encodeCentroid(p,l,!1)}else r.encodeCentroid(void 0,s,!1)}r.borderDoneWithNeighborZ[e]=u.canonical.z,r.needsCentroidUpdate=!0,v&&(u.borderDoneWithNeighborZ[n]=r.canonical.z,u.needsCentroidUpdate=!0)}else{for(const t of o)r.encodeCentroid(void 0,r.featuresOnBorder[t],!1);if(v){for(const t of h)u.encodeCentroid(void 0,u.featuresOnBorder[t],!1);u.borderDoneWithNeighborZ[n]=r.canonical.z,u.needsCentroidUpdate=!0}r.borderDoneWithNeighborZ[e]=u.canonical.z,r.needsCentroidUpdate=!0}}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(e)}const vi=new t.Color(1,0,0,1),xi=new t.Color(0,1,0,1),bi=new t.Color(0,0,1,1),Ti=new t.Color(1,0,1,1),Ei=new t.Color(0,1,1,1);function Si(e,n,i){const r=e.context,o=e.transform,s=r.gl,a="globe"===o.projection.name,l=a?["PROJECTION_GLOBE_VIEW"]:null;let c=i.projMatrix;if(a&&t.globeToMercatorTransition(o.zoom)>0){const e=t.transitionTileAABBinECEF(i.canonical,o),n=t.globeDenormalizeECEF(e);c=t.multiply(new Float32Array(16),o.globeMatrix,n),t.multiply(c,o.projMatrix,c)}const u=e.useProgram("debug",null,l),h=n.getTileByID(i.key);e.terrain&&e.terrain.setupElevationDraw(h,u);const d=t.DepthMode.disabled,p=t.StencilMode.disabled,f=e.colorModeForRenderPass(),m="$debug";r.activeTexture.set(s.TEXTURE0),e.emptyTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),a?h._makeGlobeTileDebugBuffers(e.context,o):h._makeDebugTileBoundsBuffers(e.context,o.projection);const g=h._tileDebugBuffer||e.debugBuffer,_=h._tileDebugIndexBuffer||e.debugIndexBuffer,y=h._tileDebugSegments||e.debugSegments;u.draw(r,s.LINE_STRIP,d,p,f,t.CullFaceMode.disabled,Hn(c,t.Color.red),m,g,_,y,null,null,null,[h._globeTileDebugBorderBuffer]);const v=h.latestRawTileData,x=Math.floor((v&&v.byteLength||0)/1024),b=n.getTile(i).tileSize,T=512/Math.min(b,512)*(i.overscaledZ/o.zoom)*.5;let E=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(E+=` => ${i.overscaledZ}`),E+=` ${x}kb`,function(t,e){t.initDebugOverlayCanvas();const n=t.debugOverlayCanvas,i=t.context.gl,r=t.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,n.width,n.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(e,5,5),r.strokeText(e,5,5),t.debugOverlayTexture.update(n),t.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}(e,E);const S=h._tileDebugTextBuffer||e.debugBuffer,w=h._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,A=h._tileDebugTextSegments||e.debugSegments;u.draw(r,s.TRIANGLES,d,p,t.ColorMode.alphaBlended,t.CullFaceMode.disabled,Hn(c,t.Color.transparent,T),m,S,w,A,null,null,null,[h._globeTileDebugTextBuffer])}function wi(t,e,n,i){Mi(t,0,e+n/2,t.transform.width,n,i)}function Ai(t,e,n,i){Mi(t,e-n/2,0,n,t.transform.height,i)}function Mi(e,n,i,r,o,s){const a=e.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*t.exported.devicePixelRatio,i*t.exported.devicePixelRatio,r*t.exported.devicePixelRatio,o*t.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const Ci=t.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Ii}=Ci;function Pi(t,e,n,i){t.emplaceBack(e,n,i)}class Li{constructor(e){this.vertexArray=new t.StructArrayLayout3f12,this.indices=new t.StructArrayLayout3ui6,Pi(this.vertexArray,-1,-1,1),Pi(this.vertexArray,1,-1,1),Pi(this.vertexArray,-1,1,1),Pi(this.vertexArray,1,1,1),Pi(this.vertexArray,-1,-1,-1),Pi(this.vertexArray,1,-1,-1),Pi(this.vertexArray,-1,1,-1),Pi(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=e.createVertexBuffer(this.vertexArray,Ii),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=t.SegmentVector.simpleSegment(0,0,36,12)}}function Ri(e,n,i,r,o,s){const a=e.gl,l=n.paint.get("sky-atmosphere-color"),c=n.paint.get("sky-atmosphere-halo-color"),u=n.paint.get("sky-atmosphere-sun-intensity"),h=((t,e,n,i,r)=>({u_matrix_3f:t,u_sun_direction:e,u_sun_intensity:n,u_color_tint_r:[i.r,i.g,i.b,i.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(t.fromMat4(t.create$1(),r),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,n.skyboxTexture,0),i.draw(e,a.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.frontCW,h,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const Oi=t.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Di{constructor(e){const n=new t.StructArrayLayout5f20;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const i=new t.StructArrayLayout3ui6;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(n,Oi.members),this.indexBuffer=e.createIndexBuffer(i),this.segments=t.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Bi={symbol:function(e,n,i,r,o){if("translucent"!==e.renderPass)return;const s=t.StencilMode.disabled,a=e.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(e,n,i,r,o,s,a){const l=n.transform,c="map"===o,u="map"===s;for(const n of e){const e=r.getTile(n),o=e.getBucket(i);if(!o||!o.text||!o.text.segments.get().length)continue;const s=t.evaluateSizeForZoom(o.textSizeData,l.zoom),h=ve(n,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(e),p=te(h,e.tileID.canonical,u,c,l,o.getProjection(),d),f="none"!==i.layout.get("icon-text-fit")&&o.hasIconData();if(s){const i=Math.pow(2,l.zoom-e.tileID.overscaledZ);di(o,c,u,a,t.symbolSize,l,p,n,i,s,f)}}}(r,e,i,n,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),o),0!==i.paint.get("icon-opacity").constantOr(1)&&fi(e,n,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),s,a),0!==i.paint.get("text-opacity").constantOr(1)&&fi(e,n,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),s,a),n.map.showCollisionBoxes&&(ci(e,n,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),ci(e,n,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(e,n,i,r){if("translucent"!==e.renderPass)return;const o=i.paint.get("circle-opacity"),s=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),l=void 0!==i.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=e.context,u=c.gl,h=e.transform,d=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),p=t.StencilMode.disabled,f=e.colorModeForRenderPass(),m="globe"===h.projection.name,g=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],_=[];for(let o=0;o<r.length;o++){const s=r[o],a=n.getTile(s),c=a.getBucket(i);if(!c||c.projection.name!==h.projection.name)continue;const u=c.programConfigurations.get(i.id),d=jn(i);m&&d.push("PROJECTION_GLOBE_VIEW");const p=e.useProgram("circle",u,d),f=c.layoutVertexBuffer,y=c.globeExtVertexBuffer,v=c.indexBuffer,x=h.projection.createInversionMatrix(h,s.canonical),b={programConfiguration:u,program:p,layoutVertexBuffer:f,globeExtVertexBuffer:y,indexBuffer:v,uniformValues:Vn(e,s,a,x,g,i),tile:a};if(l){const e=c.segments.get();for(const n of e)_.push({segments:new t.SegmentVector([n]),sortKey:n.sortKey,state:b})}else _.push({segments:c.segments,sortKey:0,state:b})}l&&_.sort(((t,e)=>t.sortKey-e.sortKey));const y={useDepthForOcclusion:!m};for(const n of _){const{programConfiguration:r,program:o,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:m,tile:g}=n.state,_=n.segments;e.terrain&&e.terrain.setupElevationDraw(g,o,y),e.prepareDrawProgram(c,o,g.tileID.toUnwrapped()),o.draw(c,u.TRIANGLES,d,p,f,t.CullFaceMode.disabled,m,i.id,s,l,_,i.paint,h.zoom,r,[a])}},heatmap:function(e,n,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const o=e.context,s=o.gl,a=t.StencilMode.disabled,l=new t.ColorMode([s.ONE,s.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,n,i){const r=t.gl,o=e.width*i,s=e.height*i;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,o,s]);let a=n.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),a=n.heatmapFbo=t.createFramebuffer(o,s,!1),function(t,e,n,i,r,o){const s=t.gl;s.texImage2D(s.TEXTURE_2D,0,t.isWebGL2&&t.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,r,o,0,s.RGBA,t.extRenderToTextureHalfFloat?t.isWebGL2?s.HALF_FLOAT:t.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),i.colorAttachment.set(n)}(t,0,e,a,o,s)}else r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),t.bindFramebuffer.set(a.framebuffer)}(o,e,i,"globe"===e.transform.projection.name?.5:.25),o.clear({color:t.Color.transparent});const c=e.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:null,d=u?t.CullFaceMode.frontCCW:t.CullFaceMode.disabled,p=[t.mercatorXfromLng(c.center.lng),t.mercatorYfromLat(c.center.lat)];for(let f=0;f<r.length;f++){const m=r[f];if(n.hasRenderableParent(m))continue;const g=n.getTile(m),_=g.getBucket(i);if(!_||_.projection.name!==c.projection.name)continue;const y=_.programConfigurations.get(i.id),v=e.useProgram("heatmap",y,h),{zoom:x}=e.transform;e.terrain&&e.terrain.setupElevationDraw(g,v),e.prepareDrawProgram(o,v,m.toUnwrapped());const b=c.projection.createInversionMatrix(c,m.canonical);v.draw(o,s.TRIANGLES,t.DepthMode.disabled,a,l,d,qn(e,m,g,b,p,x,i.paint.get("heatmap-intensity")),i.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,i.paint,e.transform.zoom,y,u?[_.globeExtVertexBuffer]:null)}o.viewport.set([0,0,e.width,e.height])}else"translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,n){const i=e.context,r=i.gl,o=n.heatmapFbo;if(!o)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let s=n.colorRampTexture;s||(s=n.colorRampTexture=new t.Texture(i,n.colorRamp,r.RGBA)),s.bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(i,r.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,((t,e)=>({u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}))(0,n),n.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,n.paint,e.transform.zoom)}(e,i))},line:function(e,n,i,r){if("translucent"!==e.renderPass)return;const o=i.paint.get("line-opacity"),s=i.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),l=e.colorModeForRenderPass(),c=e.terrain&&e.terrain.renderingToTexture?1:t.exported.devicePixelRatio,u=i.paint.get("line-dasharray"),h=u.constantOr(1),d=i.layout.get("line-cap"),p=i.paint.get("line-pattern"),f=p.constantOr(1),m=i.paint.get("line-gradient"),g=f?"linePattern":"line",_=e.context,y=_.gl,v=(t=>{const e=[];Kn(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const n=t.paint.get("line-trim-offset");0===n[0]&&0===n[1]||e.push("RENDER_LINE_TRIM_OFFSET");const i=t.paint.get("line-pattern").constantOr(1),r=1!==t.paint.get("line-opacity").constantOr(1);return!i&&r&&e.push("RENDER_LINE_ALPHA_DISCARD"),e})(i);let x=v.includes("RENDER_LINE_ALPHA_DISCARD");e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(x=!1);for(const o of r){const r=n.getTile(o);if(f&&!r.patternsLoaded())continue;const s=r.getBucket(i);if(!s)continue;e.prepareDrawTile();const b=s.programConfigurations.get(i.id),T=e.useProgram(g,b,v),E=p.constantOr(null);if(E&&r.imageAtlas){const t=r.imageAtlas.patternPositions[E.toString()];t&&b.setConstantPatternPositions(t)}const S=u.constantOr(null),w=d.constantOr(null);if(!f&&S&&w&&r.lineAtlas){const t=r.lineAtlas.getDash(S,w);t&&b.setConstantPatternPositions(t)}let[A,M]=i.paint.get("line-trim-offset");if("round"===w||"square"===w){const t=1;A!==M&&(0===A&&(A-=t),1===M&&(M+=t))}const C=e.terrain?o.projMatrix:null,I=f?Yn(e,r,i,C,c):Xn(e,r,i,C,s.lineClipsArray.length,c,[A,M]);if(m){const r=s.gradients[i.id];let a=r.texture;if(i.gradientVersion!==r.version){let l=256;if(i.stepInterpolant){const i=n.getSource().maxzoom,r=o.canonical.z===i?Math.ceil(1<<e.transform.maxZoom-o.canonical.z):1;l=t.clamp(t.nextPowerOfTwo(s.maxLineLength/t.EXTENT*1024*r),256,_.maxTextureSize)}r.gradient=t.renderColorRamp({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:r.gradient||void 0,clips:s.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new t.Texture(_,r.gradient,y.RGBA),r.version=i.gradientVersion,a=r.texture}_.activeTexture.set(y.TEXTURE1),a.bind(i.stepInterpolant?y.NEAREST:y.LINEAR,y.CLAMP_TO_EDGE)}h&&(_.activeTexture.set(y.TEXTURE0),r.lineAtlasTexture.bind(y.LINEAR,y.REPEAT),b.updatePaintBuffers()),f&&(_.activeTexture.set(y.TEXTURE0),r.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),b.updatePaintBuffers()),e.prepareDrawProgram(_,T,o.toUnwrapped());const P=n=>{T.draw(_,y.TRIANGLES,a,n,l,t.CullFaceMode.disabled,I,i.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,i.paint,e.transform.zoom,b,[s.layoutVertexBuffer2])};if(x){const n=e.stencilModeForClipping(o).ref;0===n&&e.terrain&&_.clear({stencil:0});const i={func:y.EQUAL,mask:255};I.u_alpha_discard_threshold=.8,P(new t.StencilMode(i,n,255,y.KEEP,y.KEEP,y.INVERT)),I.u_alpha_discard_threshold=0,P(new t.StencilMode(i,n,255,y.KEEP,y.KEEP,y.KEEP))}else P(e.stencilModeForClipping(o))}x&&(e.resetStencilClippingMasks(),e.terrain&&_.clear({stencil:0}))},fill:function(e,n,i,r){const o=i.paint.get("fill-color"),s=i.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=e.colorModeForRenderPass(),l=i.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(t.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const o=e.depthModeForSublayer(1,"opaque"===e.renderPass?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly);gi(e,n,i,r,o,a,!1)}if("translucent"===e.renderPass&&i.paint.get("fill-antialias")){const o=e.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,t.DepthMode.ReadOnly);gi(e,n,i,r,o,a,!0)}},"fill-extrusion":function(e,n,i,r){const o=i.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===e.renderPass){const s=new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==o||i.paint.get("fill-extrusion-pattern").constantOr(1))_i(e,n,i,r,s,t.StencilMode.disabled,t.ColorMode.disabled),_i(e,n,i,r,s,e.stencilModeFor3D(),e.colorModeForRenderPass()),e.resetStencilClippingMasks();else{const o=e.colorModeForRenderPass();_i(e,n,i,r,s,t.StencilMode.disabled,o)}}},hillshade:function(e,n,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const o=e.context,s=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),a=e.colorModeForRenderPass(),l=e.terrain&&e.terrain.renderingToTexture,[c,u]="translucent"!==e.renderPass||l?[{},r]:e.stencilConfigForOverlap(r);for(const r of u){const o=n.getTile(r);if(o.needsHillshadePrepare&&"offscreen"===e.renderPass)_n(e,o,i,s,t.StencilMode.disabled,a);else if("translucent"===e.renderPass){const t=l&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):c[r.overscaledZ];mn(e,r,o,i,s,t,a)}}o.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,n,i,r,o,s){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const a=e.context,l=a.gl,c=n.getSource(),u=e.useProgram("raster"),h=e.colorModeForRenderPass(),d=e.terrain&&e.terrain.renderingToTexture,[p,f]=c instanceof Ct||d?[{},r]:e.stencilConfigForOverlap(r),m=f[f.length-1].overscaledZ,g=!e.options.moving;for(const r of f){const o=d?t.DepthMode.disabled:e.depthModeForSublayer(r.overscaledZ-m,1===i.paint.get("raster-opacity")?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly,l.LESS),f=r.toUnwrapped(),_=n.getTile(r);if(d&&(!_||!_.hasData()))continue;const y=d?r.projMatrix:e.transform.calculateProjMatrix(f,g),v=e.terrain&&d?e.terrain.stencilModeForRTTOverlap(r):p[r.overscaledZ],x=s?0:i.paint.get("raster-fade-duration");_.registerFadeDuration(x);const b=n.findLoadedParent(r,0),T=Mn(_,b,n,e.transform,x);let E,S;e.terrain&&e.terrain.prepareDrawTile();const w="nearest"===i.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),_.texture.bind(w,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(w,l.CLAMP_TO_EDGE),E=Math.pow(2,b.tileID.overscaledZ-_.tileID.overscaledZ),S=[_.tileID.canonical.x*E%1,_.tileID.canonical.y*E%1]):_.texture.bind(w,l.CLAMP_TO_EDGE),_.texture.useMipmap&&a.extTextureFilterAnisotropic&&e.transform.pitch>20&&l.texParameterf(l.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax);const A=Qn(y,S||[0,0],E||1,T,i,c instanceof Ct?c.perspectiveTransform:[0,0]);if(e.prepareDrawProgram(a,u,f),c instanceof Ct)c.boundsBuffer&&c.boundsSegments&&u.draw(a,l.TRIANGLES,o,t.StencilMode.disabled,h,t.CullFaceMode.disabled,A,i.id,c.boundsBuffer,e.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:n,tileBoundsIndexBuffer:r,tileBoundsSegments:s}=e.getTileBoundsBuffers(_);u.draw(a,l.TRIANGLES,o,v,h,t.CullFaceMode.disabled,A,i.id,n,r,s)}}e.resetStencilClippingMasks()},background:function(e,n,i,r){const o=i.paint.get("background-color"),s=i.paint.get("background-opacity");if(0===s)return;const a=e.context,l=a.gl,c=e.transform,u=c.tileSize,h=i.paint.get("background-pattern");if(e.isPatternMissing(h))return;const d=!h&&1===o.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==d)return;const p=t.StencilMode.disabled,f=e.depthModeForSublayer(0,"opaque"===d?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly),m=e.colorModeForRenderPass(),g=e.useProgram(h?"backgroundPattern":"background");let _,y=r;y||(_=e.getBackgroundTiles(),y=Object.values(_).map((t=>t.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));for(const d of y){const y=d.toUnwrapped(),v=r?d.projMatrix:e.transform.calculateProjMatrix(y);e.prepareDrawTile();const x=n?n.getTile(d):_?_[d.key]:new t.Tile(d,u,c.zoom,e),b=h?si(v,s,e,h,{tileID:d,tileSize:u}):oi(v,s,o);e.prepareDrawProgram(a,g,y);const{tileBoundsBuffer:T,tileBoundsIndexBuffer:E,tileBoundsSegments:S}=e.getTileBoundsBuffers(x);g.draw(a,l.TRIANGLES,f,p,m,t.CullFaceMode.disabled,b,i.id,T,E,S)}},sky:function(e,n,i){const r=e.transform,o="mercator"===r.projection.name||"globe"===r.projection.name?1:t.smoothstep(7,8,r.zoom),s=i.paint.get("sky-opacity")*o;if(0===s)return;const a=e.context,l=i.paint.get("sky-type"),c=new t.DepthMode(a.gl.LEQUAL,t.DepthMode.ReadOnly,[0,1]),u=e.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===e.renderPass?i.needsSkyboxCapture(e)&&(function(e,n){const i=e.context,r=i.gl;let o=n.skyboxFbo;if(!o){o=n.skyboxFbo=i.createFramebuffer(32,32,!1),n.skyboxGeometry=new Li(i),n.skyboxTexture=i.gl.createTexture(),r.bindTexture(r.TEXTURE_CUBE_MAP,n.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 t=0;t<6;++t)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,r.RGBA,32,32,0,r.RGBA,r.UNSIGNED_BYTE,null)}i.bindFramebuffer.set(o.framebuffer),i.viewport.set([0,0,32,32]);const s=n.getCenter(e,!0),a=e.useProgram("skyboxCapture"),l=new Float64Array(16);t.identity(l),t.rotateY(l,l,.5*-Math.PI),Ri(i,n,a,l,s,0),t.identity(l),t.rotateY(l,l,.5*Math.PI),Ri(i,n,a,l,s,1),t.identity(l),t.rotateX(l,l,.5*-Math.PI),Ri(i,n,a,l,s,2),t.identity(l),t.rotateX(l,l,.5*Math.PI),Ri(i,n,a,l,s,3),t.identity(l),Ri(i,n,a,l,s,4),t.identity(l),t.rotateY(l,l,Math.PI),Ri(i,n,a,l,s,5),i.viewport.set([0,0,e.width,e.height])}(e,i),i.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,n,i,r,o){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,n.skyboxTexture);const u=((t,e,n,i,r)=>({u_matrix:t,u_sun_direction:e,u_cubemap:0,u_opacity:i,u_temporal_offset:r}))(l.skyboxMatrix,n.getCenter(e,!1),0,r,o);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,i,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,u,"skybox",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(e,i,c,s,u):"gradient"===l&&"sky"===e.renderPass&&function(e,n,i,r,o){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new Li(s)),s.activeTexture.set(a.TEXTURE0);let u=n.colorRampTexture;u||(u=n.colorRampTexture=new t.Texture(s,n.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((e,n,i,r,o)=>({u_matrix:e,u_color_ramp:0,u_center_direction:n,u_radius:t.degToRad(i),u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,n.getCenter(e,!1),n.paint.get("sky-gradient-radius"),r,o);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,i,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,h,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(e,i,c,s,u)},debug:function(t,e,n){for(let i=0;i<n.length;i++)Si(t,e,n[i])},custom:function(e,n,i,r){const o=e.context,s=i.implementation;if(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes("custom")||e.terrain&&(e.terrain.renderingToTexture||"offscreen"===e.renderPass)&&i.isLayerDraped()){if("offscreen"===e.renderPass){const n=s.prerender;if(n){if(e.setCustomLayerDefaults(),o.setColorMode(e.colorModeForRenderPass()),"globe"===e.transform.projection.name){const i=e.transform.pointMerc;n.call(s,o.gl,e.transform.customLayerMatrix(),e.transform.getProjection(),e.transform.globeToMercatorMatrix(),t.globeToMercatorTransition(e.transform.zoom),[i.x,i.y],e.transform.pixelsPerMeterRatio)}else n.call(s,o.gl,e.transform.customLayerMatrix());o.setDirty(),e.setBaseState()}}else if("translucent"===e.renderPass){if(e.terrain&&e.terrain.renderingToTexture){const n=s.renderToTile;if(n){const i=r[0].canonical,a=new t.MercatorCoordinate(i.x+r[0].wrap*(1<<i.z),i.y,i.z);o.setDepthMode(t.DepthMode.disabled),o.setStencilMode(t.StencilMode.disabled),o.setColorMode(e.colorModeForRenderPass()),e.setCustomLayerDefaults(),n.call(s,o.gl,a),o.setDirty(),e.setBaseState()}return}e.setCustomLayerDefaults(),o.setColorMode(e.colorModeForRenderPass()),o.setStencilMode(t.StencilMode.disabled);const n="3d"===s.renderingMode?new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D):e.depthModeForSublayer(0,t.DepthMode.ReadOnly);if(o.setDepthMode(n),"globe"===e.transform.projection.name){const n=e.transform.pointMerc;s.render(o.gl,e.transform.customLayerMatrix(),e.transform.getProjection(),e.transform.globeToMercatorMatrix(),t.globeToMercatorTransition(e.transform.zoom),[n.x,n.y],e.transform.pixelsPerMeterRatio)}else s.render(o.gl,e.transform.customLayerMatrix());o.setDirty(),e.setBaseState(),o.bindFramebuffer.set(null)}}else t.warnOnce("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")}};class Ni{constructor(e,n,i=!1){this.context=new St(e,i),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=t.SourceCache.maxUnderzooming+t.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(t,e){const n=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(n||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Ln(this,t));const i=this._terrain;this.transform.elevation=n?i:null,i.update(t,this.transform,e)}_updateFog(t){const e=t.fog;if(!e||"globe"===this.transform.projection.name||e.getOpacity(this.transform.pitch)<1||e.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[n,i]=e.getFovAdjustedRange(this.transform._fov);if(n>i)return void(this.transform.fogCullDistSq=null);const r=n+.78*(i-n);this.transform.fogCullDistSq=r*r}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,n){if(this.width=e*t.exported.devicePixelRatio,this.height=n*t.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style.order)this.style._layers[t].resize()}setup(){const e=this.context,n=new t.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(t.EXTENT,0),n.emplaceBack(0,t.EXTENT),n.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(n,t.posAttributes.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);const i=new t.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(t.EXTENT,0),i.emplaceBack(0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=e.createVertexBuffer(i,t.posAttributes.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);const r=new t.StructArrayLayout2i4;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(r,t.posAttributes.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);const o=new t.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(t.EXTENT,0,t.EXTENT,0),o.emplaceBack(0,t.EXTENT,0,t.EXTENT),o.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.mercatorBoundsBuffer=e.createVertexBuffer(o,t.boundsAttributes.members),this.mercatorBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);const s=new t.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s);const a=new t.StructArrayLayout1ui2;for(const t of[0,1,3,2,0])a.emplaceBack(t);this.debugIndexBuffer=e.createIndexBuffer(a),this.emptyTexture=new t.Texture(e,new t.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=t.create();const l=this.context.gl;this.stencilClearMode=new t.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(t.window.performance.now()),this.atmosphereBuffer=new Di(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(e,n.TRIANGLES,t.DepthMode.disabled,this.stencilClearMode,t.ColorMode.disabled,t.CullFaceMode.disabled,An(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,n,i){if(!n||this.currentStencilSource===n.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let t=!1;for(const e of i)if(void 0===this._tileClippingMaskIDs[e.key]){t=!0;break}if(!t)return}this.currentStencilSource=n.id;const r=this.context,o=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(t.ColorMode.disabled),r.setDepthMode(t.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=n.getTile(e),a=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:u}=this.getTileBoundsBuffers(i);s.draw(r,o.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:o.ALWAYS,mask:0},a,255,o.KEEP,o.KEEP,o.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,An(e.projMatrix),"$clipping",l,c,u)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new t.StencilMode({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const n=this.context.gl;return new t.StencilMode({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(e){const n=this.context.gl,i=e.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let i=0;i<o;i++)e[i+r]=new t.StencilMode({func:n.GEQUAL,mask:255},i+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=o,[e,i]}return[{[r]:t.StencilMode.disabled},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const n=1/8;return new t.ColorMode([e.CONSTANT_COLOR,e.ONE],new t.Color(n,n,n,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?t.ColorMode.unblended:t.ColorMode.alphaBlended}depthModeForSublayer(e,n,i){if(!this.opaquePassEnabledForLayer())return t.DepthMode.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new t.DepthMode(i||this.context.gl.LEQUAL,n,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){this.style=e,this.options=n,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(t.exported.now()),this.imageManager.beginFrame();const i=this.style.order,r=this.style._sourceCaches;for(const t in r){const e=r[t];e.used&&e.prepare(this.context)}const o={},s={},a={};for(const t in r){const e=r[t];o[t]=e.getVisibleCoordinates(),s[t]=o[t].slice().reverse(),a[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<i.length;t++)if(this.style._layers[i[t]].is3D()){this.opaquePassCutoff=t;break}if(this.terrain&&(this.terrain.updateTileBinding(a),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new t.GlobeSharedBuffers(this.context)),!t.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const t of i){const n=this.style._layers[t],i=e._getLayerSourceCache(n);if(!n.hasOffscreenPass()||n.isHidden(this.transform.zoom))continue;const r=i?s[i.id]:void 0;("custom"===n.type||n.isSky()||r&&r.length)&&this.renderLayer(this,i,n,r)}this.depthRangeFor3D=[0,1-(e.order.length+2)*this.numSublayers*this.depthEpsilon];const l=this.terrain;if(l&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&l.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:n.showOverdrawInspector?t.Color.black:t.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=n.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[i[this.currentLayer]],n=e._getLayerSourceCache(t);if(t.isSky())continue;const r=n?s[n.id]:void 0;this._renderTileClippingMasks(t,n,r),this.renderLayer(this,n,t,r)}if(this.style.fog&&this.transform.projection.supportsFog&&function(e,n){const i=e.context,r=i.gl,o=e.transform,s=new t.DepthMode(r.LEQUAL,t.DepthMode.ReadOnly,[0,1]),a=e.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=t.globeToMercatorTransition(o.zoom),c=n.properties.get("color").toArray01(),u=n.properties.get("high-color").toArray01(),h=n.properties.get("space-color").toArray01PremultipliedAlpha(),d=t.identity$1([]);t.rotateY$1(d,d,-t.degToRad(o._center.lng)),t.rotateX$1(d,d,t.degToRad(o._center.lat)),t.rotateZ$1(d,d,o.angle),t.rotateX$1(d,d,-o._pitch);const p=t.fromQuat(new Float32Array(16),d),f=t.mapValue(n.properties.get("star-intensity"),0,1,0,.25),m=5e-4,g=t.mapValue(n.properties.get("horizon-blend"),0,1,m,.25),_=t.globeUseCustomAntiAliasing(e,i,o)&&g===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=e.frameCounter/1e3%1,v=t.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(_,2)),b=Math.acos(x/v),T=((e,n,i,r,o,s,a,l,c,u,h,d,p,f)=>({u_frustum_tl:e,u_frustum_tr:n,u_frustum_br:i,u_frustum_bl:r,u_horizon:o,u_transition:s,u_fadeout_range:a,u_color:l,u_high_color:c,u_space_color:u,u_star_intensity:h,u_star_size:5*t.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:d,u_horizon_angle:p,u_rotation_matrix:f}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,g,c,u,h,f,y,b,p);e.prepareDrawProgram(i,a);const E=e.atmosphereBuffer;E&&a.draw(i,r.TRIANGLES,s,t.StencilMode.disabled,t.ColorMode.alphaBlended,t.CullFaceMode.backCW,T,"skybox",E.vertexBuffer,E.indexBuffer,E.segments)}(this,this.style.fog),this.renderPass="sky",(t.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){const t=this.style._layers[i[this.currentLayer]],n=e._getLayerSourceCache(t);t.isSky()&&this.renderLayer(this,n,t,n?s[n.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<i.length;){const t=this.style._layers[i[this.currentLayer]],n=e._getLayerSourceCache(t);if(t.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(t)){if(t.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const r=n?("symbol"===t.type?a:s)[n.id]:void 0;this._renderTileClippingMasks(t,n,n?o[n.id]:void 0),this.renderLayer(this,n,t,r),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let n=null;t.values(this.style._layers).forEach((t=>{const i=e._getLayerSourceCache(t);i&&!t.isHidden(this.transform.zoom)&&(!n||n.getSource().maxzoom<i.getSource().maxzoom)&&(n=i)})),n&&this.options.showTileBoundaries&&Bi.debug(this,n,n.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;wi(t,t.transform.height-(e.top||0),3,vi),wi(t,e.bottom||0,3,xi),Ai(t,e.left||0,3,bi),Ai(t,t.transform.width-(e.right||0),3,Ti);const n=t.transform.centerPoint;!function(t,e,n,i){Mi(t,e-1,n-10,2,20,i),Mi(t,e-10,n-1,20,2,i)}(t,n.x,t.transform.height-n.y,Ei)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(t.window.performance.now()),this.saveCanvasCopy())}renderLayer(t,e,n,i){n.isHidden(this.transform.zoom)||("background"===n.type||"sky"===n.type||"custom"===n.type||i&&i.length)&&(this.id=n.id,this.gpuTimingStart(n),(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes(n.type)||t.terrain&&"custom"===n.type)&&Bi[n.type](t,e,n,i,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;let n=this.gpuTimers[t.id];n||(n=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),n.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,n.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const t=this.context.extTimerQuery,e=t.createQueryEXT();this.deferredRenderGpuTimeQueries.push(e),t.beginQueryEXT(t.TIME_ELAPSED_EXT,e)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}collectDeferredRenderGpuQueries(){const t=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],t}queryGpuTimers(t){const e={};for(const n in t){const i=t[n],r=this.context.extTimerQuery,o=r.getQueryObjectEXT(i.query,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i.query),e[n]=o}return e}queryGpuTimeDeferredRender(t){if(!this.options.gpuTimingDeferredRender)return 0;const e=this.context.extTimerQuery;let n=0;for(const i of t)n+=e.getQueryObjectEXT(i,e.QUERY_RESULT_EXT)/1e6,e.deleteQueryEXT(i);return n}translatePosMatrix(e,n,i,r,o){if(!i[0]&&!i[1])return e;const s=o?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(s){const t=Math.sin(s),e=Math.cos(s);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}const a=[o?i[0]:P(n,i[0],this.transform.zoom),o?i[1]:P(n,i[1],this.transform.zoom),0],l=new Float32Array(16);return t.translate(l,e,a),l}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){return null===t||void 0!==t&&!this.imageManager.getPattern(t.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const t=this.terrain&&this.terrain.renderingToTexture,e=this.terrain&&0===this.terrain.exaggeration(),n=this.style&&this.style.fog,i=[];return this.terrainRenderModeElevated()&&i.push("TERRAIN"),"globe"===this.transform.projection.name&&i.push("GLOBE"),e&&i.push("ZERO_EXAGGERATION"),n&&!t&&0!==n.getOpacity(this.transform.pitch)&&i.push("FOG"),t&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(t,e,n){this.cache=this.cache||{};const i=n||[],r=this.currentGlobalDefines().concat(i),o=Rn.cacheKey(un[t],t,r,e);return this.cache[o]||(this.cache[o]=new Rn(this.context,t,un[t],e,ai[t],r)),this.cache[o]}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 t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(e,n,i){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const o=r.getOpacity(this.transform.pitch),s=((e,n,i,r,o,s,a,l,c,u,h)=>{const d=e.transform,p=n.properties.get("color").toArray01();p[3]=r;const f=e.frameCounter/1e3%1;return{u_fog_matrix:i?d.calculateFogTileMatrix(i):e.identityMat,u_fog_range:n.getFovAdjustedRange(d._fov),u_fog_color:p,u_fog_horizon_blend:n.properties.get("horizon-blend"),u_fog_temporal_offset:f,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:t.globeToMercatorTransition(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,r,i,o,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*t.exported.devicePixelRatio,this.transform.height*t.exported.devicePixelRatio]);n.setFogUniformValues(e,s)}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){const t=this.canvasCopy();t&&(this.frameCopies.push(t),this.tileLoaded=!1)}canvasCopy(){const t=this.context.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),e}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,n=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)n[r.key]=e[r.key]||new t.Tile(r,512,this.transform.tileZoom,this);return n}clearBackgroundTiles(){this._backgroundTiles={}}}class Fi{constructor(t=0,e=0,n=0,i=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(n)||n<0||isNaN(i)||i<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=n,this.right=i}interpolate(e,n,i){return null!=n.top&&null!=e.top&&(this.top=t.number(e.top,n.top,i)),null!=n.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,n.bottom,i)),null!=n.left&&null!=e.left&&(this.left=t.number(e.left,n.left,i)),null!=n.right&&null!=e.right&&(this.right=t.number(e.right,n.right,i)),this}getCenter(e,n){const i=t.clamp((this.left+e-this.right)/2,0,e),r=t.clamp((this.top+n-this.bottom)/2,0,n);return new t.Point(i,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Fi(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ui(e,n){const i=t.getColumn(e,3);t.fromQuat(e,n),t.setColumn(e,3,i)}function ki(e,n){const i=t.identity$1([]);return t.rotateZ$1(i,i,-n),t.rotateX$1(i,i,-e),i}function zi(e,n){const i=[e[0],e[1],0],r=[n[0],n[1],0];if(t.length(i)>=1e-15){const e=t.normalize([],i);t.scale$2(r,e,t.dot(r,e)),n[0]=r[0],n[1]=r[1]}const o=t.cross([],n,e);if(t.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return ki(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),s)}class Gi{constructor(t,e){this.position=t,this.orientation=e}get position(){return this._position}set position(e){if(e){const n=e instanceof t.MercatorCoordinate?e:new t.MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(n.x=t.wrap(n.x,0,1)),this._position=n}else this._position=null}lookAtPoint(e,n){if(this.orientation=null,!this.position)return;const i=this.position,r=this._elevation?this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(e)):0,o=t.MercatorCoordinate.fromLngLat(e,r),s=[o.x-i.x,o.y-i.y,o.z-i.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=zi(s,n)}setPitchBearing(e,n){this.orientation=ki(t.degToRad(e),t.degToRad(-n))}}class Vi{constructor(e,n){this._transform=t.identity([]),this.orientation=n,this.position=e}get mercatorPosition(){const e=this.position;return new t.MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=t.getColumn(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var n;e&&t.setColumn(this._transform,3,[(n=e)[0],n[1],n[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||t.identity$1([]),e&&Ui(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),e=this.right();return{bearing:Math.atan2(-e[1],e[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,e){this._orientation=ki(t,e),Ui(this._transform,this._orientation)}forward(){const e=t.getColumn(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=t.getColumn(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=t.getColumn(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,n){const i=new Float64Array(16);return t.invert(i,this.getWorldToCamera(e,n)),i}getWorldToCameraPosition(e,n,i){const r=this.position;t.scale$2(r,r,-e);const o=new Float64Array(16);return t.fromScaling(o,[i,i,i]),t.translate(o,o,r),o[10]*=n,o}getWorldToCamera(e,n){const i=new Float64Array(16),r=new Float64Array(4),o=this.position;return t.conjugate(r,this._orientation),t.scale$2(o,o,-e),t.fromQuat(i,r),t.translate(i,i,o),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=n,i[9]*=n,i[10]*=n,i[11]*=n,i}getCameraToClipPerspective(e,n,i,r){const o=new Float64Array(16);return t.perspective(o,e,n,i,r),o}getDistanceToElevation(e,n=!1){const i=0===e?0:t.mercatorZfromAltitude(e,n?t.latFromMercatorY(this.position[1]):this.position[1]),r=this.forward();return(i-this.position[2])/r[2]}clone(){return new Vi([...this.position],[...this.orientation])}}function ji(e,n){const i=Hi(e.projection,e.zoom,e.width,e.height),r=function(e,n,i,r,o){const s=new t.LngLat(i.lng-180*Wi,i.lat),a=new t.LngLat(i.lng+180*Wi,i.lat),l=e.project(s.lng,s.lat),c=e.project(a.lng,a.lat),u=-Math.atan2(c.y-l.y,c.x-l.x),h=t.MercatorCoordinate.fromLngLat(i);h.y=t.clamp(h.y,-1+Wi,1-Wi);const d=h.toLngLat(),p=e.project(d.lng,d.lat),f=t.MercatorCoordinate.fromLngLat(d);f.x+=Wi;const m=f.toLngLat(),g=e.project(m.lng,m.lat),_=Xi(g.x-p.x,g.y-p.y,u),y=t.MercatorCoordinate.fromLngLat(d);y.y+=Wi;const v=y.toLngLat(),x=e.project(v.lng,v.lat),b=Xi(x.x-p.x,x.y-p.y,u),T=Math.abs(_.x)/Math.abs(b.y),E=t.identity([]);t.rotateZ(E,E,-u*(1-(o?0:r)));const S=t.identity([]);return t.scale(S,S,[1,1-(1-T)*r,1]),S[4]=-b.x/b.y*r,t.rotateZ(S,S,u),t.multiply(S,E,S),S}(e.projection,0,e.center,i,n),o=$i(e);return t.scale(r,r,[o,o,1]),r}function $i(e){const n=e.projection,i=Hi(e.projection,e.zoom,e.width,e.height),r=qi(n,e.center),o=qi(n,t.LngLat.convert(n.center));return Math.pow(2,r*i+(1-i)*o)}function Hi(e,n,i,r,o=1/0){const s=e.range;if(!s)return 0;const a=Math.min(o,Math.max(i,r)),l=Math.log(a/1024)/Math.LN2;return t.smoothstep(s[0]+l,s[1]+l,n)}const Wi=1/4e4;function qi(e,n){const i=t.clamp(n.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),r=new t.LngLat(n.lng-180*Wi,i),o=new t.LngLat(n.lng+180*Wi,i),s=e.project(r.lng,i),a=e.project(o.lng,i),l=t.MercatorCoordinate.fromLngLat(r),c=t.MercatorCoordinate.fromLngLat(o),u=a.x-s.x,h=a.y-s.y,d=c.x-l.x,p=c.y-l.y,f=Math.sqrt((d*d+p*p)/(u*u+h*h));return Math.log(f)/Math.LN2}function Xi(t,e,n){const i=Math.cos(n),r=Math.sin(n);return{x:t*i-e*r,y:t*r+e*i}}class Yi{constructor(e,n,i,r,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Fi,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Vi,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const t=new Yi(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.mercatorFromTransition=this.mercatorFromTransition,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(t,e=!1){const n=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||n)&&this._updateCameraOnTerrain(),(t||n)&&this._constrainCamera(e),this._calcMatrices()}getProjection(){return t.pick(this.projection,["name","center","parallels"])}setProjection(n){this.projectionOptions=n||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=t.getProjection(this.projectionOptions);const r=!e(i,this.getProjection());return r&&this._calcMatrices(),this.mercatorFromTransition=!1,r}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=t.getProjection({name:"mercator"});const n=e!==this.projection.name;return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return t.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.Point(this.width,this.height)}get bearing(){return t.wrap(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const n=-e*Math.PI/180;var i;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(i=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),function(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),l=Math.cos(n);t[0]=i*l+o*a,t[1]=r*l+s*a,t[2]=i*-a+o*l,t[3]=r*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const n=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const t=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/t)}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=t.degToRad(e),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._setZoom(e),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const t=this._elevation;this._centerAltitude=t.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=t.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let r=0,o=0;for(let s=0;s<n.length;s++){const a=new t.Point(n[s][0]*this.width,i+n[s][1]*(this.height-i)),l=e.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,o+=c}return 0===o?NaN:r/o}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const t=this._seaLevelZoom,e=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),n=this.pixelsPerMeter/this.worldSize*e,i=this._mercatorZfromZoom(t),r=this._mercatorZfromZoom(this._maxZoom),o=Math.max(i-n,r);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}computeZoomRelativeTo(e){const n=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[n.x,n.y,n.z]:[e.x,e.y,e.z];const r=t.length(t.sub([],this._camera.position,i));return t.clamp(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let n=!1;if(e.orientation&&!t.exactEquals(e.orientation,this._camera.orientation)&&(n=this._setCameraOrientation(e.orientation)),e.position){const i=[e.position.x,e.position.y,e.position.z];t.exactEquals$1(i,this._camera.position)||(this._setCameraPosition(i),n=!0)}n&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,n=new Gi;return n.position=new t.MercatorCoordinate(e[0],e[1],e[2]),n.orientation=this._camera.orientation,n._elevation=this.elevation,n._renderWorldCopies=this.renderWorldCopies,n}_setCameraOrientation(e){if(!t.length$1(e))return!1;t.normalize$1(e,e);const n=t.transformQuat([],[0,0,-1],e),i=t.transformQuat([],[0,-1,0],e);if(i[2]<0)return!1;const r=zi(n,i);return!!r&&(this._camera.orientation=r,!0)}_setCameraPosition(e){const n=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;e[2]=t.clamp(e[2],r/i,r/n),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,n){this._unmodified=!1,this._edgeInsets.interpolate(t,e,n),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(e){const n=[new t.UnwrappedTileID(0,e)];if(this.renderWorldCopies){const i=this.pointCoordinate(new t.Point(0,0)),r=this.pointCoordinate(new t.Point(this.width,0)),o=this.pointCoordinate(new t.Point(this.width,this.height)),s=this.pointCoordinate(new t.Point(0,this.height)),a=Math.floor(Math.min(i.x,r.x,o.x,s.x)),l=Math.floor(Math.max(i.x,r.x,o.x,s.x)),c=1;for(let i=a-c;i<=l+c;i++)0!==i&&n.push(new t.UnwrappedTileID(i,e))}return n}coveringTiles(e){let n=this.coveringZoomLevel(e);const i=n,r=this.elevation&&!e.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==e.minzoom&&n<e.minzoom)return[];void 0!==e.maxzoom&&n>e.maxzoom&&(n=e.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<<n,c=[l*s.x,l*s.y,0],u="globe"===this.projection.name,h=!u,d=t.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,n,h),p=u?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=l*t.mercatorZfromAltitude(1,this.center.lat),m=this._camera.position[2]/t.mercatorZfromAltitude(1,this.center.lat),g=[l*p.x,l*p.y,m*(h?1:f)],_=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),y=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?n:0,v=e.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,x=e.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,b=this.projection.isReprojectedInTileSpace?$i(this):1,T=e=>{const n=1/4e4,i=new t.MercatorCoordinate(e.x+n,e.y,e.z),r=new t.MercatorCoordinate(e.x,e.y+n,e.z),o=e.toLngLat(),s=i.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),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)*b/n},E=e=>{const n=v,i=x;return{aabb:t.tileAABB(this,l,0,0,0,e,i,n,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:n,wrap:e,fullyVisible:!1}},S=[];let w=[];const A=n,M=e.reparseOverscaled?i:n,C=t=>t*t,I=C((m-this._centerAltitude)*f),P=t=>{if(!this._elevation||!t.tileID||!o)return;const e=this._elevation.getMinMaxForTile(t.tileID),n=t.aabb;e?(n.min[2]=e.min,n.max[2]=e.max,n.center[2]=(n.min[2]+n.max[2])/2):(t.shouldSplit=L(t),t.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},L=e=>{if(e.zoom<y)return!0;if(e.zoom===A)return!1;if(null!=e.shouldSplit)return e.shouldSplit;const n=e.aabb.distanceX(g),o=e.aabb.distanceY(g);let s=I,l=1;if(u){s=C(e.aabb.distanceZ(g));const n=Math.pow(2,e.zoom),i=t.latFromMercatorY((e.y+1)/n),r=t.latFromMercatorY(e.y/n),o=Math.min(Math.max(a,i),r),c=t.circumferenceAtLatitude(o)/t.circumferenceAtLatitude(a);if(l=o===a?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,c/this._mercatorScaleRatio),this.zoom<=t.GLOBE_ZOOM_THRESHOLD_MIN&&e.zoom===A-1&&c>=.9)return!0}else if(r&&(s=C(e.aabb.distanceZ(g)*f)),this.projection.isReprojectedInTileSpace&&i<=5){const n=Math.pow(2,e.zoom),i=T(new t.MercatorCoordinate((e.x+.5)/n,(e.y+.5)/n));l=i>.85?1:i}const c=n*n+o*o+s,h=C((1<<A-e.zoom)*_*l*((t,e)=>{if(e*C(.707)<t)return 1;const n=Math.sqrt(e/t);return n/(1.4144271570014144+(Math.pow(1.1,n-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(s,I),c));return c<h};if(this.renderWorldCopies)for(let t=1;t<=3;t++)S.push(E(-t)),S.push(E(t));for(S.push(E(0));S.length>0;){const i=S.pop(),s=i.x,a=i.y;let h=i.fullyVisible;if(!h){const t=i.aabb.intersects(d);if(0===t)continue;h=2===t}if(i.zoom!==A&&L(i))for(let e=0;e<4;e++){const n=(s<<1)+e%2,c=(a<<1)+(e>>1),d={aabb:o?i.aabb.quadrant(e):t.tileAABB(this,l,i.zoom+1,n,c,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:n,y:c,wrap:i.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};r&&!u&&(d.tileID=new t.OverscaledTileID(i.zoom+1===A?M:i.zoom+1,i.wrap,i.zoom+1,n,c),P(d)),S.push(d)}else{const r=i.zoom===A?M:i.zoom;if(e.minzoom&&e.minzoom>r)continue;const o=c[0]-(.5+s+(i.wrap<<i.zoom))*(1<<n-i.zoom),l=c[1]-.5-a,u=i.tileID?i.tileID:new t.OverscaledTileID(r,i.wrap,i.zoom,s,a);w.push({tileID:u,distanceSq:o*o+l*l})}}if(this.fogCullDistSq){const n=this.fogCullDistSq,i=this.horizonLineFromTop();w=w.filter((r=>{const o=[0,0,0,1],s=[t.EXTENT,t.EXTENT,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());t.transformMat4$1(o,o,a),t.transformMat4$1(s,s,a);const l=t.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>n&&0!==i){const n=this.calculateProjMatrix(r.tileID.toUnwrapped());let o;e.isTerrainDEM||(o=u.getMinMaxForTile(r.tileID)),o||(o={min:x,max:v});const s=t.furthestTileCorner(this.rotation),a=[s[0]*t.EXTENT,s[1]*t.EXTENT,o.max];t.transformMat4(a,a,n),c=(1-a[1])*this.height*.5<i}return l<n||c}))}return w.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(e){const n=t.clamp(e.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),i=this.projection.project(e.lng,n);return new t.Point(i.x*this.worldSize,i.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/t.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,n){let i,r;const o=this.centerPoint;if("globe"===this.projection.name){const t=this.worldSize;i=(n.x-o.x)/t,r=(n.y-o.y)/t}else{const t=this.pointCoordinate(n),e=this.pointCoordinate(o);i=t.x-e.x,r=t.y-e.y}const s=this.locationCoordinate(e);this.setLocation(new t.MercatorCoordinate(s.x-i,s.y-r))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this.projection.locationPoint(this,t,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(e,n){const i=n?t.mercatorZfromAltitude(n,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new t.MercatorCoordinate(r.x,r.y,i)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(e,n){const i=null!=n?n:this._centerAltitude,r=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.transformMat4$1(r,r,this.pixelMatrixInverse),t.transformMat4$1(o,o,this.pixelMatrixInverse);const s=o[3];t.scale$1(r,r,1/r[3]),t.scale$1(o,o,1/s);const a=r[2],l=o[2];return{p0:r,p1:o,t:a===l?0:(i-a)/(l-a)}}screenPointToMercatorRay(e){const n=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return t.transformMat4$1(n,n,this.pixelMatrixInverse),t.transformMat4$1(i,i,this.pixelMatrixInverse),t.scale$1(n,n,1/n[3]),t.scale$1(i,i,1/i[3]),n[2]=t.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,i[2]=t.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,t.scale$1(n,n,1/this.worldSize),t.scale$1(i,i,1/this.worldSize),new t.Ray([n[0],n[1],n[2]],t.normalize([],t.sub([],i,n)))}rayIntersectionCoordinate(e){const{p0:n,p1:i,t:r}=e,o=t.mercatorZfromAltitude(n[2],this._center.lat),s=t.mercatorZfromAltitude(i[2],this._center.lat);return new t.MercatorCoordinate(t.number(n[0],i[0],r)/this.worldSize,t.number(n[1],i[1],r)/this.worldSize,t.number(o,s,r))}pointCoordinate(t,e=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,e)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let n=this.projection.pointCoordinate3D(this,e.x,e.y);if(n)return new t.MercatorCoordinate(n[0],n[1],n[2]);let i=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e);const o=.02*r,s=e.clone();for(let e=0;e<10&&r-i>o;e++){s.y=t.number(i,r,.66);const e=this.projection.pointCoordinate3D(this,s.x,s.y);e?(r=s.y,n=e):i=s.y}return n?new t.MercatorCoordinate(n[0],n[1],n[2]):this.pointCoordinate(e)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return!1;if(this.elevation||this.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(e);const n=this.pointCoordinate(e);return n.y>=0&&n.y<=1}_coordinatePoint(e,n){const i=n&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,r=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return t.transformMat4$1(r,r,this.pixelMatrix),r[3]>0?new t.Point(r[0]/r[3],r[1]/r[3]):new t.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:n}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,o=this.pointLocation3D(new t.Point(n,e)),s=this.pointLocation3D(new t.Point(r,e)),a=this.pointLocation3D(new t.Point(r,i)),l=this.pointLocation3D(new t.Point(n,i));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(e,n,i,r,o)=>{const s=(e+i)/2,a=(n+r)/2,l=new t.Point(s,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,_),(o<f||y>p)&&(m(e,n,s,a,o+1),m(s,a,i,r,o+1))};if(m(n,e,r,e,1),m(r,e,r,i,1),m(r,i,n,i,1),m(n,i,n,e,1),"globe"===this.projection.name){const[e,n]=t.polesInViewport(this);e?(d=90,u=180,c=-180):n&&(h=-90,u=180,c=-180)}return new t.LngLatBounds(new t.LngLat(c,h),new t.LngLat(u,d))}_getBoundsRectangular(e,n){const{top:i,left:r}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new t.Point(r,i),l=new t.Point(s,i),c=new t.Point(s,o),u=new t.Point(r,o);let h=this.pointCoordinate(a,e),d=this.pointCoordinate(l,e);const p=this.pointCoordinate(c,n),f=this.pointCoordinate(u,n),m=(t,e)=>(e.y-t.y)/(e.x-t.x);return h.y>1&&d.y>=0?h=new t.MercatorCoordinate((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new t.MercatorCoordinate(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new t.MercatorCoordinate((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new t.MercatorCoordinate(-p.y/m(p,d)+p.x,0)),(new t.LngLatBounds).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const t=this.elevation;if(!t.visibleDemTiles.length||t.isUsingMockSource())return this._getBoundsRectangular(0,0);const e=t.visibleDemTiles.reduce(((t,e)=>{if(e.dem){const n=e.dem.tree;t.min=Math.min(t.min,n.minimums[0]),t.max=Math.max(t.max,n.maximums[0])}return t}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(e.min*t.exaggeration(),e.max*t.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(t=!0){const e=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,n=this.height/2-e*(1-this._horizonShift);return t?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-t.MAX_MERCATOR_LATITUDE,this.maxLat=t.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=t.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=t.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=t.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=t.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,e){return this.projection.createTileMatrix(this,e,t)}calculateDistanceTileData(e){const n=e.key,i=this._distanceTileDataCache;if(i[n])return i[n];const r=e.canonical,o=1/this.height,s=this.cameraWorldSize,a=s/this.zoomScale(r.z),l=(r.x+Math.pow(2,r.z)*e.wrap)*a,c=r.y*a,u=this.point;u.x*=s/this.worldSize,u.y*=s/this.worldSize;const h=this.angle,d=Math.sin(-h),p=-Math.cos(-h);return i[n]={bearing:[d,p],center:[(u.x-l)*o,(u.y-c)*o],scale:a/t.EXTENT*o},i[n]}calculateFogTileMatrix(e){const n=e.key,i=this._fogTileMatrixCache;if(i[n])return i[n];const r=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,e);return t.multiply(r,this.worldToFogMatrix,r),i[n]=new Float32Array(r),i[n]}calculateProjMatrix(e,n=!1){const i=e.key,r=n?this._alignedProjMatrixCache:this._projMatrixCache;if(r[i])return r[i];const o=this.calculatePosMatrix(e,this.worldSize);return t.multiply(o,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:n?this.alignedProjMatrix:this.projMatrix,o),r[i]=new Float32Array(o),r[i]}calculatePixelsToTileUnitsMatrix(e){const n=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[n])return i[n];const r=function(e,n){const{scale:i}=e.tileTransform,r=i*t.EXTENT/(e.tileSize*Math.pow(2,n.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return o=new Float32Array(4),l=(s=n.inverseAdjustmentMatrix)[1],c=s[2],u=s[3],d=(a=[r,r])[1],o[0]=s[0]*(h=a[0]),o[1]=l*h,o[2]=c*d,o[3]=u*d,o;var o,s,a,l,c,u,h,d}(e,this);return i[n]=r,i[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const e=1/this.worldSize,n=t.fromScaling([],[e,e,e]);return t.multiply(n,n,this.globeMatrix),n}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const e=this._elevation;this._updateCameraState();const n=t.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(n),r=this._camera.forward(),o=t.mercatorZfromAltitude(1,this._center.lat);i[2]/=o,r[2]/=o,t.normalize(r,r);const s=e.raycast(i,r,e.exaggeration());if(s){const e=t.scaleAndAdd([],i,r,s),n=new t.MercatorCoordinate(e[0],e[1],t.mercatorZfromAltitude(e[2],t.latFromMercatorY(e[1]))),a=(n.z+t.length([n.x-i[0],n.y-i[1],n.z-i[2]*o]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=n.toAltitude(),this._center=this.coordinateLocation(n),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(e=!1){if(!this._elevation)return;const n=this._elevation,i=t.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),o=n.getAtPointOrZero(new t.MercatorCoordinate(...r)),s=this.pixelsPerMeter/this.worldSize*o,a=this._minimumHeightOverTerrain(),l=r[2]-s;if(l<=a)if(l<0||e){const e=this.locationCoordinate(this._center,this._centerAltitude),n=[r[0],r[1],e.z-r[2]],i=t.length(n);n[2]-=(a-l)/this._pixelsPerMercatorPixel;const o=t.length(n);if(0===o)return;t.scale$2(n,n,i/o*this._pixelsPerMercatorPixel),this._camera.position=[r[0],r[1],e.z*this._pixelsPerMercatorPixel-n[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const n=this.center;return n.lat=t.clamp(n.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(n.lng=t.clamp(n.lng,this.minLng,this.maxLng)),this.center=n,void(this._constraining=!1)}const n=this._unmodified,{x:i,y:r}=this.point;let o=0,s=i,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&&(o=Math.max(o,this.height/(h-u)),a=(h+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const t=this.worldMinX*this.scale,e=this.worldMaxX*this.scale,n=this.worldSize/2-(t+e)/2;s=(i+n+this.worldSize)%this.worldSize-n,s-l<t&&(s=t+l),s+l>e&&(s=e-l),e-t<this.width&&(o=Math.max(o,this.width/(e-t)),s=(e+t)/2)}s===i&&a===r||(this.center=this.unproject(new t.Point(s,a))),o&&(this.zoom+=this.scaleZoom(o)),this._constrainCamera(),this._unmodified=n,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,n=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=t.mercatorZfromAltitude(1,this.center.lat)/t.mercatorZfromAltitude(1,t.GLOBE_SCALE_MATCH_LATITUDE));const i=Hi(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,i),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 r="meters"===this.projection.zAxisUnit?n:1,o=this._camera.getWorldToCamera(this.worldSize,r),s=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);s[8]=2*-e.x/this.width,s[9]=2*e.y/this.height;let a=t.mul([],s,o);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),n=t.identity([]);t.translate(n,n,[e.x*this.worldSize,e.y*this.worldSize,0]),t.multiply(n,n,ji(this)),t.translate(n,n,[-e.x*this.worldSize,-e.y*this.worldSize,0]),t.multiply(a,a,n),this.inverseAdjustmentMatrix=function(t){const e=ji(t,!0);return y([],[e[0],e[1],e[4],e[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=t.scale([],a,[this.worldSize,this.worldSize,this.worldSize/r,1]),this.projMatrix=a,this.invProjMatrix=t.invert(new Float64Array(16),this.projMatrix);const l=t.invert([],s);this.frustumCorners=t.FrustumCorners.fromInvProjectionMatrix(l,this.horizonLineFromTop(),this.height);const c=new Float32Array(16);t.identity(c),t.scale(c,c,[1,-1,1]),t.rotateX(c,c,this._pitch),t.rotateZ(c,c,this.angle);const u=t.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),h=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;u[8]=2*-e.x/this.width,u[9]=2*(e.y+h)/this.height,this.skyboxMatrix=t.multiply(c,u,c);const d=this.point,p=d.x,f=d.y,m=this.width%2/2,g=this.height%2/2,_=Math.cos(this.angle),v=Math.sin(this.angle),x=p-Math.round(p)+_*m+v*g,b=f-Math.round(f)+_*g+v*m,T=new Float64Array(a);if(t.translate(T,T,[x>.5?x-1:x,b>.5?b-1:b,0]),this.alignedProjMatrix=T,a=t.create(),t.scale(a,a,[this.width/2,-this.height/2,1]),t.translate(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=t.create(),t.scale(a,a,[1,-1,1]),t.translate(a,a,[-1,-1,0]),t.scale(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},a=t.invert(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=a,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=t.calculateGlobeMatrix(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=t.transformMat4(e,e,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=a;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,n=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,o=[e,e,n];t.scale$2(o,o,r),t.scale$2(i,i,-1),t.multiply$2(i,i,o);const s=t.create();t.translate(s,s,i),t.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,n,r)}_computeCameraPosition(t){const e=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),i=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*e-t/this.worldSize*this._centerAltitude;return[i.x/this.worldSize-n[0]*r,i.y/this.worldSize-n[1]*r,t/this.worldSize*this._centerAltitude-n[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],r=e[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(o=Math.min((n-i)/r,1)),this._camera.position=t.scaleAndAdd([],this._camera.position,e,o),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,n=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),o=t.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(t.degToRad(this._maxPitch)),a=Math.max((e[2]-o)/Math.cos(i),s),l=this._zoomFromMercatorZ(a);t.scaleAndAdd(e,e,n,a),this._pitch=t.clamp(i,t.degToRad(this.minPitch),t.degToRad(this.maxPitch)),this.angle=t.wrap(r,-Math.PI,Math.PI),this._setZoom(t.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new t.MercatorCoordinate(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}zoomFromMercatorZAdjusted(e){let n=0,i=t.GLOBE_ZOOM_THRESHOLD_MAX,r=0,o=1/0;for(;i-n>1e-6&&i>n;){const t=n+.5*(i-n),s=this.tileSize*Math.pow(2,t),a=this.getCameraToCenterDistance(this.projection,t,s),l=this.scaleZoom(a/(e*this.tileSize)),c=Math.abs(t-l);c<o&&(o=c,r=t),t<l?n=t:i=t}return r}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(t.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,n){const i=Math.min(e.x,n.x),r=Math.max(e.x,n.x),o=Math.min(e.y,n.y),s=Math.max(e.y,n.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new t.Point(i,o),new t.Point(r,s),new t.Point(i,s),new t.Point(r,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const t of a){const e=this.pointRayIntersection(t);if(e.t<0)return!0;const n=this.rayIntersectionCoordinate(e);if(n.x<l||n.y<0||n.x>c||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+t.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new t.Point(0,0),new t.Point(this.width,this.height))}zoomDeltaToMovement(e,n){const i=t.length(t.sub([],this._camera.position,e)),r=this._zoomFromMercatorZ(i)+n;return i-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function([e,n,i],r){const o=[e,n,i,1];t.transformMat4$1(o,o,r);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new t.Point(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.Point(0,e))}}getCameraToCenterDistance(t,e=this.zoom,n=this.worldSize){const i=Hi(t,e,this.width,this.height,1024),r=t.pixelSpaceConversion(this.center.lat,n,i);return.5/Math.tan(.5*this._fov)*this.height*r}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&t.multiply(e,e,this.globeMatrix),e}}function Zi(t,e){let n=!1,i=null;const r=()=>{i=null,n&&(t(),i=setTimeout(r,e),n=!1)};return()=>(n=!0,i||r(),i)}class Ji{constructor(e){this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Zi(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,t.window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),t.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const n=Ki(e);if(this._hashName){const e=this._hashName;let i=!1;const r=t.window.location.hash.slice(1).split("&").map((t=>{const r=t.split("=")[0];return r===e?(i=!0,`${r}=${n}`):t})).filter((t=>t));return i||r.push(`${e}=${n}`),`#${r.join("&")}`}return`#${n}`}_getCurrentHash(){const e=t.window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((t=>t.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const e=this._getCurrentHash();if(e.length>=3&&!e.some((t=>isNaN(t)))){const n=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(e[3]||0):t.getBearing();return t.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:n,pitch:+(e[4]||0)}),!0}return!1}_updateHashUnthrottled(){const e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());t.window.history.replaceState(t.window.history.state,null,e)}}function Ki(t,e){const n=t.getCenter(),i=Math.round(100*t.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),s=Math.round(n.lng*o)/o,a=Math.round(n.lat*o)/o,l=t.getBearing(),c=t.getPitch();let u=e?`/${s}/${a}/${i}`:`${i}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const Qi={linearity:.3,easing:t.bezier(0,0,.3,1)},tr=t.extend({deceleration:2500,maxSpeed:1400},Qi),er=t.extend({deceleration:20,maxSpeed:1400},Qi),nr=t.extend({deceleration:1e3,maxSpeed:360},Qi),ir=t.extend({deceleration:1e3,maxSpeed:90},Qi);class rr{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=t.exported.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new t.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)n.zoom+=t.zoomDelta||0,n.bearing+=t.bearingDelta||0,n.pitch+=t.pitchDelta||0,t.panDelta&&n.pan._add(t.panDelta),t.around&&(n.around=t.around),t.pinchAround&&(n.pinchAround=t.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(n.pan.mag()){const o=sr(n.pan.mag(),i,t.extend({},tr,e||{}));r.offset=n.pan.mult(o.amount/n.pan.mag()),r.center=this._map.transform.center,or(r,o)}if(n.zoom){const t=sr(n.zoom,i,er);r.zoom=this._map.transform.zoom+t.amount,or(r,t)}if(n.bearing){const e=sr(n.bearing,i,nr);r.bearing=this._map.transform.bearing+t.clamp(e.amount,-179,179),or(r,e)}if(n.pitch){const t=sr(n.pitch,i,ir);r.pitch=this._map.transform.pitch+t.amount,or(r,t)}if(r.zoom||r.bearing){const t=void 0===n.pinchAround?n.around:n.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function or(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function sr(e,n,i){const{maxSpeed:r,linearity:o,deceleration:s}=i,a=t.clamp(e*o/(n/1e3),-r,r),l=Math.abs(a)/(s*o);return{easing:i.easing,duration:1e3*l,amount:a*(l/2)}}class ar extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,i,r={}){const o=f(n.getCanvasContainer(),i),s=n.unproject(o);super(e,t.extend({point:o,lngLat:s,originalEvent:i},r)),this._defaultPrevented=!1,this.target=n}}class lr extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,i){const r="touchend"===e?i.changedTouches:i.touches,o=m(n.getCanvasContainer(),r),s=o.map((t=>n.unproject(t))),a=o.reduce(((t,e,n,i)=>t.add(e.div(i.length))),new t.Point(0,0));super(e,{points:o,point:a,lngLats:s,lngLat:n.unproject(a),originalEvent:i}),this._defaultPrevented=!1}}class cr extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,n){super(t,{originalEvent:n}),this._defaultPrevented=!1}}class ur{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new cr(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new ar(t.type,this._map,t))}mouseup(t){this._map.fire(new ar(t.type,this._map,t))}preclick(e){const n=t.extend({},e);n.type="preclick",this._map.fire(new ar(n.type,this._map,n))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||(this.preclick(t),this._map.fire(new ar(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new ar(t.type,this._map,t))}mouseover(t){this._map.fire(new ar(t.type,this._map,t))}mouseout(t){this._map.fire(new ar(t.type,this._map,t))}touchstart(t){return this._firePreventable(new lr(t.type,this._map,t))}touchmove(t){this._map.fire(new lr(t.type,this._map,t))}touchend(t){this._map.fire(new lr(t.type,this._map,t))}touchcancel(t){this._map.fire(new lr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class hr{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new ar(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ar("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new ar(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class dr{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(u(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const n=e,i=this._startPos,r=this._lastPos;if(!i||!r||r.equals(n)||!this._box&&n.dist(i)<this._clickTolerance)return;this._lastPos=n,this._box||(this._box=o("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const s=Math.min(i.x,n.x),a=Math.max(i.x,n.x),l=Math.min(i.y,n.y),c=Math.max(i.y,n.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${s}px,${l}px)`,this._box.style.width=a-s+"px",this._box.style.height=c-l+"px")}))}mouseupWindow(e,n){if(!this._active)return;const i=this._startPos,r=n;if(i&&0===e.button){if(this.reset(),p(),i.x!==r.x||i.y!==r.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:t=>t.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new t.Event(e,{originalEvent:n}))}}function pr(t,e){const n={};for(let i=0;i<t.length;i++)n[t[i].identifier]=e[i];return n}class fr{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(e,n,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){const n=new t.Point(0,0);for(const t of e)n._add(t);return n.div(e.length)}(n),this.touches=pr(i,n)))}touchmove(t,e,n){if(this.aborted||!this.centroid)return;const i=pr(n,e);for(const t in this.touches){const e=i[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,n){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class mr{constructor(t){this.singleTap=new fr(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,e,n){this.singleTap.touchstart(t,e,n)}touchmove(t,e,n){this.singleTap.touchmove(t,e,n)}touchend(t,e,n){const i=this.singleTap.touchend(t,e,n);if(i){const e=t.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(i)<30;if(e&&n||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}}class gr{constructor(){this._zoomIn=new mr({numTouches:1,numTaps:2}),this._zoomOut=new mr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,n){this._zoomIn.touchstart(t,e,n),this._zoomOut.touchstart(t,e,n)}touchmove(t,e,n){this._zoomIn.touchmove(t,e,n),this._zoomOut.touchmove(t,e,n)}touchend(t,e,n){const i=this._zoomIn.touchend(t,e,n),r=this._zoomOut.touchend(t,e,n);return i?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(i)},{originalEvent:t})}):r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(r)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const _r={0:1,2:2};class yr{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const n=g(t);this._correctButton(t,n)&&(this._lastPoint=e,this._eventButton=n)}mousemoveWindow(t,e){const n=this._lastPoint;if(n)if(t.preventDefault(),null!=this._eventButton&&function(t,e){const n=_r[e];return void 0===t.buttons||(t.buttons&n)!==n}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(n)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(n,e)}mouseupWindow(t){this._lastPoint&&g(t)===this._eventButton&&(this._moved&&p(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class vr extends yr{mousedown(t,e){super.mousedown(t,e),this._lastPoint&&(this._active=!0)}_correctButton(t,e){return 0===e&&!t.ctrlKey}_move(t,e){return{around:e,panDelta:e.sub(t)}}}class xr extends yr{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const n=.8*(e.x-t.x);if(n)return this._active=!0,{bearingDelta:n}}contextmenu(t){t.preventDefault()}}class br extends yr{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const n=-.5*(e.y-t.y);if(n)return this._active=!0,{pitchDelta:n}}contextmenu(t){t.preventDefault()}}class Tr{constructor(e,n){this._map=e,this._el=e.getCanvasContainer(),this._minTouches=1,this._clickTolerance=n.clickTolerance||1,this.reset(),t.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new t.Point(0,0)}touchstart(t,e,n){return this._calculateTransform(t,e,n)}touchmove(e,n,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length&&!t.isFullscreen())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return e.cancelable&&e.preventDefault(),this._calculateTransform(e,n,i)}}touchend(t,e,n){this._calculateTransform(t,e,n),this._active&&n.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,i){i.length>0&&(this._active=!0);const r=pr(i,n),o=new t.Point(0,0),s=new t.Point(0,0);let a=0;for(const t in r){const e=r[t],n=this._touches[t];n&&(o._add(e),s._add(e.sub(n)),a++,r[t]=e)}if(this._touches=r,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.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=o("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=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")}),500)}}class Er{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,e,n){return{}}touchstart(t,e,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,n){const i=this._firstTwoTouches;if(!i)return;t.preventDefault();const[r,o]=i,s=Sr(n,e,r),a=Sr(n,e,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,t)}touchend(t,e,n){if(!this._firstTwoTouches)return;const[i,r]=this._firstTwoTouches,o=Sr(n,e,i),s=Sr(n,e,r);o&&s||(this._active&&p(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Sr(t,e,n){for(let i=0;i<t.length;i++)if(t[i].identifier===n)return e[i]}function wr(t,e){return Math.log(t/e)/Math.LN2}class Ar extends Er{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const n=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(wr(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:wr(this._distance,n),pinchAround:e}}}function Mr(t,e){return 180*t.angleWith(e)/Math.PI}class Cr extends Er{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e){const n=this._vector;if(this._vector=t[0].sub(t[1]),n&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Mr(this._vector,n),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,n=this._startVector;if(!n)return!1;const i=Mr(t,n);return Math.abs(i)<e}}function Ir(t){return Math.abs(t.y)>Math.abs(t.x)}class Pr extends Er{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Ir(t[0].sub(t[1]))&&(this._valid=!1)}_move(e,n,i){const r=this._lastPoints;if(!r)return;const o=e[0].sub(r[0]),s=e[1].sub(r[1]);return this._map._cooperativeGestures&&!t.isFullscreen()&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(t,e,n){if(void 0!==this._valid)return this._valid;const i=t.mag()>=2,r=e.mag()>=2;if(!i&&!r)return;if(!i||!r)return null==this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const o=t.y>0==e.y>0;return Ir(t)&&Ir(e)&&o}}const Lr={panStep:100,bearingStep:15,pitchStep:10};class Rr{constructor(){const t=Lr;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,n=0,i=0,r=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?n=-1:(t.preventDefault(),r=-1);break;case 39:t.shiftKey?n=1:(t.preventDefault(),r=1);break;case 38:t.shiftKey?i=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?i=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(n=0,i=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Or,zoom:e?Math.round(a)+e*(t.shiftKey?2:1):a,bearing:s.getBearing()+n*this._bearingStep,pitch:s.getPitch()+i*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:t})}}}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 Or(t){return t*(2-t)}const Dr=4.000244140625;class Br{constructor(e,n){this._map=e,this._el=e.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||t.isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=t.exported.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==n&&n%Dr==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){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 e=f(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:e,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 e=this._map.transform;"wheel"===this._type&&e.projection.wrap&&(e._center.lng>=180||e._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const n=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>Dr?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==i&&(i=1/i);const r=n(),o=Math.pow(2,r),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*i))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:n(),r=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&r&&o){const e=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),n=o(e);s=t.number(r,i,n),e<1?this._frameId||(this._frameId=!0):a=!0}else s=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-n(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=t.ease;if(this._prevEase){const e=this._prevEase,i=(t.exported.now()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);n=t.bezier(o,s,.25,1)}return this._prevEase={start:t.exported.now(),duration:e,easing:n},n}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(t.window.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=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")}),200)}}class Nr{constructor(t,e){this._clickZoom=t,this._tapZoom=e}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 Fr{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,e){return t.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:n.getZoom()+(t.shiftKey?-1:1),around:n.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ur{constructor(){this._tap=new mr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,e,n){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=e[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(t,e,n))}touchmove(t,e,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const i=e[0],r=i.y-this._swipePoint.y;return this._swipePoint=i,t.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(t,e,n)}touchend(t,e,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(t,e,n)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class kr{constructor(t,e,n){this._el=t,this._mousePan=e,this._touchPan=n}enable(t){this._inertiaOptions=t||{},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 zr{constructor(t,e,n){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=n}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 Gr{constructor(t,e,n,i){this._el=t,this._touchZoom=e,this._touchRotate=n,this._tapDragZoom=i,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),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 Vr=t=>t.zoom||t.drag||t.pitch||t.rotate;class jr extends t.Event{}class $r{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,n){const i=t.sub([],n,e);this.radius=t.length(i[2]<0?t.div([],i,this.constants):[i[0],i[1],0])}projectRay(e){t.div(e,e,this.constants),t.normalize(e,e),t.mul$1(e,e,this.constants);const n=t.scale$2([],e,this.radius);if(n[2]>0){const e=t.scale$2([],[0,0,1],t.dot(n,[0,0,1])),i=t.scale$2([],t.normalize([],[n[0],n[1],0]),this.radius),r=t.add([],n,t.scale$2([],t.sub([],t.add([],i,e),n),2));n[0]=r[0],n[1]=r[1]}return n}}function Hr(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class Wr{constructor(e,n){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new rr(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new $r,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),t.bindAll(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[t.window,"blur",void 0]];for(const[e,n,i]of this._listeners)e.addEventListener(n,e===t.window.document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,n,i]of this._listeners)e.removeEventListener(n,e===t.window.document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,n=e.getCanvasContainer();this._add("mapEvent",new ur(e,t));const i=e.boxZoom=new dr(e,t);this._add("boxZoom",i);const r=new gr,o=new Fr;e.doubleClickZoom=new Nr(o,r),this._add("tapZoom",r),this._add("clickZoom",o);const s=new Ur;this._add("tapDragZoom",s);const a=e.touchPitch=new Pr(e);this._add("touchPitch",a);const l=new xr(t),c=new br(t);e.dragRotate=new zr(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new vr(t),h=new Tr(e,t);e.dragPan=new kr(n,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new Cr,p=new Ar;e.touchZoomRotate=new Gr(n,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new hr(e));const f=e.scrollZoom=new Br(e,this);this._add("scrollZoom",f,["mousePan"]);const m=e.keyboard=new Rr;this._add("keyboard",m);for(const n of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[n]&&e[n].enable(t[n])}_add(t,e,n){this._handlers.push({handlerName:t,handler:e,allowed:n}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Vr(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(t,e,n){for(const i in t)if(i!==n&&(!e||e.indexOf(i)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const n of t)this._el.contains(n.target)&&e.push(n);return e}handleEvent(t,e){this._updatingCamera=!0;const n="renderFrame"===t.type,i=n?void 0:t,r={needsRenderFrame:!1},o={},s={},a=t.touches?this._getMapTouches(t.touches):void 0,l=a?m(this._el,a):n?void 0:f(this._el,t);for(const{handlerName:n,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,n)?c.reset():c[e||t.type]&&(h=c[e||t.type](t,l,a),this.mergeHandlerResult(r,o,h,n,i),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[n]=c)}const c={};for(const t in this._previousActiveHandlers)s[t]||(c[t]=i);this._previousActiveHandlers=s,(Object.keys(c).length||Hr(r))&&(this._changes.push([r,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Hr(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,n,i,r,o){if(!i)return;t.extend(e,i);const s={handlerName:r,originalEvent:i.originalEvent||o};void 0!==i.zoomDelta&&(n.zoom=s),void 0!==i.panDelta&&(n.drag=s),void 0!==i.pitchDelta&&(n.pitch=s),void 0!==i.bearingDelta&&(n.rotate=s)}_applyChanges(){const e={},n={},i={};for(const[r,o,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new t.Point(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.aroundCoord&&(e.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t.extend(n,o),t.extend(i,s);this._updateMapTransform(e,n,i),this._changes=[]}_updateMapTransform(e,n,i){const r=this._map,o=r.transform,s=t=>[t.x,t.y,t.z];if((()=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Hr(e)){const t=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",t!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&r._stop(!0),!Hr(e))return void this._fireEvents(n,i,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=e;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(t=>n[t]&&!this._eventsInProgress[t])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=e[0]-t[0],f[1]=e[1]-t[1]}else{const e=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const n=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*t.mercatorScale(t.latFromMercatorY(e.y))*n,f[1]=-a.y*t.mercatorScale(o.center.lat)*n}else{const t=o.pointCoordinate(h.sub(a));e&&t&&(f[0]=t.x-e.x,f[1]=t.y-e.y)}}const m=o.zoom,g=[0,0,0];if(l){const e=s(d||o.pointCoordinate3D(h)),n={dir:t.normalize([],t.sub([],e,o._camera.position))};if(n.dir[2]<0){const i=o.zoomDeltaToMovement(e,l);t.scale$2(g,n.dir,i)}}const _=t.add(f,f,g);o._translateCameraConstrained(_),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,i,!0)}_fireEvents(e,n,i){const r=Vr(this._eventsInProgress),o=Vr(e),s={};for(const t in e){const{originalEvent:n}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=n),this._eventsInProgress[t]=e[t]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in s)this._fireEvent(t,s[t]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:n}=e[t];this._fireEvent(t,n)}const a={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:i}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=n[e]||i,a[`${t}end`]=l)}for(const t in a)this._fireEvent(t,a[t]);const c=Vr(this._eventsInProgress);if(i&&(r||o)&&!c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;e?(n(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:l})):(this._map.fire(new t.Event("moveend",{originalEvent:l})),n(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new t.Event(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{this._frameId=void 0,this.handleEvent(new jr("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const qr="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Xr extends t.Evented{constructor(e,n){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this._respectPrefersReducedMotion=!1!==n.respectPrefersReducedMotion,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,n,i){return e=t.Point.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},n),i)}panTo(e,n,i){return this.easeTo(t.extend({center:e},n),i)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,n,i){return this.easeTo(t.extend({zoom:e},n),i)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,n,i){return this.easeTo(t.extend({bearing:e},n),i)}resetNorth(e,n){return this.rotateTo(0,t.extend({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),n),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(e,n){e=t.LngLatBounds.convert(e);const i=n&&n.bearing||0,r=n&&n.pitch||0,o=e.getNorthWest(),s=e.getSouthEast();return this._cameraForBounds(this.transform,o,s,i,r,n)}_extendCameraOptions(e){const n={top:0,bottom:0,right:0,left:0};if("number"==typeof(e=t.extend({padding:n,offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding){const t=e.padding;e.padding={top:t,bottom:t,right:t,left:t}}return e.padding=t.extend(n,e.padding),e}_minimumAABBFrustumDistance(t,e){const n=e.max[0]-e.min[0],i=e.max[1]-e.min[1];return n/i>t.aspect?n/(2*Math.tan(.5*t.fovX)*t.aspect):i/(2*Math.tan(.5*t.fovY)*t.aspect)}_cameraForBoundsOnGlobe(e,n,i,r,o,s){const a=e.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=o;const c=t.LngLat.convert(n),u=t.LngLat.convert(i),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=t.latLngToECEF(h,d),f=t.normalize([],p),m=t.normalize([],t.cross([],f,[0,1,0])),g=t.cross([],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,t.latLngToECEF(c.lat,c.lng),t.latLngToECEF(u.lat,c.lng),t.latLngToECEF(u.lat,u.lng),t.latLngToECEF(c.lat,u.lng),t.latLngToECEF(h,c.lng),t.latLngToECEF(h,u.lng),t.latLngToECEF(c.lat,d),t.latLngToECEF(u.lat,d)];let v=t.Aabb.fromPoints(y.map((e=>[t.dot(m,e),t.dot(g,e),t.dot(f,e)])));const x=t.transformMat4([],v.center,_);0===t.squaredLength(x)&&t.set(x,0,0,1),t.normalize(x,x),t.scale$2(x,x,t.GLOBE_RADIUS),a.center=t.ecefToLatLng(x);const b=a.getWorldToCameraMatrix(),T=t.invert(new Float64Array(16),b);v=t.Aabb.applyTransform(v,t.multiply([],b,_)),t.transformMat4(x,x,b);const E=.5*(v.max[2]-v.min[2]),S=this._minimumAABBFrustumDistance(a,v),w=t.scale$2([],[0,0,1],E),A=t.add(w,x,w),M=S+(0===a.pitch?0:t.distance(x,A)),C=a.globeCenterInViewSpace,I=t.sub([],x,[C[0],C[1],C[2]]);t.normalize(I,I),t.scale$2(I,I,M);const P=t.add([],x,I);t.transformMat4(P,P,T);const L=t.earthRadius/t.GLOBE_RADIUS,R=t.length(P),O=t.mercatorZfromAltitude(Math.max(R*L-t.earthRadius,Number.EPSILON),0),D=Math.min(a.zoomFromMercatorZAdjusted(O),l.maxZoom);return D>.5*(t.GLOBE_ZOOM_THRESHOLD_MIN+t.GLOBE_ZOOM_THRESHOLD_MAX)?(a.setProjection({name:"mercator"}),a.zoom=D,this._cameraForBounds(a,n,i,r,o,s)):{center:a.center,zoom:D,bearing:r,pitch:o}}queryTerrainElevation(e,n){const i=this.transform.elevation;return i?(n=t.extend({},{exaggerated:!0},n),i.getAtPoint(t.MercatorCoordinate.fromLngLat(e),null,n.exaggerated)):null}_cameraForBounds(e,n,i,r,o,s){if("globe"===e.projection.name)return this._cameraForBoundsOnGlobe(e,n,i,r,o,s);const a=e.clone(),l=this._extendCameraOptions(s),c=a.padding;a.bearing=r,a.pitch=o;const u=t.LngLat.convert(n),h=t.LngLat.convert(i),d=new t.LngLat(u.lng,h.lat),p=new t.LngLat(h.lng,u.lat),f=a.project(u),m=a.project(h),g=this.queryTerrainElevation(u),_=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),v=this.queryTerrainElevation(p),x=[[f.x,f.y,Math.min(g||0,_||0,y||0,v||0)],[m.x,m.y,Math.max(g||0,_||0,y||0,v||0)]];let b=t.Aabb.fromPoints(x);const T=a.getWorldToCameraMatrix(),E=t.invert(new Float64Array(16),T);b=t.Aabb.applyTransform(b,T);const S=t.sub([],b.max,b.min),w=c.left||0,A=c.right||0,M=c.bottom||0,C=c.top||0,{left:I,right:P,top:L,bottom:R}=l.padding,O=.5*(w+A),D=.5*(C+M),B=Math.min(a.scaleZoom(a.scale*Math.min((a.width-(w+A+I+P))/S[0],(a.height-(M+C+R+L))/S[1])),l.maxZoom),N=a.scale/a.zoomScale(B);b=new t.Aabb([b.min[0]-(I+O)*N,b.min[1]-(R+D)*N,b.min[2]],[b.max[0]+(P+O)*N,b.max[1]+(L+D)*N,b.max[2]]);const F=.5*S[2],U=this._minimumAABBFrustumDistance(a,b),k=[0,0,1,0];t.transformMat4$1(k,k,T),t.normalize$2(k,k);const z=t.scale$2([],k,U+F),G=t.add([],b.center,z),V=("number"==typeof l.offset.x&&"number"==typeof l.offset.y?new t.Point(l.offset.x,l.offset.y):t.Point.convert(l.offset)).rotate(-t.degToRad(r));b.center[0]-=V.x*N,b.center[1]+=V.y*N,t.transformMat4(b.center,b.center,E),t.transformMat4(G,G,E);const j=[b.center[0],b.center[1],G[2]*a.pixelsPerMeter];t.scale$2(j,j,1/a.worldSize);const $=t.lngFromMercatorX(j[0]),H=t.latFromMercatorY(j[1]),W=Math.min(a._zoomFromMercatorZ(j[2]),l.maxZoom),q=new t.LngLat($,H);return a.mercatorFromTransition&&W<.5*(t.GLOBE_ZOOM_THRESHOLD_MIN+t.GLOBE_ZOOM_THRESHOLD_MAX)?(a.setProjection({name:"globe"}),a.zoom=W,this._cameraForBounds(a,n,i,r,o,s)):{center:q,zoom:W,bearing:r,pitch:o}}fitBounds(t,e,n){const i=this.cameraForBounds(t,e);return this._fitInternal(i,e,n)}fitScreenCoordinates(e,n,i,r,o){const s=t.Point.convert(e),a=t.Point.convert(n),l=new t.Point(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new t.Point(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new t.Point(l.x,c.y)),p=this.transform.pointLocation3D(new t.Point(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,i,g,r);return this._fitInternal(_,r,o)}_fitInternal(e,n,i){return e?(delete(n=t.extend(e,n)).padding,n.linear?this.easeTo(n,i):this.flyTo(n,i)):this}jumpTo(e,n){this.stop();const i=e.preloadOnly?this.transform.clone():this.transform;let r=!1,o=!1,s=!1;return"zoom"in e&&i.zoom!==+e.zoom&&(r=!0,i.zoom=+e.zoom),void 0!==e.center&&(i.center=t.LngLat.convert(e.center)),"bearing"in e&&i.bearing!==+e.bearing&&(o=!0,i.bearing=+e.bearing),"pitch"in e&&i.pitch!==+e.pitch&&(s=!0,i.pitch=+e.pitch),null==e.padding||i.isPaddingEqual(e.padding)||(i.padding=e.padding),e.preloadOnly?(this._preloadTiles(i),this):(this.fire(new t.Event("movestart",n)).fire(new t.Event("move",n)),r&&this.fire(new t.Event("zoomstart",n)).fire(new t.Event("zoom",n)).fire(new t.Event("zoomend",n)),o&&this.fire(new t.Event("rotatestart",n)).fire(new t.Event("rotate",n)).fire(new t.Event("rotateend",n)),s&&this.fire(new t.Event("pitchstart",n)).fire(new t.Event("pitch",n)).fire(new t.Event("pitchend",n)),this.fire(new t.Event("moveend",n)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||t.warnOnce(qr),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,n){const i=this.transform;if(!i.projection.supportsFreeCamera)return t.warnOnce(qr),this;this.stop();const r=i.zoom,o=i.pitch,s=i.bearing;i.setFreeCameraOptions(e);const a=r!==i.zoom,l=o!==i.pitch,c=s!==i.bearing;return this.fire(new t.Event("movestart",n)).fire(new t.Event("move",n)),a&&this.fire(new t.Event("zoomstart",n)).fire(new t.Event("zoom",n)).fire(new t.Event("zoomend",n)),c&&this.fire(new t.Event("rotatestart",n)).fire(new t.Event("rotate",n)).fire(new t.Event("rotateend",n)),l&&this.fire(new t.Event("pitchstart",n)).fire(new t.Event("pitch",n)).fire(new t.Event("pitchend",n)),this.fire(new t.Event("moveend",n)),this}easeTo(e,n){this._stop(!1,e.easeId),(!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate||this._prefersReducedMotion(e))&&(e.duration=0);const i=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?+e.zoom:r,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,h="padding"in e?e.padding:i.padding,d=t.Point.convert(e.offset);let p,f,m;if("globe"===i.projection.name){const n=t.MercatorCoordinate.fromLngLat(i.center),r=d.rotate(-i.angle);n.x+=r.x/i.worldSize,n.y+=r.y/i.worldSize;const o=n.toLngLat(),s=t.LngLat.convert(e.center||o);this._normalizeCenter(s),p=i.centerPoint.add(r),f=new t.Point(n.x,n.y).mult(i.worldSize),m=new t.Point(t.mercatorXfromLng(s.lng),t.mercatorYfromLat(s.lat)).mult(i.worldSize).sub(f)}else{p=i.centerPoint.add(d);const n=i.pointLocation(p),r=t.LngLat.convert(e.center||n);this._normalizeCenter(r),f=i.project(n),m=i.project(r).sub(f)}const g=i.zoomScale(l-r);let _,y;e.around&&(_=t.LngLat.convert(e.around),y=i.locationPoint(_));const v=this._zooming||l!==r,x=this._rotating||o!==c,b=this._pitching||u!==s,T=!i.isPaddingEqual(h),E=i=>E=>{if(v&&(i.zoom=t.number(r,l,E)),x&&(i.bearing=t.number(o,c,E)),b&&(i.pitch=t.number(s,u,E)),T&&(i.interpolatePadding(a,h,E),p=i.centerPoint.add(d)),_)i.setLocationAtPoint(_,y);else{const t=i.zoomScale(i.zoom-r),e=l>r?Math.min(2,g):Math.max(.5,g),n=Math.pow(e,1-E),o=i.unproject(f.add(m.mult(E*n)).mult(t));i.setLocationAtPoint(i.renderWorldCopies?o.wrap():o,p)}return e.preloadOnly||this._fireMoveEvents(n),i};if(e.preloadOnly){const t=this._emulate(E,e.duration,i);return this._preloadTiles(t),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=x,this._pitching=b,this._padding=T,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,S),this._ease(E(i),(t=>{i.recenterOnTerrain(),this._afterEase(n,t)}),e),this}_prepareEase(e,n,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",n||i.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!i.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new t.Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,r=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new t.Event("zoomend",e)),r&&this.fire(new t.Event("rotateend",e)),o&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}flyTo(e,n){if(this._prefersReducedMotion(e)){const i=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,n)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);const i=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?t.clamp(+e.zoom,i.minZoom,i.maxZoom):r,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,h="padding"in e?e.padding:i.padding,d=i.zoomScale(l-r),p=t.Point.convert(e.offset);let f=i.centerPoint.add(p);const m=i.pointLocation(f),g=t.LngLat.convert(e.center||m);this._normalizeCenter(g);const _=i.project(m),y=i.project(g).sub(_);let v=e.curve;const x=Math.max(i.width,i.height),b=x/d,T=y.mag();if("minZoom"in e){const n=t.clamp(Math.min(e.minZoom,r,l),i.minZoom,i.maxZoom),o=x/i.zoomScale(n-r);v=Math.sqrt(o/T*2)}const E=v*v;function S(t){const e=(b*b-x*x+(t?-1:1)*E*E*T*T)/(2*(t?b:x)*E*T);return Math.log(Math.sqrt(e*e+1)-e)}function w(t){return(Math.exp(t)-Math.exp(-t))/2}function A(t){return(Math.exp(t)+Math.exp(-t))/2}const M=S(0);let C=function(t){return A(M)/A(M+v*t)},I=function(t){return x*((A(M)*(w(e=M+v*t)/A(e))-w(M))/E)/T;var e},P=(S(1)-M)/v;if(Math.abs(T)<1e-6||!isFinite(P)){if(Math.abs(x-b)<1e-6)return this.easeTo(e,n);const t=b<x?-1:1;P=Math.abs(Math.log(b/x))/v,I=function(){return 0},C=function(e){return Math.exp(t*v*e)}}e.duration="duration"in e?+e.duration:1e3*P/("screenSpeed"in e?+e.screenSpeed/v:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0);const L=o!==c,R=u!==s,O=!i.isPaddingEqual(h),D=i=>d=>{const m=d*P,v=1/C(m);i.zoom=1===d?l:r+i.scaleZoom(v),L&&(i.bearing=t.number(o,c,d)),R&&(i.pitch=t.number(s,u,d)),O&&(i.interpolatePadding(a,h,d),f=i.centerPoint.add(p));const x=1===d?g:i.unproject(_.add(y.mult(I(m))).mult(v));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,f),i._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(n),i};if(e.preloadOnly){const t=this._emulate(D,e.duration,i);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=L,this._pitching=R,this._padding=O,this._prepareEase(n,!1),this._ease(D(i),(()=>this._afterEase(n)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(e,n,i){!1===i.animate||0===i.duration?(e(1),n()):(this._easeStart=t.exported.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1),n=this._onEaseFrame;n&&n(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,n){e=t.wrap(e,-180,180);const i=Math.abs(e-n);return Math.abs(e-360-n)<i&&(e-=360),Math.abs(e+360-n)<i&&(e+=360),e}_normalizeCenter(t){const e=this.transform;if(!e.renderWorldCopies||e.maxBounds)return;const n=t.lng-e.center.lng;t.lng+=n>180?-360:n<-180?360:0}_prefersReducedMotion(e){return this._respectPrefersReducedMotion&&t.exported.prefersReducedMotion&&!(e&&e.essential)}_emulate(t,e,n){const i=Math.ceil(15*e/1e3),r=[],o=t(n.clone());for(let t=0;t<=i;t++){const e=o(t/i);r.push(e.clone())}return r}}class Yr{constructor(e={}){this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const e=this.options&&this.options.compact;return this._map=t,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&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===e&&(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}_setElementTitle(t,e){const n=this._map._getUIString(`AttributionControl.${e}`);t.setAttribute("aria-label",n),t.removeAttribute("title"),t.firstElementChild&&t.firstElementChild.setAttribute("title",n)}_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 e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){const i=n.reduce(((t,e,i)=>(e.value&&(t+=`${e.key}=${e.value}${i<n.length-1?"&":""}`),t)),"?");e.href=`${t.config.FEEDBACK_URL}/${i}#${Ki(this._map,!0)}`,e.rel="noopener nofollow",this._setElementTitle(e,"MapFeedback")}}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style._sourceCaches;for(const n in e){const i=e[n];if(i.used){const e=i.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,n)=>{for(let i=n+1;i<t.length;i++)if(t[i].indexOf(e)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const n=t.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,t.length?(this._innerContainer.innerHTML=n,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 Zr{constructor(){t.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=o("div","mapboxgl-ctrl");const e=o("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),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(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const e in t){const n=t[e].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}}}class Jr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,n=e?this._queue.concat(e):this._queue;for(const e of n)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const n of e)if(!n.cancelled&&(n.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Kr(e,n,i){if(e=new t.LngLat(e.lng,e.lat),n){const r=new t.LngLat(e.lng-360,e.lat),o=new t.LngLat(e.lng+360,e.lat),s=360*Math.ceil(Math.abs(e.lng-i.center.lng)/360),a=i.locationPoint(e).distSqr(n),l=n.x<0||n.y<0||n.x>i.width||n.y>i.height;i.locationPoint(r).distSqr(n)<a&&(l||Math.abs(r.lng-i.center.lng)<s)?e=r:i.locationPoint(o).distSqr(n)<a&&(l||Math.abs(o.lng-i.center.lng)<s)&&(e=o)}for(;Math.abs(e.lng-i.center.lng)>180;){const t=i.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=i.width&&t.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e}const Qr={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%)"};class to extends t.Evented{constructor(e,n){if(super(),(e instanceof t.window.HTMLElement||n)&&(e=t.extend({element:e},n)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=e&&e.occludedOpacity||.2,e&&e.element)this._element=e.element,this._offset=t.Point.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const n=41,i=27,r=s("svg",{display:"block",height:n*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${n}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},r));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),s("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"},r),s("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"},r),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=t.Point.convert(e&&e.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()}));const i=this._element.classList;for(const t in Qr)i.remove(`mapboxgl-marker-anchor-${t}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){const t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(t){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")),t){if(!("offset"in t.options)){const e=38.1,n=13.5,i=Math.sqrt(Math.pow(n,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[i,-1*(e-n+i)],"bottom-right":[-i,-1*(e-n+i)],left:[n,-1*(e-n)],right:[-n,-1*(e-n)]}:this._offset}this._popup=t,t._marker=this,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(t){const e=t.code,n=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==n&&13!==n||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,n=this._element;this._popup&&(e===n||n.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const t=this._map,e=this._pos;if(!t||!e)return!1;const n=t.unproject(e),i=t.getFreeCameraOptions();if(!i.position)return!1;const r=i.position.toLngLat();return r.distanceTo(n)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const n=this._pos;if(!n||n.x<0||n.x>e.transform.width||n.y<0||n.y>e.transform.height)return void this._clearFadeTimer();const i=e.unproject(n);let r;e._showingGlobe()&&t.isLngLatBehindGlobe(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(i),e.transform._terrainEnabled()&&e.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 t=this._pos;if(!t||!this._map)return;const e=this._offset.mult(this._scale);this._element.style.transform=`\n            translate(${t.x}px,${t.y}px)\n            ${Qr[this._anchor]}\n            ${this._calculateXYTransform()} ${this._calculateZTransform()}\n            translate(${e.x}px,${e.y}px)\n        `}_calculateXYTransform(){const e=this._pos,n=this._map,i=this.getPitchAlignment();if(!n||!e||"map"!==i)return"";if(!n._showingGlobe()){const t=n.getPitch();return t?`rotateX(${t}deg)`:""}const r=t.radToDeg(t.globeTiltAtLngLat(n.transform,this._lngLat)),o=e.sub(t.globeCenterToScreenPoint(n.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=r/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const e=this._pos,n=this._map;if(!n||!e)return"";let i=0;const r=this.getRotationAlignment();if("map"===r)if(n._showingGlobe()){const e=n.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),r=n.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(e);i=t.radToDeg(Math.atan2(r.y,r.x))-90}else i=-n.getBearing();else if("horizon"===r){const r=t.smoothstep(4,6,n.getZoom()),o=t.globeCenterToScreenPoint(n.transform);o.y+=r*n.transform.height;const s=e.sub(o),a=t.radToDeg(Math.atan2(s.y,s.x));i=(a>90?a-270:a+90)*(1-r)}return i+=this._rotation,i?`rotateZ(${i}deg)`:""}_update(e){t.window.cancelAnimationFrame(this._updateFrameId);const n=this._map;n&&(n.transform.renderWorldCopies&&(this._lngLat=Kr(this._lngLat,this._pos,n.transform)),this._pos=n.project(this._lngLat),!0===e?this._updateFrameId=t.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),n._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(n._showingGlobe()||n.getTerrain()||n.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(e){return this._offset=t.Point.convert(e),this._update(),this}_onMove(e){const n=this._map;if(!n)return;const i=this._pointerdownPos,r=this._positionDelta;if(i&&r){if(!this._isDragging){const t=this._clickTolerance||n._clickTolerance;if(e.point.dist(i)<t)return;this._isDragging=!0}this._pos=e.point.sub(r),this._lngLat=n.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"}_addDragHandler(t){const e=this._map,n=this._pos;e&&n&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(n),this._pointerdownPos=t.point,this._state="pending",e.on("mousemove",this._onMove),e.on("touchmove",this._onMove),e.once("mouseup",this._onUp),e.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;const e=this._map;return e&&(t?(e.on("mousedown",this._addDragHandler),e.on("touchstart",this._addDragHandler)):(e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(t){return this._occludedOpacity=t||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const eo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},no=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function io(e=new t.Point(0,0),n="bottom"){if("number"==typeof e){const i=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(n){case"top":return new t.Point(0,e);case"top-left":return new t.Point(i,i);case"top-right":return new t.Point(-i,i);case"bottom":return new t.Point(0,-e);case"bottom-left":return new t.Point(i,-i);case"bottom-right":return new t.Point(-i,-i);case"left":return new t.Point(e,0);case"right":return new t.Point(-e,0)}return new t.Point(0,0)}return e instanceof t.Point||Array.isArray(e)?t.Point.convert(e):t.Point.convert(e[n]||[0,0])}class ro{constructor(t){this.jumpTo(t)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const n=t.easeCubicInOut((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,e,n){this._start=this.getValue(e),this._end=t,this._startTime=e,this._endTime=e+n}}const oo={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","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"},so={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,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},ao={showCompass:!0,showZoom:!0,visualizePitch:!1};class lo{constructor(e,n,i=!1){this._clickTolerance=10,this.element=n,this.mouseRotate=new xr({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,i&&(this.mousePitch=new br({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),u()}move(t,e){const n=this.map,i=this.mouseRotate.mousemoveWindow(t,e),r=i&&i.bearingDelta;if(r&&n.setBearing(n.getBearing()+r),this.mousePitch){const i=this.mousePitch.mousemoveWindow(t,e),r=i&&i.pitchDelta;r&&n.setPitch(n.getPitch()+r)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),t.window.removeEventListener("mousemove",this.mousemove),t.window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),f(this.element,e)),t.window.addEventListener("mousemove",this.mousemove),t.window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,f(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=m(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.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()}}const co={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},uo={maxWidth:100,unit:"metric"},ho={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},po={version:t.version,supported:n,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:class extends Xr{constructor(e){if(t.LivePerformanceUtils.mark(t.PerformanceMarkers.create),null!=(e=t.extend({},so,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&t.isSafariWithAntialiasingBug(t.window)&&(e.antialias=!1,t.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Yi(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._useWebGL2=e.useWebGL2,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._collectResourceTiming=e.collectResourceTiming,this._optimizeForTerrain=e.optimizeForTerrain,this._language=this._parseLanguage(e.language),this._worldview=e.worldview,this._renderTaskQueue=new Jr,this._domRenderTaskQueue=new Jr,this._controls=[],this._markers=[],this._popups=[],this._mapId=t.uniqueId(),this._locale=t.extend({},oo,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._performanceMetricsCollection=e.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ro(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof t.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&t.warnOnce("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."),e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1),t.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),t.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Wr(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),this._hash=e.hash&&new Ji("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),e.attributionControl&&this.addControl(new Yr({customAttribution:e.customAttribution})),this._logoControl=new Zr,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new t.Event(`${e.dataType}dataloading`,e))}))}_getMapId(){return this._mapId}addControl(e,n){if(void 0===n&&(n=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[n];return-1!==n.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(e);return n>-1&&this._controls.splice(n,1),e.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){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 n=!this._moving;return n&&this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)),this.fire(new t.Event("resize",e)),n&&this.fire(new t.Event("moveend",e)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()<e?this.setZoom(e):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()<e?this.setPitch(e):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?85:e)>85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?t.window.navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?t.window.navigator.language:e)):e}setLanguage(t){const e=this._parseLanguage(t);if(!this.style||e===this._language)return this;this._language=e,this.style._reloadSources();for(const t of this._controls)t._setLanguage&&t._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(t){return this.style&&t!==this._worldview?(this._worldview=t,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(t){return this._lazyInitEmptyStyle(),t?"string"==typeof t&&(t={name:t}):t=null,this._useExplicitProjection=!!t,this._prioritizeAndUpdateProjection(t,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const e=this.transform,n=e.projection.name;let i;"globe"===n&&e.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?(e.setMercatorFromTransition(),i=!0):"mercator"===n&&e.zoom<t.GLOBE_ZOOM_THRESHOLD_MAX&&(e.setProjection({name:"globe"}),i=!0),i&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(t,e){return this._updateProjection(t||e||{name:"mercator"})}_updateProjection(e){let n;if(n="globe"===e.name&&this.transform.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate(),n){this.painter.clearBackgroundTiles();for(const t in this.style._sourceCaches)this.style._sourceCaches[t].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(e){return this.transform.locationPoint3D(t.LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(t.Point.convert(e))}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(t,e,n){if("mouseenter"===t||"mouseover"===t){let i=!1;const r=r=>{const o=e.filter((t=>this.getLayer(t))),s=o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?i||(i=!0,n.call(this,new ar(t,this,r.originalEvent,{features:s}))):i=!1},o=()=>{i=!1};return{layers:new Set(e),listener:n,delegates:{mousemove:r,mouseout:o}}}if("mouseleave"===t||"mouseout"===t){let i=!1;const r=r=>{const o=e.filter((t=>this.getLayer(t)));(o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?i=!0:i&&(i=!1,n.call(this,new ar(t,this,r.originalEvent)))},o=e=>{i&&(i=!1,n.call(this,new ar(t,this,e.originalEvent)))};return{layers:new Set(e),listener:n,delegates:{mousemove:r,mouseout:o}}}{const i=t=>{const i=e.filter((t=>this.getLayer(t))),r=i.length?this.queryRenderedFeatures(t.point,{layers:i}):[];r.length&&(t.features=r,n.call(this,t),delete t.features)};return{layers:new Set(e),listener:n,delegates:{[t]:i}}}}on(t,e,n){if(void 0===n)return super.on(t,e);Array.isArray(e)||(e=[e]);const i=this._createDelegatedListener(t,e,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(i);for(const t in i.delegates)this.on(t,i.delegates[t]);return this}once(t,e,n){if(void 0===n)return super.once(t,e);Array.isArray(e)||(e=[e]);const i=this._createDelegatedListener(t,e,n);for(const t in i.delegates)this.once(t,i.delegates[t]);return this}off(t,e,n){if(void 0===n)return super.off(t,e);e=new Set(Array.isArray(e)?e:[e]);const i=(t,e)=>{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0},r=this._delegatedListeners?this._delegatedListeners[t]:void 0;return r&&(t=>{for(let r=0;r<t.length;r++){const o=t[r];if(o.listener===n&&i(o.layers,e)){for(const t in o.delegates)this.off(t,o.delegates[t]);return t.splice(r,1),this}}})(r),this}queryRenderedFeatures(e,n){return this.style?(void 0!==n||void 0===e||e instanceof t.Point||Array.isArray(e)||(n=e,e=void 0),this.style.queryRenderedFeatures(e=e||[[0,0],[this.transform.width,this.transform.height]],n=n||{},this.transform)):[]}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}isPointOnSurface(e){const{name:n}=this.transform.projection;return"globe"!==n&&"mercator"!==n&&t.warnOnce(`${n} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(t.Point.convert(e))}setStyle(e,n){return!1!==(n=t.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},n)).diff&&n.localIdeographFontFamily===this._localIdeographFontFamily&&n.localFontFamily===this._localFontFamily&&this.style&&e?(this._diffStyle(e,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._localFontFamily=n.localFontFamily,this._updateStyle(e,n))}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t&&(this.style=new Je(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Je(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,n){if("string"==typeof e){const i=this._requestManager.normalizeStyleURL(e),r=this._requestManager.transformRequest(i,t.ResourceType.Style);t.getJSON(r,((e,i)=>{e?this.fire(new t.ErrorEvent(e)):i&&this._updateDiff(i,n)}))}else"object"==typeof e&&this._updateDiff(e,n)}_updateDiff(e,n){try{this.style.setState(e)&&this._update(!0)}catch(i){t.warnOnce(`Unable to perform style diff: ${i.message||i.error||i}.  Rebuilding the style from scratch.`),this._updateStyle(e,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(t.warnOnce("There is no style added to the map."),!1)}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){return!!this.style&&this.style._isSourceCacheLoaded(t)}areTilesLoaded(){const t=this.style&&this.style._sourceCaches;for(const e in t){const n=t[e]._tiles;for(const t in n){const e=n[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,n){this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,n)}removeSource(t){return this.style.removeSource(t),this._updateTerrain(),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(e,n,{pixelRatio:i=1,sdf:r=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),n instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&n instanceof t.window.ImageBitmap){const{width:l,height:c,data:u}=t.exported.getImageData(n);this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},u),pixelRatio:i,stretchX:o,stretchY:s,content:a,sdf:r,version:0})}else if(void 0===n.width||void 0===n.height)this.fire(new t.ErrorEvent(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:l,height:c}=n,u=n;this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:i,stretchX:o,stretchY:s,content:a,sdf:r,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}updateImage(e,n){const i=this.style.getImage(e);if(!i)return void this.fire(new t.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=n instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&n instanceof t.window.ImageBitmap?t.exported.getImageData(n):n,{width:o,height:s}=r;void 0!==o&&void 0!==s?o===i.data.width&&s===i.data.height?(i.data.replace(r.data,!(n instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&n instanceof t.window.ImageBitmap)),this.style.updateImage(e,i)):this.fire(new t.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${s})\n                must be that same as the previous version of the image\n                (${i.data.width}, ${i.data.height})`))):this.fire(new t.ErrorEvent(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`")))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(e,n){t.getImage(this._requestManager.transformRequest(e,t.ResourceType.Image),((e,i)=>{n(e,i instanceof t.window.HTMLImageElement?t.exported.getImageData(i):i)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,n){return this.style.setLayerZoomRange(t,e,n),this._update(!0)}setFilter(t,e,n={}){return this.style.setFilter(t,e,n),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,n,i={}){return this.style.setPaintProperty(t,e,n,i),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,n,i={}){return this.style.setLayoutProperty(t,e,n,i),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(t){return this._lazyInitEmptyStyle(),!t&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(t.LngLat.convert(e),this.transform):0}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let i,r,o,s=this._container;for(;s&&(!r||!o);){const e=t.window.getComputedStyle(s).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(r=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(o=i[3])),s=s.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=o?Math.abs(n/o):n}_detectMissingCSS(){"rgb(250, 128, 114)"!==t.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&t.warnOnce("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 t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();const e=this._canvasContainer=o("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=o("canvas","mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const n=this._controlContainer=o("div","mapboxgl-control-container",t),i=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{i[t]=o("div",`mapboxgl-ctrl-${t}`,n)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,n){const i=t.exported.devicePixelRatio||1;this._canvas.width=i*Math.ceil(e),this._canvas.height=i*Math.ceil(n),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${n}px`}_addMarker(t){this._markers.push(t)}_removeMarker(t){const e=this._markers.indexOf(t);-1!==e&&this._markers.splice(e,1)}_addPopup(t){this._popups.push(t)}_removePopup(t){const e=this._popups.indexOf(t);-1!==e&&this._popups.splice(e,1)}_setupPainter(){const e=t.extend({},n.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._useWebGL2&&this._canvas.getContext("webgl2",e),r=i||this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);r?(this._useWebGL2&&!i&&t.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),t.storeAuthState(r,!0),this.painter=new Ni(r,this.transform,!!i),this.on("data",(t=>{"source"===t.dataType&&this.painter.setTileLoadedFlag(!0)})),t.exported$1.testSupport(r)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.loaded()||this.loaded()&&!this.isMoving()?t():this._domRenderTaskQueue.add(t)}_render(e){let n;const i=this.painter.context.extTimerQuery,r=t.exported.now();if(this.listens("gpu-timing-frame")&&(n=i.createQueryEXT(),i.beginQueryEXT(i.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],t.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],t.window.performance.now())),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;this._updateProjectionTransition();const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,n=this.transform.pitch,i=t.exported.now(),r=new t.EvaluationParameters(e,{now:i,fadeDuration:o,pitch:n,transition:this.style.getTransition()});this.style.update(r)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(r),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(r),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:o,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 t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const e=t.exported.now()-r;i.endQueryEXT(i.TIME_ELAPSED_EXT,n),setTimeout((()=>{const o=i.getQueryObjectEXT(n,i.QUERY_RESULT_EXT)/1e6;i.deleteQueryEXT(n),this.fire(new t.Event("gpu-timing-frame",{cpuTime:e,gpuTime:o})),t.window.performance.mark("frame-gpu",{startTime:r,detail:{gpuTime:o}})}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const n=this.painter.queryGpuTimers(e);this.fire(new t.Event("gpu-timing-layer",{layerTimes:n}))}),50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const n=this.painter.queryGpuTimeDeferredRender(e);this.fire(new t.Event("gpu-timing-deferred-render",{gpuTime:n}))}),50)}const a=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(a||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(s=this._updateAverageElevation(r,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new t.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new t.Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,t.LivePerformanceUtils.mark(t.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&t.postPerformanceEvent(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(t){for(const e of this._markers)t&&!this.getRenderWorldCopies()&&(e._lngLat=e._lngLat.wrap()),e._update();for(const e of this._popups)!t||this.getRenderWorldCopies()||e._trackPointer||(e._lngLat=e._lngLat.wrap()),e._update()}_updateAverageElevation(t,e=!1){const n=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((e||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){const e=this.transform.averageElevation;let i=this.transform.sampleAverageElevation(),r=!1;this.transform.elevation&&(r=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(i)?i=0:this._averageElevationLastSampledAt=t;const o=Math.abs(e-i);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(i),n(i);this._averageElevation.easeTo(i,t,300)}else if(o>1e-4)return this._averageElevation.jumpTo(i),n(i)}return!!this._averageElevation.isEasing(t)&&n(this._averageElevation.getValue(t))}_authenticate(){t.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===t.AUTH_ERR_MSG||401===e.status)){const e=this.painter.context.gl;t.storeAuthState(e,!1),this._logoControl instanceof Zr&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new t.ErrorEvent(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/")))}})),t.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){const t=this._isDragging();this.painter.updateTerrain(this.style,t)}_calculateSpeedIndex(){const t=this.painter.canvasCopy(),e=this.painter.getCanvasCopiesAndTimestamps();e.timeStamps.push(performance.now());const n=this.painter.context.gl,i=n.createFramebuffer();function r(t){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0);const e=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,e),e}return n.bindFramebuffer(n.FRAMEBUFFER,i),this._canvasPixelComparison(r(t),e.canvasCopies.map(r),e.timeStamps)}_canvasPixelComparison(t,e,n){let i=n[1]-n[0];const r=t.length/4;for(let o=0;o<e.length;o++){const s=e[o];let a=0;for(let e=0;e<s.length;e+=4)s[e]===t[e]&&s[e+1]===t[e+1]&&s[e+2]===t[e+2]&&s[e+3]===t[e+3]&&(a+=1);i+=(n[o+2]-n[o+1])*(1-a/r)}return i}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.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),void 0!==t.window&&(t.window.removeEventListener("resize",this._onWindowResize,!1),t.window.removeEventListener("orientationchange",this._onWindowResize,!1),t.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),t.window.removeEventListener("online",this._onWindowOnline,!1),t.window.removeEventListener("visibilitychange",this._onVisibilityChange,!1));const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e&&e.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),t.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new t.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(e){this._renderNextFrame=this._renderNextFrame||e,this.style&&!this._frame&&(this._frame=t.exported.frame((t=>{const e=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,e&&this._render(t)})))}_preloadTiles(e){const n=this.style?Object.values(this.style._sourceCaches):[];return t.asyncAll(n,((t,n)=>t._preloadTiles(e,n)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}_onVisibilityChange(){"hidden"===t.window.document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(t){this._showTileAABBs!==t&&(this._showTileAABBs=t,t&&this._update())}_setCacheLimits(e,n){t.setCacheLimits(e,n)}get version(){return t.version}},NavigationControl:class{constructor(e){this.options=t.extend({},ao,e),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(t=>{this._map&&this._map.zoomIn({},{originalEvent:t})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(t=>{this._map&&this._map.zoomOut({},{originalEvent:t})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(t=>{const e=this._map;e&&(this.options.visualizePitch?e.resetNorthPitch({},{originalEvent:t}):e.resetNorth({},{originalEvent:t}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map;if(!t)return;const e=t.getZoom(),n=e===t.getMaxZoom(),i=e===t.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_rotateCompassArrow(){const t=this._map;if(!t)return;const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=e)}))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),t.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&t.on("pitch",this._rotateCompassArrow),t.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new lo(t,this._compass,this.options.visualizePitch)),this._container}onRemove(){const t=this._map;t&&(this._container.remove(),this.options.showZoom&&t.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&t.off("pitch",this._rotateCompassArrow),t.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(t,e){const n=o("button",t,this._container);return n.type="button",n.addEventListener("click",e),n}_setButtonTitle(t,e){if(!this._map)return;const n=this._map._getUIString(`NavigationControl.${e}`);t.setAttribute("aria-label",n),t.firstElementChild&&t.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends t.Evented{constructor(e){super(),this.options=t.extend({geolocation:t.window.navigator.geolocation},co,e),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Zi(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(t){return this._map=t,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){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 n=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((t=>n("denied"!==t.state))).catch((()=>n())):n()}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),n=t.coords;return!!e&&(n.longitude<e.getWest()||n.longitude>e.getEast()||n.latitude<e.getSouth()||n.latitude>e.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(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");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(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}}_updateCamera(e){const n=new t.LngLat(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=this._map.getBearing(),o=t.extend({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(i),o,{geolocateSource:!0})}_updateMarker(e){if(e){const n=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,n=t.mercatorZfromAltitude(1,e._center.lat)*e.worldSize,i=Math.ceil(2*this._accuracy*n);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.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 t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new to({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new to({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.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new t.Event("trackuserlocationend")))}))}}_onDeviceOrientation(t){this._userLocationDotMarker&&(t.webkitCompassHeading?this._heading=t.webkitCompassHeading:!0===t.absolute&&(this._heading=-1*t.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return t.warnOnce("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 t.Event("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 t.Event("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 t.Event("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 t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(t={maximumAge:6e5,timeout:0},this._noTimeout=!0):(t=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,t),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{t.window.addEventListener("ondeviceorientationabsolute"in t.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==t.window.DeviceMotionEvent&&"function"==typeof t.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),t.window.removeEventListener("deviceorientation",this._onDeviceOrientation),t.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:Yr,ScaleControl:class{constructor(e){this.options=t.extend({},uo,e),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(t){return!1}}(),t.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const t=this.options.maxWidth||100,e=this._map,n=e._containerHeight/2,i=e._containerWidth/2-t/2,r=e.unproject([i,n]),o=e.unproject([i+t,n]),s=r.distanceTo(o);if("imperial"===this.options.unit){const e=3.2808*s;e>5280?this._setScale(t,e/5280,"mile"):this._setScale(t,e,"foot")}else"nautical"===this.options.unit?this._setScale(t,s/1852,"nautical-mile"):s>=1e3?this._setScale(t,s/1e3,"kilometer"):this._setScale(t,s,"meter")}_setScale(t,e,n){this._map._requestDomTask((()=>{const i=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let n=t/e;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(n),e*n}(e),r=i/e;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==n?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:n}).format(i):`${i}&nbsp;${ho[n]}`,this._container.style.width=t*r+"px"}))}onAdd(t){return this._map=t,this._language=t.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.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(t){this._language=t,this._update()}setUnit(t){this.options.unit=t,this._update()}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in t.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!t.window.document.fullscreenEnabled&&!t.window.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",t)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.window.document.fullscreenElement||t.window.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()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends t.Evented{constructor(e){super(),this.options=t.extend(Object.create(eo),e),t.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),e._addPopup(this),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new t.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),e._canvasContainer&&e._canvasContainer.classList.remove("mapboxgl-track-pointer"),e._removePopup(this),this._map=void 0),this.fire(new t.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const n=this._map;return n&&(n.on("move",this._update),n.off("mousemove",this._onMouseEvent),n._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const t=this._map;return t&&(t.off("move",this._update),t.on("mousemove",this._onMouseEvent),t.on("drag",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(t.window.document.createTextNode(e))}setHTML(e){const n=t.window.document.createDocumentFragment(),i=t.window.document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)n.appendChild(r);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){let e=this._content;if(e)for(;e.hasChildNodes();)e.firstChild&&e.removeChild(e.firstChild);else e=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(e.appendChild(t),this.options.closeButton){const t=this._closeButton=o("button","mapboxgl-popup-close-button",e);t.type="button",t.setAttribute("aria-label","Close popup"),t.setAttribute("aria-hidden","true"),t.innerHTML="&#215;",t.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(t){return this._classList.add(t),this._updateClassList(),this}removeClassName(t){return this._classList.delete(t),this._updateClassList(),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){let e;return this._classList.delete(t)?e=!1:(this._classList.add(t),e=!0),this._updateClassList(),e}_onMouseEvent(t){this._update(t.point)}_getAnchor(t){if(this.options.anchor)return this.options.anchor;const e=this._map,n=this._container,i=this._pos;if(!e||!n||!i)return"bottom";const r=n.offsetWidth,o=n.offsetHeight,s=i.x<r/2,a=i.x>e.transform.width-r/2;if(i.y+t<o)return s?"top-left":a?"top-right":"top";if(i.y>e.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const t=this._container;if(!t)return;const e=[...this._classList];e.push("mapboxgl-popup"),this._anchor&&e.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&e.push("mapboxgl-popup-track-pointer"),t.className=e.join(" ")}_update(e){const n=this._map,i=this._content;if(!n||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=o("div","mapboxgl-popup",n.getContainer()),this._tip=o("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),n.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Kr(this._lngLat,this._pos,n.transform)),!this._trackPointer||e){const t=this._pos=this._trackPointer&&e?e:n.project(this._lngLat),i=io(this.options.offset),r=this._anchor=this._getAnchor(i.y),o=io(this.options.offset,r),s=t.add(o).round();n._requestDomTask((()=>{this._container&&r&&(this._container.style.transform=`${Qr[r]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&n._showingGlobe()){const e=t.isLngLatBehindGlobe(n.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(no);t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._container&&(this._container.style.opacity=`${t}`),this._content&&(this._content.style.pointerEvents=t?"auto":"none")}},Marker:to,Style:Je,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.Point,MercatorCoordinate:t.MercatorCoordinate,FreeCameraOptions:Gi,Evented:t.Evented,config:t.config,prewarm:function(){kt().acquire(Nt)},clearPrewarmedResources:function(){const t=Ut;t&&t.isPreloaded()&&1===t.numActive()&&(t.release(Nt),Ut=null)},get accessToken(){return t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return Ft.workerCount},set workerCount(t){Ft.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){t.clearTileCache(e)},workerUrl:"",workerClass:null,setNow:t.exported.setNow,restoreNow:t.exported.restoreNow};return po}));var r=n;return r}()}(mapboxGl$1)),mapboxGl$1.exports}var mapboxGlExports=requireMapboxGl(),mapboxgl=getDefaultExportFromCjs(mapboxGlExports);class Marker extends mapboxGlExports.Evented{constructor(t){super();const e=this,n=document.createElement("div"),i=t.element;i.style.transition="opacity 300ms",e._element=n.appendChild(i),e._marker=new mapboxGlExports.Marker({element:n}),e._minZoom=t.minZoom||0,e._visible=!0,bindAll(["_onClick","_onMouseEnter","_onMouseLeave","_onZoom"],e)}addTo(t){const e=this,n=e._element;return e._map=t,e._zoom=t.getZoom(),e._setVisibility(e._zoom>=e._minZoom),e._marker.addTo(t.map),t.on("zoom",e._onZoom),n.addEventListener("click",e._onClick),n.addEventListener("mouseenter",e._onMouseEnter),n.addEventListener("mouseleave",e._onMouseLeave),n.addEventListener("mousemove",e._onMouseMove),e}remove(){const t=this,e=t._element;return e.removeEventListener("click",t._onClick),e.removeEventListener("mouseenter",t._onMouseEnter),e.removeEventListener("mouseleave",t._onMouseLeave),e.removeEventListener("mousemove",t._onMouseMove),t._map.off("zoom",t._onZoom),t._marker.remove(),t}setLngLat(t){return this._marker.setLngLat(t),this}setActivity(t){const e=this._element.classList;return t?e.add("active"):e.remove("active"),this}setVisibility(t){const e=this,n=e._visible;return e._visible=t,e._zoom>=e._minZoom&&(!n&&t?e._setVisibility(!0):n&&!t&&e._setVisibility(!1)),e}_setVisibility(t){const e=this,n=e._element.style;t?(n.opacity=1,n.pointerEvents="auto"):(n.opacity=0,n.pointerEvents="none",e._hover&&e._onMouseLeave())}_onClick(t){this.fire({type:"click"}),t.stopPropagation()}_onMouseEnter(){this._hover=!0,this.fire({type:"mouseenter"})}_onMouseLeave(){delete this._hover,this.fire({type:"mouseleave"})}_onMouseMove(t){t.stopPropagation()}_onZoom(){const t=this,e=t._zoom,n=t._zoom=t._map.getZoom(),i=t._minZoom;t._visible&&(e<i&&n>=i?t._setVisibility(!0):e>=i&&n<i&&t._setVisibility(!1))}}var earthRadius=6371008.8,factors={meters:earthRadius,metres:earthRadius,millimeters:1e3*earthRadius,millimetres:1e3*earthRadius,centimeters:100*earthRadius,centimetres:100*earthRadius,kilometers:earthRadius/1e3,kilometres:earthRadius/1e3,miles:earthRadius/1609.344,nauticalmiles:earthRadius/1852,inches:39.37*earthRadius,yards:earthRadius/1.0936,feet:3.28084*earthRadius,radians:1,degrees:earthRadius/111325};function feature(t,e,n){if(!isObject$5(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&&validateBBox(i),r&&validateId(r);var o={type:"Feature"};return r&&(o.id=r),i&&(o.bbox=i),o.properties=e||{},o.geometry=t,o}function point(t,e,n){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(!isNumber(t[0])||!isNumber(t[1]))throw new Error("coordinates must contain numbers");return feature({type:"Point",coordinates:t},e,n)}function polygon(t,e,n){if(!t)throw new Error("coordinates is required");for(var i=0;i<t.length;i++){var r=t[i];if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var o=0;o<r[r.length-1].length;o++){if(0===i&&0===o&&!isNumber(r[0][0])||!isNumber(r[0][1]))throw new Error("coordinates must contain numbers");if(r[r.length-1][o]!==r[0][o])throw new Error("First and last Position are not equivalent.")}}return feature({type:"Polygon",coordinates:t},e,n)}function lineString(t,e,n){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(!isNumber(t[0][1])||!isNumber(t[0][1]))throw new Error("coordinates must contain numbers");return feature({type:"LineString",coordinates:t},e,n)}function featureCollection(t,e){if(!isObject$5(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&&validateBBox(n),i&&validateId(i);var r={type:"FeatureCollection"};return i&&(r.id=i),n&&(r.bbox=n),r.features=t,r}function radiansToLength(t,e){if(null==t)throw new Error("radians is required");if(e&&"string"!=typeof e)throw new Error("units must be a string");var n=factors[e||"kilometers"];if(!n)throw new Error(e+" units is invalid");return t*n}function lengthToRadians(t,e){if(null==t)throw new Error("distance is required");if(e&&"string"!=typeof e)throw new Error("units must be a string");var n=factors[e||"kilometers"];if(!n)throw new Error(e+" units is invalid");return t/n}function radiansToDegrees(t){if(null==t)throw new Error("radians is required");return 180*(t%(2*Math.PI))/Math.PI}function degreesToRadians(t){if(null==t)throw new Error("degrees is required");return t%360*Math.PI/180}function isNumber(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function isObject$5(t){return!!t&&t.constructor===Object}function validateBBox(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(!isNumber(t))throw new Error("bbox must only contain numbers")}))}function validateId(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 coordEach(t,e,n){if(null!==t)for(var i,r,o,s,a,l,c,u,h=0,d=0,p=t.type,f="FeatureCollection"===p,m="Feature"===p,g=f?t.features.length:1,_=0;_<g;_++){a=(u=!!(c=f?t.features[_].geometry:m?t.geometry:t)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var y=0;y<a;y++){var v=0,x=0;if(null!==(s=u?c.geometries[y]:c)){l=s.coordinates;var b=s.type;switch(h=!n||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===e(l,d,_,v,x))return!1;d++,v++;break;case"LineString":case"MultiPoint":for(i=0;i<l.length;i++){if(!1===e(l[i],d,_,v,x))return!1;d++,"MultiPoint"===b&&v++}"LineString"===b&&v++;break;case"Polygon":case"MultiLineString":for(i=0;i<l.length;i++){for(r=0;r<l[i].length-h;r++){if(!1===e(l[i][r],d,_,v,x))return!1;d++}"MultiLineString"===b&&v++,"Polygon"===b&&x++}"Polygon"===b&&v++;break;case"MultiPolygon":for(i=0;i<l.length;i++){for("MultiPolygon"===b&&(x=0),r=0;r<l[i].length;r++){for(o=0;o<l[i][r].length-h;o++){if(!1===e(l[i][r][o],d,_,v,x))return!1;d++}x++}v++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===coordEach(s.geometries[i],e,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function featureEach(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 geomEach(t,e){var n,i,r,o,s,a,l,c,u,h,d=0,p="FeatureCollection"===t.type,f="Feature"===t.type,m=p?t.features.length:1;for(n=0;n<m;n++){for(c=p?t.features[n].properties:f?t.properties:{},u=p?t.features[n].bbox:f?t.bbox:void 0,h=p?t.features[n].id:f?t.id:void 0,s=(l=!!(a=p?t.features[n].geometry:f?t.geometry:t)&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<s;r++)if(null!==(o=l?a.geometries[r]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,d,c,u,h))return!1;break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)if(!1===e(o.geometries[i],d,c,u,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,d,c,u,h))return!1;d++}}function flattenEach(t,e){geomEach(t,(function(t,n,i,r,o){var s,a=null===t?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==e(feature(t,i,{bbox:r,id:o}),n,0)&&void 0}switch(a){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var l=0;l<t.coordinates.length;l++){if(!1===e(feature({type:s,coordinates:t.coordinates[l]},i),n,l))return!1}}))}var mapboxGlAnimatedPopup$1={exports:{}},mapboxGlAnimatedPopup=mapboxGlAnimatedPopup$1.exports,hasRequiredMapboxGlAnimatedPopup;
/*!
 * 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
 */function requireMapboxGlAnimatedPopup(){return hasRequiredMapboxGlAnimatedPopup||(hasRequiredMapboxGlAnimatedPopup=1,function(t){t.exports=function(t){const e=t.version.split(".").map((t=>+t)),n={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*(Math.PI/2)),easeOutSine:t=>Math.sin(t*(Math.PI/2)),easeInOutSine:t=>-.5*(Math.cos(Math.PI*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*--t)),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic(t){let e=1.70158,n=0,i=1;return 0===t?0:1===t?1:(n||(n=.3),e=n/(2*Math.PI)*Math.asin(1/i),-i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n))},easeOutElastic(t){let e=1.70158,n=0,i=1;return 0===t?0:1===t?1:(n||(n=.3),e=n/(2*Math.PI)*Math.asin(1/i),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},easeInOutElastic(t){let e=1.70158,n=0,i=1;return 0===t?0:2==(t/=.5)?1:(n||(n=.45),e=n/(2*Math.PI)*Math.asin(1/i),t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-n.easeOutBounce(1-t),easeOutBounce:t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,easeInOutBounce:t=>t<.5?.5*n.easeInBounce(2*t):.5*n.easeOutBounce(2*t-1)+.5},i={scale:(t,e,n)=>{t.transform=`scale(${n?1-e:e})`},opacity:(t,e,n)=>{t.opacity=n?1-e:e}};function r(t,e,r,o,s,a){let l;const c="string"==typeof a?i[a]||i.scale:a,u=performance.now(),h=()=>{if(l)return;const i=performance.now()-u,a=0===r?1:Math.min(i/r,1),d=n[e](a);c(t,d,o),a<1?requestAnimationFrame(h):s&&s()};return h(),()=>{l=!0}}function o(t,...e){for(const n of e)for(const e in n)"object"==typeof n[e]?(t[e]||(t[e]={}),o(t[e],n[e])):t[e]=n[e];return t}function s(t){for(const e of t.values()){const t=e.match(/mapboxgl-popup-anchor-(.+)/);if(t)return t[1].replace("-"," ")}}const a={openingAnimation:{transform:"scale",duration:1e3,easing:"easeOutElastic"},closingAnimation:{transform:"scale",duration:300,easing:"easeInBack"}};class l extends t.Popup{constructor(t){super(t),o(this.options,o({},a,t))}addTo(...t){return this._map&&this._remove(),super.addTo(...t)}_remove(){const t=this._wrapperContainer;this._cancelAnimation&&this._cancelAnimation(),t&&t.parentNode&&(t.parentNode.removeChild(t),delete this._wrapperContainer),super.remove()}remove(){if(this._wrapperContainer){const{easing:t,duration:e,transform:n}=this.options.closingAnimation;this._cancelAnimation&&this._cancelAnimation(),this._cancelAnimation=r(this._container.style,t,e,!0,(()=>{this._remove()}),n)}else super.remove();return this}_update(...t){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;const n=this._map._requestDomTask;let i,o=this._wrapperContainer,a=this._container;Object.defineProperty(this,"_container",{configurable:!0,get:()=>a,set:t=>{const{easing:e,duration:n,transform:i}=this.options.openingAnimation;o=this._wrapperContainer=document.createElement("div"),o.className="mapboxgl-popup-wrapper",o.style.position="absolute",o.style.willChange="transform",o.style.pointerEvents="none",a=t,a.style.position="relative",this._map.getContainer().appendChild(o),o.appendChild(a),this._cancelAnimation=r(a.style,e,n,!1,null,i)}}),e[0]>=2&&e[1]>=3||e[0]>=3?this._map._requestDomTask=t=>{n.call(this._map,(()=>{i=a?a.style.transform:"scale(0)",t(),o.style.transform=a.style.transform,a.style.transform=i,a.style.transformOrigin=this._anchor?this._anchor.replace("-"," "):s(a.classList)}))}:i=a?a.style.transform:"scale(0)",super._update(...t),delete this._container,this._container=a,e[0]>=2&&e[1]>=3||e[0]>=3?this._map._requestDomTask=n:(o.style.transform=a.style.transform,a.style.transform=i,a.style.transformOrigin=s(a.classList))}}return l}(requireMapboxGl())}(mapboxGlAnimatedPopup$1)),mapboxGlAnimatedPopup$1.exports}var mapboxGlAnimatedPopupExports=requireMapboxGlAnimatedPopup(),Popup$1=getDefaultExportFromCjs(mapboxGlAnimatedPopupExports);const animation={instances:{},count:0,initialized:!1,init(){animation.initialized||(animation.initialized=!0,function t(){const e=animation.instances,n=Object.keys(e),i=n.length,r=performance.now();for(let t=0;t<i;t++){const i=n[t],o=e[i];if(o){const t=o.nextFrame||0;if(t<=r){const{clock:e,duration:n,frameRate:s=1/0}=o,a=e?e.getHighResTime():r,l=a-(o.start=o.start||a);o.callback&&o.callback(Math.min(l,n),n),o.nextFrame=Math.max(t+1e3/s,r),l>=n&&(o.complete&&o.complete(),animation.stop(i))}}}requestAnimationFrame(t)}())},isActive:t=>t in animation.instances,start:t=>(t.duration=valueOrDefault(t.duration,1/0),animation.instances[animation.count]=t,animation.count++),stop(t){const e=animation.instances;e[t]&&delete e[t]},setFrameRate(t,e){const n=animation.instances[t];n&&(e>0?n.frameRate=e:delete n.frameRate)}};var japaneseHolidays$2={exports:{}},japaneseHolidays$1=japaneseHolidays$2.exports,hasRequiredJapaneseHolidays$1,japaneseHolidays,hasRequiredJapaneseHolidays;function requireJapaneseHolidays$1(){return hasRequiredJapaneseHolidays$1||(hasRequiredJapaneseHolidays$1=1,function(t){(function(){var e,n,i,r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,T,E,S,w;_=function(t,e,n,i,r,o,s,a){var l;return(l=new Date(2e3,0,1)).setTime(t.getTime()+1e3*(60*(60*(24*(null!=i?i:0)+(null!=r?r:0))+(null!=o?o:0))+(null!=s?s:0))+(null!=a?a:0)),l.setFullYear(l.getFullYear()+(null!=e?e:0)+Math.floor((l.getMonth()+(null!=n?n:0))/12)),l.setMonth(((l.getMonth()+(null!=n?n:0))%12+12)%12),l},S=function(t){return _(t,0,0,0,9)},p=function(t){return _(t,0,0,0,-9)},w=function(t,e,n){return new Date(Date.UTC(t,e,n))},f=function(t,e,n){return p(w(t,e,n))},o=function(t){return S(t).getUTCDay()},r=function(t){return S(t).getUTCDate()},c=function(t){return S(t).getUTCMonth()},s=function(t){return S(t).getUTCFullYear()},a=function(t){return S(t).getUTCHours()},l=function(t){return S(t).getUTCMinutes()},u=function(t,e){return function(n){var i;return i=f(n,t-1,1),_(i,0,0,(7-(o(i)-1))%7+7*(e-1))}},b=function(t){return new Date(31556940400*(t-1949)-6558667e5)},x=function(t){var e;return e=b(t),f(t,c(e),r(e))},v=function(t){var e;return(e={1603:23,2074:23,2355:23,2384:22}[t])?f(t,8,e):new Date(3155691e4*(t-1948)-67131691e4)},y=function(t){var e;return e=v(t),f(t,c(e),r(e))},e=[["元日",(T=function(t,e){return function(n){return f(n,t-1,e)}})(1,1),1949],["成人の日",T(1,15),1949,1999],["成人の日",u(1,2),2e3],["建国記念の日",T(2,11),1967],["天皇誕生日",T(2,23),2020],["昭和天皇の大喪の礼",T(2,24),1989,1989],["春分の日",x,1949],["皇太子明仁親王の結婚の儀",T(4,10),1959,1959],["天皇誕生日",T(4,29),1949,1988],["みどりの日",T(4,29),1989,2006],["昭和の日",T(4,29),2007],["即位の日",T(5,1),2019,2019],["憲法記念日",T(5,3),1949],["みどりの日",T(5,4),2007],["こどもの日",T(5,5),1949],["皇太子徳仁親王の結婚の儀",T(6,9),1993,1993],["海の日",T(7,20),1996,2002],["海の日",u(7,3),2003,2019],["海の日",T(7,23),2020,2020],["海の日",T(7,22),2021,2021],["海の日",u(7,3),2022],["山の日",T(8,11),2016,2019],["山の日",T(8,10),2020,2020],["山の日",T(8,8),2021,2021],["山の日",T(8,11),2022],["敬老の日",T(9,15),1966,2002],["敬老の日",u(9,3),2003],["秋分の日",y,1948],["体育の日",T(10,10),1966,1999],["体育の日",u(10,2),2e3,2019],["スポーツの日",T(7,24),2020,2020],["スポーツの日",T(7,23),2021,2021],["スポーツの日",u(10,2),2022],["即位礼正殿の儀",T(10,22),2019,2019],["文化の日",T(11,3),1948],["即位礼正殿の儀",T(11,12),1990,1990],["勤労感謝の日",T(11,23),1948],["天皇誕生日",T(12,23),1989,2018]],n=function(t){var e;if(t<f(1973,3,29)||0!==o(t))return null;if(e=_(t,0,0,1),!d(e,!1))return e;if(t<f(2007,0,1))return null;for(;;)if(e=_(e,0,0,1),!d(e,!1))return e},m=function(t){var e;return s(t)<1988?null:d(_(t,0,0,2),!1)?(e=_(t,0,0,1),d(e,!1)||0===o(e)||1===o(e)?null:e):null},h={true:{},false:{}},i=function(t,i){var o,s,a,l,u,d,p,g,_,y,v,x,b;if(null!=(o=h[i=!(null!=i&&!i)][t]))return o;for(b={},u=0,g=e.length;u<g;u++)null!=(a=e[u])[2]&&t<a[2]||null!=a[3]&&a[3]<t||null!=(l=a[1](t))&&(b[[y=c(l)+1,s=r(l)]]=a[0]);for(v in h[!1][t]=b,p=[],b)v=v.split(","),null!=(l=m(f(t,v[0]-1,v[1])))&&(y=c(l)+1,s=r(l),p.push([y,s]));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=n(f(t,v[0]-1,v[1])))&&(x[[y=c(l)+1,s=r(l)]]="振替休日");return h[!0][t]=x,h[i][t]},(E=null!=(g=null!==t?t.exports:void 0)?g:this.JapaneseHolidays={}).getHolidaysOf=function(t,e){var n,r,o,s;for(n in s=[],o=i(t,e))r=o[n],s.push({month:parseInt(n.split(",")[0]),date:parseInt(n.split(",")[1]),name:r});return s.sort((function(t,e){return t.month-e.month||t.date-e.date})),s},d=function(t,e){return i(s(t),e)[[c(t)+1,r(t)]]},E.isHoliday=function(t,e){return i(t.getFullYear(),e)[[t.getMonth()+1,t.getDate()]]},E.isHolidayAt=d,E.shiftDate=_,E.u2j=S,E.j2u=p,E.jDate=f,E.uDate=w,E.getJDay=o,E.getJDate=r,E.getJMonth=c,E.getJFullYear=s,E.getJHours=a,E.getJMinutes=l,E.__forTest={shunbunWithTime:b,shubunWithTime:v}}).call(japaneseHolidays$1)}(japaneseHolidays$2)),japaneseHolidays$2.exports}function requireJapaneseHolidays(){if(hasRequiredJapaneseHolidays)return japaneseHolidays;hasRequiredJapaneseHolidays=1;var t=requireJapaneseHolidays$1();return japaneseHolidays=t}var japaneseHolidaysExports=requireJapaneseHolidays(),JapaneseHolidays=getDefaultExportFromCjs(japaneseHolidaysExports);class Clock$1{constructor(t,e){const n=this;n.reset(),n.setDate(t),n.setSpeed(e)}reset(){const t=this;t.baseTime=0,t.baseHighResTime=0,t.speed=1}setSpeed(t){if(isNaN(t))return;const e=this;e.baseTime=e.getTime()-Date.now()*t,e.baseHighResTime=e.getHighResTime()-performance.now()*t,e.speed=t}setDate(t){if(!(t instanceof Date))return;const e=this,n=e.baseTime,i=-e.getTimezoneOffset(),r=e.baseTime=t.getTime()+i-Date.now()*e.speed;e.baseHighResTime+=r-n}getJSTDate(t){const e=this.getTimezoneOffset();return new Date(valueOrDefault(t,this.getTime())+e)}getTime(t){const e=this;if(!t)return e.baseTime+Date.now()*e.speed;const n=e.getJSTDate(),i=t.split(":"),r=+i[0],o=+i[1],s=-e.getTimezoneOffset()+864e5*((n.getHours()<3?-1:0)+(r<3?1:0));return n.setHours(r,o,0,0)+s+configs.minDelay}getString(t){const e=this.getJSTDate(t);return`${e.getFullYear()}-${`0${e.getMonth()+1}`.slice(-2)}-${`0${e.getDate()}`.slice(-2)} ${`0${e.getHours()}`.slice(-2)}:${`0${e.getMinutes()}`.slice(-2)}:${`0${e.getSeconds()}`.slice(-2)}`}getTimeString(t){const e=this.getJSTDate(t);return`${`0${e.getHours()}`.slice(-2)}:${`0${e.getMinutes()}`.slice(-2)}`}getTimeOffset(){return this.getTime()-this.getTime("03:00")}getHighResTime(){return this.baseHighResTime+performance.now()*this.speed}getTimezoneOffset(){return 6e4*((new Date).getTimezoneOffset()+540)}getCalendar(){const t=this.getJSTDate(),e=t.getHours();e<3&&t.setHours(e-24);const n=t.getDay(),i=t.getFullYear(),r=t.getMonth(),o=t.getDate();return 0===n||JapaneseHolidays.isHoliday(t)||2022===i&&11===r&&o>=30||2023===i&&0===r&&o<=3?"Holiday":6===n?"Saturday":"Weekday"}}const DATE_FORMAT={year:"numeric",month:"short",day:"numeric",weekday:"short"},DATE_COMPONENTS=[{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 ClockControl extends mapboxGlExports.Evented{constructor(t){super();const e=this;e._lang=t.lang,e._dict=t.dict,e._clock=t.clock,e._mode=t.mode||"realtime"}getDefaultPosition(){return"top-left"}onAdd(t){const e=this;return e._map=t,e._container=createElement$1("div",{className:"mapboxgl-ctrl ctrl-group"}),e._element=createElement$1("div",{className:"clock-ctrl"},e._container),e._update(),function t(){const n=e._clock.getTime();Math.floor(n/1e3)!==Math.floor(e._lastRefresh/1e3)&&(e._refresh(),e._lastRefresh=n),e._container&&requestAnimationFrame(t)}(),e._container}onRemove(){const t=this,e=t._container;e.parentNode.removeChild(e),delete t._container,delete t._map}setMode(t){const e=this;e._mode=t,delete e._tempDate,e._editing=!1,e._update()}_onChange(){this.fire({type:"change",clock:this._clock})}_update(){const t=this,e=t._element,n=t._dict,i=t._clock,r=t._mode,o=t._editing;if(e.innerHTML=["realtime"!==r&&o?"":'<span id="date"></span><br><span id="time"></span><br>',"playback"!==r||o?"":['<div class="clock-button">',`<span><button id="edit-time-button">${n["edit-date-time"]}</button></span>`,"</div>"].join(""),"playback"===r&&o?['<div class="clock-controller">',DATE_COMPONENTS.slice(0,3).map((({id:t})=>['<span class="spin-box">',`<div><button id="${t}-increase-button" class="top-button"><span class="increase-icon"></span></button></div>`,`<div id="${t}"></div>`,`<div><button id="${t}-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>',DATE_COMPONENTS.slice(-3).map((({id:t})=>['<span class="spin-box">',`<div><button id="${t}-increase-button" class="top-button"><span class="increase-icon"></span></button></div>`,`<div id="${t}"></div>`,`<div><button id="${t}-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">${n.cancel}</button></span>`,'<span class="clock-controller-separator"></span>',`<span><button id="edit-time-ok-button" disabled>${n.ok}</button></span>`,"</div>"].join(""):"","playback"===r?['<div class="speed-controller">','<span><button id="speed-decrease-button" class="left-button"',1===i.speed?" disabled":"",'><span class="decrease-icon"></span></button></span>',`<span id="clock-speed">${i.speed}${n["x-speed"]}</span>`,'<span><button id="speed-increase-button" class="right-button"',600===i.speed?" disabled":"",'><span class="increase-icon"></span></button></span>',"</div>"].join(""):""].join(""),t._refresh(),"playback"===r&&o&&(e.querySelector("#edit-time-cancel-button").addEventListener("click",(()=>{delete t._tempDate,t._editing=!1,t._update()})),e.querySelector("#edit-time-ok-button").addEventListener("click",(()=>{const e=t._tempDate;e&&(i.setDate(e),t._onChange(),delete t._tempDate),t._editing=!1,t._update()}))),"playback"!==r||o||e.querySelector("#edit-time-button").addEventListener("click",(()=>{t._editing=!0,t._update()})),"playback"===r&&o)for(const{id:n,fn:r}of DATE_COMPONENTS)e.querySelector(`#${n}-increase-button`).addEventListener("click",(()=>{const e=t._tempDate=t._tempDate||i.getJSTDate();e[`set${r}`](e[`get${r}`]()+1),t._refresh()})),e.querySelector(`#${n}-decrease-button`).addEventListener("click",(()=>{const e=t._tempDate=t._tempDate||i.getJSTDate();e[`set${r}`](e[`get${r}`]()-1),t._refresh()}));"playback"===r&&(e.querySelector("#speed-increase-button").addEventListener("click",(t=>{let r=i.speed;r+=r<10?1:r<100?10:100,i.setSpeed(r),t.currentTarget.disabled=600===r,e.querySelector("#speed-decrease-button").disabled=!1,e.querySelector("#clock-speed").innerHTML=r+n["x-speed"]})),e.querySelector("#speed-decrease-button").addEventListener("click",(t=>{let r=i.speed;r-=r<=10?1:r<=100?10:100,i.setSpeed(r),t.currentTarget.disabled=1===r,e.querySelector("#speed-increase-button").disabled=!1,e.querySelector("#clock-speed").innerHTML=r+n["x-speed"]})))}_refresh(){const t=this,e=t._element;let n=t._clock.getJSTDate();if(t._editing){const i=t._tempDate;if(i){n=i;for(const{id:t}of DATE_COMPONENTS)e.querySelector(`#${t}`).classList.add("desc-caution");e.querySelector("#edit-time-ok-button").disabled=!1}for(const{id:t,fn:i,digits:r,extra:o}of DATE_COMPONENTS)e.querySelector(`#${t}`).innerHTML=`0${n[`get${i}`]()+o}`.slice(-r)}else{const i=t._lang;let r=n.toLocaleDateString(i,DATE_FORMAT);"ja"===i&&JapaneseHolidays.isHoliday(n)&&(r=r.replace(/\(.+\)/,"(祝)")),e.querySelector("#date").innerHTML=r,e.querySelector("#time").innerHTML=n.toLocaleTimeString(i)}}}class MapboxGLButtonControl{constructor(t){this._options=t.map((t=>({className:t.className||"",title:t.title||"",eventHandler:t.eventHandler})))}onAdd(t){const e=this;return e._map=t,e._container=createElement$1("div",{className:"mapboxgl-ctrl mapboxgl-ctrl-group"}),e._buttons=e._options.map((t=>{const n=t.title,i=createElement$1("button",{className:t.className,type:"button",title:n,onclick:t.eventHandler},e._container),r=createElement$1("span",{className:"mapboxgl-ctrl-icon"},i);return i.setAttribute("aria-label",n),r.setAttribute("aria-hidden",!0),i})),e._container}onRemove(){const t=this._container;t.parentNode.removeChild(t),delete this._map}}class SearchControl{constructor(t){const e=this;e._title=t.title,e._placeholder=t.placeholder,e._list=t.list,e._eventHandler=t.eventHandler}onAdd(t){const e=this;e._map=t;const n=e._container=createElement$1("div",{className:"mapboxgl-ctrl mapboxgl-ctrl-group"}),i=()=>{e._button.classList.remove("expanded"),e._searchBox.classList.add("disabled")},r=e._button=createElement$1("button",{className:"mapboxgl-ctrl-search",type:"button",title:e._title,onmousedown:()=>{e._searchBox.removeEventListener("blur",i)},onmouseup:()=>{e._searchBox.addEventListener("blur",i)},onclick:()=>{const t=e._searchBox;t.classList.toggle("disabled"),e._button.classList.toggle("expanded")?(t.value="",t.focus()):e._eventHandler({value:t.value})}},n),o=createElement$1("span",{className:"mapboxgl-ctrl-icon"},r);r.setAttribute("aria-label",e._title),o.setAttribute("aria-hidden",!0);const s=e._searchBox=createElement$1("input",{className:"search-box disabled",type:"text",list:e._list,placeholder:e._placeholder},r);return s.addEventListener("blur",i),s.addEventListener("change",(()=>{document.activeElement===s&&e._eventHandler({value:s.value})&&s.blur()})),s.addEventListener("keydown",(t=>{isTouchDevice()&&"Enter"===t.code&&e._eventHandler({value:s.value})&&s.blur()})),s.addEventListener("click",(t=>{t.stopPropagation()})),s.addEventListener("keyup",(t=>{"Space"===t.code&&t.preventDefault()})),n}onRemove(){const t=this._container;t.parentNode.removeChild(t),delete this._map}}class Dataset{constructor(t,e,n){const i=this;if(i.DataClass=t,i.lookup=new Map,e)for(const r of e)i.lookup.set(r.id,new t(r,n))}load(t,e){const n=this,i=n.lookup;for(const r of t){const t=r.id;i.has(t)?i.get(t).update(r,e):i.set(t,new n.DataClass(r,e))}}get(t){return this.lookup.get(t)}getOrAdd(t){const e=this.lookup;if(e.has(t))return e.get(t);const n=new this.DataClass;return e.set(t,n),n}getAll(){return this.lookup.values()}}class Airport{constructor(t){const e=this;e.id=t.id,e.title=t.title,e.direction=t.direction}}class Flight{constructor(t,e){const n=this,{s:i,dp:r,ds:o,adt:s,edt:a,sdt:l,ar:c,or:u,aat:h,eat:d,sat:p}=t;n.id=t.id,n.n=t.n,n.a=e.operators.get(t.a),i&&(n.s=e.flightStatuses.get(i)),r&&(n.dp=e.airports.get(r)),o&&(n.ds=e.airports.get(o)),s&&(n.adt=getTimeOffset(s)),a&&(n.edt=getTimeOffset(a)),l&&(n.sdt=getTimeOffset(l)),c&&(n.ar=e.airports.get(c)),u&&(n.or=e.airports.get(u)),h&&(n.aat=getTimeOffset(h)),d&&(n.eat=getTimeOffset(d)),p&&(n.sat=getTimeOffset(p))}update(t,e){const n=this,{s:i,adt:r,edt:o,sdt:s,aat:a,eat:l,sat:c}=t;i&&(n.s=e.flightStatuses.get(i)),r&&(n.adt=getTimeOffset(r)),o&&(n.edt=getTimeOffset(o)),s&&(n.sdt=getTimeOffset(s)),a&&(n.aat=getTimeOffset(a)),l&&(n.eat=getTimeOffset(l)),c&&(n.sat=getTimeOffset(c))}}class FlightStatus{constructor(t){this.id=t.id,this.title=t.title}}class Operator{constructor(t){const e=this;e.id=t.id,e.title=t.title,e.color=t.color,e.tailcolor=t.tailcolor}}class POI{constructor(t){const e=this,{uptime:n,facilities:i}=t;e.id=t.id,e.coord=t.coord,e.title=t.title,e.description=t.description,n&&(e.uptime=n.map((({open:t,close:e,calendar:n})=>{const i={open:getTimeOffset(t),close:getTimeOffset(e)};return n&&(i.calendar=n),i}))),i&&(e.facilities=i)}}class RailDirection{constructor(t){this.id=t.id,this.title=t.title}}class Railway{constructor(t,e){const n=this,{dynamic:i,altitude:r}=t;n.id=t.id,n.title=t.title,n.stations=t.stations.map((t=>e.stations.getOrAdd(t))),n.ascending=e.railDirections.get(t.ascending),n.descending=e.railDirections.get(t.descending),r&&(n.altitude=r),n.color=t.color,n.carComposition=t.carComposition,i&&(n.dynamic=i)}}class Station{constructor(t,e){t&&this.update(t,e)}update(t,e){const n=this,{railway:i,coord:r,utitle:o,thumbnail:s,exit:a,altitude:l,alternate:c,ascending:u,descending:h,group:d}=t;n.id=t.id,i&&(n.railway=e.railways.get(i)),r&&(n.coord=r),n.title=t.title,o&&(n.utitle=o),s&&(n.thumbnail=s),a&&(n.exit=a.map((t=>e.pois.get(t)))),l&&(n.altitude=l),c&&(n.alternate=e.stations.getOrAdd(c)),void 0!==u&&(n.ascending=u?e.railDirections.get(u):null),void 0!==h&&(n.descending=h?e.railDirections.get(h):null),d&&(n.group=d)}}class TrainTimetable{constructor(t,e){if(!t)return;const n=this,{os:i,ds:r,tt:o,nm:s,v:a}=t,l=e.stations;n.id=t.id,n.t=t.t,n.r=e.railways.get(t.r),n.n=t.n,n.y=e.trainTypes.get(t.y),n.d=e.railDirections.get(t.d),i&&(n.os=i.map((t=>l.get(t)))),r&&(n.ds=r.map((t=>l.get(t)))),n.stations=o.map((({s:t})=>l.get(t))),n.arrivalTimes=o.map((({a:t})=>t?getTimeOffset(t):void 0)),n.departureTimes=o.map((({d:t})=>t?getTimeOffset(t):void 0)),s&&(n.nm=s),a&&(n.v=e.trainVehicleTypes.get(a));const c=n.arrivalTimes.concat(n.departureTimes).filter((t=>!isNaN(t)));n.start=Math.min(...c)-configs.standingDuration,n.end=Math.max(...c)}update(t,e){const n=this,{pt:i,nt:r}=t,o=e.timetables,s=configs.standingDuration;if(i)for(const t of i){const e=o.get(t);if(e){const t=n.stations.length-1,i=n.arrivalTimes[t],r=n.departureTimes[t];n.pt=n.pt||[],n.pt.push(e),void 0!==i?n.start=Math.min(n.start,i-s):void 0!==r&&(n.start=Math.min(n.start,r-s))}}if(r){for(const t of r){const e=o.get(t);e&&(n.nt=n.nt||[],n.nt.push(e))}n.nt&&(n.departureTimes[n.stations.length-1]=n.nt[0].departureTimes[0])}}clone(){const t=this,e=new TrainTimetable;return e.id=t.id,e.t=t.t,e.r=t.r,e.n=t.n,e.y=t.y,e.d=t.d,e.os=t.os,e.ds=t.ds,e.pt=t.pt,e.nt=t.nt,e.stations=t.stations.slice(),e.arrivalTimes=t.arrivalTimes.slice(),e.departureTimes=t.departureTimes.slice(),e.nm=t.nm,e.v=t.v,e.start=t.start,e.end=t.end,e}getConnectingTrainIds(){const{nt:t,t:e}=this;return t?[e].concat(...t.map((t=>t.getConnectingTrainIds()))):[e]}}class Train{constructor(t,e){const n=this,i=t instanceof TrainTimetable,{r:r,y:o,d:s,os:a,ds:l,ts:c,fs:u,nm:h,v:d,delay:p,carComposition:f}=t;n.id=i?t.t:t.id,n.r=i?r:e.railways.get(r),n.n=t.n,n.y=i?o:e.trainTypes.get(o),n.d=i?s:e.railDirections.get(s),a&&(n.os=i?a:a.map((t=>e.stations.get(t)))),l&&(n.ds=i?l:l.map((t=>e.stations.get(t)))),c&&(n.ts=e.stations.get(c)),u&&(n.fs=e.stations.get(u)),i&&(n.timetable=t),h&&(n.nm=h),d&&(n.v=i?d:e.trainVehicleTypes.get(d));const m=n.r;n.direction=n.d===m.ascending?1:-1,n.altitude=m.altitude,isNaN(p)||(n.delay=p),n.carComposition=isNaN(f)?m.carComposition:f}update(t,e){const n=this,{os:i,ds:r}=n,{y:o,os:s,ds:a,ts:l,fs:c,v:u,delay:h,carComposition:d}=t,p=e.stations;if(o&&(n.y=e.trainTypes.get(o)),s){const t=n.timetable;if(n.os=s.map((t=>p.get(t))),i&&s[0]!==i[0].id&&t){const e=t.stations;for(let i=0,r=e.length;i<r;i++)if(e[i].id===s[0]){n.timetable=t.clone(),n.timetable.stations.splice(0,i),n.timetable.arrivalTimes.splice(0,i+1,void 0),n.timetable.departureTimes.splice(0,i);break}}}if(a){const t=n.timetable;if(n.ds=a.map((t=>p.get(t))),r&&a[0]!==r[0].id&&t){const e=t.stations;for(let i=0,r=e.length;i<r;i++)if(e[i].id===a[0]){n.timetable=t.clone(),n.timetable.stations.splice(i+1),n.timetable.arrivalTimes.splice(i,1/0,valueOrDefault(n.timetable.arrivalTimes[i],n.timetable.departureTimes[i])),n.timetable.departureTimes.splice(i,1/0,void 0);break}}}l&&(n.ts=p.get(l)),c&&(n.fs=p.get(c)),u&&(n.v=e.trainVehicleTypes.get(u)),isNaN(h)||(n.delay=h),isNaN(d)||(n.carComposition=d)}}class TrainTimetables{constructor(t,e){const n=this,i=new Map;n.array=[],n.trainLookup=new Map,n.railwayDirectionLookup=new Map;for(const r of t){const t=new TrainTimetable(r,e);n.add(t),i.set(t.id,t)}for(const n of t)if(n.pt||n.nt){i.get(n.id).update(n,{...e,timetables:i})}}add(t){const{array:e,trainLookup:n,railwayDirectionLookup:i}=this,r=t.t,o=n.get(r),s=`${t.r.id}:${t.d.id}`,a=i.get(s);e.push(t),Array.isArray(o)?o.push(t):n.set(r,o?[o,t]:t),a?a.push(t):i.set(s,[t])}getByTrainId(t){const e=this.trainLookup.get(t);return Array.isArray(e)?e:e?[e]:[]}getByDirectionId(t,e){return this.railwayDirectionLookup.get(`${t}:${e}`)||[]}getAll(){return this.array}getConnectingTrainIds(t){const e=new Set;for(const n of this.getByTrainId(t))for(const t of n.getConnectingTrainIds())e.add(t);return Array.from(e)}clear(){const t=this;t.array=[],t.trainLookup=new Map,t.railwayDirectionLookup=new Map}}class TrainType{constructor(t){this.id=t.id,this.title=t.title}}class TrainVehicleType{constructor(t){this.id=t.id,this.color=t.color}}function z(){const t=["W5i9k8k+","fSozumk7WOWOWOhdMgjwxa1JW7HPt8obW7VcIM/cR34peSoFW6BcOSo9gmoGW7ZcI8opWRZcLg5+k8khWQxcJCkUcGZdRH3dISoGW5tdTSkODmkTW7RdS8oCW4GBjXqxWRn6W7q","W6lcMCkTyZNcGmogtZ/cPSkIWR/dMa","fSovW7DGW5FdRY1kWRddSf7dStFdTmkhWRHliwlcHCkGsCoyW7/cGbBcMhhcK8oQE351E1JdKKBdLsJcICobWQf8FCowqWjafghcPXm0W7/cRmoOW6PhWPf0WQDUWQxcGW","iXlcLSkBee/dMmo3W4ZcMSk1","qx3dLmkjWRj5WPRcOgO5rgxdLCkjW6illcNdRLRdRmoEW7RcLCktwI7cV3HjrmkRxmkoWQv4BIPAbKhdSdVdImo9xSomW5DSz8k3CG7cVCkFW7uJw8kaW71Lj8kGWRumW5FcNtOiW6iDnCo7WQNdGxVdQemMp8ohASkQWQSVW5i","uCozWQDWW5ddQIy"];return(z=function(){return t})()}function y(t,e){const n=z();return y=function(e,i){let r=n[e-=0];if(void 0===y.nrYKbJ){y.XVTYZg=function(t,e){let n,i,r=[],o=0,s="";for(t=function(t){let e="",n="";for(let n,i,r=0,o=0;i=t.charAt(o++);~i&&(n=r%4?64*n+i:i,r++%4)?e+=String.fromCharCode(255&n>>(-2*r&6)):0)i="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(i);for(let t=0,i=e.length;t<i;t++)n+="%"+("00"+e.charCodeAt(t).toString(16)).slice(-2);return decodeURIComponent(n)}(t),i=0;i<256;i++)r[i]=i;for(i=0;i<256;i++)o=(o+r[i]+e.charCodeAt(i%e.length))%256,n=r[i],r[i]=r[o],r[o]=n;i=0,o=0;for(let e=0;e<t.length;e++)i=(i+1)%256,o=(o+r[i])%256,n=r[i],r[i]=r[o],r[o]=n,s+=String.fromCharCode(t.charCodeAt(e)^r[(r[i]+r[o])%256]);return s},t=arguments,y.nrYKbJ=!0}const o=e+n[0],s=t[o];return s?r=s:(void 0===y.RGcreR&&(y.RGcreR=!0),r=y.XVTYZg(r,i),t[o]=r),r},y(t,e)}function extend$3(t,...e){const n=y,i={};i[n(0,"pe6Y")]=n(1,"!NJq"),i[n(2,"YiUq")]=n(3,"zWjH");const r={};r[n(4,"CZL0")]=n(5,"ZS6]"),r[n(6,"zWjH")]=i;const o=r;for(const n of[o,...e])for(const e in n)t[e]=n[e];return t}function pickObject(t,e,n){const i=t.__deck;if(i.deckPicker){const t=i.pickObject({x:n.x,y:n.y,layerIds:[e]});if(t)return t.object}}function getCoord(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 getCoords(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")}function getType(t,e){if(!t)throw new Error("geojson is required");if(t.geometry&&t.geometry.type)return t.geometry.type;if(t.type)return t.type;throw new Error("geojson is invalid")}function bearing(t,e,n){if(!isObject$5(n=n||{}))throw new Error("options is invalid");if(!0===n.final)return calculateFinalBearing(t,e);var i=getCoord(t),r=getCoord(e),o=degreesToRadians(i[0]),s=degreesToRadians(r[0]),a=degreesToRadians(i[1]),l=degreesToRadians(r[1]),c=Math.sin(s-o)*Math.cos(l),u=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(s-o);return radiansToDegrees(Math.atan2(c,u))}function calculateFinalBearing(t,e){var n=bearing(e,t);return n=(n+180)%360}var concaveman$1={exports:{}},rbush_min$1={exports:{}},rbush_min=rbush_min$1.exports,hasRequiredRbush_min;function requireRbush_min(){return hasRequiredRbush_min||(hasRequiredRbush_min=1,function(t){t.exports=function(){function t(t,i,r,o,s){!function t(n,i,r,o,s){for(;o>r;){if(o-r>600){var a=o-r+1,l=i-r+1,c=Math.log(a),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(a-u)/a)*(l-a/2<0?-1:1);t(n,i,Math.max(r,Math.floor(i-l*u/a+h)),Math.min(o,Math.floor(i+(a-l)*u/a+h)),s)}var d=n[i],p=r,f=o;for(e(n,r,i),s(n[o],d)>0&&e(n,r,o);p<f;){for(e(n,p,f),p++,f--;s(n[p],d)<0;)p++;for(;s(n[f],d)>0;)f--}0===s(n[r],d)?e(n,r,f):e(n,++f,o),f<=i&&(r=f+1),i<=f&&(o=f-1)}}(t,i,r||0,o||t.length-1,s||n)}function e(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function n(t,e){return t<e?-1:t>e?1:0}var i=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(t,e,n){if(!n)return e.indexOf(t);for(var i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function o(t,e){s(t,0,t.children.length,e,t)}function s(t,e,n,i,r){r||(r=f(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var o=e;o<n;o++){var s=t.children[o];a(r,t.leaf?i(s):s)}return r}function a(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function l(t,e){return t.minX-e.minX}function c(t,e){return t.minY-e.minY}function u(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function h(t){return t.maxX-t.minX+(t.maxY-t.minY)}function d(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function p(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function f(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(e,n,i,r,o){for(var s=[n,i];s.length;)if(!((i=s.pop())-(n=s.pop())<=r)){var a=n+Math.ceil((i-n)/r/2)*r;t(e,a,n,i,o),s.push(n,a,a,i)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(t){var e=this.data,n=[];if(!p(t,e))return n;for(var i=this.toBBox,r=[];e;){for(var o=0;o<e.children.length;o++){var s=e.children[o],a=e.leaf?i(s):s;p(t,a)&&(e.leaf?n.push(s):d(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n},i.prototype.collides=function(t){var e=this.data;if(!p(t,e))return!1;for(var n=[];e;){for(var i=0;i<e.children.length;i++){var r=e.children[i],o=e.leaf?this.toBBox(r):r;if(p(t,o)){if(e.leaf||d(t,o))return!0;n.push(r)}}e=n.pop()}return!1},i.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.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 i=this.data;this.data=n,n=i}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},i.prototype.clear=function(){return this.data=f([]),this},i.prototype.remove=function(t,e){if(!t)return this;for(var n,i,o,s=this.data,a=this.toBBox(t),l=[],c=[];s||l.length;){if(s||(s=l.pop(),i=l[l.length-1],n=c.pop(),o=!0),s.leaf){var u=r(t,s.children,e);if(-1!==u)return s.children.splice(u,1),l.push(s),this._condense(l),this}o||s.leaf||!d(s,a)?i?(n++,s=i.children[n],o=!1):s=null:(l.push(s),c.push(n),n=0,i=s,s=s.children[0])}return this},i.prototype.toBBox=function(t){return t},i.prototype.compareMinX=function(t,e){return t.minX-e.minX},i.prototype.compareMinY=function(t,e){return t.minY-e.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(t){return this.data=t,this},i.prototype._all=function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},i.prototype._build=function(t,e,n,i){var r,s=n-e+1,a=this._maxEntries;if(s<=a)return o(r=f(t.slice(e,n+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(s)/Math.log(a)),a=Math.ceil(s/Math.pow(a,i-1))),(r=f([])).leaf=!1,r.height=i;var l=Math.ceil(s/a),c=l*Math.ceil(Math.sqrt(a));m(t,e,n,c,this.compareMinX);for(var u=e;u<=n;u+=c){var h=Math.min(u+c-1,n);m(t,u,h,l,this.compareMinY);for(var d=u;d<=h;d+=l){var p=Math.min(d+l-1,h);r.children.push(this._build(t,d,p,i-1))}}return o(r,this.toBBox),r},i.prototype._chooseSubtree=function(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){for(var r=1/0,o=1/0,s=void 0,a=0;a<e.children.length;a++){var l=e.children[a],c=u(l),h=(d=t,p=l,(Math.max(p.maxX,d.maxX)-Math.min(p.minX,d.minX))*(Math.max(p.maxY,d.maxY)-Math.min(p.minY,d.minY))-c);h<o?(o=h,r=c<r?c:r,s=l):h===o&&c<r&&(r=c,s=l)}e=s||e.children[0]}var d,p;return e},i.prototype._insert=function(t,e,n){var i=n?t:this.toBBox(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),a(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)},i.prototype._split=function(t,e){var n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var s=this._chooseSplitIndex(n,r,i),a=f(n.children.splice(s,n.children.length-s));a.height=n.height,a.leaf=n.leaf,o(n,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)},i.prototype._splitRoot=function(t,e){this.data=f([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(t,e,n){for(var i,r,o,a,l,c,h,d=1/0,p=1/0,f=e;f<=n-e;f++){var m=s(t,0,f,this.toBBox),g=s(t,f,n,this.toBBox),_=(r=m,o=g,a=void 0,l=void 0,c=void 0,h=void 0,a=Math.max(r.minX,o.minX),l=Math.max(r.minY,o.minY),c=Math.min(r.maxX,o.maxX),h=Math.min(r.maxY,o.maxY),Math.max(0,c-a)*Math.max(0,h-l)),y=u(m)+u(g);_<d?(d=_,i=f,p=y<p?y:p):_===d&&y<p&&(p=y,i=f)}return i||n-e},i.prototype._chooseSplitAxis=function(t,e,n){var i=t.leaf?this.compareMinX:l,r=t.leaf?this.compareMinY:c;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)},i.prototype._allDistMargin=function(t,e,n,i){t.children.sort(i);for(var r=this.toBBox,o=s(t,0,e,r),l=s(t,n-e,n,r),c=h(o)+h(l),u=e;u<n-e;u++){var d=t.children[u];a(o,t.leaf?r(d):d),c+=h(o)}for(var p=n-e-1;p>=e;p--){var f=t.children[p];a(l,t.leaf?r(f):f),c+=h(l)}return c},i.prototype._adjustParentBBoxes=function(t,e,n){for(var i=n;i>=0;i--)a(e[i],t)},i.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():o(t[e],this.toBBox)},i}()}(rbush_min$1)),rbush_min$1.exports}class TinyQueue{constructor(t=[],e=defaultCompare$1){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(n(i,o)>=0)break;e[t]=o,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1),o=e[i];const s=i+1;if(s<this.length&&n(e[s],o)<0&&(i=s,o=e[s]),n(o,r)>=0)break;e[t]=o,t=i}e[t]=r}}function defaultCompare$1(t,e){return t<e?-1:t>e?1:0}var tinyqueue=Object.freeze({__proto__:null,default:TinyQueue}),require$$1=getAugmentedNamespace(tinyqueue),pointInPolygon={exports:{}},flat,hasRequiredFlat,nested,hasRequiredNested,hasRequiredPointInPolygon;function requireFlat(){return hasRequiredFlat||(hasRequiredFlat=1,flat=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,l=0,c=a-1;l<a;c=l++){var u=e[n+2*l+0],h=e[n+2*l+1],d=e[n+2*c+1];h>o!=d>o&&r<(e[n+2*c+0]-u)*(o-h)/(d-h)+u&&(s=!s)}return s}),flat}function requireNested(){return hasRequiredNested||(hasRequiredNested=1,nested=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,l=0,c=a-1;l<a;c=l++){var u=e[l+n][0],h=e[l+n][1],d=e[c+n][1];h>o!=d>o&&r<(e[c+n][0]-u)*(o-h)/(d-h)+u&&(s=!s)}return s}),nested}function requirePointInPolygon(){if(hasRequiredPointInPolygon)return pointInPolygon.exports;hasRequiredPointInPolygon=1;var t=requireFlat(),e=requireNested();return pointInPolygon.exports=function(n,i,r,o){return i.length>0&&Array.isArray(i[0])?e(n,i,r,o):t(n,i,r,o)},pointInPolygon.exports.nested=e,pointInPolygon.exports.flat=t,pointInPolygon.exports}var orient2d_min$1={exports:{}},orient2d_min=orient2d_min$1.exports,hasRequiredOrient2d_min,hasRequiredConcaveman;function requireOrient2d_min(){return hasRequiredOrient2d_min||(hasRequiredOrient2d_min=1,function(t,e){!function(t){const e=134217729,n=33306690738754706e-32;function i(t,e,n,i,r){let o,s,a,l,c=e[0],u=i[0],h=0,d=0;u>c==u>-c?(o=c,c=e[++h]):(o=u,u=i[++d]);let p=0;if(h<t&&d<n)for(u>c==u>-c?(a=o-((s=c+o)-c),c=e[++h]):(a=o-((s=u+o)-u),u=i[++d]),o=s,0!==a&&(r[p++]=a);h<t&&d<n;)u>c==u>-c?(a=o-((s=o+c)-(l=s-o))+(c-l),c=e[++h]):(a=o-((s=o+u)-(l=s-o))+(u-l),u=i[++d]),o=s,0!==a&&(r[p++]=a);for(;h<t;)a=o-((s=o+c)-(l=s-o))+(c-l),c=e[++h],o=s,0!==a&&(r[p++]=a);for(;d<n;)a=o-((s=o+u)-(l=s-o))+(u-l),u=i[++d],o=s,0!==a&&(r[p++]=a);return 0===o&&0!==p||(r[p++]=o),p}function r(t){return new Float64Array(t)}const o=33306690738754716e-32,s=22204460492503146e-32,a=11093356479670487e-47,l=r(4),c=r(8),u=r(12),h=r(16),d=r(4);t.orient2d=function(t,r,p,f,m,g){const _=(r-g)*(p-m),y=(t-m)*(f-g),v=_-y;if(0===_||0===y||_>0!=y>0)return v;const x=Math.abs(_+y);return Math.abs(v)>=o*x?v:-function(t,r,o,p,f,m,g){let _,y,v,x,b,T,E,S,w,A,M,C,I,P,L,R,O,D;const B=t-f,N=o-f,F=r-m,U=p-m;b=(L=(S=B-(E=(T=e*B)-(T-B)))*(A=U-(w=(T=e*U)-(T-U)))-((P=B*U)-E*w-S*w-E*A))-(M=L-(O=(S=F-(E=(T=e*F)-(T-F)))*(A=N-(w=(T=e*N)-(T-N)))-((R=F*N)-E*w-S*w-E*A))),l[0]=L-(M+b)+(b-O),b=(I=P-((C=P+M)-(b=C-P))+(M-b))-(M=I-R),l[1]=I-(M+b)+(b-R),b=(D=C+M)-C,l[2]=C-(D-b)+(M-b),l[3]=D;let k=function(t,e){let n=e[0];for(let i=1;i<t;i++)n+=e[i];return n}(4,l),z=s*g;if(k>=z||-k>=z)return k;if(_=t-(B+(b=t-B))+(b-f),v=o-(N+(b=o-N))+(b-f),y=r-(F+(b=r-F))+(b-m),x=p-(U+(b=p-U))+(b-m),0===_&&0===y&&0===v&&0===x)return k;if(z=a*g+n*Math.abs(k),(k+=B*x+U*_-(F*v+N*y))>=z||-k>=z)return k;b=(L=(S=_-(E=(T=e*_)-(T-_)))*(A=U-(w=(T=e*U)-(T-U)))-((P=_*U)-E*w-S*w-E*A))-(M=L-(O=(S=y-(E=(T=e*y)-(T-y)))*(A=N-(w=(T=e*N)-(T-N)))-((R=y*N)-E*w-S*w-E*A))),d[0]=L-(M+b)+(b-O),b=(I=P-((C=P+M)-(b=C-P))+(M-b))-(M=I-R),d[1]=I-(M+b)+(b-R),b=(D=C+M)-C,d[2]=C-(D-b)+(M-b),d[3]=D;const G=i(4,l,4,d,c);b=(L=(S=B-(E=(T=e*B)-(T-B)))*(A=x-(w=(T=e*x)-(T-x)))-((P=B*x)-E*w-S*w-E*A))-(M=L-(O=(S=F-(E=(T=e*F)-(T-F)))*(A=v-(w=(T=e*v)-(T-v)))-((R=F*v)-E*w-S*w-E*A))),d[0]=L-(M+b)+(b-O),b=(I=P-((C=P+M)-(b=C-P))+(M-b))-(M=I-R),d[1]=I-(M+b)+(b-R),b=(D=C+M)-C,d[2]=C-(D-b)+(M-b),d[3]=D;const V=i(G,c,4,d,u);b=(L=(S=_-(E=(T=e*_)-(T-_)))*(A=x-(w=(T=e*x)-(T-x)))-((P=_*x)-E*w-S*w-E*A))-(M=L-(O=(S=y-(E=(T=e*y)-(T-y)))*(A=v-(w=(T=e*v)-(T-v)))-((R=y*v)-E*w-S*w-E*A))),d[0]=L-(M+b)+(b-O),b=(I=P-((C=P+M)-(b=C-P))+(M-b))-(M=I-R),d[1]=I-(M+b)+(b-R),b=(D=C+M)-C,d[2]=C-(D-b)+(M-b),d[3]=D;const j=i(V,u,4,d,h);return h[j-1]}(t,r,p,f,m,g,x)},t.orient2dfast=function(t,e,n,i,r,o){return(e-o)*(n-r)-(t-r)*(i-o)},Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,orient2d_min$1.exports)),orient2d_min$1.exports}function requireConcaveman(){if(hasRequiredConcaveman)return concaveman$1.exports;hasRequiredConcaveman=1;var t=requireRbush_min(),e=require$$1,n=requirePointInPolygon(),i=requireOrient2d_min().orient2d;function r(e,i,r){i=Math.max(0,void 0===i?2:i),r=r||0;var s=function(t){for(var e=t[0],i=t[0],r=t[0],o=t[0],s=0;s<t.length;s++){var a=t[s];a[0]<e[0]&&(e=a),a[0]>r[0]&&(r=a),a[1]<i[1]&&(i=a),a[1]>o[1]&&(o=a)}var l=[e,i,r,o],c=l.slice();for(s=0;s<t.length;s++)n(t[s],l)||c.push(t[s]);return function(t){t.sort(g);for(var e=[],n=0;n<t.length;n++){for(;e.length>=2&&u(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var i=[],r=t.length-1;r>=0;r--){for(;i.length>=2&&u(i[i.length-2],i[i.length-1],t[r])<=0;)i.pop();i.push(t[r])}return i.pop(),e.pop(),e.concat(i)}(c)}(e),a=new t(16);a.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},a.compareMinX=function(t,e){return t[0]-e[0]},a.compareMinY=function(t,e){return t[1]-e[1]},a.load(e);for(var l,c=[],f=0;f<s.length;f++){var m=s[f];a.remove(m),l=d(m,l),c.push(l)}var _=new t(16);for(f=0;f<c.length;f++)_.insert(h(c[f]));for(var y=i*i,v=r*r;c.length;){var x=c.shift(),b=x.p,T=x.next.p,E=p(b,T);if(!(E<v)){var S=E/y;(m=o(a,x.prev.p,b,T,x.next.next.p,S,_))&&Math.min(p(m,b),p(m,T))<=S&&(c.push(x),c.push(d(m,x)),a.remove(m),_.remove(x),_.insert(h(x)),_.insert(h(x.next)))}}x=l;var w=[];do{w.push(x.p),x=x.next}while(x!==l);return w.push(x.p),w}function o(t,n,i,r,o,l,u){for(var h=new e([],s),d=t.data;d;){for(var p=0;p<d.children.length;p++){var m=d.children[p],g=d.leaf?f(m,i,r):a(i,r,m);g>l||h.push({node:m,dist:g})}for(;h.length&&!h.peek().node.children;){var _=h.pop(),y=_.node,v=f(y,n,i),x=f(y,r,o);if(_.dist<v&&_.dist<x&&c(i,y,u)&&c(r,y,u))return y}(d=h.pop())&&(d=d.node)}return null}function s(t,e){return t.dist-e.dist}function a(t,e,n){if(l(t,n)||l(e,n))return 0;var i=m(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;var r=m(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;var o=m(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===o)return 0;var s=m(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===s?0:Math.min(i,r,o,s)}function l(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function c(t,e,n){for(var i,r,o,s,a=Math.min(t[0],e[0]),l=Math.min(t[1],e[1]),c=Math.max(t[0],e[0]),h=Math.max(t[1],e[1]),d=n.search({minX:a,minY:l,maxX:c,maxY:h}),p=0;p<d.length;p++)if(r=d[p].next.p,o=t,(i=d[p].p)!==(s=e)&&r!==o&&u(i,r,o)>0!=u(i,r,s)>0&&u(o,s,i)>0!=u(o,s,r)>0)return!1;return!0}function u(t,e,n){return i(t[0],t[1],e[0],e[1],n[0],n[1])}function h(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function d(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function p(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function f(t,e,n){var i=e[0],r=e[1],o=n[0]-i,s=n[1]-r;if(0!==o||0!==s){var a=((t[0]-i)*o+(t[1]-r)*s)/(o*o+s*s);a>1?(i=n[0],r=n[1]):a>0&&(i+=o*a,r+=s*a)}return(o=t[0]-i)*o+(s=t[1]-r)*s}function m(t,e,n,i,r,o,s,a){var l,c,u,h,d=n-t,p=i-e,f=s-r,m=a-o,g=t-r,_=e-o,y=d*d+p*p,v=d*f+p*m,x=f*f+m*m,b=d*g+p*_,T=f*g+m*_,E=y*x-v*v,S=E,w=E;0===E?(c=0,S=1,h=T,w=x):(h=y*T-v*b,(c=v*T-x*b)<0?(c=0,h=T,w=x):c>S&&(c=S,h=T+v,w=x)),h<0?(h=0,-b<0?c=0:-b>y?c=S:(c=-b,S=y)):h>w&&(h=w,-b+v<0?c=0:-b+v>y?c=S:(c=-b+v,S=y));var A=(1-(u=0===h?0:h/w))*r+u*s-((1-(l=0===c?0:c/S))*t+l*n),M=(1-u)*o+u*a-((1-l)*e+l*i);return A*A+M*M}function g(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}return e.default&&(e=e.default),concaveman$1.exports=r,concaveman$1.exports.default=r,concaveman$1.exports}var concavemanExports=requireConcaveman(),concaveman=getDefaultExportFromCjs(concavemanExports);function convex(t,e){if(!isObject$5(e=e||{}))throw new Error("options is invalid");var n=e.concavity||1/0,i=[];if(coordEach(t,(function(t){i.push([t[0],t[1]])})),!i.length)return null;var r=concaveman(i,n);return r.length>3?polygon([r]):null}function centroid(t,e){var n=0,i=0,r=0;return coordEach(t,(function(t){n+=t[0],i+=t[1],r++}),!0),point([n/r,i/r],e)}function centerOfMass(t,e){switch(getType(t)){case"Point":return t;case"Polygon":var n=[];coordEach(t,(function(t){n.push(t)}));var i,r,o,s,a,l,c,u,h=centroid(t,e),d=h.geometry.coordinates,p=0,f=0,m=0,g=n.map((function(t){return[t[0]-d[0],t[1]-d[1]]}));for(i=0;i<n.length-1;i++)m+=u=(s=(r=g[i])[0])*(c=(o=g[i+1])[1])-(a=o[0])*(l=r[1]),p+=(s+a)*u,f+=(l+c)*u;if(0===m)return h;var _=1/(6*(.5*m));return point([d[0]+_*p,d[1]+_*f],e);default:var y=convex(t);return y?centerOfMass(y,e):centroid(t,e)}}function distance$1(t,e,n){if(!isObject$5(n=n||{}))throw new Error("options is invalid");var i=n.units,r=getCoord(t),o=getCoord(e),s=degreesToRadians(o[1]-r[1]),a=degreesToRadians(o[0]-r[0]),l=degreesToRadians(r[1]),c=degreesToRadians(o[1]),u=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(l)*Math.cos(c);return radiansToLength(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),i)}const DOUBLE_PI=2*Math.PI,DEGREE_TO_RADIAN$1=Math.PI/180,MEAN_EARTH_RADIUS=6371.0088;function destination$1(t,e,n){const i=getCoord(t),r=i[0]*DEGREE_TO_RADIAN$1,o=i[1]*DEGREE_TO_RADIAN$1,s=n*DEGREE_TO_RADIAN$1,a=e/MEAN_EARTH_RADIUS,l=Math.sin(o),c=Math.cos(o),u=Math.sin(a),h=Math.cos(a),d=Math.sin(s),p=Math.cos(s),f=Math.asin(l*h+c*u*p);return[(r+Math.atan2(d*u*c,h-l*Math.sin(f)))%DOUBLE_PI/DEGREE_TO_RADIAN$1,f%DOUBLE_PI/DEGREE_TO_RADIAN$1]}function featureFilter(t,e){const n=[];return featureEach(t,(t=>{e(t.properties)&&n.push(t)})),featureCollection(n)}function updateDistances(t){const e=getCoords(t),n=t.properties.distances=[];let i,r,o,s=0,a=e[0];for(let t=0,l=e.length;t<l-1;t++){const l=a;a=e[t+1];const c=distance$1(l,a);i=bearing(l,a),r=((a[2]||0)-(l[2]||0))/c,o=Math.atan(r/1e3),n.push([s,i,r,o]),s+=c}n.push([s,i,r,o])}function getCoordAndBearing(t,e,n,i){const r=t.geometry.coordinates,o=t.properties.distances,s=r.length,a=[];let l=0,c=s-1;for(e-=i*(n-1)/2;l!==c-1;){const t=Math.floor((l+c)/2);e<o[t][0]?c=t:l=t}let u=l;for(let t=0;t<n;e+=i,t++){for(;e>o[u+1][0]&&u<s-2;)u++;const[t,n,i,l]=o[u],c=r[u],h=e-t;a.push({coord:destination$1(c,h,n),altitude:(c[2]||0)+i*h,bearing:n,pitch:l})}return a}function getAltitude(t){return getCoords(t)[0][0][2]}function getCenterCoord(t){return getCoord(centerOfMass(t))}function emptyFeatureCollection(){return featureCollection([])}var csscolorparser={},hasRequiredCsscolorparser;function requireCsscolorparser(){if(hasRequiredCsscolorparser)return csscolorparser;hasRequiredCsscolorparser=1;var t={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 e(t){return(t=Math.round(t))<0?0:t>255?255:t}function n(t){return t<0?0:t>1?1:t}function i(t){return e("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function r(t){return n("%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))}function o(t,e,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?t+(e-t)*n*6:2*n<1?e:3*n<2?t+(e-t)*(2/3-n)*6:t}try{csscolorparser.parseCSSColor=function(n){var s,a=n.replace(/ /g,"").toLowerCase();if(a in t)return t[a].slice();if("#"===a[0])return 4===a.length?(s=parseInt(a.substr(1),16))>=0&&s<=4095?[(3840&s)>>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)<<4,1]:null:7===a.length&&(s=parseInt(a.substr(1),16))>=0&&s<=16777215?[(16711680&s)>>16,(65280&s)>>8,255&s,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:[i(h[0]),i(h[1]),i(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[e(255*o(_,g,p+1/3)),e(255*o(_,g,p)),e(255*o(_,g,p-1/3)),d];default:return null}}return null}}catch(t){}return csscolorparser}var csscolorparserExports=requireCsscolorparser(),suncalc={exports:{}},hasRequiredSuncalc;function requireSuncalc(){return hasRequiredSuncalc||(hasRequiredSuncalc=1,function(t){!function(){var e=Math.PI,n=Math.sin,i=Math.cos,r=Math.tan,o=Math.asin,s=Math.atan2,a=Math.acos,l=e/180,c=864e5,u=2440588,h=2451545;function d(t){return new Date((t+.5-u)*c)}function p(t){return function(t){return t.valueOf()/c-.5+u}(t)-h}var f=23.4397*l;function m(t,e){return s(n(t)*i(f)-r(e)*n(f),i(t))}function g(t,e){return o(n(e)*i(f)+i(e)*n(f)*n(t))}function _(t,e,o){return s(n(t),i(t)*n(e)-r(o)*i(e))}function y(t,e,r){return o(n(e)*n(r)+i(e)*i(r)*i(t))}function v(t,e){return l*(280.16+360.9856235*t)-e}function x(t){return l*(357.5291+.98560028*t)}function b(t){return t+l*(1.9148*n(t)+.02*n(2*t)+3e-4*n(3*t))+102.9372*l+e}function T(t){var e=b(x(t));return{dec:g(e,0),ra:m(e,0)}}var E={getPosition:function(t,e,n){var i=l*-n,r=l*e,o=p(t),s=T(o),a=v(o,i)-s.ra;return{azimuth:_(a,r,s.dec),altitude:y(a,r,s.dec)}}},S=E.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];E.addTime=function(t,e,n){S.push([t,e,n])};var w=9e-4;function A(t,n,i){return w+(t+n)/(2*e)+i}function M(t,e,i){return h+t+.0053*n(e)-.0069*n(2*i)}function C(t,e,r,o,s,l,c){var u=function(t,e,r){return a((n(t)-n(e)*n(r))/(i(e)*i(r)))}(t,r,o);return M(A(u,e,s),l,c)}function I(t){var e=l*(134.963+13.064993*t),r=l*(93.272+13.22935*t),o=l*(218.316+13.176396*t)+6.289*l*n(e),s=5.128*l*n(r),a=385001-20905*i(e);return{ra:m(o,s),dec:g(o,s),dist:a}}function P(t,e){return new Date(t.valueOf()+e*c/24)}E.getTimes=function(t,n,i,r){var o,s,a,c,u=l*-i,h=l*n,f=function(t){return-2.076*Math.sqrt(t)/60}(r=r||0),m=function(t,n){return Math.round(t-w-n/(2*e))}(p(t),u),_=A(0,u,m),y=x(_),v=b(y),T=g(v,0),E=M(_,y,v),I={solarNoon:d(E),nadir:d(E-.5)};for(o=0,s=S.length;o<s;o+=1)c=C(((a=S[o])[0]+f)*l,u,h,T,m,y,v),I[a[1]]=d(E-(c-E)),I[a[2]]=d(c);return I},E.getMoonPosition=function(t,e,o){var a=l*-o,c=l*e,u=p(t),h=I(u),d=v(u,a)-h.ra,f=y(d,c,h.dec),m=s(n(d),r(c)*i(h.dec)-n(h.dec)*i(d));return f+=function(t){return t<0&&(t=0),2967e-7/Math.tan(t+.00312536/(t+.08901179))}(f),{azimuth:_(d,c,h.dec),altitude:f,distance:h.dist,parallacticAngle:m}},E.getMoonIllumination=function(t){var e=p(t||new Date),r=T(e),o=I(e),l=149598e3,c=a(n(r.dec)*n(o.dec)+i(r.dec)*i(o.dec)*i(r.ra-o.ra)),u=s(l*n(c),o.dist-l*i(c)),h=s(i(r.dec)*n(r.ra-o.ra),n(r.dec)*i(o.dec)-i(r.dec)*n(o.dec)*i(r.ra-o.ra));return{fraction:(1+i(u))/2,phase:.5+.5*u*(h<0?-1:1)/Math.PI,angle:h}},E.getMoonTimes=function(t,e,n,i){var r=new Date(t);i?r.setUTCHours(0,0,0,0):r.setHours(0,0,0,0);for(var o,s,a,c,u,h,d,p,f,m,g,_,y,v=.133*l,x=E.getMoonPosition(r,e,n).altitude-v,b=1;b<=24&&(o=E.getMoonPosition(P(r,b),e,n).altitude-v,p=((u=(x+(s=E.getMoonPosition(P(r,b+1),e,n).altitude-v))/2-o)*(d=-(h=(s-x)/2)/(2*u))+h)*d+o,m=0,(f=h*h-4*u*o)>=0&&(g=d-(y=Math.sqrt(f)/(2*Math.abs(u))),_=d+y,Math.abs(g)<=1&&m++,Math.abs(_)<=1&&m++,g<-1&&(g=_)),1===m?x<0?a=b+g:c=b+g:2===m&&(a=b+(p<0?_:g),c=b+(p<0?g:_)),!a||!c);b+=2)x=s;var T={};return a&&(T.rise=P(r,a)),c&&(T.set=P(r,c)),a||c||(T[p>0?"alwaysUp":"alwaysDown"]=!0),T},t.exports=E}()}(suncalc)),suncalc.exports}var suncalcExports=requireSuncalc(),SunCalc=getDefaultExportFromCjs(suncalcExports);const HOUR=36e5,RADIAN_TO_DEGREE$1=180/Math.PI,BG_LAYER_IDS=["background","background-underground"];function getBounds$1(t){const e=new mapboxGlExports.LngLatBounds;for(const n of t)e.extend(n);return e}function setLayerProps(t,e,n){t.getLayer(e).implementation.setProps(n)}function getSunlightColor(t,e){const n=t.getCenter(),{sunrise:i,sunset:r}=SunCalc.getTimes(e,n.lat,n.lng),o=i.getTime(),s=r.getTime();let a,l,c,u;return e>=o-HOUR&&e<o?(a=(e-o)/HOUR+1,l=lerp$5(.4,.8,a),c=lerp$5(.4,.9,a),u=lerp$5(.5,1,a)):e>=o&&e<o+HOUR?(a=(e-o)/HOUR,l=lerp$5(.8,1,a),c=lerp$5(.9,1,a),u=1):e>=o+HOUR&&e<s-HOUR?l=c=u=1:e>=s-HOUR&&e<s?(a=(e-s)/HOUR+1,l=1,c=lerp$5(1,.9,a),u=lerp$5(1,.8,a)):e>=s&&e<s+HOUR?(a=(e-s)/HOUR,l=lerp$5(1,.4,a),c=lerp$5(.9,.4,a),u=lerp$5(.8,.5,a)):(l=c=.4,u=.5),{r:l,g:c,b:u}}function setSunlight(t,e){const n=t.getCenter(),{azimuth:i,altitude:r}=SunCalc.getPosition(e,n.lat,n.lng),o=180+i*RADIAN_TO_DEGREE$1,s=90-r*RADIAN_TO_DEGREE$1,{r:a,g:l,b:c}=getSunlightColor(t,e);t.setLight({position:[1.15,o,s],color:`rgb(${255*a},${255*l},${255*c})`})}function hasDarkBackground(t,e){return e?BG_LAYER_IDS.reduce(((e,n)=>{const i=t.getLayer(n).paint,{r:r,g:o,b:s}=i.get("background-color"),a=i.get("background-opacity");return e+luminance({r:r*a,g:o*a,b:s*a})}),0)<.5:BG_LAYER_IDS.reduce(((e,n)=>{const[i,r,o]=csscolorparserExports.parseCSSColor(t.getPaintProperty(n,"background-color")),s=valueOrDefault(t.getPaintProperty(n,"background-opacity"),1);return e+luminance({r:i*s,g:r*s,b:o*s})}),0)<127.5}function getScaledColorString(t,e){return`rgba(${t.r*e.r},${t.g*e.g},${t.b*e.b},${t.a})`}function getStyleColors(t,e){const n={background:["background-color"],line:["line-color"],fill:["fill-color","fill-outline-color"]},i=[];return t.getStyle().layers.filter((({metadata:t})=>t&&t[e])).forEach((({id:e,type:r})=>{for(const o of n[r]){const n=t.getPaintProperty(e,o);if(!n)return;if("string"==typeof n){const[t,r,s,a]=csscolorparserExports.parseCSSColor(n);i.push({id:e,key:o,color:{r:t,g:r,b:s,a:a}})}else if(n.stops){const t=[];n.stops.forEach(((e,n)=>{const[i,r,o,s]=csscolorparserExports.parseCSSColor(e[1]);t.push({index:n,value:{r:i,g:r,b:o,a:s}})})),i.push({id:e,key:o,color:t})}else if("case"===n[0]||"interpolate"===n[0]){const t=[];n.forEach(((e,n)=>{if(n>=1&&"string"==typeof e){const[i,r,o,s]=csscolorparserExports.parseCSSColor(e);t.push({index:n,value:{r:i,g:r,b:o,a:s}})}})),i.push({id:e,key:o,color:t})}}})),i}function setStyleColors(t,e,n){let i;for(const{id:r,key:o,color:s}of e){if(Array.isArray(s)){i=t.getPaintProperty(r,o);for(const{index:t,value:e}of s){const r=getScaledColorString(e,n);i.stops?i.stops[t][1]=r:i[t]=r}}else i=getScaledColorString(s,n);t.setPaintProperty(r,o,i)}}function getStyleOpacities(t,e){const{_layers:n,_order:i}=t.style,r={"background-underground":1,"building-underground-underground":["interpolate",["linear"],["zoom"],14.5,0,15,1]},o=[];return i.map((t=>n[t])).filter((({metadata:t})=>t&&t[e])).forEach((({id:e,type:n,metadata:i})=>{if("custom"===n)return void o.push({id:e,metadata:i});const s=`${n}-opacity`,a=r[e]||valueOrDefault(t.getPaintProperty(e,s),1);if(isNaN(a)){if(a.stops){const t=[];a.stops.forEach(((e,n)=>{t.push({index:n,value:e[1]})})),o.push({id:e,key:s,opacity:t,metadata:i})}else if("case"===a[0]||"interpolate"===a[0]){const t=[];a.forEach(((e,n)=>{n%2!=0||isNaN(e)||t.push({index:n,value:e})})),o.push({id:e,key:s,opacity:t,metadata:i})}}else o.push({id:e,key:s,opacity:a,metadata:i})})),o}function setStyleOpacities(t,e,n){let i,r;for(const{id:o,key:s,opacity:a,metadata:l}of e)if(i=Array.isArray(n)?n.reduce(((t,e)=>valueOrDefault(t,l[e])),void 0):l[n],s){if(Array.isArray(a)){r=t.getPaintProperty(o,s);for(const{index:t,value:e}of a){const n=e*i;r.stops?r.stops[t][1]=n:r[t]=n}}else r=a*i;t.setPaintProperty(o,s,r)}else setLayerProps(t,o,{opacity:i})}function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function toPropertyKey(t){var e=toPrimitive(t,"string");return"symbol"==_typeof(e)?e:e+""}function _defineProperty(t,e,n){return(e=toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function assert$c(t,e){if(!t)throw new Error(e||"loader assertion failed.")}const isBrowser$3=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),matches$1="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);matches$1&&parseFloat(matches$1[1]);const VERSION$a="3.4.15";function assert$b(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}const globals$1={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},global_=globals$1.global||globals$1.self||globals$1.window||{},isBrowser$2="object"!=typeof process||"[object process]"!==String(process)||process.browser,isWorker="function"==typeof importScripts,isMobile="undefined"!=typeof window&&void 0!==window.orientation,matches="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);matches&&parseFloat(matches[1]);class WorkerJob{constructor(t,e){_defineProperty(this,"name",void 0),_defineProperty(this,"workerThread",void 0),_defineProperty(this,"isRunning",!0),_defineProperty(this,"result",void 0),_defineProperty(this,"_resolve",(()=>{})),_defineProperty(this,"_reject",(()=>{})),this.name=t,this.workerThread=e,this.result=new Promise(((t,e)=>{this._resolve=t,this._reject=e}))}postMessage(t,e){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:e})}done(t){assert$b(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){assert$b(this.isRunning),this.isRunning=!1,this._reject(t)}}let Worker$1=class{terminate(){}};const workerURLCache=new Map;function getLoadableWorkerURL(t){assert$b(t.source&&!t.url||!t.source&&t.url);let e=workerURLCache.get(t.source||t.url);return e||(t.url&&(e=getLoadableWorkerURLFromURL(t.url),workerURLCache.set(t.url,e)),t.source&&(e=getLoadableWorkerURLFromSource(t.source),workerURLCache.set(t.source,e))),assert$b(e),e}function getLoadableWorkerURLFromURL(t){if(!t.startsWith("http"))return t;return getLoadableWorkerURLFromSource(buildScriptSource(t))}function getLoadableWorkerURLFromSource(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function buildScriptSource(t){return"try {\n  importScripts('".concat(t,"');\n} catch (error) {\n  console.error(error);\n  throw error;\n}")}function getTransferList(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0;const i=n||new Set;if(t){if(isTransferable(t))i.add(t);else if(isTransferable(t.buffer))i.add(t.buffer);else if(ArrayBuffer.isView(t));else if(e&&"object"==typeof t)for(const n in t)getTransferList(t[n],e,i)}else;return void 0===n?Array.from(i):[]}function isTransferable(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}const NOOP$1=()=>{};class WorkerThread{static isSupported(){return"undefined"!=typeof Worker&&isBrowser$2||void 0!==Worker$1&&!isBrowser$2}constructor(t){_defineProperty(this,"name",void 0),_defineProperty(this,"source",void 0),_defineProperty(this,"url",void 0),_defineProperty(this,"terminated",!1),_defineProperty(this,"worker",void 0),_defineProperty(this,"onMessage",void 0),_defineProperty(this,"onError",void 0),_defineProperty(this,"_loadableURL","");const{name:e,source:n,url:i}=t;assert$b(n||i),this.name=e,this.source=n,this.url=i,this.onMessage=NOOP$1,this.onError=t=>{},this.worker=isBrowser$2?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=NOOP$1,this.onError=NOOP$1,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||getTransferList(t),this.worker.postMessage(t,e)}_getErrorFromErrorEvent(t){let e="Failed to load ";return e+="worker ".concat(this.name," from ").concat(this.url,". "),t.message&&(e+="".concat(t.message," in ")),t.lineno&&(e+=":".concat(t.lineno,":").concat(t.colno)),new Error(e)}_createBrowserWorker(){this._loadableURL=getLoadableWorkerURL({source:this.source,url:this.url});const t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},t.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},t.onmessageerror=t=>{},t}_createNodeWorker(){let t;if(this.url){const e=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);t=new Worker$1(e,{eval:!1})}else{if(!this.source)throw new Error("no worker");t=new Worker$1(this.source,{eval:!0})}return t.on("message",(t=>{this.onMessage(t)})),t.on("error",(t=>{this.onError(t)})),t.on("exit",(t=>{})),t}}class WorkerPool{static isSupported(){return WorkerThread.isSupported()}constructor(t){_defineProperty(this,"name","unnamed"),_defineProperty(this,"source",void 0),_defineProperty(this,"url",void 0),_defineProperty(this,"maxConcurrency",1),_defineProperty(this,"maxMobileConcurrency",1),_defineProperty(this,"onDebug",(()=>{})),_defineProperty(this,"reuseWorkers",!0),_defineProperty(this,"props",{}),_defineProperty(this,"jobQueue",[]),_defineProperty(this,"idleQueue",[]),_defineProperty(this,"count",0),_defineProperty(this,"isDestroyed",!1),this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach((t=>t.destroy())),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},void 0!==t.name&&(this.name=t.name),void 0!==t.maxConcurrency&&(this.maxConcurrency=t.maxConcurrency),void 0!==t.maxMobileConcurrency&&(this.maxMobileConcurrency=t.maxMobileConcurrency),void 0!==t.reuseWorkers&&(this.reuseWorkers=t.reuseWorkers),void 0!==t.onDebug&&(this.onDebug=t.onDebug)}async startJob(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(t,e,n)=>t.done(n),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(t,e)=>t.error(e);const i=new Promise((i=>(this.jobQueue.push({name:t,onMessage:e,onError:n,onStart:i}),this)));return this._startQueuedJob(),await i}async _startQueuedJob(){if(!this.jobQueue.length)return;const t=this._getAvailableWorker();if(!t)return;const e=this.jobQueue.shift();if(e){this.onDebug({message:"Starting job",name:e.name,workerThread:t,backlog:this.jobQueue.length});const n=new WorkerJob(e.name,t);t.onMessage=t=>e.onMessage(n,t.type,t.payload),t.onError=t=>e.onError(n,t),e.onStart(n);try{await n.result}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const t="".concat(this.name.toLowerCase()," (#").concat(this.count," of ").concat(this.maxConcurrency,")");return new WorkerThread({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return isMobile?this.maxMobileConcurrency:this.maxConcurrency}}const DEFAULT_PROPS$4={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}};class WorkerFarm{static isSupported(){return WorkerThread.isSupported()}static getWorkerFarm(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return WorkerFarm._workerFarm=WorkerFarm._workerFarm||new WorkerFarm({}),WorkerFarm._workerFarm.setProps(t),WorkerFarm._workerFarm}constructor(t){_defineProperty(this,"props",void 0),_defineProperty(this,"workerPools",new Map),this.props={...DEFAULT_PROPS$4},this.setProps(t),this.workerPools=new Map}destroy(){for(const t of this.workerPools.values())t.destroy();this.workerPools=new Map}setProps(t){this.props={...this.props,...t};for(const t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(t){const{name:e,source:n,url:i}=t;let r=this.workerPools.get(e);return r||(r=new WorkerPool({name:e,source:n,url:i}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(e,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}_defineProperty(WorkerFarm,"_workerFarm",void 0);const NPM_TAG="latest";function getWorkerURL(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=e[t.id]||{},i="".concat(t.id,"-worker.js");let r=n.workerUrl;if(r||"compression"!==t.id||(r=e.workerUrl),"test"===e._workerType&&(r="modules/".concat(t.module,"/dist/").concat(i)),!r){let e=t.version;"latest"===e&&(e=NPM_TAG);const n=e?"@".concat(e):"";r="https://unpkg.com/@loaders.gl/".concat(t.module).concat(n,"/dist/").concat(i)}return assert$b(r),r}function validateWorkerVersion(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:VERSION$a;assert$b(t,"no worker provided");return!(!e||!t.version)}const readFileAsArrayBuffer=null,readFileAsText=null,requireFromFile=null,requireFromString=null;var node=Object.freeze({__proto__:null,readFileAsArrayBuffer:readFileAsArrayBuffer,readFileAsText:readFileAsText,requireFromFile:requireFromFile,requireFromString:requireFromString});const VERSION$9="3.4.15",loadLibraryPromises={};async function loadLibrary(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e&&(t=getLibraryUrl(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})),loadLibraryPromises[t]=loadLibraryPromises[t]||loadLibraryFromFile(t),await loadLibraryPromises[t]}function getLibraryUrl(t,e,n){if(t.startsWith("http"))return t;const i=n.modules||{};return i[t]?i[t]:isBrowser$2?n.CDN?(assert$b(n.CDN.startsWith("http")),"".concat(n.CDN,"/").concat(e,"@").concat(VERSION$9,"/dist/libs/").concat(t)):isWorker?"../src/libs/".concat(t):"modules/".concat(e,"/src/libs/").concat(t):"modules/".concat(e,"/dist/libs/").concat(t)}async function loadLibraryFromFile(t){if(t.endsWith("wasm")){const e=await fetch(t);return await e.arrayBuffer()}if(!isBrowser$2)try{return node&&requireFromFile&&await requireFromFile(t)}catch(t){return null}if(isWorker)return importScripts(t);const e=await fetch(t);return loadLibraryFromString(await e.text(),t)}function loadLibraryFromString(t,e){if(!isBrowser$2)return requireFromString;if(isWorker)return eval.call(global_,t),null;const n=document.createElement("script");n.id=e;try{n.appendChild(document.createTextNode(t))}catch(e){n.text=t}return document.body.appendChild(n),null}function canParseWithWorker(t,e){return!!WorkerFarm.isSupported()&&(!!(isBrowser$2||null!=e&&e._nodeWorkers)&&(t.worker&&(null==e?void 0:e.worker)))}async function parseWithWorker(t,e,n,i,r){const o=t.id,s=getWorkerURL(t,n),a=WorkerFarm.getWorkerFarm(n).getWorkerPool({name:o,url:s});n=JSON.parse(JSON.stringify(n)),i=JSON.parse(JSON.stringify(i||{}));const l=await a.startJob("process-on-worker",onMessage.bind(null,r));l.postMessage("process",{input:e,options:n,context:i});const c=await l.result;return await c.result}async function onMessage(t,e,n,i){switch(n){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":const{id:n,input:r,options:o}=i;try{const i=await t(r,o);e.postMessage("done",{id:n,result:i})}catch(t){const i=t instanceof Error?t.message:"unknown error";e.postMessage("error",{id:n,error:i})}}}function getFirstCharacters$1(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof t)return t.slice(0,e);if(ArrayBuffer.isView(t))return getMagicString$3(t.buffer,t.byteOffset,e);if(t instanceof ArrayBuffer){return getMagicString$3(t,0,e)}return""}function getMagicString$3(t,e,n){if(t.byteLength<=e+n)return"";const i=new DataView(t);let r="";for(let t=0;t<n;t++)r+=String.fromCharCode(i.getUint8(e+t));return r}function parseJSON(t){try{return JSON.parse(t)}catch(e){throw new Error('Failed to parse JSON from data starting with "'.concat(getFirstCharacters$1(t),'"'))}}function compareArrayBuffers(t,e,n){if(t.byteLength<(n=n||t.byteLength)||e.byteLength<n)return!1;const i=new Uint8Array(t),r=new Uint8Array(e);for(let t=0;t<i.length;++t)if(i[t]!==r[t])return!1;return!0}function concatenateArrayBuffers(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];const i=e.map((t=>t instanceof ArrayBuffer?new Uint8Array(t):t)),r=i.reduce(((t,e)=>t+e.byteLength),0),o=new Uint8Array(r);let s=0;for(const t of i)o.set(t,s),s+=t.byteLength;return o.buffer}function sliceArrayBuffer(t,e,n){const i=void 0!==n?new Uint8Array(t).subarray(e,e+n):new Uint8Array(t).subarray(e);return new Uint8Array(i).buffer}function padToNBytes(t,e){return assert$c(t>=0),assert$c(e>0),t+(e-1)&~(e-1)}function copyToArray(t,e,n){let i;if(t instanceof ArrayBuffer)i=new Uint8Array(t);else{i=new Uint8Array(t.buffer||t.arrayBuffer,t.byteOffset,t.byteLength)}return e.set(i,n),n+padToNBytes(i.byteLength,4)}async function concatenateArrayBuffersAsync(t){const e=[];for await(const n of t)e.push(n);return concatenateArrayBuffers(...e)}function getHiResTimestamp$1(){let t;if("undefined"!=typeof window&&window.performance)t=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const e=process.hrtime();t=1e3*e[0]+e[1]/1e6}else t=Date.now();return t}class Stat{constructor(t,e){_defineProperty(this,"name",void 0),_defineProperty(this,"type",void 0),_defineProperty(this,"sampleSize",1),_defineProperty(this,"time",void 0),_defineProperty(this,"count",void 0),_defineProperty(this,"samples",void 0),_defineProperty(this,"lastTiming",void 0),_defineProperty(this,"lastSampleTime",void 0),_defineProperty(this,"lastSampleCount",void 0),_defineProperty(this,"_count",0),_defineProperty(this,"_time",0),_defineProperty(this,"_samples",0),_defineProperty(this,"_startTime",0),_defineProperty(this,"_timerPending",!1),this.name=t,this.type=e,this.reset()}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=getHiResTimestamp$1(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(getHiResTimestamp$1()-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 Stats{constructor(t){_defineProperty(this,"id",void 0),_defineProperty(this,"stats",{}),this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t){return this._getOrCreate({name:t,type:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"count"})}get size(){return Object.keys(this.stats).length}reset(){for(const t in this.stats)this.stats[t].reset();return this}forEach(t){for(const e in this.stats)t(this.stats[e])}getTable(){const t={};return this.forEach((e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}})),t}_initializeStats(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((t=>this._getOrCreate(t)))}_getOrCreate(t){if(!t||!t.name)return null;const{name:e,type:n}=t;return this.stats[e]||(this.stats[e]=t instanceof Stat?t:new Stat(e,n)),this.stats[e]}}const STAT_QUEUED_REQUESTS="Queued Requests",STAT_ACTIVE_REQUESTS="Active Requests",STAT_CANCELLED_REQUESTS="Cancelled Requests",STAT_QUEUED_REQUESTS_EVER="Queued Requests Ever",STAT_ACTIVE_REQUESTS_EVER="Active Requests Ever",DEFAULT_PROPS$3={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class RequestScheduler{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_defineProperty(this,"props",void 0),_defineProperty(this,"stats",void 0),_defineProperty(this,"activeRequestCount",0),_defineProperty(this,"requestQueue",[]),_defineProperty(this,"requestMap",new Map),_defineProperty(this,"deferredUpdate",null),this.props={...DEFAULT_PROPS$3,...t},this.stats=new Stats({id:this.props.id}),this.stats.get(STAT_QUEUED_REQUESTS),this.stats.get(STAT_ACTIVE_REQUESTS),this.stats.get(STAT_CANCELLED_REQUESTS),this.stats.get(STAT_QUEUED_REQUESTS_EVER),this.stats.get(STAT_ACTIVE_REQUESTS_EVER)}scheduleRequest(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>0;if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);const n={handle:t,priority:0,getPriority:e},i=new Promise((t=>(n.resolve=t,n)));return this.requestQueue.push(n),this.requestMap.set(t,i),this._issueNewRequests(),i}_issueRequest(t){const{handle:e,resolve:n}=t;let i=!1;const r=()=>{i||(i=!0,this.requestMap.delete(e),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:r}):Promise.resolve({done:r})}_issueNewRequests(){this.deferredUpdate||(this.deferredUpdate=setTimeout((()=>this._issueNewRequestsAsync()),0))}_issueNewRequestsAsync(){this.deferredUpdate=null;const t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==t){this._updateAllRequests();for(let e=0;e<t;++e){const t=this.requestQueue.shift();t&&this._issueRequest(t)}}}_updateAllRequests(){const t=this.requestQueue;for(let e=0;e<t.length;++e){const n=t[e];this._updateRequest(n)||(t.splice(e,1),this.requestMap.delete(n.handle),e--)}t.sort(((t,e)=>t.priority-e.priority))}_updateRequest(t){return t.priority=t.getPriority(t.handle),!(t.priority<0)||(t.resolve(null),!1)}}let pathPrefix$1="";const fileAliases={};function resolvePath(t){for(const e in fileAliases)if(t.startsWith(e)){t=t.replace(e,fileAliases[e])}return t.startsWith("http://")||t.startsWith("https://")||(t="".concat(pathPrefix$1).concat(t)),t}function toArrayBuffer$1(t){return t}function isBuffer$1(t){return t&&"object"==typeof t&&t.isBuffer}function toArrayBuffer(t){if(isBuffer$1(t))return toArrayBuffer$1(t);if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return 0===t.byteOffset&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);if("string"==typeof t){const e=t;return(new TextEncoder).encode(e).buffer}if(t&&"object"==typeof t&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function filename(t){const e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):""}function dirname(t){const e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}const isBoolean=t=>"boolean"==typeof t,isFunction=t=>"function"==typeof t,isObject$4=t=>null!==t&&"object"==typeof t,isPureObject=t=>isObject$4(t)&&t.constructor==={}.constructor,isIterable=t=>t&&"function"==typeof t[Symbol.iterator],isAsyncIterable$1=t=>t&&"function"==typeof t[Symbol.asyncIterator],isResponse=t=>"undefined"!=typeof Response&&t instanceof Response||t&&t.arrayBuffer&&t.text&&t.json,isBlob=t=>"undefined"!=typeof Blob&&t instanceof Blob,isBuffer=t=>t&&"object"==typeof t&&t.isBuffer,isReadableDOMStream=t=>"undefined"!=typeof ReadableStream&&t instanceof ReadableStream||isObject$4(t)&&isFunction(t.tee)&&isFunction(t.cancel)&&isFunction(t.getReader),isReadableNodeStream=t=>isObject$4(t)&&isFunction(t.read)&&isFunction(t.pipe)&&isBoolean(t.readable),isReadableStream=t=>isReadableDOMStream(t)||isReadableNodeStream(t),DATA_URL_PATTERN=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,MIME_TYPE_PATTERN=/^([-\w.]+\/[-\w.+]+)/;function parseMIMEType(t){const e=MIME_TYPE_PATTERN.exec(t);return e?e[1]:t}function parseMIMETypeFromURL(t){const e=DATA_URL_PATTERN.exec(t);return e?e[1]:""}const QUERY_STRING_PATTERN=/\?.*/;function extractQueryString(t){const e=t.match(QUERY_STRING_PATTERN);return e&&e[0]}function stripQueryString(t){return t.replace(QUERY_STRING_PATTERN,"")}function getResourceUrl(t){if(isResponse(t)){return t.url}if(isBlob(t)){return t.name||""}return"string"==typeof t?t:""}function getResourceMIMEType(t){if(isResponse(t)){const e=t,n=e.headers.get("content-type")||"",i=stripQueryString(e.url);return parseMIMEType(n)||parseMIMETypeFromURL(i)}if(isBlob(t)){return t.type||""}return"string"==typeof t?parseMIMETypeFromURL(t):""}function getResourceContentLength(t){if(isResponse(t)){return t.headers["content-length"]||-1}if(isBlob(t)){return t.size}return"string"==typeof t?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function makeResponse(t){if(isResponse(t))return t;const e={},n=getResourceContentLength(t);n>=0&&(e["content-length"]=String(n));const i=getResourceUrl(t),r=getResourceMIMEType(t);r&&(e["content-type"]=r);const o=await getInitialDataUrl(t);o&&(e["x-first-bytes"]=o),"string"==typeof t&&(t=(new TextEncoder).encode(t));const s=new Response(t,{headers:e});return Object.defineProperty(s,"url",{value:i}),s}async function checkResponse(t){if(!t.ok){const e=await getResponseError(t);throw new Error(e)}}async function getResponseError(t){let e="Failed to fetch resource ".concat(t.url," (").concat(t.status,"): ");try{const n=t.headers.get("Content-Type");let i=t.statusText;n.includes("application/json")&&(i+=" ".concat(await t.text())),e+=i,e=e.length>60?"".concat(e.slice(0,60),"..."):e}catch(t){}return e}async function getInitialDataUrl(t){if("string"==typeof t)return"data:,".concat(t.slice(0,5));if(t instanceof Blob){const e=t.slice(0,5);return await new Promise((t=>{const n=new FileReader;n.onload=e=>{var n;return t(null==e||null===(n=e.target)||void 0===n?void 0:n.result)},n.readAsDataURL(e)}))}if(t instanceof ArrayBuffer){const e=arrayBufferToBase64(t.slice(0,5));return"data:base64,".concat(e)}return null}function arrayBufferToBase64(t){let e="";const n=new Uint8Array(t);for(let t=0;t<n.byteLength;t++)e+=String.fromCharCode(n[t]);return btoa(e)}async function fetchFile(t,e){if("string"==typeof t){t=resolvePath(t);let n=e;return null!=e&&e.fetch&&"function"!=typeof(null==e?void 0:e.fetch)&&(n=e.fetch),await fetch(t,n)}return await makeResponse(t)}function isElectron(t){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 e="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent;return!!(e&&e.indexOf("Electron")>=0)}function isBrowser$1(){return!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||isElectron()}const globals={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"==typeof process&&process},window_$1=globals.window||globals.self||globals.global,process_=globals.process||{},VERSION$8="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";isBrowser$1();const window$1=globalThis;function getBrowser$1(t){if(!isBrowser$1())return"Node";if(isElectron())return"Electron";const e=("undefined"!=typeof navigator?navigator:{}).userAgent||"";if(e.indexOf("Edge")>-1)return"Edge";const n=-1!==e.indexOf("MSIE "),i=-1!==e.indexOf("Trident/");return n||i?"IE":window$1.chrome?"Chrome":window$1.safari?"Safari":window$1.mozInnerScreenX?"Firefox":"Unknown"}function getStorage(t){try{const e=window[t],n="__storage_test__";return e.setItem(n,n),e.removeItem(n),e}catch(t){return null}}class LocalStorage{constructor(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";_defineProperty(this,"storage",void 0),_defineProperty(this,"id",void 0),_defineProperty(this,"config",void 0),this.storage=getStorage(n),this.id=t,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let t={};if(this.storage){const e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}}function formatTime(t){let e;return e=t<10?"".concat(t.toFixed(2),"ms"):t<100?"".concat(t.toFixed(1),"ms"):t<1e3?"".concat(t.toFixed(0),"ms"):"".concat((t/1e3).toFixed(2),"s"),e}function leftPad(t){const e=Math.max((arguments.length>1&&void 0!==arguments[1]?arguments[1]:8)-t.length,0);return"".concat(" ".repeat(e)).concat(t)}function formatImage(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const r=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>i&&(n=Math.min(n,i/t.width));const o=t.width*n,s=t.height*n,a=["font-size:1px;","padding:".concat(Math.floor(s/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(s,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(s,"px;"),"color:transparent;"].join("");return["".concat(e," %c+"),a]}let COLOR;function getColor(t){return"string"==typeof t?COLOR[t.toUpperCase()]||COLOR.WHITE:t}function addColor(t,e,n){return isBrowser$1||"string"!=typeof t||(e&&(e=getColor(e),t="[".concat(e,"m").concat(t,"[39m")),n&&(e=getColor(n),t="[".concat(n+10,"m").concat(t,"[49m"))),t}function autobind(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const n=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(n);for(const n of i)"function"==typeof t[n]&&(e.find((t=>n===t))||(t[n]=t[n].bind(t)))}function assert$a(t,e){if(!t)throw new Error(e||"Assertion failed")}function getHiResTimestamp(){let t;var e,n;if("performance"in window_$1)t=null==window_$1||null===(e=window_$1.performance)||void 0===e||null===(n=e.now)||void 0===n?void 0:n.call(e);else if("hrtime"in process_){var i;const e=null==process_||null===(i=process_.hrtime)||void 0===i?void 0:i.call(process_);t=1e3*e[0]+e[1]/1e6}else t=Date.now();return t}!function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(COLOR||(COLOR={}));const originalConsole={debug:console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},DEFAULT_SETTINGS={enabled:!0,level:0};function noop$3(){}const cache$1={},ONCE={once:!0};class Log{constructor(){let{id:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};_defineProperty(this,"id",void 0),_defineProperty(this,"VERSION",VERSION$8),_defineProperty(this,"_startTs",getHiResTimestamp()),_defineProperty(this,"_deltaTs",getHiResTimestamp()),_defineProperty(this,"_storage",void 0),_defineProperty(this,"userData",{}),_defineProperty(this,"LOG_THROTTLE_TIMEOUT",0),this.id=t,this.userData={},this._storage=new LocalStorage("__probe-".concat(this.id,"__"),DEFAULT_SETTINGS),this.timeStamp("".concat(this.id," started")),autobind(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((getHiResTimestamp()-this._startTs).toPrecision(10))}getDelta(){return Number((getHiResTimestamp()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}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(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,e){this._storage.setConfiguration({[t]:e})}settings(){}assert(t,e){assert$a(t,e)}warn(t){return this._getLogFunction(0,t,originalConsole.warn,arguments,ONCE)}error(t){return this._getLogFunction(0,t,originalConsole.error,arguments)}deprecated(t,e){return this.warn("`".concat(t,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(t,e){return this.error("`".concat(t,"` has been removed. Use `").concat(e,"` instead"))}probe(t,e){return this._getLogFunction(t,e,originalConsole.log,arguments,{time:!0,once:!0})}log(t,e){return this._getLogFunction(t,e,originalConsole.debug,arguments)}info(t,e){return this._getLogFunction(t,e,console.info,arguments)}once(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return this._getLogFunction(t,e,originalConsole.debug||originalConsole.info,arguments,ONCE)}table(t,e,n){return e?this._getLogFunction(t,e,console.table||noop$3,n&&[n],{tag:getTableHeader(e)}):noop$3}image(t){let{logLevel:e,priority:n,image:i,message:r="",scale:o=1}=t;return this._shouldLog(e||n)?logImageInBrowser({image:i,message:r,scale:o}):noop$3}time(t,e){return this._getLogFunction(t,e,console.time?console.time:console.info)}timeEnd(t,e){return this._getLogFunction(t,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,e){return this._getLogFunction(t,e,console.timeStamp||noop$3)}group(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const i=normalizeArguments({logLevel:t,message:e,opts:n}),{collapsed:r}=n;return i.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(t,e){return this.group(t,e,Object.assign({},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||noop$3)}withGroup(t,e,n){this.group(t,e)();try{n()}finally{this.groupEnd(t)()}}trace(){}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=normalizeLogLevel(t)}_getLogFunction(t,e,n,i,r){if(this._shouldLog(t)){r=normalizeArguments({logLevel:t,message:e,args:i,opts:r}),assert$a(n=n||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=getHiResTimestamp();const o=r.tag||r.message;if(r.once){if(cache$1[o])return noop$3;cache$1[o]=getHiResTimestamp()}return e=decorateMessage(this.id,r.message,r),n.bind(console,e,...r.args)}return noop$3}}function normalizeLogLevel(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return assert$a(Number.isFinite(e)&&e>=0),e}function normalizeArguments(t){const{logLevel:e,message:n}=t;t.logLevel=normalizeLogLevel(e);const i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==n;);switch(typeof e){case"string":case"function":void 0!==n&&i.unshift(n),t.message=e;break;case"object":Object.assign(t,e)}"function"==typeof t.message&&(t.message=t.message());const r=typeof t.message;return assert$a("string"===r||"object"===r),Object.assign(t,{args:i},t.opts)}function decorateMessage(t,e,n){if("string"==typeof e){const i=n.time?leftPad(formatTime(n.total)):"";e=addColor(e=n.time?"".concat(t,": ").concat(i,"  ").concat(e):"".concat(t,": ").concat(e),n.color,n.background)}return e}function logImageInBrowser(t){let{image:e,message:n="",scale:i=1}=t;if("string"==typeof e){const t=new Image;return t.onload=()=>{formatImage(t,n,i)},t.src=e,noop$3}const r=e.nodeName||"";if("img"===r.toLowerCase())return noop$3;if("canvas"===r.toLowerCase()){const t=new Image;return t.onload=()=>{},t.src=e.toDataURL(),noop$3}return noop$3}function getTableHeader(t){for(const e in t)for(const n in t[e])return n||"untitled";return"empty"}_defineProperty(Log,"VERSION",VERSION$8);const probeLog=new Log({id:"loaders.gl"});class NullLog{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}class ConsoleLog{constructor(){_defineProperty(this,"console",void 0),this.console=console}log(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.console.log.bind(this.console,...e)}info(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.console.info.bind(this.console,...e)}warn(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.console.warn.bind(this.console,...e)}error(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.console.error.bind(this.console,...e)}}const DEFAULT_LOADER_OPTIONS={fetch:null,mimeType:void 0,nothrow:!1,log:new ConsoleLog,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:isBrowser$3,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},REMOVED_LOADER_OPTIONS={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 getGlobalLoaderState(){globalThis.loaders=globalThis.loaders||{};const{loaders:t}=globalThis;return t._state=t._state||{},t._state}const getGlobalLoaderOptions=()=>{const t=getGlobalLoaderState();return t.globalOptions=t.globalOptions||{...DEFAULT_LOADER_OPTIONS},t.globalOptions};function normalizeOptions(t,e,n,i){return n=n||[],validateOptions(t,n=Array.isArray(n)?n:[n]),normalizeOptionsInternal(e,t,i)}function validateOptions(t,e){validateOptionsObject(t,null,DEFAULT_LOADER_OPTIONS,REMOVED_LOADER_OPTIONS,e);for(const n of e){validateOptionsObject(t&&t[n.id]||{},n.id,n.options&&n.options[n.id]||{},n.deprecatedOptions&&n.deprecatedOptions[n.id]||{},e)}}function validateOptionsObject(t,e,n,i,r){const o=e||"Top level",s=e?"".concat(e,"."):"";for(const a in t){const l=!e&&isObject$4(t[a]);if(!(a in n)&&!("baseUri"===a&&!e)&&!("workerUrl"===a&&e))if(a in i)probeLog.warn("".concat(o," loader option '").concat(s).concat(a,"' no longer supported, use '").concat(i[a],"'"))();else if(!l){const t=findSimilarOption(a,r);probeLog.warn("".concat(o," loader option '").concat(s).concat(a,"' not recognized. ").concat(t))()}}}function findSimilarOption(t,e){const n=t.toLowerCase();let i="";for(const r of e)for(const e in r.options){if(t===e)return"Did you mean '".concat(r.id,".").concat(e,"'?");const o=e.toLowerCase();(n.startsWith(o)||o.startsWith(n))&&(i=i||"Did you mean '".concat(r.id,".").concat(e,"'?"))}return i}function normalizeOptionsInternal(t,e,n){const i={...t.options||{}};return addUrlOptions(i,n),null===i.log&&(i.log=new NullLog),mergeNestedFields(i,getGlobalLoaderOptions()),mergeNestedFields(i,e),i}function mergeNestedFields(t,e){for(const n in e)if(n in e){t[n]=isPureObject(e[n])&&isPureObject(t[n])?{...t[n],...e[n]}:e[n]}}function addUrlOptions(t,e){e&&!("baseUri"in t)&&(t.baseUri=e)}function isLoaderObject(t){var e;if(!t)return!1;Array.isArray(t)&&(t=t[0]);return Array.isArray(null===(e=t)||void 0===e?void 0:e.extensions)}function normalizeLoader(t){var e,n;let i;return assert$c(t,"null loader"),assert$c(isLoaderObject(t),"invalid loader"),Array.isArray(t)&&(i=t[1],t=t[0],t={...t,options:{...t.options,...i}}),(null!==(e=t)&&void 0!==e&&e.parseTextSync||null!==(n=t)&&void 0!==n&&n.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}const getGlobalLoaderRegistry=()=>{const t=getGlobalLoaderState();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function registerLoaders(t){const e=getGlobalLoaderRegistry();t=Array.isArray(t)?t:[t];for(const n of t){const t=normalizeLoader(n);e.find((e=>t===e))||e.unshift(t)}}function getRegisteredLoaders(){return getGlobalLoaderRegistry()}const log$3=new Log({id:"loaders.gl"}),EXT_PATTERN=/\.([^.]+)$/;async function selectLoader(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if(!validHTTPResponse(t))return null;let r=selectLoaderSync(t,e,{...n,nothrow:!0},i);if(r)return r;if(isBlob(t)&&(r=selectLoaderSync(t=await t.slice(0,10).arrayBuffer(),e,n,i)),!(r||null!=n&&n.nothrow))throw new Error(getNoValidLoaderMessage(t));return r}function selectLoaderSync(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if(!validHTTPResponse(t))return null;if(e&&!Array.isArray(e))return normalizeLoader(e);let r=[];e&&(r=r.concat(e)),null!=n&&n.ignoreRegisteredLoaders||r.push(...getRegisteredLoaders()),normalizeLoaders(r);const o=selectLoaderInternal(t,r,n,i);if(!(o||null!=n&&n.nothrow))throw new Error(getNoValidLoaderMessage(t));return o}function selectLoaderInternal(t,e,n,i){const r=getResourceUrl(t),o=getResourceMIMEType(t),s=stripQueryString(r)||(null==i?void 0:i.url);let a=null,l="";var c;(null!=n&&n.mimeType&&(a=findLoaderByMIMEType(e,null==n?void 0:n.mimeType),l="match forced by supplied MIME type ".concat(null==n?void 0:n.mimeType)),a=a||findLoaderByUrl(e,s),l=l||(a?"matched url ".concat(s):""),a=a||findLoaderByMIMEType(e,o),l=l||(a?"matched MIME type ".concat(o):""),a=a||findLoaderByInitialBytes(e,t),l=l||(a?"matched initial data ".concat(getFirstCharacters(t)):""),a=a||findLoaderByMIMEType(e,null==n?void 0:n.fallbackMimeType),l=l||(a?"matched fallback MIME type ".concat(o):""),l)&&log$3.log(1,"selectLoader selected ".concat(null===(c=a)||void 0===c?void 0:c.name,": ").concat(l,"."));return a}function validHTTPResponse(t){return!(t instanceof Response&&204===t.status)}function getNoValidLoaderMessage(t){const e=getResourceUrl(t),n=getResourceMIMEType(t);let i="No valid loader found (";i+=e?"".concat(filename(e),", "):"no url provided, ",i+="MIME type: ".concat(n?'"'.concat(n,'"'):"not provided",", ");const r=t?getFirstCharacters(t):"";return i+=r?' first bytes: "'.concat(r,'"'):"first bytes: not available",i+=")",i}function normalizeLoaders(t){for(const e of t)normalizeLoader(e)}function findLoaderByUrl(t,e){const n=e&&EXT_PATTERN.exec(e),i=n&&n[1];return i?findLoaderByExtension(t,i):null}function findLoaderByExtension(t,e){e=e.toLowerCase();for(const n of t)for(const t of n.extensions)if(t.toLowerCase()===e)return n;return null}function findLoaderByMIMEType(t,e){for(const n of t){if(n.mimeTypes&&n.mimeTypes.includes(e))return n;if(e==="application/x.".concat(n.id))return n}return null}function findLoaderByInitialBytes(t,e){if(!e)return null;for(const n of t)if("string"==typeof e){if(testDataAgainstText(e,n))return n}else if(ArrayBuffer.isView(e)){if(testDataAgainstBinary(e.buffer,e.byteOffset,n))return n}else if(e instanceof ArrayBuffer){if(testDataAgainstBinary(e,0,n))return n}return null}function testDataAgainstText(t,e){if(e.testText)return e.testText(t);return(Array.isArray(e.tests)?e.tests:[e.tests]).some((e=>t.startsWith(e)))}function testDataAgainstBinary(t,e,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some((i=>testBinary(t,e,n,i)))}function testBinary(t,e,n,i){if(i instanceof ArrayBuffer)return compareArrayBuffers(i,t,i.byteLength);switch(typeof i){case"function":return i(t,n);case"string":return i===getMagicString$2(t,e,i.length);default:return!1}}function getFirstCharacters(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof t)return t.slice(0,e);if(ArrayBuffer.isView(t))return getMagicString$2(t.buffer,t.byteOffset,e);if(t instanceof ArrayBuffer){return getMagicString$2(t,0,e)}return""}function getMagicString$2(t,e,n){if(t.byteLength<e+n)return"";const i=new DataView(t);let r="";for(let t=0;t<n;t++)r+=String.fromCharCode(i.getUint8(e+t));return r}const DEFAULT_CHUNK_SIZE$2=262144;function*makeStringIterator(t,e){const n=(null==e?void 0:e.chunkSize)||DEFAULT_CHUNK_SIZE$2;let i=0;const r=new TextEncoder;for(;i<t.length;){const e=Math.min(t.length-i,n),o=t.slice(i,i+e);i+=e,yield r.encode(o)}}const DEFAULT_CHUNK_SIZE$1=262144;function makeArrayBufferIterator(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){const{chunkSize:n=DEFAULT_CHUNK_SIZE$1}=e;let i=0;for(;i<t.byteLength;){const e=Math.min(t.byteLength-i,n),r=new ArrayBuffer(e),o=new Uint8Array(t,i,e);new Uint8Array(r).set(o),i+=e,yield r}}()}const DEFAULT_CHUNK_SIZE=1048576;async function*makeBlobIterator(t,e){const n=(null==e?void 0:e.chunkSize)||DEFAULT_CHUNK_SIZE;let i=0;for(;i<t.size;){const e=i+n,r=await t.slice(i,e).arrayBuffer();i=e,yield r}}function makeStreamIterator(t,e){return isBrowser$3?makeBrowserStreamIterator(t,e):makeNodeStreamIterator(t)}async function*makeBrowserStreamIterator(t,e){const n=t.getReader();let i;try{for(;;){const t=i||n.read();null!=e&&e._streamReadAhead&&(i=n.read());const{done:r,value:o}=await t;if(r)return;yield toArrayBuffer(o)}}catch(t){n.releaseLock()}}async function*makeNodeStreamIterator(t,e){for await(const e of t)yield toArrayBuffer(e)}function makeIterator(t,e){if("string"==typeof t)return makeStringIterator(t,e);if(t instanceof ArrayBuffer)return makeArrayBufferIterator(t,e);if(isBlob(t))return makeBlobIterator(t,e);if(isReadableStream(t))return makeStreamIterator(t,e);if(isResponse(t)){return makeStreamIterator(t.body,e)}throw new Error("makeIterator")}const ERR_DATA="Cannot convert supplied data type";function getArrayBufferOrStringFromDataSync(t,e,n){if(e.text&&"string"==typeof t)return t;if(isBuffer(t)&&(t=t.buffer),t instanceof ArrayBuffer){const n=t;if(e.text&&!e.binary){return new TextDecoder("utf8").decode(n)}return n}if(ArrayBuffer.isView(t)){if(e.text&&!e.binary){return new TextDecoder("utf8").decode(t)}let n=t.buffer;const i=t.byteLength||t.length;return 0===t.byteOffset&&i===n.byteLength||(n=n.slice(t.byteOffset,t.byteOffset+i)),n}throw new Error(ERR_DATA)}async function getArrayBufferOrStringFromData(t,e,n){const i=t instanceof ArrayBuffer||ArrayBuffer.isView(t);if("string"==typeof t||i)return getArrayBufferOrStringFromDataSync(t,e);if(isBlob(t)&&(t=await makeResponse(t)),isResponse(t)){const n=t;return await checkResponse(n),e.binary?await n.arrayBuffer():await n.text()}if(isReadableStream(t)&&(t=makeIterator(t,n)),isIterable(t)||isAsyncIterable$1(t))return concatenateArrayBuffersAsync(t);throw new Error(ERR_DATA)}function getFetchFunction(t,e){const n=getGlobalLoaderOptions(),i=t||n;return"function"==typeof i.fetch?i.fetch:isObject$4(i.fetch)?t=>fetchFile(t,i):null!=e&&e.fetch?null==e?void 0:e.fetch:fetchFile}function getLoaderContext(t,e,n){if(n)return n;const i={fetch:getFetchFunction(e,t),...t};if(i.url){const t=stripQueryString(i.url);i.baseUrl=t,i.queryString=extractQueryString(i.url),i.filename=filename(t),i.baseUrl=dirname(t)}return Array.isArray(i.loaders)||(i.loaders=null),i}function getLoadersFromContext(t,e){if(!e&&t&&!Array.isArray(t))return t;let n;if(t&&(n=Array.isArray(t)?t:[t]),e&&e.loaders){const t=Array.isArray(e.loaders)?e.loaders:[e.loaders];n=n?[...n,...t]:t}return n&&n.length?n:null}async function parse$3(t,e,n,i){assert$b(!i||"object"==typeof i),!e||Array.isArray(e)||isLoaderObject(e)||(i=void 0,n=e,e=void 0),n=n||{};const r=getResourceUrl(t=await t),o=getLoadersFromContext(e,i),s=await selectLoader(t,o,n);return s?(i=getLoaderContext({url:r,parse:parse$3,loaders:o},n=normalizeOptions(n,s,o,r),i||null),await parseWithLoader(s,t,n,i)):null}async function parseWithLoader(t,e,n,i){if(validateWorkerVersion(t),isResponse(e)){const t=e,{ok:n,redirected:r,status:o,statusText:s,type:a,url:l}=t,c=Object.fromEntries(t.headers.entries());i.response={headers:c,ok:n,redirected:r,status:o,statusText:s,type:a,url:l}}if(e=await getArrayBufferOrStringFromData(e,t,n),t.parseTextSync&&"string"==typeof e)return n.dataType="text",t.parseTextSync(e,n,i,t);if(canParseWithWorker(t,n))return await parseWithWorker(t,e,n,i,parse$3);if(t.parseText&&"string"==typeof e)return await t.parseText(e,n,i,t);if(t.parse)return await t.parse(e,n,i,t);throw assert$b(!t.parseSync),new Error("".concat(t.id," loader - no parser found and worker is disabled"))}async function load(t,e,n,i){Array.isArray(e)||isLoaderObject(e)||(n=e,e=void 0);const r=getFetchFunction(n);let o=t;return"string"==typeof t&&(o=await r(t)),isBlob(t)&&(o=await r(t)),await parse$3(o,e,n)}const VERSION$7="3.4.15",{_parseImageNode:_parseImageNode}=globalThis,IMAGE_SUPPORTED="undefined"!=typeof Image,IMAGE_BITMAP_SUPPORTED="undefined"!=typeof ImageBitmap,NODE_IMAGE_SUPPORTED=Boolean(_parseImageNode),DATA_SUPPORTED=!!isBrowser$3||NODE_IMAGE_SUPPORTED;function isImageTypeSupported(t){switch(t){case"auto":return IMAGE_BITMAP_SUPPORTED||IMAGE_SUPPORTED||DATA_SUPPORTED;case"imagebitmap":return IMAGE_BITMAP_SUPPORTED;case"image":return IMAGE_SUPPORTED;case"data":return DATA_SUPPORTED;default:throw new Error("@loaders.gl/images: image ".concat(t," not supported in this environment"))}}function getDefaultImageType(){if(IMAGE_BITMAP_SUPPORTED)return"imagebitmap";if(IMAGE_SUPPORTED)return"image";if(DATA_SUPPORTED)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function getImageType(t){const e=getImageTypeOrNull(t);if(!e)throw new Error("Not an image");return e}function getImageData(t){switch(getImageType(t)){case"data":return t;case"image":case"imagebitmap":const e=document.createElement("canvas"),n=e.getContext("2d");if(!n)throw new Error("getImageData");return e.width=t.width,e.height=t.height,n.drawImage(t,0,0),n.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function getImageTypeOrNull(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&t instanceof Image?"image":t&&"object"==typeof t&&t.data&&t.width&&t.height?"data":null}const SVG_DATA_URL_PATTERN=/^data:image\/svg\+xml/,SVG_URL_PATTERN=/\.svg((\?|#).*)?$/;function isSVG(t){return t&&(SVG_DATA_URL_PATTERN.test(t)||SVG_URL_PATTERN.test(t))}function getBlobOrSVGDataUrl(t,e){if(isSVG(e)){let e=(new TextDecoder).decode(t);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(e=unescape(encodeURIComponent(e)))}catch(t){throw new Error(t.message)}return"data:image/svg+xml;base64,".concat(btoa(e))}return getBlob(t,e)}function getBlob(t,e){if(isSVG(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function parseToImage(t,e,n){const i=getBlobOrSVGDataUrl(t,n),r=self.URL||self.webkitURL,o="string"!=typeof i&&r.createObjectURL(i);try{return await loadToImage(o||i,e)}finally{o&&r.revokeObjectURL(o)}}async function loadToImage(t,e){const n=new Image;return n.src=t,e.image&&e.image.decode&&n.decode?(await n.decode(),n):await new Promise(((e,i)=>{try{n.onload=()=>e(n),n.onerror=e=>i(new Error("Could not load image ".concat(t,": ").concat(e)))}catch(t){i(t)}}))}const EMPTY_OBJECT={};let imagebitmapOptionsSupported=!0;async function parseToImageBitmap(t,e,n){let i;if(isSVG(n)){i=await parseToImage(t,e,n)}else i=getBlob(t,n);const r=e&&e.imagebitmap;return await safeCreateImageBitmap(i,r)}async function safeCreateImageBitmap(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!isEmptyObject(e)&&imagebitmapOptionsSupported||(e=null),e)try{return await createImageBitmap(t,e)}catch(t){imagebitmapOptionsSupported=!1}return await createImageBitmap(t)}function isEmptyObject(t){for(const e in t||EMPTY_OBJECT)return!1;return!0}function getISOBMFFMediaType(t){return checkString(t,"ftyp",4)&&96&t[8]?decodeMajorBrand(t):null}function decodeMajorBrand(t){switch(getUTF8String(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function getUTF8String(t,e,n){return String.fromCharCode(...t.slice(e,n))}function stringToBytes(t){return[...t].map((t=>t.charCodeAt(0)))}function checkString(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const i=stringToBytes(e);for(let e=0;e<i.length;++e)if(i[e]!==t[e+n])return!1;return!0}const BIG_ENDIAN=!1,LITTLE_ENDIAN=!0;function getBinaryImageMetadata(t){const e=toDataView(t);return getPngMetadata(e)||getJpegMetadata(e)||getGifMetadata(e)||getBmpMetadata(e)||getISOBMFFMetadata(e)}function getISOBMFFMetadata(t){const e=getISOBMFFMediaType(new Uint8Array(t instanceof DataView?t.buffer:t));return e?{mimeType:e.mimeType,width:0,height:0}:null}function getPngMetadata(t){const e=toDataView(t);return e.byteLength>=24&&2303741511===e.getUint32(0,BIG_ENDIAN)?{mimeType:"image/png",width:e.getUint32(16,BIG_ENDIAN),height:e.getUint32(20,BIG_ENDIAN)}:null}function getGifMetadata(t){const e=toDataView(t);return e.byteLength>=10&&1195984440===e.getUint32(0,BIG_ENDIAN)?{mimeType:"image/gif",width:e.getUint16(6,LITTLE_ENDIAN),height:e.getUint16(8,LITTLE_ENDIAN)}:null}function getBmpMetadata(t){const e=toDataView(t);return e.byteLength>=14&&16973===e.getUint16(0,BIG_ENDIAN)&&e.getUint32(2,LITTLE_ENDIAN)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,LITTLE_ENDIAN),height:e.getUint32(22,LITTLE_ENDIAN)}:null}function getJpegMetadata(t){const e=toDataView(t);if(!(e.byteLength>=3&&65496===e.getUint16(0,BIG_ENDIAN)&&255===e.getUint8(2)))return null;const{tableMarkers:n,sofMarkers:i}=getJpegMarkers();let r=2;for(;r+9<e.byteLength;){const t=e.getUint16(r,BIG_ENDIAN);if(i.has(t))return{mimeType:"image/jpeg",height:e.getUint16(r+5,BIG_ENDIAN),width:e.getUint16(r+7,BIG_ENDIAN)};if(!n.has(t))return null;r+=2,r+=e.getUint16(r,BIG_ENDIAN)}return null}function getJpegMarkers(){const t=new Set([65499,65476,65484,65501,65534]);for(let e=65504;e<65520;++e)t.add(e);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function toDataView(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function parseToNodeImage(t,e){const{mimeType:n}=getBinaryImageMetadata(t)||{},i=globalThis._parseImageNode;return assert$c(i),await i(t,n)}async function parseImage(t,e,n){const i=((e=e||{}).image||{}).type||"auto",{url:r}=n||{};let o;switch(getLoadableImageType(i)){case"imagebitmap":o=await parseToImageBitmap(t,e,r);break;case"image":o=await parseToImage(t,e,r);break;case"data":o=await parseToNodeImage(t);break;default:assert$c(!1)}return"data"===i&&(o=getImageData(o)),o}function getLoadableImageType(t){switch(t){case"auto":case"data":return getDefaultImageType();default:return isImageTypeSupported(t),t}}const EXTENSIONS$2=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],MIME_TYPES$1=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],DEFAULT_IMAGE_LOADER_OPTIONS={image:{type:"auto",decode:!0}},ImageLoader$1={id:"image",module:"images",name:"Images",version:VERSION$7,mimeTypes:MIME_TYPES$1,extensions:EXTENSIONS$2,parse:parseImage,tests:[t=>Boolean(getBinaryImageMetadata(new DataView(t)))],options:DEFAULT_IMAGE_LOADER_OPTIONS},MIME_TYPES=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/tiff","image/svg","image/svg+xml","image/bmp","image/vnd.microsoft.icon"];async function getSupportedImageFormats(){const t=new Set;for(const e of MIME_TYPES){(isBrowser$3?await checkBrowserImageFormatSupportAsync(e):checkNodeImageFormatSupport(e))&&t.add(e)}return t}function checkNodeImageFormatSupport(t){const e=["image/png","image/jpeg","image/gif"],{_parseImageNode:n,_imageFormatsNode:i=e}=globalThis;return Boolean(n)&&i.includes(t)}const TEST_IMAGE={"image/avif":"data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=","image/webp":"data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"};async function checkBrowserImageFormatSupportAsync(t){const e=TEST_IMAGE[t];return!e||await testBrowserImageFormatSupportAsync(e)}async function testBrowserImageFormatSupportAsync(t){return new Promise((e=>{const n=new Image;n.src=t,n.onload=()=>e(n.height>0),n.onerror=()=>e(!1)}))}var log$2=new Log({id:"deck"});let loggers={};function register(t){loggers=t}function debug(t,e,n,i){log$2.level>0&&loggers[t]&&loggers[t].call(null,e,n,i)}function isJSON(t){const e=t[0],n=t[t.length-1];return"{"===e&&"}"===n||"["===e&&"]"===n}var jsonLoader={id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:isJSON,parseTextSync:JSON.parse};function checkVersion(){const t="8.9.36",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error("deck.gl - multiple versions detected: ".concat(e," vs ").concat(t));return e||(log$2.log(1,"deck.gl ".concat(t))(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:log$2,_registerLoggers:register},registerLoaders([jsonLoader,[ImageLoader$1,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}const VERSION$6=checkVersion(),COORDINATE_SYSTEM={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(COORDINATE_SYSTEM,"IDENTITY",{get:()=>(log$2.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const PROJECTION_MODE={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},UNIT={common:0,meters:1,pixels:2},EVENTS={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}},log$1=new Log({id:"luma.gl"});function assert$9(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}const ERR_CONTEXT="Invalid WebGLRenderingContext",ERR_WEBGL2="Requires WebGL2";function isWebGL(t){return"undefined"!=typeof WebGLRenderingContext&&t instanceof WebGLRenderingContext||("undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||Boolean(t&&Number.isFinite(t._version)))}function isWebGL2$1(t){return"undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||Boolean(t&&2===t._version)}function getWebGL2Context(t){return isWebGL2$1(t)?t:null}function assertWebGLContext(t){return assert$9(isWebGL(t),ERR_CONTEXT),t}function assertWebGL2Context(t){return assert$9(isWebGL2$1(t),ERR_WEBGL2),t}const glErrorShadow={};function error(t){globalThis.console&&globalThis.console.error&&globalThis.console.error(t)}function log(t){globalThis.console&&globalThis.console.log&&globalThis.console.log(t)}function synthesizeGLError(t,e){glErrorShadow[t]=!0,error(e)}function wrapGLError(t){const e=t.getError;t.getError=function(){let n;do{n=e.apply(t),0!==n&&(glErrorShadow[n]=!0)}while(0!==n);for(n in glErrorShadow)if(glErrorShadow[n])return delete glErrorShadow[n],parseInt(n,10);return 0}}const WebGLVertexArrayObjectOES=function t(e){const n=e.gl;this.ext=e,this.isAlive=!0,this.hasBeenBound=!1,this.elementArrayBuffer=null,this.attribs=new Array(e.maxVertexAttribs);for(let e=0;e<this.attribs.length;e++){const i=new t.VertexAttrib(n);this.attribs[e]=i}this.maxAttrib=0};WebGLVertexArrayObjectOES.VertexAttrib=function(t){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()},WebGLVertexArrayObjectOES.VertexAttrib.prototype.recache=function(){this.cached=[this.size,this.type,this.normalized,this.stride,this.offset].join(":")};const OESVertexArrayObject=function(t){const e=this;this.gl=t,wrapGLError(t);const n=this.original={getParameter:t.getParameter,enableVertexAttribArray:t.enableVertexAttribArray,disableVertexAttribArray:t.disableVertexAttribArray,bindBuffer:t.bindBuffer,getVertexAttrib:t.getVertexAttrib,vertexAttribPointer:t.vertexAttribPointer};t.getParameter=function(t){return t===e.VERTEX_ARRAY_BINDING_OES?e.currentVertexArrayObject===e.defaultVertexArrayObject?null:e.currentVertexArrayObject:n.getParameter.apply(this,arguments)},t.enableVertexAttribArray=function(t){const i=e.currentVertexArrayObject;i.maxAttrib=Math.max(i.maxAttrib,t);return i.attribs[t].enabled=!0,n.enableVertexAttribArray.apply(this,arguments)},t.disableVertexAttribArray=function(t){const i=e.currentVertexArrayObject;i.maxAttrib=Math.max(i.maxAttrib,t);return i.attribs[t].enabled=!1,n.disableVertexAttribArray.apply(this,arguments)},t.bindBuffer=function(t,i){switch(t){case 34962:e.currentArrayBuffer=i;break;case 34963:e.currentVertexArrayObject.elementArrayBuffer=i}return n.bindBuffer.apply(this,arguments)},t.getVertexAttrib=function(t,i){const r=e.currentVertexArrayObject.attribs[t];switch(i){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 n.getVertexAttrib.apply(this,arguments)}},t.vertexAttribPointer=function(t,i,r,o,s,a){const l=e.currentVertexArrayObject;l.maxAttrib=Math.max(l.maxAttrib,t);const c=l.attribs[t];return c.buffer=e.currentArrayBuffer,c.size=i,c.type=r,c.normalized=o,c.stride=s,c.offset=a,c.recache(),n.vertexAttribPointer.apply(this,arguments)},t.instrumentExtension&&t.instrumentExtension(this,"OES_vertex_array_object"),t.canvas&&t.canvas.addEventListener("webglcontextrestored",(()=>{log("OESVertexArrayObject emulation library context restored"),e.reset_()}),!0),this.reset_()};function polyfillVertexArrayObject(t){if("function"==typeof t.createVertexArray)return;const e=t.getSupportedExtensions;t.getSupportedExtensions=function(){const t=e.call(this)||[];return t.indexOf("OES_vertex_array_object")<0&&t.push("OES_vertex_array_object"),t};const n=t.getExtension;t.getExtension=function(e){const i=n.call(this,e);return i||("OES_vertex_array_object"!==e?null:(t.__OESVertexArrayObject||(this.__OESVertexArrayObject=new OESVertexArrayObject(this)),this.__OESVertexArrayObject))}}OESVertexArrayObject.prototype.VERTEX_ARRAY_BINDING_OES=34229,OESVertexArrayObject.prototype.reset_=function(){if(void 0!==this.vertexArrayObjects)for(let t=0;t<this.vertexArrayObjects.length;++t)this.vertexArrayObjects.isAlive=!1;this.maxVertexAttribs=this.gl.getParameter(34921),this.defaultVertexArrayObject=new WebGLVertexArrayObjectOES(this),this.currentVertexArrayObject=null,this.currentArrayBuffer=null,this.vertexArrayObjects=[this.defaultVertexArrayObject],this.bindVertexArrayOES(null)},OESVertexArrayObject.prototype.createVertexArrayOES=function(){const t=new WebGLVertexArrayObjectOES(this);return this.vertexArrayObjects.push(t),t},OESVertexArrayObject.prototype.deleteVertexArrayOES=function(t){t.isAlive=!1,this.vertexArrayObjects.splice(this.vertexArrayObjects.indexOf(t),1),this.currentVertexArrayObject===t&&this.bindVertexArrayOES(null)},OESVertexArrayObject.prototype.isVertexArrayOES=function(t){return!!(t&&t instanceof WebGLVertexArrayObjectOES&&t.hasBeenBound&&t.ext===this)},OESVertexArrayObject.prototype.bindVertexArrayOES=function(t){const e=this.gl;if(t&&!t.isAlive)return void synthesizeGLError(1282,"bindVertexArrayOES: attempt to bind deleted arrayObject");const n=this.original,i=this.currentVertexArrayObject;this.currentVertexArrayObject=t||this.defaultVertexArrayObject,this.currentVertexArrayObject.hasBeenBound=!0;const r=this.currentVertexArrayObject;if(i===r)return;i&&r.elementArrayBuffer===i.elementArrayBuffer||n.bindBuffer.call(e,34963,r.elementArrayBuffer);let o=this.currentArrayBuffer;const s=Math.max(i?i.maxAttrib:0,r.maxAttrib);for(let t=0;t<=s;t++){const s=r.attribs[t],a=i?i.attribs[t]:null;if(i&&s.enabled===a.enabled||(s.enabled?n.enableVertexAttribArray.call(e,t):n.disableVertexAttribArray.call(e,t)),s.enabled){let r=!1;i&&s.buffer===a.buffer||(o!==s.buffer&&(n.bindBuffer.call(e,34962,s.buffer),o=s.buffer),r=!0),(r||s.cached!==a.cached)&&n.vertexAttribPointer.call(e,t,s.size,s.type,s.normalized,s.stride,s.offset)}}this.currentArrayBuffer!==o&&n.bindBuffer.call(e,34962,this.currentArrayBuffer)};const OES_element_index="OES_element_index",WEBGL_draw_buffers$1="WEBGL_draw_buffers",EXT_disjoint_timer_query$1="EXT_disjoint_timer_query",EXT_disjoint_timer_query_webgl2="EXT_disjoint_timer_query_webgl2",EXT_texture_filter_anisotropic$1="EXT_texture_filter_anisotropic",WEBGL_debug_renderer_info="WEBGL_debug_renderer_info",GL_FRAGMENT_SHADER_DERIVATIVE_HINT=35723,GL_DONT_CARE=4352,GL_GPU_DISJOINT_EXT$1=36795,GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047,GL_UNMASKED_VENDOR_WEBGL=37445,GL_UNMASKED_RENDERER_WEBGL=37446,getWebGL2ValueOrZero=t=>isWebGL2$1(t)?void 0:0,WEBGL_PARAMETERS={3074:t=>isWebGL2$1(t)?void 0:36064,[GL_FRAGMENT_SHADER_DERIVATIVE_HINT]:t=>isWebGL2$1(t)?void 0:GL_DONT_CARE,35977:getWebGL2ValueOrZero,32937:getWebGL2ValueOrZero,[GL_GPU_DISJOINT_EXT$1]:(t,e)=>{const n=isWebGL2$1(t)?t.getExtension(EXT_disjoint_timer_query_webgl2):t.getExtension(EXT_disjoint_timer_query$1);return n&&n.GPU_DISJOINT_EXT?e(n.GPU_DISJOINT_EXT):0},[GL_UNMASKED_VENDOR_WEBGL]:(t,e)=>{const n=t.getExtension(WEBGL_debug_renderer_info);return e(n&&n.UNMASKED_VENDOR_WEBGL||7936)},[GL_UNMASKED_RENDERER_WEBGL]:(t,e)=>{const n=t.getExtension(WEBGL_debug_renderer_info);return e(n&&n.UNMASKED_RENDERER_WEBGL||7937)},[GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT]:(t,e)=>{const n=t.luma.extensions[EXT_texture_filter_anisotropic$1];return n?e(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1},32883:getWebGL2ValueOrZero,35071:getWebGL2ValueOrZero,37447:getWebGL2ValueOrZero,36063:(t,e)=>{if(!isWebGL2$1(t)){const n=t.getExtension(WEBGL_draw_buffers$1);return n?e(n.MAX_COLOR_ATTACHMENTS_WEBGL):0}},35379:getWebGL2ValueOrZero,35374:getWebGL2ValueOrZero,35377:getWebGL2ValueOrZero,34852:t=>{if(!isWebGL2$1(t)){const e=t.getExtension(WEBGL_draw_buffers$1);return e?e.MAX_DRAW_BUFFERS_WEBGL:0}},36203:t=>t.getExtension(OES_element_index)?2147483647:65535,33001:t=>t.getExtension(OES_element_index)?16777216:65535,33e3:t=>16777216,37157:getWebGL2ValueOrZero,35373:getWebGL2ValueOrZero,35657:getWebGL2ValueOrZero,36183:getWebGL2ValueOrZero,37137:getWebGL2ValueOrZero,34045:getWebGL2ValueOrZero,35978:getWebGL2ValueOrZero,35979:getWebGL2ValueOrZero,35968:getWebGL2ValueOrZero,35376:getWebGL2ValueOrZero,35375:getWebGL2ValueOrZero,35659:getWebGL2ValueOrZero,37154:getWebGL2ValueOrZero,35371:getWebGL2ValueOrZero,35658:getWebGL2ValueOrZero,35076:getWebGL2ValueOrZero,35077:getWebGL2ValueOrZero,35380:getWebGL2ValueOrZero};function getParameterPolyfill(t,e,n){const i=WEBGL_PARAMETERS[n],r="function"==typeof i?i(t,e,n):i;return void 0!==r?r:e(n)}const OES_vertex_array_object="OES_vertex_array_object",ANGLE_instanced_arrays="ANGLE_instanced_arrays",WEBGL_draw_buffers="WEBGL_draw_buffers",EXT_disjoint_timer_query="EXT_disjoint_timer_query",EXT_texture_filter_anisotropic="EXT_texture_filter_anisotropic",ERR_VAO_NOT_SUPPORTED="VertexArray requires WebGL2 or OES_vertex_array_object extension";function getExtensionData(t,e){return{webgl2:isWebGL2$1(t),ext:t.getExtension(e)}}const WEBGL2_CONTEXT_POLYFILLS={[OES_vertex_array_object]:{meta:{suffix:"OES"},createVertexArray:()=>{assert$9(!1,ERR_VAO_NOT_SUPPORTED)},deleteVertexArray:()=>{},bindVertexArray:()=>{},isVertexArray:()=>!1},[ANGLE_instanced_arrays]:{meta:{suffix:"ANGLE"},vertexAttribDivisor(t,e){assert$9(0===e,"WebGL instanced rendering not supported")},drawElementsInstanced:()=>{},drawArraysInstanced:()=>{}},[WEBGL_draw_buffers]:{meta:{suffix:"WEBGL"},drawBuffers:()=>{assert$9(!1)}},[EXT_disjoint_timer_query]:{meta:{suffix:"EXT"},createQuery:()=>{assert$9(!1)},deleteQuery:()=>{assert$9(!1)},beginQuery:()=>{assert$9(!1)},endQuery:()=>{},getQuery(t,e){return this.getQueryObject(t,e)},getQueryParameter(t,e){return this.getQueryObject(t,e)},getQueryObject:()=>{}}},WEBGL2_CONTEXT_OVERRIDES={readBuffer:(t,e,n)=>{isWebGL2$1(t)&&e(n)},getVertexAttrib:(t,e,n,i)=>{const{webgl2:r,ext:o}=getExtensionData(t,ANGLE_instanced_arrays);let s;switch(i){case 35069:s=!!r&&void 0;break;case 35070:s=r||o?void 0:0}return void 0!==s?s:e(n,i)},getProgramParameter:(t,e,n,i)=>{if(!isWebGL2$1(t))switch(i){case 35967:return 35981;case 35971:case 35382:return 0}return e(n,i)},getInternalformatParameter:(t,e,n,i,r)=>isWebGL2$1(t)||32937!==r?t.getInternalformatParameter(n,i,r):new Int32Array([0]),getTexParameter(t,e,n,i){if(34046===i){const{extensions:e}=t.luma,n=e[EXT_texture_filter_anisotropic];i=n&&n.TEXTURE_MAX_ANISOTROPY_EXT||34046}return e(n,i)},getParameter:getParameterPolyfill,hint:(t,e,n,i)=>e(n,i)};function polyfillContext(t){t.luma=t.luma||{};const{luma:e}=t;return e.polyfilled||(polyfillVertexArrayObject(t),initializeExtensions(t),installPolyfills(t,WEBGL2_CONTEXT_POLYFILLS),installOverrides(t,{target:e,target2:t}),e.polyfilled=!0),t}function initializeExtensions(t){t.luma.extensions={};const e=t.getSupportedExtensions()||[];for(const n of e)t.luma[n]=t.getExtension(n)}function installOverrides(t,e){let{target:n,target2:i}=e;Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((e=>{if("function"==typeof WEBGL2_CONTEXT_OVERRIDES[e]){const r=t[e]?t[e].bind(t):()=>{},o=WEBGL2_CONTEXT_OVERRIDES[e].bind(null,t,r);n[e]=o,i[e]=o}}))}function installPolyfills(t,e){for(const n of Object.getOwnPropertyNames(e))"overrides"!==n&&polyfillExtension(t,{extension:n,target:t.luma,target2:t})}function polyfillExtension(t,e){let{extension:n,target:i,target2:r}=e;const o=WEBGL2_CONTEXT_POLYFILLS[n];assert$9(o);const{meta:s={}}=o,{suffix:a=""}=s,l=t.getExtension(n);for(const e of Object.keys(o)){const n="".concat(e).concat(a);let s=null;"meta"===e||"function"==typeof t[e]||(l&&"function"==typeof l[n]?s=function(){return l[n](...arguments)}:"function"==typeof o[e]&&(s=o[e].bind(i))),s&&(i[e]=s,r[e]=s)}}globalThis.polyfillContext=polyfillContext;const GL_PARAMETER_DEFAULTS={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},enable=(t,e,n)=>e?t.enable(n):t.disable(n),hint=(t,e,n)=>t.hint(n,e),pixelStorei=(t,e,n)=>t.pixelStorei(n,e),drawFramebuffer=(t,e)=>{const n=isWebGL2$1(t)?36009:36160;return t.bindFramebuffer(n,e)},readFramebuffer=(t,e)=>t.bindFramebuffer(36008,e);function isArray$2(t){return Array.isArray(t)||ArrayBuffer.isView(t)}const GL_PARAMETER_SETTERS={3042:enable,32773:(t,e)=>t.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(t,e)=>t.clearColor(...e),3107:(t,e)=>t.colorMask(...e),2884:enable,2885:(t,e)=>t.cullFace(e),2929:enable,2931:(t,e)=>t.clearDepth(e),2932:(t,e)=>t.depthFunc(e),2928:(t,e)=>t.depthRange(...e),2930:(t,e)=>t.depthMask(e),3024:enable,35723:hint,36006:drawFramebuffer,2886:(t,e)=>t.frontFace(e),33170:hint,2849:(t,e)=>t.lineWidth(e),32823:enable,32824:"polygonOffset",10752:"polygonOffset",35977:enable,32938:"sampleCoverage",32939:"sampleCoverage",3089:enable,3088:(t,e)=>t.scissor(...e),2960:enable,2961:(t,e)=>t.clearStencil(e),2968:(t,e)=>t.stencilMaskSeparate(1028,e),36005:(t,e)=>t.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(t,e)=>t.viewport(...e),3333:pixelStorei,3317:pixelStorei,37440:pixelStorei,37441:pixelStorei,37443:pixelStorei,3330:pixelStorei,3332:pixelStorei,3331:pixelStorei,36010:readFramebuffer,3314:pixelStorei,32878:pixelStorei,3316:pixelStorei,3315:pixelStorei,32877:pixelStorei,framebuffer:(t,e)=>t.bindFramebuffer(36160,e&&"handle"in e?e.handle:e),blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{e=isArray$2(e)?e:[e,e],t.blendEquationSeparate(...e)},blendFunc:(t,e)=>{e=isArray$2(e)&&2===e.length?[...e,...e]:e,t.blendFuncSeparate(...e)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=isArray$2(e)?e:[e,e];const[n,i]=e;t.stencilMaskSeparate(1028,n),t.stencilMaskSeparate(1029,i)},stencilFunc:(t,e)=>{e=isArray$2(e)&&3===e.length?[...e,...e]:e;const[n,i,r,o,s,a]=e;t.stencilFuncSeparate(1028,n,i,r),t.stencilFuncSeparate(1029,o,s,a)},stencilOp:(t,e)=>{e=isArray$2(e)&&3===e.length?[...e,...e]:e;const[n,i,r,o,s,a]=e;t.stencilOpSeparate(1028,n,i,r),t.stencilOpSeparate(1029,o,s,a)},viewport:(t,e)=>t.viewport(...e)};function getValue(t,e,n){return void 0!==e[t]?e[t]:n[t]}const GL_COMPOSITE_PARAMETER_SETTERS={blendEquation:(t,e,n)=>t.blendEquationSeparate(getValue(32777,e,n),getValue(34877,e,n)),blendFunc:(t,e,n)=>t.blendFuncSeparate(getValue(32969,e,n),getValue(32968,e,n),getValue(32971,e,n),getValue(32970,e,n)),polygonOffset:(t,e,n)=>t.polygonOffset(getValue(32824,e,n),getValue(10752,e,n)),sampleCoverage:(t,e,n)=>t.sampleCoverage(getValue(32938,e,n),getValue(32939,e,n)),stencilFuncFront:(t,e,n)=>t.stencilFuncSeparate(1028,getValue(2962,e,n),getValue(2967,e,n),getValue(2963,e,n)),stencilFuncBack:(t,e,n)=>t.stencilFuncSeparate(1029,getValue(34816,e,n),getValue(36003,e,n),getValue(36004,e,n)),stencilOpFront:(t,e,n)=>t.stencilOpSeparate(1028,getValue(2964,e,n),getValue(2965,e,n),getValue(2966,e,n)),stencilOpBack:(t,e,n)=>t.stencilOpSeparate(1029,getValue(34817,e,n),getValue(34818,e,n),getValue(34819,e,n))},GL_HOOKED_SETTERS={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,n)=>t({[e]:n}),hint:(t,e,n)=>t({[e]:n}),bindFramebuffer:(t,e,n)=>{switch(e){case 36160:return t({36006:n,36010:n});case 36009:return t({36006:n});case 36008:return t({36010:n});default:return null}},blendColor:(t,e,n,i,r)=>t({32773:new Float32Array([e,n,i,r])}),blendEquation:(t,e)=>t({32777:e,34877:e}),blendEquationSeparate:(t,e,n)=>t({32777:e,34877:n}),blendFunc:(t,e,n)=>t({32969:e,32968:n,32971:e,32970:n}),blendFuncSeparate:(t,e,n,i,r)=>t({32969:e,32968:n,32971:i,32970:r}),clearColor:(t,e,n,i,r)=>t({3106:new Float32Array([e,n,i,r])}),clearDepth:(t,e)=>t({2931:e}),clearStencil:(t,e)=>t({2961:e}),colorMask:(t,e,n,i,r)=>t({3107:[e,n,i,r]}),cullFace:(t,e)=>t({2885:e}),depthFunc:(t,e)=>t({2932:e}),depthRange:(t,e,n)=>t({2928:new Float32Array([e,n])}),depthMask:(t,e)=>t({2930:e}),frontFace:(t,e)=>t({2886:e}),lineWidth:(t,e)=>t({2849:e}),polygonOffset:(t,e,n)=>t({32824:e,10752:n}),sampleCoverage:(t,e,n)=>t({32938:e,32939:n}),scissor:(t,e,n,i,r)=>t({3088:new Int32Array([e,n,i,r])}),stencilMask:(t,e)=>t({2968:e,36005:e}),stencilMaskSeparate:(t,e,n)=>t({[1028===e?2968:36005]:n}),stencilFunc:(t,e,n,i)=>t({2962:e,2967:n,2963:i,34816:e,36003:n,36004:i}),stencilFuncSeparate:(t,e,n,i,r)=>t({[1028===e?2962:34816]:n,[1028===e?2967:36003]:i,[1028===e?2963:36004]:r}),stencilOp:(t,e,n,i)=>t({2964:e,2965:n,2966:i,34817:e,34818:n,34819:i}),stencilOpSeparate:(t,e,n,i,r)=>t({[1028===e?2964:34817]:n,[1028===e?2965:34818]:i,[1028===e?2966:34819]:r}),viewport:(t,e,n,i,r)=>t({2978:[e,n,i,r]})},isEnabled=(t,e)=>t.isEnabled(e),GL_PARAMETER_GETTERS={3042:isEnabled,2884:isEnabled,2929:isEnabled,3024:isEnabled,32823:isEnabled,32926:isEnabled,32928:isEnabled,3089:isEnabled,2960:isEnabled,35977:isEnabled};function isObjectEmpty$1(t){for(const e in t)return!1;return!0}function deepArrayEqual(t,e){if(t===e)return!0;const n=Array.isArray(t)||ArrayBuffer.isView(t),i=Array.isArray(e)||ArrayBuffer.isView(e);if(n&&i&&t.length===e.length){for(let n=0;n<t.length;++n)if(t[n]!==e[n])return!1;return!0}return!1}function installGetterOverride(t,e){const n=t[e].bind(t);t[e]=function(){const e=arguments.length<=0?void 0:arguments[0];return e in t.state.cache&&t.state.enable?t.state.cache[e]:n(...arguments)},Object.defineProperty(t[e],"name",{value:"".concat(e,"-from-cache"),configurable:!1})}function installSetterSpy(t,e,n){const i=t[e].bind(t);t[e]=function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];const{valueChanged:s,oldValue:a}=n(t.state._updateCache,...r);return s&&i(...r),a},Object.defineProperty(t[e],"name",{value:"".concat(e,"-to-cache"),configurable:!1})}function installProgramSpy(t){const e=t.useProgram.bind(t);t.useProgram=function(n){t.state.program!==n&&(e(n),t.state.program=n)}}class GLState{constructor(t){let{copyState:e=!1,log:n=()=>{}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.program=null,this.stateStack=[],this.enable=!0,this.cache=e?getParameters(t):Object.assign({},GL_PARAMETER_DEFAULTS),this.log=n,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(){this.stateStack.push({})}pop(){assert$9(this.stateStack.length>0);setParameters(this.gl,this.stateStack[this.stateStack.length-1]),this.stateStack.pop()}_updateCache(t){let e,n=!1;const i=this.stateStack.length>0&&this.stateStack[this.stateStack.length-1];for(const r in t){assert$9(void 0!==r);const o=t[r],s=this.cache[r];deepArrayEqual(o,s)||(n=!0,e=s,i&&!(r in i)&&(i[r]=s),this.cache[r]=o)}return{valueChanged:n,oldValue:e}}}function trackContextState(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{enable:n=!0,copyState:i}=e;if(assert$9(void 0!==i),!t.state){const{polyfillContext:e}=globalThis;e&&e(t),t.state=new GLState(t,{copyState:i}),installProgramSpy(t);for(const e in GL_HOOKED_SETTERS){installSetterSpy(t,e,GL_HOOKED_SETTERS[e])}installGetterOverride(t,"getParameter"),installGetterOverride(t,"isEnabled")}return t.state.enable=n,t}function pushContextState(t){t.state||trackContextState(t,{copyState:!1}),t.state.push()}function popContextState(t){assert$9(t.state),t.state.pop()}function setParameters(t,e){if(assert$9(isWebGL(t),"setParameters requires a WebGL context"),isObjectEmpty$1(e))return;const n={};for(const i in e){const r=Number(i),o=GL_PARAMETER_SETTERS[i];o&&("string"==typeof o?n[o]=!0:o(t,e[i],r))}const i=t.state&&t.state.cache;if(i)for(const r in n){(0,GL_COMPOSITE_PARAMETER_SETTERS[r])(t,e,i)}}function getParameters(t,e){if("number"==typeof(e=e||GL_PARAMETER_DEFAULTS)){const n=e,i=GL_PARAMETER_GETTERS[n];return i?i(t,n):t.getParameter(n)}const n=Array.isArray(e)?e:Object.keys(e),i={};for(const e of n){const n=GL_PARAMETER_GETTERS[e];i[e]=n?n(t,Number(e)):t.getParameter(Number(e))}return i}function resetParameters(t){setParameters(t,GL_PARAMETER_DEFAULTS)}function withParameters(t,e,n){if(isObjectEmpty$1(e))return n(t);const{nocatch:i=!0}=e;let r;if(pushContextState(t),setParameters(t,e),i)r=n(t),popContextState(t);else try{r=n(t)}finally{popContextState(t)}return r}function cssToDeviceRatio(t){const{luma:e}=t;if(t.canvas&&e){const n=e.canvasSizeInfo,i="clientWidth"in n?n.clientWidth:t.canvas.clientWidth;return i?t.drawingBufferWidth/i:1}return 1}function cssToDevicePixels(t,e){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return scalePixels$1(e,cssToDeviceRatio(t),t.drawingBufferWidth,t.drawingBufferHeight,n)}function getDevicePixelRatio(t){const e="undefined"==typeof window?1:window.devicePixelRatio||1;return Number.isFinite(t)?t<=0?1:t:t?e:1}function scalePixels$1(t,e,n,i,r){const o=scaleX(t[0],e,n);let s=scaleY(t[1],e,i,r),a=scaleX(t[0]+1,e,n);const l=a===n-1?a:a-1;let c;return a=scaleY(t[1]+1,e,i,r),r?(a=0===a?a:a+1,c=s,s=a):c=a===i-1?a:a-1,{x:o,y:s,width:Math.max(l-o+1,1),height:Math.max(c-s+1,1)}}function scaleX(t,e,n){return Math.min(Math.round(t*e),n-1)}function scaleY(t,e,n,i){return i?Math.max(0,n-1-Math.round(t*e)):Math.min(Math.round(t*e),n-1)}const isBrowser=isBrowser$1(),isPage$1=isBrowser&&"undefined"!=typeof document,CONTEXT_DEFAULTS={webgl2:!0,webgl1:!0,throwOnError:!0,manageState:!0,canvas:null,debug:!1,width:800,height:600};function createGLContext(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};assert$9(isBrowser,"createGLContext only available in the browser.\nCreate your own headless context or use 'createHeadlessContext' from @luma.gl/test-utils"),t=Object.assign({},CONTEXT_DEFAULTS,t);const{width:e,height:n}=t;function i(e){if(t.throwOnError)throw new Error(e);return null}let r;t.onError=i;const{canvas:o}=t;return r=createBrowserContext(getCanvas({canvas:o,width:e,height:n,onError:i}),t),r?(r=instrumentGLContext(r,t),logInfo(r),r):null}function instrumentGLContext(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t||t._instrumented)return t;t._version=t._version||getVersion(t),t.luma=t.luma||{},t.luma.canvasSizeInfo=t.luma.canvasSizeInfo||{},e=Object.assign({},CONTEXT_DEFAULTS,e);const{manageState:n,debug:i}=e;return n&&trackContextState(t,{copyState:!1,log:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return log$1.log(1,...e)()}}),isBrowser&&i&&(globalThis.makeDebugContext?(t=globalThis.makeDebugContext(t,e),log$1.level=Math.max(log$1.level,1)):log$1.warn('WebGL debug mode not activated. import "@luma.gl/debug" to enable.')()),t._instrumented=!0,t}function getContextDebugInfo(t){const e=t.getParameter(7936),n=t.getParameter(7937),i=t.getExtension("WEBGL_debug_renderer_info");return{vendor:i&&t.getParameter(i.UNMASKED_VENDOR_WEBGL||7936)||e,renderer:i&&t.getParameter(i.UNMASKED_RENDERER_WEBGL||7937)||n,vendorMasked:e,rendererMasked:n,version:t.getParameter(7938),shadingLanguageVersion:t.getParameter(35724)}}function resizeGLContext(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.canvas){return void setDevicePixelRatio(t,getDevicePixelRatio(e.useDevicePixels),e)}const n=t.getExtension("STACKGL_resize_drawingbuffer");n&&"width"in e&&"height"in e&&n.resize(e.width,e.height)}function createBrowserContext(t,e){const{onError:n}=e;let i=null;const r=t=>i=t.statusMessage||i;t.addEventListener("webglcontextcreationerror",r,!1);const{webgl1:o=!0,webgl2:s=!0}=e;let a=null;return s&&(a=a||t.getContext("webgl2",e),a=a||t.getContext("experimental-webgl2",e)),o&&(a=a||t.getContext("webgl",e),a=a||t.getContext("experimental-webgl",e)),t.removeEventListener("webglcontextcreationerror",r,!1),a?(e.onContextLost&&t.addEventListener("webglcontextlost",e.onContextLost,!1),e.onContextRestored&&t.addEventListener("webglcontextrestored",e.onContextRestored,!1),a):n("Failed to create ".concat(s&&!o?"WebGL2":"WebGL"," context: ").concat(i||"Unknown error"))}function getCanvas(t){let e,{canvas:n,width:i=800,height:r=600,onError:o}=t;if("string"==typeof n){isPage$1&&"complete"===document.readyState||o("createGLContext called on canvas '".concat(n,"' before page was loaded")),e=document.getElementById(n)}else n?e=n:(e=document.createElement("canvas"),e.id="lumagl-canvas",e.style.width=Number.isFinite(i)?"".concat(i,"px"):"100%",e.style.height=Number.isFinite(r)?"".concat(r,"px"):"100%",document.body.insertBefore(e,document.body.firstChild));return e}function logInfo(t){const e=isWebGL2$1(t)?"WebGL2":"WebGL1",n=getContextDebugInfo(t),i="(".concat(n.vendor,",").concat(n.renderer,")"),r=t.debug?" debug":"";log$1.info(1,"".concat(e).concat(r," context ").concat(i))()}function getVersion(t){return"undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext?2:1}function setDevicePixelRatio(t,e,n){let i="width"in n?n.width:t.canvas.clientWidth,r="height"in n?n.height:t.canvas.clientHeight;i&&r||(log$1.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,i=t.canvas.width||1,r=t.canvas.height||1),t.luma=t.luma||{},t.luma.canvasSizeInfo=t.luma.canvasSizeInfo||{};const o=t.luma.canvasSizeInfo;if(o.clientWidth!==i||o.clientHeight!==r||o.devicePixelRatio!==e){let n=e;const o=Math.floor(i*n),s=Math.floor(r*n);t.canvas.width=o,t.canvas.height=s,t.drawingBufferWidth===o&&t.drawingBufferHeight===s||(log$1.warn("Device pixel ratio clamped")(),n=Math.min(t.drawingBufferWidth/i,t.drawingBufferHeight/r),t.canvas.width=Math.floor(i*n),t.canvas.height=Math.floor(r*n)),Object.assign(t.luma.canvasSizeInfo,{clientWidth:i,clientHeight:r,devicePixelRatio:e})}}const VERSION$5="8.5.21",STARTUP_MESSAGE="set luma.log.level=1 (or higher) to trace rendering";class StatsManager{constructor(){this.stats=new Map}get(t){return this.stats.has(t)||this.stats.set(t,new Stats({id:t})),this.stats.get(t)}}const lumaStats=new StatsManager;if(globalThis.luma&&globalThis.luma.VERSION!==VERSION$5)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat(VERSION$5));function requestAnimationFrame$1(t){return"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,1e3/60)}function cancelAnimationFrame(t){return"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(t):clearTimeout(t)}function assert$8(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}function getKeyValue(t,e){if("string"!=typeof e)return e;const n=Number(e);if(!isNaN(n))return n;const i=t[e=e.replace(/^.*\./,"")];return assert$8(void 0!==i,"Accessing undefined constant GL.".concat(e)),i}function getKey(t,e){e=Number(e);for(const n in t)if(t[n]===e)return"GL.".concat(n);return String(e)}globalThis.luma||(isBrowser$1()&&log$1.log(1,"luma.gl ".concat(VERSION$5," - ").concat(STARTUP_MESSAGE))(),globalThis.luma=globalThis.luma||{VERSION:VERSION$5,version:VERSION$5,log:log$1,stats:lumaStats,globals:{modules:{},nodeIO:{}}});const uidCounters={};function uid(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";uidCounters[t]=uidCounters[t]||1;const e=uidCounters[t]++;return"".concat(t,"-").concat(e)}function isPowerOfTwo$1(t){return assert$8("number"==typeof t,"Input must be a number"),t&&!(t&t-1)}function isObjectEmpty(t){let e=!0;for(const n in t){e=!1;break}return e}function stubRemovedMethods(t,e,n,i){const r="See luma.gl ".concat(n," Upgrade Guide at https://luma.gl/docs/upgrade-guide"),o=Object.getPrototypeOf(t);i.forEach((t=>{o.methodName||(o[t]=()=>{throw log$1.removed("Calling removed method ".concat(e,".").concat(t,": "),r)(),new Error(t)})}))}const ERR_RESOURCE_METHOD_UNDEFINED="Resource subclass must define virtual methods";let Resource$1=class{get[Symbol.toStringTag](){return"Resource"}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};assertWebGLContext(t);const{id:n,userData:i={}}=e;this.gl=t,this.gl2=t,this.id=n||uid(this[Symbol.toStringTag]),this.userData=i,this._bound=!1,this._handle=e.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:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this._handle&&this._deleteHandle(this._handle);return this._handle&&this._removeStats(),this._handle=null,e&&t&&e.filter(Boolean).forEach((t=>t.delete())),this}bind(){let t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.handle;return"function"!=typeof e?(this._bindHandle(e),this):(this._bound?t=e():(this._bindHandle(this.handle),this._bound=!0,t=e(),this._bound=!1,this._bindHandle(null)),t)}unbind(){this.bind(null)}getParameter(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};assert$8(t=getKeyValue(this.gl,t));const n=(this.constructor.PARAMETERS||{})[t];if(n){const t=isWebGL2$1(this.gl);if(!((!("webgl2"in n)||t)&&(!("extension"in n)||this.gl.getExtension(n.extension)))){return t?"webgl2"in n?n.webgl2:n.webgl1:n.webgl1}}return this._getParameter(t,e)}getParameters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{parameters:e,keys:n}=t,i=this.constructor.PARAMETERS||{},r=isWebGL2$1(this.gl),o={},s=e||Object.keys(i);for(const e of s){const s=i[e];if(s&&(!("webgl2"in s)||r)&&(!("extension"in s)||this.gl.getExtension(s.extension))){const i=n?getKey(this.gl,e):e;o[i]=this.getParameter(e,t),n&&"GLenum"===s.type&&(o[i]=getKey(this.gl,o[i]))}}return o}setParameter(t,e){assert$8(t=getKeyValue(this.gl,t));const n=(this.constructor.PARAMETERS||{})[t];if(n){const t=isWebGL2$1(this.gl);if(!((!("webgl2"in n)||t)&&(!("extension"in n)||this.gl.getExtension(n.extension))))throw new Error("Parameter not available on this platform");"GLenum"===n.type&&(e=getKeyValue(e))}return this._setParameter(t,e),this}setParameters(t){for(const e in t)this.setParameter(e,t[e]);return this}stubRemovedMethods(t,e,n){return stubRemovedMethods(this,t,e,n)}initialize(t){}_createHandle(){throw new Error(ERR_RESOURCE_METHOD_UNDEFINED)}_deleteHandle(){throw new Error(ERR_RESOURCE_METHOD_UNDEFINED)}_bindHandle(t){throw new Error(ERR_RESOURCE_METHOD_UNDEFINED)}_getOptsFromHandle(){throw new Error(ERR_RESOURCE_METHOD_UNDEFINED)}_getParameter(t,e){throw new Error(ERR_RESOURCE_METHOD_UNDEFINED)}_setParameter(t,e){throw new Error(ERR_RESOURCE_METHOD_UNDEFINED)}_context(){return this.gl.luma=this.gl.luma||{},this.gl.luma}_addStats(){const t=this[Symbol.toStringTag],e=lumaStats.get("Resource Counts");e.get("Resources Created").incrementCount(),e.get("".concat(t,"s Created")).incrementCount(),e.get("".concat(t,"s Active")).incrementCount()}_removeStats(){const t=this[Symbol.toStringTag];lumaStats.get("Resource Counts").get("".concat(t,"s Active")).decrementCount()}_trackAllocatedMemory(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag];this._trackAllocatedMemoryForContext(t,e),this._trackAllocatedMemoryForContext(t,e,this.gl.canvas&&this.gl.canvas.id),this.byteLength=t}_trackAllocatedMemoryForContext(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag];const n=lumaStats.get("Memory Usage".concat(arguments.length>2&&void 0!==arguments[2]?arguments[2]:""));n.get("GPU Memory").addCount(t),n.get("".concat(e," Memory")).addCount(t)}_trackDeallocatedMemory(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];this._trackDeallocatedMemoryForContext(t),this._trackDeallocatedMemoryForContext(t,this.gl.canvas&&this.gl.canvas.id),this.byteLength=0}_trackDeallocatedMemoryForContext(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];const e=lumaStats.get("Memory Usage".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:""));e.get("GPU Memory").subtractCount(this.byteLength),e.get("".concat(t," Memory")).subtractCount(this.byteLength)}};const ERR_TYPE_DEDUCTION="Failed to deduce GL constant from typed array";function getGLTypeFromTypedArray(t){switch(ArrayBuffer.isView(t)?t.constructor:t){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(ERR_TYPE_DEDUCTION)}}function getTypedArrayFromGLType(t){let{clamped:e=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return e?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 flipRows(t){let{data:e,width:n,height:i,bytesPerPixel:r=4,temp:o}=t;const s=n*r;o=o||new Uint8Array(s);for(let t=0;t<i/2;++t){const n=t*s,r=(i-t-1)*s;o.set(e.subarray(n,n+s)),e.copyWithin(n,r,r+s),e.set(o,r)}}function scalePixels(t){let{data:e,width:n,height:i}=t;const r=Math.round(n/2),o=Math.round(i/2),s=new Uint8Array(r*o*4);for(let t=0;t<o;t++)for(let i=0;i<r;i++)for(let o=0;o<4;o++)s[4*(t*r+i)+o]=e[4*(2*t*n+2*i)+o];return{data:s,width:r,height:o}}function checkProps(t,e,n){const{removedProps:i={},deprecatedProps:r={},replacedProps:o={}}=n;for(const n in i)if(n in e){const e=i[n]?"".concat(t,".").concat(i[n]):"N/A";log$1.removed("".concat(t,".").concat(n),e)()}for(const n in r)if(n in e){const e=r[n];log$1.deprecated("".concat(t,".").concat(n),"".concat(t,".").concat(e))()}let s=null;for(const n in o)if(n in e){const i=o[n];log$1.deprecated("".concat(t,".").concat(n),"".concat(t,".").concat(i))(),s=s||Object.assign({},e),s[i]=e[n],delete s[n]}return s||e}const DEFAULT_ACCESSOR_VALUES={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},PROP_CHECKS={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}};class Accessor{static getBytesPerElement(t){return getTypedArrayFromGLType(t.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(t){assert$8(t.size);return getTypedArrayFromGLType(t.type||5126).BYTES_PER_ELEMENT*t.size}static resolve(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Accessor(...[DEFAULT_ACCESSOR_VALUES,...e])}constructor(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];e.forEach((t=>this._assign(t))),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return Accessor.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return Accessor.getBytesPerVertex(this)}_assign(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=checkProps("Accessor",t,PROP_CHECKS),void 0!==t.type&&(this.type=t.type,5124!==t.type&&5125!==t.type||(this.integer=!0)),void 0!==t.size&&(this.size=t.size),void 0!==t.offset&&(this.offset=t.offset),void 0!==t.stride&&(this.stride=t.stride),void 0!==t.normalized&&(this.normalized=t.normalized),void 0!==t.integer&&(this.integer=t.integer),void 0!==t.divisor&&(this.divisor=t.divisor),void 0!==t.buffer&&(this.buffer=t.buffer),void 0!==t.index&&(this.index="boolean"==typeof t.index?t.index?1:0:t.index),void 0!==t.instanced&&(this.divisor=t.instanced?1:0),void 0!==t.isInstanced&&(this.divisor=t.isInstanced?1:0),this}}const DEBUG_DATA_LENGTH=10,DEPRECATED_PROPS={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"},PROP_CHECKS_INITIALIZE={removedProps:{},replacedProps:{bytes:"byteLength"},deprecatedProps:DEPRECATED_PROPS},PROP_CHECKS_SET_PROPS={removedProps:DEPRECATED_PROPS};class Buffer extends Resource$1{get[Symbol.toStringTag](){return"Buffer"}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.stubRemovedMethods("Buffer","v6.0",["layout","setLayout","getIndexedParameter"]),this.target=e.target||(this.gl.webgl2?36662:34962),this.initialize(e),Object.seal(this)}getElementCount(){return Math.round(this.byteLength/Accessor.getBytesPerElement(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor))}getVertexCount(){return Math.round(this.byteLength/Accessor.getBytesPerVertex(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor))}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ArrayBuffer.isView(t)&&(t={data:t}),Number.isFinite(t)&&(t={byteLength:t}),t=checkProps("Buffer",t,PROP_CHECKS_INITIALIZE),this.usage=t.usage||35044,this.debugData=null,this.setAccessor(Object.assign({},t,t.accessor)),t.data?this._setData(t.data,t.offset,t.byteLength):this._setByteLength(t.byteLength||0),this}setProps(t){return"accessor"in(t=checkProps("Buffer",t,PROP_CHECKS_SET_PROPS))&&this.setAccessor(t.accessor),this}setAccessor(t){return delete(t=Object.assign({},t)).buffer,this.accessor=new Accessor(t),this}reallocate(t){return t>this.byteLength?(this._setByteLength(t),!0):(this.bytesUsed=t,!1)}setData(t){return this.initialize(t)}subData(t){ArrayBuffer.isView(t)&&(t={data:t});const{data:e,offset:n=0,srcOffset:i=0}=t,r=t.byteLength||t.length;assert$8(e);const o=this.gl.webgl2?36663:this.target;return this.gl.bindBuffer(o,this.handle),0!==i||void 0!==r?(assertWebGL2Context(this.gl),this.gl.bufferSubData(this.target,n,e,i,r)):this.gl.bufferSubData(o,n,e),this.gl.bindBuffer(o,null),this.debugData=null,this._inferType(e),this}copyData(t){let{sourceBuffer:e,readOffset:n=0,writeOffset:i=0,size:r}=t;const{gl:o}=this;return assertWebGL2Context(o),o.bindBuffer(36662,e.handle),o.bindBuffer(36663,this.handle),o.copyBufferSubData(36662,36663,n,i,r),o.bindBuffer(36662,null),o.bindBuffer(36663,null),this.debugData=null,this}getData(){let{dstData:t=null,srcByteOffset:e=0,dstOffset:n=0,length:i=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};assertWebGL2Context(this.gl);const r=getTypedArrayFromGLType(this.accessor.type||5126,{clamped:!1}),o=this._getAvailableElementCount(e),s=n;let a,l;t?(l=t.length,a=l-s):(a=Math.min(o,i||o),l=s+a);const c=Math.min(o,a);return i=i||c,assert$8(i<=c),t=t||new r(l),this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,t,n,i),this.gl.bindBuffer(36662,null),t}bind(){let{target:t=this.target,index:e=this.accessor&&this.accessor.index,offset:n=0,size:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 35345===t||35982===t?void 0!==i?this.gl.bindBufferRange(t,e,this.handle,n,i):(assert$8(0===n),this.gl.bindBufferBase(t,e,this.handle)):this.gl.bindBuffer(t,this.handle),this}unbind(){let{target:t=this.target,index:e=this.accessor&&this.accessor.index}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 35345===t||35982===t?this.gl.bindBufferBase(t,e,null):this.gl.bindBuffer(t,null),this}getDebugData(){return this.debugData?{data:this.debugData,changed:!1}:(this.debugData=this.getData({length:Math.min(DEBUG_DATA_LENGTH,this.byteLength)}),{data:this.debugData,changed:!0})}invalidateDebugData(){this.debugData=null}_setData(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.byteLength+e;assert$8(ArrayBuffer.isView(t)),this._trackDeallocatedMemory();const i=this._getTarget();this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.usage),this.gl.bufferSubData(i,e,t),this.gl.bindBuffer(i,null),this.debugData=t.slice(0,DEBUG_DATA_LENGTH),this.bytesUsed=n,this._trackAllocatedMemory(n);const r=getGLTypeFromTypedArray(t);return assert$8(r),this.setAccessor(new Accessor(this.accessor,{type:r})),this}_setByteLength(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.usage;assert$8(t>=0),this._trackDeallocatedMemory();let n=t;0===t&&(n=new Float32Array(0));const i=this._getTarget();return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,e),this.gl.bindBuffer(i,null),this.usage=e,this.debugData=null,this.bytesUsed=t,this._trackAllocatedMemory(t),this}_getTarget(){return this.gl.webgl2?36663:this.target}_getAvailableElementCount(t){const e=t/getTypedArrayFromGLType(this.accessor.type||5126,{clamped:!1}).BYTES_PER_ELEMENT;return this.getElementCount()-e}_inferType(t){this.accessor.type||this.setAccessor(new Accessor(this.accessor,{type:getGLTypeFromTypedArray(t)}))}_createHandle(){return this.gl.createBuffer()}_deleteHandle(){this.gl.deleteBuffer(this.handle),this._trackDeallocatedMemory()}_getParameter(t){this.gl.bindBuffer(this.target,this.handle);const e=this.gl.getBufferParameter(this.target,t);return this.gl.bindBuffer(this.target,null),e}get type(){return log$1.deprecated("Buffer.type","Buffer.accessor.type")(),this.accessor.type}get bytes(){return log$1.deprecated("Buffer.bytes","Buffer.byteLength")(),this.byteLength}setByteLength(t){return log$1.deprecated("setByteLength","reallocate")(),this.reallocate(t)}updateAccessor(t){return log$1.deprecated("updateAccessor(...)","setAccessor(new Accessor(buffer.accessor, ...)")(),this.accessor=new Accessor(this.accessor,t),this}}const TEXTURE_FORMATS={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}},DATA_FORMAT_CHANNELS={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},TYPE_SIZES={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function isFormatSupported$1(t,e){const n=TEXTURE_FORMATS[e];if(!n)return!1;if(void 0===n.gl1&&void 0===n.gl2)return!0;const i=isWebGL2$1(t)&&n.gl2||n.gl1;return"string"==typeof i?t.getExtension(i):i}function isLinearFilteringSupported(t,e){const n=TEXTURE_FORMATS[e];switch(n&&n.types[0]){case 5126:return t.getExtension("OES_texture_float_linear");case 5131:return t.getExtension("OES_texture_half_float_linear");default:return!0}}const NPOT_MIN_FILTERS=[9729,9728],WebGLBuffer=globalThis.WebGLBuffer||function(){};let Texture$1=class extends Resource$1{get[Symbol.toStringTag](){return"Texture"}static isSupported(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{format:n,linearFiltering:i}=e;let r=!0;return n&&(r=r&&isFormatSupported$1(t,n),r=r&&(!i||isLinearFilteringSupported(t,n))),r}constructor(t,e){const{id:n=uid("texture"),handle:i,target:r}=e;super(t,{id:n,handle:i}),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 t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.data;if(e instanceof Promise)return e.then((e=>this.initialize(Object.assign({},t,{pixels:e,data:e})))),this;const n="undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement;if(n&&e.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,e.addEventListener("loadeddata",(()=>this.initialize(t))),this;const{pixels:i=null,format:r=6408,border:o=0,recreate:s=!1,parameters:a={},pixelStore:l={},textureUnit:c}=t;e||(e=i);let{width:u,height:h,dataFormat:d,type:p,compressed:f=!1,mipmaps:m=!0}=t;const{depth:g=0}=t;return({width:u,height:h,compressed:f,dataFormat:d,type:p}=this._deduceParameters({format:r,type:p,dataFormat:d,compressed:f,data:e,width:u,height:h})),this.width=u,this.height=h,this.depth=g,this.format=r,this.type=p,this.dataFormat=d,this.border=o,this.textureUnit=c,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),m&&this._isNPOT()&&(log$1.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),m=!1,this._updateForNPOT(a)),this.mipmaps=m,this.setImageData({data:e,width:u,height:h,depth:g,format:r,type:p,dataFormat:d,border:o,mipmaps:m,parameters:l,compressed:f}),m&&this.generateMipmap(),this.setParameters(a),s&&(this.data=e),n&&(this._video={video:e,parameters:a,lastTime:e.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?e.currentTime:-1}),this}update(){if(this._video){const{video:t,parameters:e,lastTime:n}=this._video;if(n===t.currentTime||t.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:t,parameters:e}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=t.currentTime}}resize(t){let{height:e,width:n,mipmaps:i=!1}=t;return n!==this.width||e!==this.height?this.initialize({width:n,height:e,format:this.format,type:this.type,dataFormat:this.dataFormat,border:this.border,mipmaps:i}):this}generateMipmap(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isNPOT()?(log$1.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),this):(this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),withParameters(this.gl,t,(()=>{this.gl.generateMipmap(this.target)})),this.gl.bindTexture(this.target,null),this)}setImageData(t){this._trackDeallocatedMemory("Texture");const{target:e=this.target,pixels:n=null,level:i=0,format:r=this.format,border:o=this.border,offset:s=0,parameters:a={}}=t;let{data:l=null,type:c=this.type,width:u=this.width,height:h=this.height,dataFormat:d=this.dataFormat,compressed:p=!1}=t;l||(l=n),({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(withParameters(this.gl,a,(()=>{switch(g){case"null":f.texImage2D(e,i,r,u,h,o,d,c,l);break;case"typed-array":f.texImage2D(e,i,r,u,h,o,d,c,l,s);break;case"buffer":m=assertWebGL2Context(f),m.bindBuffer(35052,l.handle||l),m.texImage2D(e,i,r,u,h,o,d,c,s),m.bindBuffer(35052,null);break;case"browser-object":isWebGL2$1(f)?f.texImage2D(e,i,r,u,h,o,d,c,l):f.texImage2D(e,i,r,d,c,l);break;case"compressed":for(const[t,n]of l.entries())f.compressedTexImage2D(e,t,n.format,n.width,n.height,o,n.data),_+=n.levelSize;break;default:assert$8(!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*(DATA_FORMAT_CHANNELS[this.dataFormat]||4)*(TYPE_SIZES[this.type]||1),"Texture")}return this.loaded=!0,this}setSubImageData(t){let{target:e=this.target,pixels:n=null,data:i=null,x:r=0,y:o=0,width:s=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={}}=t;if(({type:u,dataFormat:h,compressed:d,width:s,height:a}=this._deduceParameters({format:c,type:u,dataFormat:h,compressed:d,data:i,width:s,height:a})),assert$8(0===this.depth,"texSubImage not supported for 3D textures"),i||(i=n),i&&i.data){const t=i;i=t.data,s=t.shape[0],a=t.shape[1]}i instanceof Buffer&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),withParameters(this.gl,m,(()=>{if(d)this.gl.compressedTexSubImage2D(e,l,r,o,s,a,c,i);else if(null===i)this.gl.texSubImage2D(e,l,r,o,s,a,h,u,null);else if(ArrayBuffer.isView(i))this.gl.texSubImage2D(e,l,r,o,s,a,h,u,i,p);else if(i instanceof WebGLBuffer){const t=assertWebGL2Context(this.gl);t.bindBuffer(35052,i),t.texSubImage2D(e,l,r,o,s,a,h,u,p),t.bindBuffer(35052,null)}else if(isWebGL2$1(this.gl)){assertWebGL2Context(this.gl).texSubImage2D(e,l,r,o,s,a,h,u,i)}else this.gl.texSubImage2D(e,l,r,o,h,u,i)})),this.gl.bindTexture(this.target,null)}copyFramebuffer(){return null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit;const{gl:e}=this;return void 0!==t&&(this.textureUnit=t,e.activeTexture(33984+t)),e.bindTexture(this.target,this.handle),t}unbind(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit;const{gl:e}=this;return void 0!==t&&(this.textureUnit=t,e.activeTexture(33984+t)),e.bindTexture(this.target,null),t}_getDataType(t){let{data:e,compressed:n=!1}=t;return n?{data:e,dataType:"compressed"}:null===e?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof Buffer?{data:e.handle,dataType:"buffer"}:e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(t){const{format:e,data:n}=t;let{width:i,height:r,dataFormat:o,type:s,compressed:a}=t;const l=TEXTURE_FORMATS[e];return o=o||l&&l.dataFormat,s=s||l&&l.types[0],a=a||l&&l.compressed,({width:i,height:r}=this._deduceImageSize(n,i,r)),{dataFormat:o,type:s,compressed:a,width:i,height:r,format:e,data:n}}_deduceImageSize(t,e,n){let i;return i="undefined"!=typeof ImageData&&t instanceof ImageData?{width:t.width,height:t.height}:"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?{width:t.naturalWidth,height:t.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?{width:t.width,height:t.height}:"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement?{width:t.videoWidth,height:t.videoHeight}:t?{width:e,height:n}:{width:e>=0?e:1,height:n>=0?n:1},assert$8(i,"Could not deduced texture size"),assert$8(void 0===e||i.width===e,"Deduced texture width does not match supplied width"),assert$8(void 0===n||i.height===n,"Deduced texture height does not match supplied height"),i}_createHandle(){return this.gl.createTexture()}_deleteHandle(){this.gl.deleteTexture(this.handle),this._trackDeallocatedMemory("Texture")}_getParameter(t){switch(t){case 4096:return this.width;case 4097:return this.height;default:this.gl.bindTexture(this.target,this.handle);const e=this.gl.getTexParameter(this.target,t);return this.gl.bindTexture(this.target,null),e}}_setParameter(t,e){switch(this.gl.bindTexture(this.target,this.handle),e=this._getNPOTParam(t,e),t){case 33082:case 33083:this.gl.texParameterf(this.handle,t,e);break;case 4096:case 4097:assert$8(!1);break;default:this.gl.texParameteri(this.target,t,e)}return this.gl.bindTexture(this.target,null),this}_isNPOT(){return!isWebGL2$1(this.gl)&&(!(!this.width||!this.height)&&(!isPowerOfTwo$1(this.width)||!isPowerOfTwo$1(this.height)))}_updateForNPOT(t){void 0===t[this.gl.TEXTURE_MIN_FILTER]&&(t[this.gl.TEXTURE_MIN_FILTER]=this.gl.LINEAR),void 0===t[this.gl.TEXTURE_WRAP_S]&&(t[this.gl.TEXTURE_WRAP_S]=this.gl.CLAMP_TO_EDGE),void 0===t[this.gl.TEXTURE_WRAP_T]&&(t[this.gl.TEXTURE_WRAP_T]=this.gl.CLAMP_TO_EDGE)}_getNPOTParam(t,e){if(this._isNPOT())switch(t){case 10241:-1===NPOT_MIN_FILTERS.indexOf(e)&&(e=9729);break;case 10242:case 10243:33071!==e&&(e=33071)}return e}},pathPrefix="";function loadImage$1(t,e){return assert$8("string"==typeof t),t=pathPrefix+t,new Promise(((n,i)=>{try{const r=new Image;r.onload=()=>n(r),r.onerror=()=>i(new Error("Could not load image ".concat(t,"."))),r.crossOrigin=e&&e.crossOrigin||"anonymous",r.src=t}catch(t){i(t)}}))}class Texture2D extends Texture$1{get[Symbol.toStringTag](){return"Texture2D"}static isSupported(t,e){return Texture$1.isSupported(t,e)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};assertWebGLContext(t),(e instanceof Promise||"string"==typeof e)&&(e={data:e}),"string"==typeof e.data&&(e=Object.assign({},e,{data:loadImage$1(e.data)})),super(t,Object.assign({},e,{target:3553})),this.initialize(e),Object.seal(this)}}const FACES=[34069,34070,34071,34072,34073,34074];class TextureCube extends Texture$1{get[Symbol.toStringTag](){return"TextureCube"}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};assertWebGLContext(t),super(t,Object.assign({},e,{target:34067})),this.initialize(e),Object.seal(this)}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{mipmaps:e=!0,parameters:n={}}=t;return this.opts=t,this.setCubeMapImageData(t).then((()=>{this.loaded=!0,e&&this.generateMipmap(t),this.setParameters(n)})),this}subImage(t){let{face:e,data:n,x:i=0,y:r=0,mipmapLevel:o=0}=t;return this._subImage({target:e,data:n,x:i,y:r,mipmapLevel:o})}async setCubeMapImageData(t){let{width:e,height:n,pixels:i,data:r,border:o=0,format:s=6408,type:a=5121}=t;const{gl:l}=this,c=i||r,u=await Promise.all(FACES.map((t=>{const e=c[t];return Promise.all(Array.isArray(e)?e:[e])})));this.bind(),FACES.forEach(((t,i)=>{u[i].length>1&&!1!==this.opts.mipmaps&&log$1.warn("".concat(this.id," has mipmap and multiple LODs."))(),u[i].forEach(((i,r)=>{e&&n?l.texImage2D(t,r,s,e,n,o,s,a,i):l.texImage2D(t,r,s,s,a,i)}))})),this.unbind()}setImageDataForFace(t){const{face:e,width:n,height:i,pixels:r,data:o,border:s=0,format:a=6408,type:l=5121}=t,{gl:c}=this,u=r||o;return this.bind(),u instanceof Promise?u.then((n=>this.setImageDataForFace(Object.assign({},t,{face:e,data:n,pixels:n})))):this.width||this.height?c.texImage2D(e,0,a,n,i,s,a,l,u):c.texImage2D(e,0,a,a,l,u),this}}TextureCube.FACES=FACES;class Texture3D extends Texture$1{get[Symbol.toStringTag](){return"Texture3D"}static isSupported(t){return isWebGL2$1(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};assertWebGL2Context(t),e=Object.assign({depth:1},e,{target:32879,unpackFlipY:!1}),super(t,e),this.initialize(e),Object.seal(this)}setImageData(t){let{level:e=0,dataFormat:n=6408,width:i,height:r,depth:o=1,border:s=0,format:a,type:l=5121,offset:c=0,data:u,parameters:h={}}=t;if(this._trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle),withParameters(this.gl,h,(()=>{ArrayBuffer.isView(u)&&this.gl.texImage3D(this.target,e,n,i,r,o,s,a,l,u),u instanceof Buffer&&(this.gl.bindBuffer(35052,u.handle),this.gl.texImage3D(this.target,e,n,i,r,o,s,a,l,c))})),u&&u.byteLength)this._trackAllocatedMemory(u.byteLength,"Texture");else{this._trackAllocatedMemory(this.width*this.height*this.depth*(DATA_FORMAT_CHANNELS[this.dataFormat]||4)*(TYPE_SIZES[this.type]||1),"Texture")}return this.loaded=!0,this}}const EXT_FLOAT_WEBGL2="EXT_color_buffer_float";var RENDERBUFFER_FORMATS={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:EXT_FLOAT_WEBGL2,bpp:2},33327:{gl2:EXT_FLOAT_WEBGL2,bpp:4},34842:{gl2:EXT_FLOAT_WEBGL2,bpp:8},33326:{gl2:EXT_FLOAT_WEBGL2,bpp:4},33328:{gl2:EXT_FLOAT_WEBGL2,bpp:8},34836:{gl2:EXT_FLOAT_WEBGL2,bpp:16},35898:{gl2:EXT_FLOAT_WEBGL2,bpp:4}};function isFormatSupported(t,e,n){const i=n[e];if(!i)return!1;const r=isWebGL2$1(t)&&i.gl2||i.gl1;return"string"==typeof r?t.getExtension(r):r}class Renderbuffer extends Resource$1{get[Symbol.toStringTag](){return"Renderbuffer"}static isSupported(t){let{format:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{format:null};return!e||isFormatSupported(t,e,RENDERBUFFER_FORMATS)}static getSamplesForFormat(t,e){let{format:n}=e;return t.getInternalformatParameter(36161,n,32937)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.initialize(e),Object.seal(this)}initialize(t){let{format:e,width:n=1,height:i=1,samples:r=0}=t;return assert$8(e,"Needs format"),this._trackDeallocatedMemory(),this.gl.bindRenderbuffer(36161,this.handle),0!==r&&isWebGL2$1(this.gl)?this.gl.renderbufferStorageMultisample(36161,r,e,n,i):this.gl.renderbufferStorage(36161,e,n,i),this.format=e,this.width=n,this.height=i,this.samples=r,this._trackAllocatedMemory(this.width*this.height*(this.samples||1)*RENDERBUFFER_FORMATS[this.format].bpp),this}resize(t){let{width:e,height:n}=t;return e!==this.width||n!==this.height?this.initialize({width:e,height:n,format:this.format,samples:this.samples}):this}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this._trackDeallocatedMemory()}_bindHandle(t){this.gl.bindRenderbuffer(36161,t)}_syncHandle(t){this.format=this.getParameter(36164),this.width=this.getParameter(36162),this.height=this.getParameter(36163),this.samples=this.getParameter(36011)}_getParameter(t){this.gl.bindRenderbuffer(36161,this.handle);return this.gl.getRenderbufferParameter(36161,t)}}const GL_DEPTH_BUFFER_BIT=256,GL_STENCIL_BUFFER_BIT=1024,GL_COLOR_BUFFER_BIT=16384,GL_COLOR=6144,GL_DEPTH=6145,GL_STENCIL=6146,GL_DEPTH_STENCIL=34041,ERR_ARGUMENTS="clear: bad arguments";function clear(t){let{framebuffer:e=null,color:n=null,depth:i=null,stencil:r=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o={};e&&(o.framebuffer=e);let s=0;n&&(s|=GL_COLOR_BUFFER_BIT,!0!==n&&(o.clearColor=n)),i&&(s|=GL_DEPTH_BUFFER_BIT,!0!==i&&(o.clearDepth=i)),r&&(s|=GL_STENCIL_BUFFER_BIT,!0!==i&&(o.clearStencil=i)),assert$8(0!==s,ERR_ARGUMENTS),withParameters(t,o,(()=>{t.clear(s)}))}function clearBuffer(t){let{framebuffer:e=null,buffer:n=GL_COLOR,drawBuffer:i=0,value:r=[0,0,0,0]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};assertWebGL2Context(t),withParameters(t,{framebuffer:e},(()=>{switch(n){case GL_COLOR:switch(r.constructor){case Int32Array:t.clearBufferiv(n,i,r);break;case Uint32Array:t.clearBufferuiv(n,i,r);break;case Float32Array:default:t.clearBufferfv(n,i,r)}break;case GL_DEPTH:t.clearBufferfv(GL_DEPTH,0,[r]);break;case GL_STENCIL:t.clearBufferiv(GL_STENCIL,0,[r]);break;case GL_DEPTH_STENCIL:const[e,o]=r;t.clearBufferfi(GL_DEPTH_STENCIL,0,e,o);break;default:assert$8(!1,ERR_ARGUMENTS)}}))}function glFormatToComponents(t){switch(t){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return assert$8(!1),0}}function readPixelsToArray(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{sourceX:n=0,sourceY:i=0,sourceFormat:r=6408}=e;let{sourceAttachment:o=36064,target:s=null,sourceWidth:a,sourceHeight:l,sourceType:c}=e;const{framebuffer:u,deleteFramebuffer:h}=getFramebuffer$1(t);assert$8(u);const{gl:d,handle:p,attachments:f}=u;a=a||u.width,l=l||u.height,36064===o&&null===p&&(o=1028),assert$8(f[o]),c=c||f[o].type,s=getPixelArray(s,c,r,a,l),c=c||getGLTypeFromTypedArray(s);const m=d.bindFramebuffer(36160,p);return d.readPixels(n,i,a,l,r,c,s),d.bindFramebuffer(36160,m||null),h&&u.delete(),s}function copyToDataUrl(t){let{sourceAttachment:e=36064,targetMaxHeight:n=Number.MAX_SAFE_INTEGER}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=readPixelsToArray(t,{sourceAttachment:e}),{width:r,height:o}=t;for(;o>n;)({data:i,width:r,height:o}=scalePixels({data:i,width:r,height:o}));flipRows({data:i,width:r,height:o});const s=document.createElement("canvas");s.width=r,s.height=o;const a=s.getContext("2d"),l=a.createImageData(r,o);return l.data.set(i),a.putImageData(l,0,0),s.toDataURL()}function copyToTexture(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{sourceX:i=0,sourceY:r=0,targetMipmaplevel:o=0,targetInternalFormat:s=6408}=n;let{targetX:a,targetY:l,targetZ:c,width:u,height:h}=n;const{framebuffer:d,deleteFramebuffer:p}=getFramebuffer$1(t);assert$8(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);assert$8(e);let y=null;if(e instanceof Texture$1&&(y=e,u=Number.isFinite(u)?u:y.width,h=Number.isFinite(h)?h:y.height,y.bind(0),e=y.target),g)switch(e){case 3553:case 34067:f.copyTexSubImage2D(e,o,a,l,i,r,u,h);break;case 35866:case 32879:assertWebGL2Context(f).copyTexSubImage3D(e,o,a,l,c,i,r,u,h)}else f.copyTexImage2D(e,o,s,i,r,u,h,0);return y&&y.unbind(),f.bindFramebuffer(36160,_||null),p&&d.delete(),y}function getFramebuffer$1(t){return t instanceof Framebuffer?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:toFramebuffer(t),deleteFramebuffer:!0}}function getPixelArray(t,e,n,i,r){if(t)return t;return new(getTypedArrayFromGLType(e=e||5121,{clamped:!1}))(i*r*glFormatToComponents(n))}const FEATURES$1={WEBGL2:"WEBGL2",VERTEX_ARRAY_OBJECT:"VERTEX_ARRAY_OBJECT",TIMER_QUERY:"TIMER_QUERY",INSTANCED_RENDERING:"INSTANCED_RENDERING",MULTIPLE_RENDER_TARGETS:"MULTIPLE_RENDER_TARGETS",ELEMENT_INDEX_UINT32:"ELEMENT_INDEX_UINT32",BLEND_EQUATION_MINMAX:"BLEND_EQUATION_MINMAX",FLOAT_BLEND:"FLOAT_BLEND",COLOR_ENCODING_SRGB:"COLOR_ENCODING_SRGB",TEXTURE_DEPTH:"TEXTURE_DEPTH",TEXTURE_FLOAT:"TEXTURE_FLOAT",TEXTURE_HALF_FLOAT:"TEXTURE_HALF_FLOAT",TEXTURE_FILTER_LINEAR_FLOAT:"TEXTURE_FILTER_LINEAR_FLOAT",TEXTURE_FILTER_LINEAR_HALF_FLOAT:"TEXTURE_FILTER_LINEAR_HALF_FLOAT",TEXTURE_FILTER_ANISOTROPIC:"TEXTURE_FILTER_ANISOTROPIC",COLOR_ATTACHMENT_RGBA32F:"COLOR_ATTACHMENT_RGBA32F",COLOR_ATTACHMENT_FLOAT:"COLOR_ATTACHMENT_FLOAT",COLOR_ATTACHMENT_HALF_FLOAT:"COLOR_ATTACHMENT_HALF_FLOAT",GLSL_FRAG_DATA:"GLSL_FRAG_DATA",GLSL_FRAG_DEPTH:"GLSL_FRAG_DEPTH",GLSL_DERIVATIVES:"GLSL_DERIVATIVES",GLSL_TEXTURE_LOD:"GLSL_TEXTURE_LOD"};function checkFloat32ColorAttachment(t){const e=new Texture2D(t,{format:6408,type:5126,dataFormat:6408}),n=new Framebuffer(t,{id:"test-framebuffer",check:!1,attachments:{36064:e}}),i=n.getStatus();return e.delete(),n.delete(),36053===i}var WEBGL_FEATURES$1={[FEATURES$1.WEBGL2]:[!1,!0],[FEATURES$1.VERTEX_ARRAY_OBJECT]:["OES_vertex_array_object",!0],[FEATURES$1.TIMER_QUERY]:["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"],[FEATURES$1.INSTANCED_RENDERING]:["ANGLE_instanced_arrays",!0],[FEATURES$1.MULTIPLE_RENDER_TARGETS]:["WEBGL_draw_buffers",!0],[FEATURES$1.ELEMENT_INDEX_UINT32]:["OES_element_index_uint",!0],[FEATURES$1.BLEND_EQUATION_MINMAX]:["EXT_blend_minmax",!0],[FEATURES$1.FLOAT_BLEND]:["EXT_float_blend"],[FEATURES$1.COLOR_ENCODING_SRGB]:["EXT_sRGB",!0],[FEATURES$1.TEXTURE_DEPTH]:["WEBGL_depth_texture",!0],[FEATURES$1.TEXTURE_FLOAT]:["OES_texture_float",!0],[FEATURES$1.TEXTURE_HALF_FLOAT]:["OES_texture_half_float",!0],[FEATURES$1.TEXTURE_FILTER_LINEAR_FLOAT]:["OES_texture_float_linear"],[FEATURES$1.TEXTURE_FILTER_LINEAR_HALF_FLOAT]:["OES_texture_half_float_linear"],[FEATURES$1.TEXTURE_FILTER_ANISOTROPIC]:["EXT_texture_filter_anisotropic"],[FEATURES$1.COLOR_ATTACHMENT_RGBA32F]:[checkFloat32ColorAttachment,"EXT_color_buffer_float"],[FEATURES$1.COLOR_ATTACHMENT_FLOAT]:[!1,"EXT_color_buffer_float"],[FEATURES$1.COLOR_ATTACHMENT_HALF_FLOAT]:["EXT_color_buffer_half_float"],[FEATURES$1.GLSL_FRAG_DATA]:["WEBGL_draw_buffers",!0],[FEATURES$1.GLSL_FRAG_DEPTH]:["EXT_frag_depth",!0],[FEATURES$1.GLSL_DERIVATIVES]:["OES_standard_derivatives",!0],[FEATURES$1.GLSL_TEXTURE_LOD]:["EXT_shader_texture_lod",!0]};const LOG_UNSUPPORTED_FEATURE=2;function hasFeature(t,e){return hasFeatures$1(t,e)}function hasFeatures$1(t,e){return(e=Array.isArray(e)?e:[e]).every((e=>isFeatureSupported(t,e)))}function getFeatures(t){t.luma=t.luma||{},t.luma.caps=t.luma.caps||{};for(const e in WEBGL_FEATURES$1)void 0===t.luma.caps[e]&&(t.luma.caps[e]=isFeatureSupported(t,e));return t.luma.caps}function isFeatureSupported(t,e){return t.luma=t.luma||{},t.luma.caps=t.luma.caps||{},void 0===t.luma.caps[e]&&(t.luma.caps[e]=queryFeature(t,e)),t.luma.caps[e]||log$1.log(LOG_UNSUPPORTED_FEATURE,"Feature: ".concat(e," not supported"))(),t.luma.caps[e]}function queryFeature(t,e){const n=WEBGL_FEATURES$1[e];let i;assert$8(n,e);const r=isWebGL2$1(t)&&n[1]||n[0];if("function"==typeof r)i=r(t);else if(Array.isArray(r)){i=!0;for(const e of r)i=i&&Boolean(t.getExtension(e))}else"string"==typeof r?i=Boolean(t.getExtension(r)):"boolean"==typeof r?i=r:assert$8(!1);return i}const ERR_MULTIPLE_RENDERTARGETS="Multiple render targets not supported";class Framebuffer extends Resource$1{get[Symbol.toStringTag](){return"Framebuffer"}static isSupported(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{colorBufferFloat:n,colorBufferHalfFloat:i}=e;let r=!0;return n&&(r=Boolean(t.getExtension("EXT_color_buffer_float")||t.getExtension("WEBGL_color_buffer_float")||t.getExtension("OES_texture_float"))),i&&(r=r&&Boolean(t.getExtension("EXT_color_buffer_float")||t.getExtension("EXT_color_buffer_half_float"))),r}static getDefaultFramebuffer(t){return t.luma=t.luma||{},t.luma.defaultFramebuffer=t.luma.defaultFramebuffer||new Framebuffer(t,{id:"default-framebuffer",handle:null,attachments:{}}),t.luma.defaultFramebuffer}get MAX_COLOR_ATTACHMENTS(){const t=assertWebGL2Context(this.gl);return t.getParameter(t.MAX_COLOR_ATTACHMENTS)}get MAX_DRAW_BUFFERS(){const t=assertWebGL2Context(this.gl);return t.getParameter(t.MAX_DRAW_BUFFERS)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.width=null,this.height=null,this.attachments={},this.readBuffer=36064,this.drawBuffers=[36064],this.ownResources=[],this.initialize(e),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(t){let{width:e=1,height:n=1,attachments:i=null,color:r=!0,depth:o=!0,stencil:s=!1,check:a=!0,readBuffer:l,drawBuffers:c}=t;if(assert$8(e>=0&&n>=0,"Width and height need to be integers"),this.width=e,this.height=n,i)for(const t in i){const r=i[t];(Array.isArray(r)?r[0]:r).resize({width:e,height:n})}else i=this._createDefaultAttachments(r,o,s,e,n);this.update({clearAttachments:!0,attachments:i,readBuffer:l,drawBuffers:c}),i&&a&&this.checkStatus()}delete(){for(const t of this.ownResources)t.delete();return super.delete(),this}update(t){let{attachments:e={},readBuffer:n,drawBuffers:i,clearAttachments:r=!1,resizeAttachments:o=!0}=t;this.attach(e,{clearAttachments:r,resizeAttachments:o});const{gl:s}=this,a=s.bindFramebuffer(36160,this.handle);return n&&this._setReadBuffer(n),i&&this._setDrawBuffers(i),s.bindFramebuffer(36160,a||null),this}resize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{width:e,height:n}=t;if(null===this.handle)return assert$8(void 0===e&&void 0===n),this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;void 0===e&&(e=this.gl.drawingBufferWidth),void 0===n&&(n=this.gl.drawingBufferHeight),e!==this.width&&n!==this.height&&log$1.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(e,"x").concat(n))();for(const t in this.attachments)this.attachments[t].resize({width:e,height:n});return this.width=e,this.height=n,this}attach(t){let{clearAttachments:e=!1,resizeAttachments:n=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i={};e&&Object.keys(this.attachments).forEach((t=>{i[t]=null})),Object.assign(i,t);const r=this.gl.bindFramebuffer(36160,this.handle);for(const t in i){assert$8(void 0!==t,"Misspelled framebuffer binding point?");const e=Number(t),r=i[e];let o=r;if(o)if(o instanceof Renderbuffer)this._attachRenderbuffer({attachment:e,renderbuffer:o});else if(Array.isArray(r)){const[t,n=0,i=0]=r;o=t,this._attachTexture({attachment:e,texture:t,layer:n,level:i})}else this._attachTexture({attachment:e,texture:o,layer:0,level:0});else this._unattach(e);n&&o&&o.resize({width:this.width,height:this.height})}this.gl.bindFramebuffer(36160,r||null),Object.assign(this.attachments,t),Object.keys(this.attachments).filter((t=>!this.attachments[t])).forEach((t=>{delete this.attachments[t]}))}checkStatus(){const t=this.getStatus();if(36053!==t)throw new Error(_getFrameBufferStatus(t));return this}getStatus(){const{gl:t}=this,e=t.bindFramebuffer(36160,this.handle),n=t.checkFramebufferStatus(36160);return t.bindFramebuffer(36160,e||null),n}clear(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:e,depth:n,stencil:i,drawBuffers:r=[]}=t,o=this.gl.bindFramebuffer(36160,this.handle);return(e||n||i)&&clear(this.gl,{color:e,depth:n,stencil:i}),r.forEach(((t,e)=>{clearBuffer(this.gl,{drawBuffer:e,value:t})})),this.gl.bindFramebuffer(36160,o||null),this}readPixels(){return null}readPixelsToBuffer(){return null}copyToDataUrl(){return null}copyToImage(){return null}copyToTexture(){return null}blit(){return null}invalidate(t){let{attachments:e=[],x:n=0,y:i=0,width:r,height:o}=t;const s=assertWebGL2Context(this.gl),a=s.bindFramebuffer(36008,this.handle);return 0===n&&0===i&&void 0===r&&void 0===o?s.invalidateFramebuffer(36008,e):s.invalidateFramebuffer(36008,e,n,i,r,o),s.bindFramebuffer(36008,a),this}getAttachmentParameter(t,e,n){let i=this._getAttachmentParameterFallback(e);return null===i&&(this.gl.bindFramebuffer(36160,this.handle),i=this.gl.getFramebufferAttachmentParameter(36160,t,e),this.gl.bindFramebuffer(36160,null)),n&&i>1e3&&(i=getKey(this.gl,i)),i}getAttachmentParameters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36064,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.constructor.ATTACHMENT_PARAMETERS||[];const i={};for(const r of n){i[e?getKey(this.gl,r):r]=this.getAttachmentParameter(t,r,e)}return i}getParameters(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const e=Object.keys(this.attachments),n={};for(const i of e){const e=Number(i);n[t?getKey(this.gl,e):e]=this.getAttachmentParameters(e,t)}return n}show(){return"undefined"!=typeof window&&window.open(copyToDataUrl(this),"luma-debug-texture"),this}log(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t>log$1.level||"undefined"==typeof window)return this;e=e||"Framebuffer ".concat(this.id);const n=copyToDataUrl(this,{targetMaxHeight:100});return log$1.image({logLevel:t,message:e,image:n},e)(),this}bind(){let{target:t=36160}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.gl.bindFramebuffer(t,this.handle),this}unbind(){let{target:t=36160}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.gl.bindFramebuffer(t,null),this}_createDefaultAttachments(t,e,n,i,r){let o=null;return t&&(o=o||{},o[36064]=new Texture2D(this.gl,{id:"".concat(this.id,"-color0"),pixels:null,format:6408,type:5121,width:i,height:r,mipmaps:!1,parameters:{10241:9729,10240:9729,10242:33071,10243:33071}}),this.ownResources.push(o[36064])),e&&n?(o=o||{},o[33306]=new Renderbuffer(this.gl,{id:"".concat(this.id,"-depth-stencil"),format:35056,width:i,height:111}),this.ownResources.push(o[33306])):e?(o=o||{},o[36096]=new Renderbuffer(this.gl,{id:"".concat(this.id,"-depth"),format:33189,width:i,height:r}),this.ownResources.push(o[36096])):n&&assert$8(!1),o}_unattach(t){const e=this.attachments[t];e&&(e instanceof Renderbuffer?this.gl.framebufferRenderbuffer(36160,t,36161,null):this.gl.framebufferTexture2D(36160,t,3553,null,0),delete this.attachments[t])}_attachRenderbuffer(t){let{attachment:e=36064,renderbuffer:n}=t;const{gl:i}=this;i.framebufferRenderbuffer(36160,e,36161,n.handle),this.attachments[e]=n}_attachTexture(t){let{attachment:e=36064,texture:n,layer:i,level:r}=t;const{gl:o}=this;switch(o.bindTexture(n.target,n.handle),n.target){case 35866:case 32879:assertWebGL2Context(o).framebufferTextureLayer(36160,e,n.target,r,i);break;case 34067:const t=mapIndexToCubeMapFace(i);o.framebufferTexture2D(36160,e,t,n.handle,r);break;case 3553:o.framebufferTexture2D(36160,e,3553,n.handle,r);break;default:assert$8(!1,"Illegal texture type")}o.bindTexture(n.target,null),this.attachments[e]=n}_setReadBuffer(t){const e=getWebGL2Context(this.gl);e?e.readBuffer(t):assert$8(36064===t||1029===t,ERR_MULTIPLE_RENDERTARGETS),this.readBuffer=t}_setDrawBuffers(t){const{gl:e}=this,n=assertWebGL2Context(e);if(n)n.drawBuffers(t);else{const n=e.getExtension("WEBGL_draw_buffers");n?n.drawBuffersWEBGL(t):assert$8(1===t.length&&(36064===t[0]||1029===t[0]),ERR_MULTIPLE_RENDERTARGETS)}this.drawBuffers=t}_getAttachmentParameterFallback(t){const e=getFeatures(this.gl);switch(t){case 36052:return e.WEBGL2?null:0;case 33298:case 33299:case 33300:case 33301:case 33302:case 33303:return e.WEBGL2?null:8;case 33297:return e.WEBGL2?null:5125;case 33296:return e.WEBGL2||e.EXT_sRGB?null:9729;default:return null}}_createHandle(){return this.gl.createFramebuffer()}_deleteHandle(){this.gl.deleteFramebuffer(this.handle)}_bindHandle(t){return this.gl.bindFramebuffer(36160,t)}}function mapIndexToCubeMapFace(t){return t<34069?t+34069:t}function _getFrameBufferStatus(t){return(Framebuffer.STATUS||{})[t]||"Framebuffer error ".concat(t)}const FRAMEBUFFER_ATTACHMENT_PARAMETERS=[36049,36048,33296,33298,33299,33300,33301,33302,33303];function cloneTextureFrom(t,e){assert$8(t instanceof Texture2D||t instanceof TextureCube||t instanceof Texture3D);const n=t.constructor,{gl:i,width:r,height:o,format:s,type:a,dataFormat:l,border:c,mipmaps:u}=t;return new n(i,Object.assign({width:r,height:o,format:s,type:a,dataFormat:l,border:c,mipmaps:u},e))}function toFramebuffer(t,e){const{gl:n,width:i,height:r,id:o}=t;return new Framebuffer(n,Object.assign({},e,{id:"framebuffer-for-".concat(o),width:i,height:r,attachments:{36064:t}}))}function getShaderName$1(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unnamed";const n=t.match(/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/);return n?n[1]:e}Framebuffer.ATTACHMENT_PARAMETERS=FRAMEBUFFER_ATTACHMENT_PARAMETERS;const GL_FRAGMENT_SHADER=35632,GL_VERTEX_SHADER=35633;function getShaderTypeName(t){switch(t){case GL_FRAGMENT_SHADER:return"fragment";case GL_VERTEX_SHADER:return"vertex";default:return"unknown type"}}function parseGLSLCompilerError(t,e,n,i){const r=t.split(/\r?\n/),o={},s={},a=i||getShaderName$1(e)||"(unnamed)",l="".concat(getShaderTypeName(n)," shader ").concat(a);for(let e=0;e<r.length;e++){const n=r[e];if(n.length<=1)continue;const i=n.split(":"),a=i[0],c=parseInt(i[2],10);if(isNaN(c))throw new Error("GLSL compilation error in ".concat(l,": ").concat(t));"WARNING"!==a?o[c]=n:s[c]=n}const c=addLineNumbers(e);return{shaderName:l,errors:formatErrors(o,c),warnings:formatErrors(s,c)}}function formatErrors(t,e){let n="";for(let i=0;i<e.length;i++){if((t[i+3]||t[i+2]||t[i+1])&&(n+="".concat(e[i],"\n"),t[i+1])){const e=t[i+1],r=e.split(":",3),o=r[0],s=parseInt(r[1],10)||0,a=e.substring(r.join(":").length+1).trim();n+=padLeft("^^^ ".concat(o,": ").concat(a,"\n\n"),s)}}return n}function addLineNumbers(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:": ";const i=t.split(/\r?\n/),r=String(i.length+e-1).length;return i.map(((t,i)=>{const o=String(i+e);return padLeft(o,r-o.length)+n+t}))}function padLeft(t,e){let n="";for(let t=0;t<e;++t)n+=" ";return"".concat(n).concat(t)}function getShaderVersion(t){let e=100;const n=t.match(/[^\s]+/g);if(n.length>=2&&"#version"===n[0]){const t=parseInt(n[1],10);Number.isFinite(t)&&(e=t)}return e}const ERR_SOURCE="Shader: GLSL source code must be a JavaScript string";class Shader extends Resource$1{get[Symbol.toStringTag](){return"Shader"}static getTypeName(t){switch(t){case 35633:return"vertex-shader";case 35632:return"fragment-shader";default:return assert$8(!1),"unknown"}}constructor(t,e){assertWebGLContext(t),assert$8("string"==typeof e.source,ERR_SOURCE);super(t,{id:getShaderName$1(e.source,null)||e.id||uid("unnamed ".concat(Shader.getTypeName(e.shaderType)))}),this.shaderType=e.shaderType,this.source=e.source,this.initialize(e)}initialize(t){let{source:e}=t;const n=getShaderName$1(e,null);n&&(this.id=uid(n)),this._compile(e)}getParameter(t){return this.gl.getShaderParameter(this.handle,t)}toString(){return"".concat(Shader.getTypeName(this.shaderType),":").concat(this.id)}getName(){return getShaderName$1(this.source)||"unnamed-shader"}getSource(){return this.gl.getShaderSource(this.handle)}getTranslatedSource(){const t=this.gl.getExtension("WEBGL_debug_shaders");return t?t.getTranslatedShaderSource(this.handle):"No translated source available. WEBGL_debug_shaders not implemented"}_compile(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.source;t.startsWith("#version ")||(t="#version 100\n".concat(t)),this.source=t,this.gl.shaderSource(this.handle,this.source),this.gl.compileShader(this.handle);if(!this.getParameter(35713)){const t=this.gl.getShaderInfoLog(this.handle),{shaderName:e,warnings:n}=parseGLSLCompilerError(t,this.source,this.shaderType,this.id);throw log$1.warn("GLSL compilation warnings in ".concat(e,"\n").concat(n))(),new Error("GLSL compilation errors in ".concat(e))}}_deleteHandle(){this.gl.deleteShader(this.handle)}_getOptsFromHandle(){return{type:this.getParameter(35663),source:this.getSource()}}}class VertexShader extends Shader{get[Symbol.toStringTag](){return"VertexShader"}constructor(t,e){"string"==typeof e&&(e={source:e}),super(t,Object.assign({},e,{shaderType:35633}))}_createHandle(){return this.gl.createShader(35633)}}class FragmentShader extends Shader{get[Symbol.toStringTag](){return"FragmentShader"}constructor(t,e){"string"==typeof e&&(e={source:e}),super(t,Object.assign({},e,{shaderType:35632}))}_createHandle(){return this.gl.createShader(35632)}}const UNIFORM_SETTERS={5126:getArraySetter.bind(null,"uniform1fv",toFloatArray,1,setVectorUniform),35664:getArraySetter.bind(null,"uniform2fv",toFloatArray,2,setVectorUniform),35665:getArraySetter.bind(null,"uniform3fv",toFloatArray,3,setVectorUniform),35666:getArraySetter.bind(null,"uniform4fv",toFloatArray,4,setVectorUniform),5124:getArraySetter.bind(null,"uniform1iv",toIntArray,1,setVectorUniform),35667:getArraySetter.bind(null,"uniform2iv",toIntArray,2,setVectorUniform),35668:getArraySetter.bind(null,"uniform3iv",toIntArray,3,setVectorUniform),35669:getArraySetter.bind(null,"uniform4iv",toIntArray,4,setVectorUniform),35670:getArraySetter.bind(null,"uniform1iv",toIntArray,1,setVectorUniform),35671:getArraySetter.bind(null,"uniform2iv",toIntArray,2,setVectorUniform),35672:getArraySetter.bind(null,"uniform3iv",toIntArray,3,setVectorUniform),35673:getArraySetter.bind(null,"uniform4iv",toIntArray,4,setVectorUniform),35674:getArraySetter.bind(null,"uniformMatrix2fv",toFloatArray,4,setMatrixUniform),35675:getArraySetter.bind(null,"uniformMatrix3fv",toFloatArray,9,setMatrixUniform),35676:getArraySetter.bind(null,"uniformMatrix4fv",toFloatArray,16,setMatrixUniform),35678:getSamplerSetter,35680:getSamplerSetter,5125:getArraySetter.bind(null,"uniform1uiv",toUIntArray,1,setVectorUniform),36294:getArraySetter.bind(null,"uniform2uiv",toUIntArray,2,setVectorUniform),36295:getArraySetter.bind(null,"uniform3uiv",toUIntArray,3,setVectorUniform),36296:getArraySetter.bind(null,"uniform4uiv",toUIntArray,4,setVectorUniform),35685:getArraySetter.bind(null,"uniformMatrix2x3fv",toFloatArray,6,setMatrixUniform),35686:getArraySetter.bind(null,"uniformMatrix2x4fv",toFloatArray,8,setMatrixUniform),35687:getArraySetter.bind(null,"uniformMatrix3x2fv",toFloatArray,6,setMatrixUniform),35688:getArraySetter.bind(null,"uniformMatrix3x4fv",toFloatArray,12,setMatrixUniform),35689:getArraySetter.bind(null,"uniformMatrix4x2fv",toFloatArray,8,setMatrixUniform),35690:getArraySetter.bind(null,"uniformMatrix4x3fv",toFloatArray,12,setMatrixUniform),35678:getSamplerSetter,35680:getSamplerSetter,35679:getSamplerSetter,35682:getSamplerSetter,36289:getSamplerSetter,36292:getSamplerSetter,36293:getSamplerSetter,36298:getSamplerSetter,36299:getSamplerSetter,36300:getSamplerSetter,36303:getSamplerSetter,36306:getSamplerSetter,36307:getSamplerSetter,36308:getSamplerSetter,36311:getSamplerSetter},FLOAT_ARRAY={},INT_ARRAY={},UINT_ARRAY={},array1=[0];function toTypedArray$1(t,e,n,i){1===e&&"boolean"==typeof t&&(t=t?1:0),Number.isFinite(t)&&(array1[0]=t,t=array1);const r=t.length;if(r%e&&log$1.warn("Uniform size should be multiples of ".concat(e),t)(),t instanceof n)return t;let o=i[r];o||(o=new n(r),i[r]=o);for(let e=0;e<r;e++)o[e]=t[e];return o}function toFloatArray(t,e){return toTypedArray$1(t,e,Float32Array,FLOAT_ARRAY)}function toIntArray(t,e){return toTypedArray$1(t,e,Int32Array,INT_ARRAY)}function toUIntArray(t,e){return toTypedArray$1(t,e,Uint32Array,UINT_ARRAY)}function getUniformSetter(t,e,n){const i=UNIFORM_SETTERS[n.type];if(!i)throw new Error("Unknown GLSL uniform type ".concat(n.type));return i().bind(null,t,e)}function parseUniformName(t){if("]"!==t[t.length-1])return{name:t,length:1,isArray:!1};const e=t.match(/([^[]*)(\[[0-9]+\])?/);if(!e||e.length<2)throw new Error("Failed to parse GLSL uniform name ".concat(t));return{name:e[1],length:e[2]||1,isArray:Boolean(e[2])}}function checkUniformValues(t,e,n){for(const i in t){const r=t[i];if((!n||Boolean(n[i]))&&!checkUniformValue(r))throw e=e?"".concat(e," "):"",new Error("".concat(e," Bad uniform ").concat(i))}return!0}function checkUniformValue(t){return Array.isArray(t)||ArrayBuffer.isView(t)?checkUniformArray(t):!!isFinite(t)||(!0===t||!1===t||(t instanceof Texture$1||(t instanceof Renderbuffer||t instanceof Framebuffer&&Boolean(t.texture))))}function copyUniform(t,e,n){if(Array.isArray(n)||ArrayBuffer.isView(n))if(t[e]){const i=t[e];for(let t=0,e=n.length;t<e;++t)i[t]=n[t]}else t[e]=n.slice();else t[e]=n}function checkUniformArray(t){if(0===t.length)return!1;const e=Math.min(t.length,16);for(let n=0;n<e;++n)if(!Number.isFinite(t[n]))return!1;return!0}function getSamplerSetter(){let t=null;return(e,n,i)=>{const r=t!==i;return r&&(e.uniform1i(n,i),t=i),r}}function getArraySetter(t,e,n,i){let r=null,o=null;return(s,a,l)=>{const c=e(l,n),u=c.length;let h=!1;if(null===r)r=new Float32Array(u),o=u,h=!0;else{assert$8(o===u,"Uniform length cannot change.");for(let t=0;t<u;++t)if(c[t]!==r[t]){h=!0;break}}return h&&(i(s,t,a,c),r.set(c)),h}}function setVectorUniform(t,e,n,i){t[e](n,i)}function setMatrixUniform(t,e,n,i){t[e](n,!1,i)}const GL_BYTE=5120,GL_UNSIGNED_BYTE=5121,GL_SHORT=5122,GL_UNSIGNED_SHORT=5123,GL_POINTS=0,GL_LINES=1,GL_LINE_LOOP=2,GL_LINE_STRIP=3,GL_TRIANGLES=4,GL_TRIANGLE_STRIP=5,GL_TRIANGLE_FAN=6,GL_FLOAT=5126,GL_FLOAT_VEC2=35664,GL_FLOAT_VEC3=35665,GL_FLOAT_VEC4=35666,GL_INT=5124,GL_INT_VEC2=35667,GL_INT_VEC3=35668,GL_INT_VEC4=35669,GL_UNSIGNED_INT=5125,GL_UNSIGNED_INT_VEC2=36294,GL_UNSIGNED_INT_VEC3=36295,GL_UNSIGNED_INT_VEC4=36296,GL_BOOL=35670,GL_BOOL_VEC2=35671,GL_BOOL_VEC3=35672,GL_BOOL_VEC4=35673,GL_FLOAT_MAT2=35674,GL_FLOAT_MAT3=35675,GL_FLOAT_MAT4=35676,GL_FLOAT_MAT2x3=35685,GL_FLOAT_MAT2x4=35686,GL_FLOAT_MAT3x2=35687,GL_FLOAT_MAT3x4=35688,GL_FLOAT_MAT4x2=35689,GL_FLOAT_MAT4x3=35690,COMPOSITE_GL_TYPES={[GL_FLOAT]:[GL_FLOAT,1,"float"],[GL_FLOAT_VEC2]:[GL_FLOAT,2,"vec2"],[GL_FLOAT_VEC3]:[GL_FLOAT,3,"vec3"],[GL_FLOAT_VEC4]:[GL_FLOAT,4,"vec4"],[GL_INT]:[GL_INT,1,"int"],[GL_INT_VEC2]:[GL_INT,2,"ivec2"],[GL_INT_VEC3]:[GL_INT,3,"ivec3"],[GL_INT_VEC4]:[GL_INT,4,"ivec4"],[GL_UNSIGNED_INT]:[GL_UNSIGNED_INT,1,"uint"],[GL_UNSIGNED_INT_VEC2]:[GL_UNSIGNED_INT,2,"uvec2"],[GL_UNSIGNED_INT_VEC3]:[GL_UNSIGNED_INT,3,"uvec3"],[GL_UNSIGNED_INT_VEC4]:[GL_UNSIGNED_INT,4,"uvec4"],[GL_BOOL]:[GL_FLOAT,1,"bool"],[GL_BOOL_VEC2]:[GL_FLOAT,2,"bvec2"],[GL_BOOL_VEC3]:[GL_FLOAT,3,"bvec3"],[GL_BOOL_VEC4]:[GL_FLOAT,4,"bvec4"],[GL_FLOAT_MAT2]:[GL_FLOAT,8,"mat2"],[GL_FLOAT_MAT2x3]:[GL_FLOAT,8,"mat2x3"],[GL_FLOAT_MAT2x4]:[GL_FLOAT,8,"mat2x4"],[GL_FLOAT_MAT3]:[GL_FLOAT,12,"mat3"],[GL_FLOAT_MAT3x2]:[GL_FLOAT,12,"mat3x2"],[GL_FLOAT_MAT3x4]:[GL_FLOAT,12,"mat3x4"],[GL_FLOAT_MAT4]:[GL_FLOAT,16,"mat4"],[GL_FLOAT_MAT4x2]:[GL_FLOAT,16,"mat4x2"],[GL_FLOAT_MAT4x3]:[GL_FLOAT,16,"mat4x3"]};function getPrimitiveDrawMode(t){switch(t){case GL_POINTS:return GL_POINTS;case GL_LINES:case GL_LINE_STRIP:case GL_LINE_LOOP:return GL_LINES;case GL_TRIANGLES:case GL_TRIANGLE_STRIP:case GL_TRIANGLE_FAN:return GL_TRIANGLES;default:return assert$8(!1),0}}function decomposeCompositeGLType(t){const e=COMPOSITE_GL_TYPES[t];if(!e)return null;const[n,i]=e;return{type:n,components:i}}function getCompositeGLType(t,e){switch(t){case GL_BYTE:case GL_UNSIGNED_BYTE:case GL_SHORT:case GL_UNSIGNED_SHORT:t=GL_FLOAT}for(const n in COMPOSITE_GL_TYPES){const[i,r,o]=COMPOSITE_GL_TYPES[n];if(i===t&&r===e)return{glType:n,name:o}}return null}class ProgramConfiguration{constructor(t){this.id=t.id,this.attributeInfos=[],this.attributeInfosByName={},this.attributeInfosByLocation=[],this.varyingInfos=[],this.varyingInfosByName={},Object.seal(this),this._readAttributesFromProgram(t),this._readVaryingsFromProgram(t)}getAttributeInfo(t){const e=Number(t);return Number.isFinite(e)?this.attributeInfosByLocation[e]:this.attributeInfosByName[t]||null}getAttributeLocation(t){const e=this.getAttributeInfo(t);return e?e.location:-1}getAttributeAccessor(t){const e=this.getAttributeInfo(t);return e?e.accessor:null}getVaryingInfo(t){const e=Number(t);return Number.isFinite(e)?this.varyingInfos[e]:this.varyingInfosByName[t]||null}getVaryingIndex(t){const e=this.getVaryingInfo();return e?e.location:-1}getVaryingAccessor(t){const e=this.getVaryingInfo();return e?e.accessor:null}_readAttributesFromProgram(t){const{gl:e}=t,n=e.getProgramParameter(t.handle,35721);for(let i=0;i<n;i++){const{name:n,type:r,size:o}=e.getActiveAttrib(t.handle,i),s=e.getAttribLocation(t.handle,n);s>=0&&this._addAttribute(s,n,r,o)}this.attributeInfos.sort(((t,e)=>t.location-e.location))}_readVaryingsFromProgram(t){const{gl:e}=t;if(!isWebGL2$1(e))return;const n=e.getProgramParameter(t.handle,35971);for(let i=0;i<n;i++){const{name:n,type:r,size:o}=e.getTransformFeedbackVarying(t.handle,i);this._addVarying(i,n,r,o)}this.varyingInfos.sort(((t,e)=>t.location-e.location))}_addAttribute(t,e,n,i){const{type:r,components:o}=decomposeCompositeGLType(n),s={type:r,size:i*o};this._inferProperties(t,e,s);const a={location:t,name:e,accessor:new Accessor(s)};this.attributeInfos.push(a),this.attributeInfosByLocation[t]=a,this.attributeInfosByName[a.name]=a}_inferProperties(t,e,n){/instance/i.test(e)&&(n.divisor=1)}_addVarying(t,e,n,i){const{type:r,components:o}=decomposeCompositeGLType(n),s={location:t,name:e,accessor:new Accessor({type:r,size:i*o})};this.varyingInfos.push(s),this.varyingInfosByName[s.name]=s}}const LOG_PROGRAM_PERF_PRIORITY=4,GL_SEPARATE_ATTRIBS=35981,V6_DEPRECATED_METHODS=["setVertexArray","setAttributes","setBuffers","unsetBuffers","use","getUniformCount","getUniformInfo","getUniformLocation","getUniformValue","getVarying","getFragDataLocation","getAttachedShaders","getAttributeCount","getAttributeLocation","getAttributeInfo"];class Program extends Resource$1{get[Symbol.toStringTag](){return"Program"}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.stubRemovedMethods("Program","v6.0",V6_DEPRECATED_METHODS),this._isCached=!1,this.initialize(e),Object.seal(this),this._setId(e.id)}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{hash:e,vs:n,fs:i,varyings:r,bufferMode:o=GL_SEPARATE_ATTRIBS}=t;return this.hash=e||"",this.vs="string"==typeof n?new VertexShader(this.gl,{id:"".concat(t.id,"-vs"),source:n}):n,this.fs="string"==typeof i?new FragmentShader(this.gl,{id:"".concat(t.id,"-fs"),source:i}):i,assert$8(this.vs instanceof VertexShader),assert$8(this.fs instanceof FragmentShader),this.uniforms={},this._textureUniforms={},r&&r.length>0&&(assertWebGL2Context(this.gl),this.varyings=r,this.gl2.transformFeedbackVaryings(this.handle,r,o)),this._compileAndLink(),this._readUniformLocationsFromLinkedProgram(),this.configuration=new ProgramConfiguration(this),this.setProps(t)}delete(){return this._isCached?this:super.delete(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}setProps(t){return"uniforms"in t&&this.setUniforms(t.uniforms),this}draw(t){let{logPriority:e,drawMode:n=4,vertexCount:i,offset:r=0,start:o,end:s,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}=t;if((m||g)&&(log$1.deprecated("Program.draw({uniforms})","Program.setUniforms(uniforms)")(),this.setUniforms(m||{})),log$1.priority>=e){const t=p?p.id:"default",r="mode=".concat(getKey(this.gl,n)," verts=").concat(i," ")+"instances=".concat(c," indexType=").concat(getKey(this.gl,l)," ")+"isInstanced=".concat(u," isIndexed=").concat(a," ")+"Framebuffer=".concat(t);log$1.log(e,r)()}return assert$8(h),this.gl.useProgram(this.handle),!(!this._areTexturesRenderable()||0===i||u&&0===c)&&(h.bindForDraw(i,c,(()=>{if(void 0!==p&&(f=Object.assign({},f,{framebuffer:p})),d){const t=getPrimitiveDrawMode(n);d.begin(t)}this._bindTextures(),withParameters(this.gl,f,(()=>{a&&u?this.gl2.drawElementsInstanced(n,i,l,r,c):a&&isWebGL2$1(this.gl)&&!isNaN(o)&&!isNaN(s)?this.gl2.drawRangeElements(n,o,s,i,l,r):a?this.gl.drawElements(n,i,l,r):u?this.gl2.drawArraysInstanced(n,r,i,c):this.gl.drawArrays(n,r,i)})),d&&d.end()})),!0)}setUniforms(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};log$1.priority>=2&&checkUniformValues(t,this.id,this._uniformSetters),this.gl.useProgram(this.handle);for(const e in t){const n=t[e],i=this._uniformSetters[e];if(i){let t=n,r=!1;if(t instanceof Framebuffer&&(t=t.texture),t instanceof Texture$1)if(r=this.uniforms[e]!==n,r){void 0===i.textureIndex&&(i.textureIndex=this._textureIndexCounter++);const n=t,{textureIndex:r}=i;n.bind(r),t=r,this._textureUniforms[e]=n}else t=i.textureIndex;else this._textureUniforms[e]&&delete this._textureUniforms[e];(i(t)||r)&&copyUniform(this.uniforms,e,n)}}return this}_areTexturesRenderable(){let t=!0;for(const e in this._textureUniforms){const n=this._textureUniforms[e];n.update(),t=t&&n.loaded}return t}_bindTextures(){for(const t in this._textureUniforms){this._textureUniforms[t].bind(this._uniformSetters[t].textureIndex)}}_createHandle(){return this.gl.createProgram()}_deleteHandle(){this.gl.deleteProgram(this.handle)}_getOptionsFromHandle(t){const e=this.gl.getAttachedShaders(t),n={};for(const t of e){switch(this.gl.getShaderParameter(this.handle,35663)){case 35633:n.vs=new VertexShader({handle:t});break;case 35632:n.fs=new FragmentShader({handle:t})}}return n}_getParameter(t){return this.gl.getProgramParameter(this.handle,t)}_setId(t){if(!t){const t=this._getName();this.id=uid(t)}}_getName(){let t=this.vs.getName()||this.fs.getName();return t=t.replace(/shader/i,""),t=t?"".concat(t,"-program"):"program",t}_compileAndLink(){const{gl:t}=this;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),log$1.time(LOG_PROGRAM_PERF_PRIORITY,"linkProgram for ".concat(this._getName()))(),t.linkProgram(this.handle),log$1.timeEnd(LOG_PROGRAM_PERF_PRIORITY,"linkProgram for ".concat(this._getName()))(),t.debug||log$1.level>0){if(!t.getProgramParameter(this.handle,35714))throw new Error("Error linking: ".concat(t.getProgramInfoLog(this.handle)));t.validateProgram(this.handle);if(!t.getProgramParameter(this.handle,35715))throw new Error("Error validating: ".concat(t.getProgramInfoLog(this.handle)))}}_readUniformLocationsFromLinkedProgram(){const{gl:t}=this;this._uniformSetters={},this._uniformCount=this._getParameter(35718);for(let e=0;e<this._uniformCount;e++){const n=this.gl.getActiveUniform(this.handle,e),{name:i}=parseUniformName(n.name);let r=t.getUniformLocation(this.handle,i);if(this._uniformSetters[i]=getUniformSetter(t,r,n),n.size>1)for(let e=0;e<n.size;e++)r=t.getUniformLocation(this.handle,"".concat(i,"[").concat(e,"]")),this._uniformSetters["".concat(i,"[").concat(e,"]")]=getUniformSetter(t,r,n)}this._textureIndexCounter=0}getActiveUniforms(t,e){return this.gl2.getActiveUniforms(this.handle,t,e)}getUniformBlockIndex(t){return this.gl2.getUniformBlockIndex(this.handle,t)}getActiveUniformBlockParameter(t,e){return this.gl2.getActiveUniformBlockParameter(this.handle,t,e)}uniformBlockBinding(t,e){this.gl2.uniformBlockBinding(this.handle,t,e)}}const GL_QUERY_RESULT=34918,GL_QUERY_RESULT_AVAILABLE=34919,GL_TIME_ELAPSED_EXT=35007,GL_GPU_DISJOINT_EXT=36795,GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976,GL_ANY_SAMPLES_PASSED=35887,GL_ANY_SAMPLES_PASSED_CONSERVATIVE=36202;class Query extends Resource$1{get[Symbol.toStringTag](){return"Query"}static isSupported(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=isWebGL2$1(t),i=hasFeatures$1(t,FEATURES$1.TIMER_QUERY);let r=n||i;for(const t of e)switch(t){case"queries":r=r&&n;break;case"timers":r=r&&i;break;default:assert$8(!1)}return r}constructor(t){super(t,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(GL_TIME_ELAPSED_EXT)}beginOcclusionQuery(){let{conservative:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.begin(t?GL_ANY_SAMPLES_PASSED_CONSERVATIVE:GL_ANY_SAMPLES_PASSED)}beginTransformFeedbackQuery(){return this.begin(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)}begin(t){return this._queryPending||(this.target=t,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 t=this.gl2.getQueryParameter(this.handle,GL_QUERY_RESULT_AVAILABLE);return t&&(this._queryPending=!1),t}isTimerDisjoint(){return this.gl2.getParameter(GL_GPU_DISJOINT_EXT)}getResult(){return this.gl2.getQueryParameter(this.handle,GL_QUERY_RESULT)}getTimerMilliseconds(){return this.getResult()/1e6}createPoll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.POSITIVE_INFINITY;if(this._pollingPromise)return this._pollingPromise;let e=0;return this._pollingPromise=new Promise(((n,i)=>{const r=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):e++>t?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(r)};requestAnimationFrame(r)})),this._pollingPromise}_createHandle(){return Query.isSupported(this.gl)?this.gl2.createQuery():null}_deleteHandle(){this.gl2.deleteQuery(this.handle)}}class TransformFeedback extends Resource$1{get[Symbol.toStringTag](){return"TransformFeedback"}static isSupported(t){return isWebGL2$1(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};assertWebGL2Context(t),super(t,e),this.initialize(e),this.stubRemovedMethods("TransformFeedback","v6.0",["pause","resume"]),Object.seal(this)}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.buffers={},this.unused={},this.configuration=null,this.bindOnUse=!0,isObjectEmpty(this.buffers)||this.bind((()=>this._unbindBuffers())),this.setProps(t),this}setProps(t){"program"in t&&(this.configuration=t.program&&t.program.configuration),"configuration"in t&&(this.configuration=t.configuration),"bindOnUse"in t&&(t=t.bindOnUse),"buffers"in t&&this.setBuffers(t.buffers)}setBuffers(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.bind((()=>{for(const e in t)this.setBuffer(e,t[e])})),this}setBuffer(t,e){const n=this._getVaryingIndex(t),{buffer:i,byteSize:r,byteOffset:o}=this._getBufferParams(e);return n<0?(this.unused[t]=i,log$1.warn("".concat(this.id," unused varying buffer ").concat(t))(),this):(this.buffers[n]=e,this.bindOnUse||this._bindBuffer(n,i,o,r),this)}begin(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.gl.bindTransformFeedback(36386,this.handle),this._bindBuffers(),this.gl.beginTransformFeedback(t),this}end(){return this.gl.endTransformFeedback(),this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null),this}_getBufferParams(t){let e,n,i;return t instanceof Buffer==!1?(i=t.buffer,n=t.byteSize,e=t.byteOffset):i=t,void 0===e&&void 0===n||(e=e||0,n=n||i.byteLength-e),{buffer:i,byteOffset:e,byteSize:n}}_getVaryingInfo(t){return this.configuration&&this.configuration.getVaryingInfo(t)}_getVaryingIndex(t){if(this.configuration)return this.configuration.getVaryingInfo(t).location;const e=Number(t);return Number.isFinite(e)?e:-1}_bindBuffers(){if(this.bindOnUse)for(const t in this.buffers){const{buffer:e,byteSize:n,byteOffset:i}=this._getBufferParams(this.buffers[t]);this._bindBuffer(t,e,i,n)}}_unbindBuffers(){if(this.bindOnUse)for(const t in this.buffers)this._bindBuffer(t,null)}_bindBuffer(t,e){let n=arguments.length>3?arguments[3]:void 0;const i=e&&e.handle;return i&&void 0!==n?this.gl.bindBufferRange(35982,t,i,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n):this.gl.bindBufferBase(35982,t,i),this}_createHandle(){return this.gl.createTransformFeedback()}_deleteHandle(){this.gl.deleteTransformFeedback(this.handle)}_bindHandle(t){this.gl.bindTransformFeedback(36386,this.handle)}}let arrayBuffer=null;function getScratchArrayBuffer(t){return(!arrayBuffer||arrayBuffer.byteLength<t)&&(arrayBuffer=new ArrayBuffer(t)),arrayBuffer}function getScratchArray(t,e){return new t(getScratchArrayBuffer(t.BYTES_PER_ELEMENT*e),0,e)}function fillArray$1(t){let{target:e,source:n,start:i=0,count:r=1}=t;const o=n.length,s=r*o;let a=0;for(let t=i;a<o;a++)e[t++]=n[a];for(;a<s;)a<s-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+s-a),a=s);return e}const ERR_ELEMENTS="elements must be GL.ELEMENT_ARRAY_BUFFER";class VertexArrayObject extends Resource$1{get[Symbol.toStringTag](){return"VertexArrayObject"}static isSupported(t){return!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).constantAttributeZero||(isWebGL2$1(t)||"Chrome"===getBrowser$1())}static getDefaultArray(t){return t.luma=t.luma||{},t.luma.defaultVertexArray||(t.luma.defaultVertexArray=new VertexArrayObject(t,{handle:null,isDefaultArray:!0})),t.luma.defaultVertexArray}static getMaxAttributes(t){return VertexArrayObject.MAX_ATTRIBUTES=VertexArrayObject.MAX_ATTRIBUTES||t.getParameter(34921),VertexArrayObject.MAX_ATTRIBUTES}static setConstant(t,e,n){switch(n.constructor){case Float32Array:VertexArrayObject._setConstantFloatArray(t,e,n);break;case Int32Array:VertexArrayObject._setConstantIntArray(t,e,n);break;case Uint32Array:VertexArrayObject._setConstantUintArray(t,e,n);break;default:assert$8(!1)}}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,Object.assign({},e,{id:e.id||e.program&&e.program.id})),this.buffer=null,this.bufferValue=null,this.isDefaultArray=e.isDefaultArray||!1,this.gl2=t,this.initialize(e),Object.seal(this)}delete(){return super.delete(),this.buffer&&this.buffer.delete(),this}get MAX_ATTRIBUTES(){return VertexArrayObject.getMaxAttributes(this.gl)}initialize(){return this.setProps(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}setProps(t){return this}setElementBuffer(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return assert$8(!t||34963===t.target,ERR_ELEMENTS),this.bind((()=>{this.gl.bindBuffer(34963,t?t.handle:null)})),this}setBuffer(t,e,n){if(34963===e.target)return this.setElementBuffer(e,n);const{size:i,type:r,stride:o,offset:s,normalized:a,integer:l,divisor:c}=n,{gl:u,gl2:h}=this;return t=Number(t),this.bind((()=>{u.bindBuffer(34962,e.handle),l?(assert$8(isWebGL2$1(u)),h.vertexAttribIPointer(t,i,r,o,s)):u.vertexAttribPointer(t,i,r,a,o,s),u.enableVertexAttribArray(t),h.vertexAttribDivisor(t,c||0)})),this}enable(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return!e&&0===t&&!VertexArrayObject.isSupported(this.gl,{constantAttributeZero:!0})||(t=Number(t),this.bind((()=>e?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)))),this}getConstantBuffer(t,e){const n=this._normalizeConstantArrayValue(e),i=n.byteLength*t,r=n.length*t;let o=!this.buffer;if(this.buffer=this.buffer||new Buffer(this.gl,i),o=o||this.buffer.reallocate(i),o=o||!this._compareConstantArrayValues(n,this.bufferValue),o){const t=getScratchArray(e.constructor,r);fillArray$1({target:t,source:n,start:0,count:r}),this.buffer.subData(t),this.bufferValue=e}return this.buffer}_normalizeConstantArrayValue(t){return Array.isArray(t)?new Float32Array(t):t}_compareConstantArrayValues(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let n=0;n<t.length;++n)if(t[n]!==e[n])return!1;return!0}static _setConstantFloatArray(t,e,n){switch(n.length){case 1:t.vertexAttrib1fv(e,n);break;case 2:t.vertexAttrib2fv(e,n);break;case 3:t.vertexAttrib3fv(e,n);break;case 4:t.vertexAttrib4fv(e,n);break;default:assert$8(!1)}}static _setConstantIntArray(t,e,n){switch(assert$8(isWebGL2$1(t)),n.length){case 1:t.vertexAttribI1iv(e,n);break;case 2:t.vertexAttribI2iv(e,n);break;case 3:t.vertexAttribI3iv(e,n);break;case 4:t.vertexAttribI4iv(e,n);break;default:assert$8(!1)}}static _setConstantUintArray(t,e,n){switch(assert$8(isWebGL2$1(t)),n.length){case 1:t.vertexAttribI1uiv(e,n);break;case 2:t.vertexAttribI2uiv(e,n);break;case 3:t.vertexAttribI3uiv(e,n);break;case 4:t.vertexAttribI4uiv(e,n);break;default:assert$8(!1)}}_createHandle(){return this.gl.createVertexArray()}_deleteHandle(t){return this.gl2.deleteVertexArray(t),[this.elements]}_bindHandle(t){this.gl2.bindVertexArray(t)}_getParameter(t,e){let{location:n}=e;return assert$8(Number.isFinite(n)),this.bind((()=>34373===t?this.gl.getVertexAttribOffset(n,t):this.gl.getVertexAttrib(n,t)))}}const ERR_ATTRIBUTE_TYPE="VertexArray: attributes must be Buffers or constants (i.e. typed array)",MULTI_LOCATION_ATTRIBUTE_REGEXP=/^(.+)__LOCATION_([0-9]+)$/,DEPRECATIONS_V6=["setBuffers","setGeneric","clearBindings","setLocations","setGenericValues","setDivisor","enable","disable"];class VertexArray{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.id=e.id||e.program&&e.program.id,this.gl=t,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 VertexArrayObject(t),stubRemovedMethods(this,"VertexArray","v6.0",DEPRECATIONS_V6),this.initialize(e),Object.seal(this)}delete(){this.buffer&&this.buffer.delete(),this.vertexArrayObject.delete()}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.reset(),this.configuration=null,this.bindOnUse=!1,this.setProps(t)}reset(){this.elements=null,this.elementsAccessor=null;const{MAX_ATTRIBUTES:t}=this.vertexArrayObject;return this.values=new Array(t).fill(null),this.accessors=new Array(t).fill(null),this.unused={},this.drawParams=null,this}setProps(t){return"program"in t&&(this.configuration=t.program&&t.program.configuration),"configuration"in t&&(this.configuration=t.configuration),"attributes"in t&&this.setAttributes(t.attributes),"elements"in t&&this.setElementBuffer(t.elements),"bindOnUse"in t&&(t=t.bindOnUse),this}clearDrawParams(){this.drawParams=null}getDrawParams(){return this.drawParams=this.drawParams||this._updateDrawParams(),this.drawParams}setAttributes(t){return Object.assign(this.attributes,t),this.vertexArrayObject.bind((()=>{for(const e in t){this._setAttribute(e,t[e])}this.gl.bindBuffer(34962,null)})),this}setElementBuffer(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.elements=t,this.elementsAccessor=e,this.clearDrawParams(),this.vertexArrayObject.setElementBuffer(t,e),this}setBuffer(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(34963===e.target)return this.setElementBuffer(e,n);const{location:i,accessor:r}=this._resolveLocationAndAccessor(t,e,e.accessor,n);return i>=0&&(this.values[i]=e,this.accessors[i]=r,this.clearDrawParams(),this.vertexArrayObject.setBuffer(i,e,r)),this}setConstant(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{location:i,accessor:r}=this._resolveLocationAndAccessor(t,e,Object.assign({size:e.length},n));return i>=0&&(e=this.vertexArrayObject._normalizeConstantArrayValue(e),this.values[i]=e,this.accessors[i]=r,this.clearDrawParams(),this.vertexArrayObject.enable(i,!1)),this}unbindBuffers(){return this.vertexArrayObject.bind((()=>{this.elements&&this.vertexArrayObject.setElementBuffer(null),this.buffer=this.buffer||new Buffer(this.gl,{accessor:{size:4}});for(let t=0;t<this.vertexArrayObject.MAX_ATTRIBUTES;t++)this.values[t]instanceof Buffer&&(this.gl.disableVertexAttribArray(t),this.gl.bindBuffer(34962,this.buffer.handle),this.gl.vertexAttribPointer(t,1,5126,!1,0,0))})),this}bindBuffers(){return this.vertexArrayObject.bind((()=>{this.elements&&this.setElementBuffer(this.elements);for(let t=0;t<this.vertexArrayObject.MAX_ATTRIBUTES;t++){const e=this.values[t];e instanceof Buffer&&this.setBuffer(t,e)}})),this}bindForDraw(t,e,n){let i;return this.vertexArrayObject.bind((()=>{this._setConstantAttributes(t,e),i=n()})),i}_resolveLocationAndAccessor(t,e,n,i){const r={location:-1,accessor:null},{location:o,name:s}=this._getAttributeIndex(t);if(!Number.isFinite(o)||o<0)return this.unused[t]=e,log$1.once(3,(()=>"unused value ".concat(t," in ").concat(this.id)))(),r;const a=this._getAttributeInfo(s||o);if(!a)return r;const l=Accessor.resolve(a.accessor,this.accessors[o]||{},n,i),{size:c,type:u}=l;return assert$8(Number.isFinite(c)&&Number.isFinite(u)),{location:o,accessor:l}}_getAttributeInfo(t){return this.configuration&&this.configuration.getAttributeInfo(t)}_getAttributeIndex(t){const e=Number(t);if(Number.isFinite(e))return{location:e};const n=MULTI_LOCATION_ATTRIBUTE_REGEXP.exec(t),i=n?n[1]:t,r=n?Number(n[2]):0;return this.configuration?{location:this.configuration.getAttributeLocation(i)+r,name:i}:{location:-1}}_setAttribute(t,e){if(e instanceof Buffer)this.setBuffer(t,e);else if(Array.isArray(e)&&e.length&&e[0]instanceof Buffer){this.setBuffer(t,e[0],e[1])}else if(ArrayBuffer.isView(e)||Array.isArray(e)){this.setConstant(t,e)}else{if(!(e.buffer instanceof Buffer))throw new Error(ERR_ATTRIBUTE_TYPE);this.setBuffer(t,e.buffer,e)}}_setConstantAttributes(t,e){const n=Math.max(0|t,0|e);let i=this.values[0];ArrayBuffer.isView(i)&&this._setConstantAttributeZero(i,n);for(let t=1;t<this.vertexArrayObject.MAX_ATTRIBUTES;t++)i=this.values[t],ArrayBuffer.isView(i)&&this._setConstantAttribute(t,i)}_setConstantAttributeZero(t,e){if(VertexArrayObject.isSupported(this.gl,{constantAttributeZero:!0}))return void this._setConstantAttribute(0,t);const n=this.vertexArrayObject.getConstantBuffer(e,t);this.vertexArrayObject.setBuffer(0,n,this.accessors[0])}_setConstantAttribute(t,e){VertexArrayObject.setConstant(this.gl,t,e)}_updateDrawParams(){const t={isIndexed:!1,isInstanced:!1,indexCount:1/0,vertexCount:1/0,instanceCount:1/0};for(let e=0;e<this.vertexArrayObject.MAX_ATTRIBUTES;e++)this._updateDrawParamsForLocation(t,e);return this.elements&&(t.elementCount=this.elements.getElementCount(this.elements.accessor),t.isIndexed=!0,t.indexType=this.elementsAccessor.type||this.elements.accessor.type,t.indexOffset=this.elementsAccessor.offset||0),t.indexCount===1/0&&(t.indexCount=0),t.vertexCount===1/0&&(t.vertexCount=0),t.instanceCount===1/0&&(t.instanceCount=0),t}_updateDrawParamsForLocation(t,e){const n=this.values[e],i=this.accessors[e];if(!n)return;const{divisor:r}=i,o=r>0;if(t.isInstanced=t.isInstanced||o,n instanceof Buffer){const e=n;if(o){const n=e.getVertexCount(i);t.instanceCount=Math.min(t.instanceCount,n)}else{const n=e.getVertexCount(i);t.vertexCount=Math.min(t.vertexCount,n)}}}setElements(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return log$1.deprecated("setElements","setElementBuffer")(),this.setElementBuffer(t,e)}}function formatArrayValue(t,e){const{maxElts:n=16,size:i=1}=e;let r="[";for(let o=0;o<t.length&&o<n;++o)o>0&&(r+=",".concat(o%i==0?" ":"")),r+=formatValue$1(t[o],e);const o=t.length>n?"...":"]";return"".concat(r).concat(o)}function formatValue$1(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{isInteger:n=!1}=e;if(Array.isArray(t)||ArrayBuffer.isView(t))return formatArrayValue(t,e);if(!Number.isFinite(t))return String(t);if(Math.abs(t)<1e-16)return n?"0":"0.";if(n)return t.toFixed(0);if(Math.abs(t)>100&&Math.abs(t)<1e4)return t.toFixed(0);const i=t.toPrecision(2);return i.indexOf(".0")===i.length-2?i.slice(0,-1):i}function getDebugTableForUniforms(t){let{header:e="Uniforms",program:n,uniforms:i,undefinedOnly:r=!1}=t;assert$8(n);const o=".*Matrix",s={},a=Object.keys(n._uniformSetters).sort();let l=0;for(const t of a)t.match(".*_.*")||t.match(o)||addUniformToTable({table:s,header:e,uniforms:i,uniformName:t,undefinedOnly:r})&&l++;for(const t of a)t.match(o)&&addUniformToTable({table:s,header:e,uniforms:i,uniformName:t,undefinedOnly:r})&&l++;for(const t of a)s[t]||addUniformToTable({table:s,header:e,uniforms:i,uniformName:t,undefinedOnly:r})&&l++;let c=0;const u={};if(!r)for(const t in i){const n=i[t];s[t]||(c++,u[t]={Type:"NOT USED: ".concat(n),[e]:formatValue$1(n)})}return{table:s,count:l,unusedTable:u,unusedCount:c}}function addUniformToTable(t){let{table:e,header:n,uniforms:i,uniformName:r,undefinedOnly:o}=t;const s=i[r],a=isUniformDefined(s);return(!o||!a)&&(e[r]={[n]:a?formatValue$1(s):"N/A","Uniform Type":a?s:"NOT PROVIDED"},!0)}function isUniformDefined(t){return null!=t}function getDebugTableForVertexArray(t){let{vertexArray:e,header:n="Attributes"}=t;if(!e.configuration)return{};const i={};e.elements&&(i.ELEMENT_ARRAY_BUFFER=getDebugTableRow(e,e.elements,null,n));const r=e.values;for(const t in r){const o=e._getAttributeInfo(t);if(o){let s="".concat(t,": ").concat(o.name);const a=e.accessors[o.location];a&&(s="".concat(t,": ").concat(getGLSLDeclaration$1(o.name,a))),i[s]=getDebugTableRow(e,r[t],a,n)}}return i}function getDebugTableRow(t,e,n,i){const{gl:r}=t;if(!e)return{[i]:"null","Format ":"N/A"};let o,s,a,l="NOT PROVIDED",c=1,u=0,h=0;if(n&&(l=n.type,c=n.size,l=String(l).replace("Array",""),o=-1!==l.indexOf("nt")),e instanceof Buffer){const t=e,{data:d,changed:p}=t.getDebugData();let f;if(s=p?"*":"",a=d,h=t.byteLength,u=h/d.BYTES_PER_ELEMENT/c,n){f="".concat(n.divisor>0?"I ":"P "," ").concat(u," (x").concat(c,"=").concat(h," bytes ").concat(getKey(r,l),")")}else o=!0,f="".concat(h," bytes");return{[i]:"".concat(s).concat(formatValue$1(a,{size:c,isInteger:o})),"Format ":f}}return a=e,c=e.length,l=String(e.constructor.name).replace("Array",""),o=-1!==l.indexOf("nt"),{[i]:"".concat(formatValue$1(a,{size:c,isInteger:o})," (constant)"),"Format ":"".concat(c,"x").concat(l," (constant)")}}function getGLSLDeclaration$1(t,e){const{type:n,size:i}=e,r=getCompositeGLType(n,i);return r?"".concat(t," (").concat(r.name,")"):t}function getDebugTableForProgramConfiguration(t){const e={},n="Accessors for ".concat(t.id);for(const i of t.attributeInfos)if(i){const t=getGLSLDeclaration(i);e["in ".concat(t)]={[n]:JSON.stringify(i.accessor)}}for(const i of t.varyingInfos)if(i){const t=getGLSLDeclaration(i);e["out ".concat(t)]={[n]:JSON.stringify(i.accessor)}}return e}function getGLSLDeclaration(t){const{type:e,size:n}=t.accessor,i=getCompositeGLType(e,n);return i?"".concat(i.name," ").concat(t.name):t.name}const isPage=isBrowser$1()&&"undefined"!=typeof document;let statIdCounter=0;class AnimationLoop{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{onCreateContext:e=t=>createGLContext(t),onAddHTML:n=null,onInitialize:i=()=>{},onRender:r=()=>{},onFinalize:o=()=>{},onError:s,gl:a=null,glOptions:l={},debug:c=!1,createFramebuffer:u=!1,autoResizeViewport:h=!0,autoResizeDrawingBuffer:d=!0,stats:p=lumaStats.get("animation-loop-".concat(statIdCounter++))}=t;let{useDevicePixels:f=!0}=t;"useDevicePixelRatio"in t&&(log$1.deprecated("useDevicePixelRatio","useDevicePixels")(),f=t.useDevicePixelRatio),this.props={onCreateContext:e,onAddHTML:n,onInitialize:i,onRender:r,onFinalize:o,onError:s,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(t){return assert$8("string"==typeof t),this.needsRedraw=this.needsRedraw||t,this}setProps(t){return"autoResizeViewport"in t&&(this.autoResizeViewport=t.autoResizeViewport),"autoResizeDrawingBuffer"in t&&(this.autoResizeDrawingBuffer=t.autoResizeDrawingBuffer),"useDevicePixels"in t&&(this.useDevicePixels=t.useDevicePixels),this}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._running)return this;this._running=!0;const e=this._getPageLoadPromise().then((()=>!this._running||this._initialized?null:(this._createWebGLContext(t),this._createFramebuffer(),this._startEventHandling(),this._initializeCallbackData(),this._updateCallbackData(),this._resizeCanvasDrawingBuffer(),this._resizeViewport(),this._gpuTimeQuery=Query.isSupported(this.gl,["timers"])?new Query(this.gl):null,this._initialized=!0,this.onInitialize(this.animationProps)))).then((t=>{this._running&&(this._addCallbackData(t||{}),!1!==t&&this._startLoop())}));return this.props.onError&&e.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(t){return this.timeline=t,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise((t=>{this._resolveNextFrame=t}))),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(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const n=document.getElementById(t);return n?Number(n.value):e}setViewParameters(){return log$1.removed("AnimationLoop.setViewParameters","AnimationLoop.setProps")(),this}_startLoop(){const t=()=>{this._running&&(this.redraw(),this._animationFrameId=this._requestAnimationFrame(t))};this._cancelAnimationFrame(this._animationFrameId),this._animationFrameId=this._requestAnimationFrame(t)}_getPageLoadPromise(){return this._pageLoadPromise||(this._pageLoadPromise=isPage?new Promise(((t,e)=>{isPage&&"complete"===document.readyState?t(document):window.addEventListener("load",(()=>{t(document)}))})):Promise.resolve({})),this._pageLoadPromise}_setDisplay(t){this.display&&(this.display.delete(),this.display.animationLoop=null),t&&(t.animationLoop=this),this.display=t}_cancelAnimationFrame(t){return this.display&&this.display.cancelAnimationFrame?this.display.cancelAnimationFrame(t):cancelAnimationFrame(t)}_requestAnimationFrame(t){if(this._running)return this.display&&this.display.requestAnimationFrame?this.display.requestAnimationFrame(t):requestAnimationFrame$1(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:t,height:e,aspect:n}=this._getSizeAndAspect();t===this.animationProps.width&&e===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=e,this.animationProps.aspect=n,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(t){"object"==typeof t&&null!==t&&(this.animationProps=Object.assign({},this.animationProps,t))}_createWebGLContext(t){if(this.offScreen=t.canvas&&"undefined"!=typeof OffscreenCanvas&&t.canvas instanceof OffscreenCanvas,t=Object.assign({},t,this.props.glOptions),this.gl=this.props.gl?instrumentGLContext(this.props.gl,t):this.onCreateContext(t),!isWebGL(this.gl))throw new Error("AnimationLoop.onCreateContext - illegal context returned");resetParameters(this.gl),this._createInfoDiv()}_createInfoDiv(){if(this.gl.canvas&&this.props.onAddHTML){const t=document.createElement("div");document.body.appendChild(t),t.style.position="relative";const e=document.createElement("div");e.style.position="absolute",e.style.left="10px",e.style.bottom="10px",e.style.width="300px",e.style.background="white",t.appendChild(this.gl.canvas),t.appendChild(e);const n=this.props.onAddHTML(e);n&&(e.innerHTML=n)}}_getSizeAndAspect(){const t=this.gl.drawingBufferWidth,e=this.gl.drawingBufferHeight;let n=1;const{canvas:i}=this.gl;return i&&i.clientHeight?n=i.clientWidth/i.clientHeight:t>0&&e>0&&(n=t/e),{width:t,height:e,aspect:n}}_resizeViewport(){this.autoResizeViewport&&this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.autoResizeDrawingBuffer&&resizeGLContext(this.gl,{useDevicePixels:this.useDevicePixels})}_createFramebuffer(){this.props.createFramebuffer&&(this.framebuffer=new Framebuffer(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:t}=this.gl;t&&(t.addEventListener("mousemove",this._onMousemove),t.addEventListener("mouseleave",this._onMouseleave))}_onMousemove(t){this.animationProps._mousePosition=[t.offsetX,t.offsetY]}_onMouseleave(t){this.animationProps._mousePosition=null}}const VERTEX_SHADER$1="vs",FRAGMENT_SHADER$1="fs";function assert$7(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}const TYPE_DEFINITIONS$1={number:{validate:(t,e)=>Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)},array:{validate:(t,e)=>Array.isArray(t)||ArrayBuffer.isView(t)}};function parsePropTypes$1(t){const e={};for(const n in t){const i=parsePropType$1(t[n]);e[n]=i}return e}function parsePropType$1(t){let e=getTypeOf$1(t);return"object"===e?t?"type"in t?Object.assign({},t,TYPE_DEFINITIONS$1[t.type]):"value"in t?(e=getTypeOf$1(t.value),Object.assign({type:e},t,TYPE_DEFINITIONS$1[e])):{type:"object",value:t}:{type:"object",value:null}:Object.assign({type:e,value:t},TYPE_DEFINITIONS$1[e])}function getTypeOf$1(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}const VERTEX_SHADER="vs",FRAGMENT_SHADER="fs";class ShaderModule{constructor(t){let{name:e,vs:n,fs:i,dependencies:r=[],uniforms:o,getUniforms:s,deprecations:a=[],defines:l={},inject:c={},vertexShader:u,fragmentShader:h}=t;assert$7("string"==typeof e),this.name=e,this.vs=n||u,this.fs=i||h,this.getModuleUniforms=s,this.dependencies=r,this.deprecations=this._parseDeprecationDefinitions(a),this.defines=l,this.injections=normalizeInjections(c),o&&(this.uniforms=parsePropTypes$1(o))}getModuleSource(t){let e;switch(t){case VERTEX_SHADER:e=this.vs||"";break;case FRAGMENT_SHADER:e=this.fs||"";break;default:assert$7(!1)}return"#define MODULE_".concat(this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),"\n").concat(e,"// END MODULE_").concat(this.name,"\n\n")}getUniforms(t,e){return this.getModuleUniforms?this.getModuleUniforms(t,e):this.uniforms?this._defaultGetUniforms(t):{}}getDefines(){return this.defines}checkDeprecations(t,e){this.deprecations.forEach((n=>{n.regex.test(t)&&(n.deprecated?e.deprecated(n.old,n.new)():e.removed(n.old,n.new)())}))}_parseDeprecationDefinitions(t){return t.forEach((t=>{if("function"===t.type)t.regex=new RegExp("\\b".concat(t.old,"\\("));else t.regex=new RegExp("".concat(t.type," ").concat(t.old,";"))})),t}_defaultGetUniforms(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={},n=this.uniforms;for(const i in n){const r=n[i];i in t&&!r.private?(r.validate&&assert$7(r.validate(t[i],r),"".concat(this.name,": invalid ").concat(i)),e[i]=t[i]):e[i]=r.value}return e}}function normalizeInjections(t){const e={vs:{},fs:{}};for(const n in t){let i=t[n];"string"==typeof i&&(i={order:0,injection:i}),e[n.slice(0,2)][n]=i}return e}function resolveModules(t){return getShaderDependencies(instantiateModules(t))}function getShaderDependencies(t){const e={},n={};return getDependencyGraph({modules:t,level:0,moduleMap:e,moduleDepth:n}),Object.keys(n).sort(((t,e)=>n[e]-n[t])).map((t=>e[t]))}function getDependencyGraph(t){let{modules:e,level:n,moduleMap:i,moduleDepth:r}=t;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(const t of e)i[t.name]=t,(void 0===r[t.name]||r[t.name]<n)&&(r[t.name]=n);for(const t of e)t.dependencies&&getDependencyGraph({modules:t.dependencies,level:n+1,moduleMap:i,moduleDepth:r})}function instantiateModules(t,e){return t.map((t=>(t instanceof ShaderModule||(assert$7("string"!=typeof t,"Shader module use by name is deprecated. Import shader module '".concat(t,"' and use it directly.")),assert$7(t.name,"shader module has no name"),(t=new ShaderModule(t)).dependencies=instantiateModules(t.dependencies)),t)))}function isOldIE(){const t="undefined"!=typeof window&&window.navigator||{},e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).userAgent||t.userAgent||"",n=-1!==e.indexOf("MSIE "),i=-1!==e.indexOf("Trident/");return n||i}const GL_VENDOR=7936,GL_RENDERER=7937,GL_VERSION=7938,GL_SHADING_LANGUAGE_VERSION=35724,WEBGL_FEATURES={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]},FEATURES={};function isWebGL2(t){return"undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||Boolean(t&&2===t._version)}function getContextInfo(t){const e=t.getExtension("WEBGL_debug_renderer_info"),n=t.getParameter(e&&e.UNMASKED_VENDOR_WEBGL||GL_VENDOR),i=t.getParameter(e&&e.UNMASKED_RENDERER_WEBGL||GL_RENDERER);return{gpuVendor:identifyGPUVendor(n,i),vendor:n,renderer:i,version:t.getParameter(GL_VERSION),shadingLanguageVersion:t.getParameter(GL_SHADING_LANGUAGE_VERSION)}}function identifyGPUVendor(t,e){return t.match(/NVIDIA/i)||e.match(/NVIDIA/i)?"NVIDIA":t.match(/INTEL/i)||e.match(/INTEL/i)?"INTEL":t.match(/AMD/i)||e.match(/AMD/i)||t.match(/ATI/i)||e.match(/ATI/i)?"AMD":"UNKNOWN GPU"}Object.keys(WEBGL_FEATURES).forEach((t=>{FEATURES[t]=t}));const compiledGlslExtensions={};function canCompileGLGSExtension(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=WEBGL_FEATURES[e];if(assert$7(i,e),!isOldIE(n))return!0;if(e in compiledGlslExtensions)return compiledGlslExtensions[e];const r=n.behavior||"enable",o="#extension GL_".concat(i[0]," : ").concat(r,"\nvoid main(void) {}"),s=t.createShader(35633);t.shaderSource(s,o),t.compileShader(s);const a=t.getShaderParameter(s,35713);return t.deleteShader(s),compiledGlslExtensions[e]=a,a}function getFeature(t,e){const n=WEBGL_FEATURES[e];assert$7(n,e);const i=isWebGL2(t)&&n[1]||n[0],r="string"==typeof i?Boolean(t.getExtension(i)):i;return assert$7(!1===r||!0===r),r}function hasFeatures(t,e){return(e=Array.isArray(e)?e:[e]).every((e=>getFeature(t,e)))}function getPlatformShaderDefines(t){switch(getContextInfo(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"}}function getVersionDefines(t,e,n){let i="#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 hasFeatures(t,FEATURES.GLSL_FRAG_DEPTH)&&(i+="\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"),hasFeatures(t,FEATURES.GLSL_DERIVATIVES)&&canCompileGLGSExtension(t,FEATURES.GLSL_DERIVATIVES)&&(i+="\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"),hasFeatures(t,FEATURES.GLSL_FRAG_DATA)&&canCompileGLGSExtension(t,FEATURES.GLSL_FRAG_DATA,{behavior:"require"})&&(i+="\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"),hasFeatures(t,FEATURES.GLSL_TEXTURE_LOD)&&(i+="// 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"),i}const MODULE_INJECTORS_VS="#ifdef MODULE_LOGDEPTH\n  logdepth_adjustPosition(gl_Position);\n#endif\n",MODULE_INJECTORS_FS="#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",MODULE_INJECTORS={[VERTEX_SHADER$1]:MODULE_INJECTORS_VS,[FRAGMENT_SHADER$1]:MODULE_INJECTORS_FS},DECLARATION_INJECT_MARKER="__LUMA_INJECT_DECLARATIONS__",REGEX_START_OF_MAIN$1=/void\s+main\s*\([^)]*\)\s*\{\n?/,REGEX_END_OF_MAIN=/}\n?[^{}]*$/,fragments=[];function injectShader(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=e===VERTEX_SHADER$1;for(const e in n){const i=n[e];i.sort(((t,e)=>t.order-e.order)),fragments.length=i.length;for(let t=0,e=i.length;t<e;++t)fragments[t]=i[t].injection;const o="".concat(fragments.join("\n"),"\n");switch(e){case"vs:#decl":r&&(t=t.replace(DECLARATION_INJECT_MARKER,o));break;case"vs:#main-start":r&&(t=t.replace(REGEX_START_OF_MAIN$1,(t=>t+o)));break;case"vs:#main-end":r&&(t=t.replace(REGEX_END_OF_MAIN,(t=>o+t)));break;case"fs:#decl":r||(t=t.replace(DECLARATION_INJECT_MARKER,o));break;case"fs:#main-start":r||(t=t.replace(REGEX_START_OF_MAIN$1,(t=>t+o)));break;case"fs:#main-end":r||(t=t.replace(REGEX_END_OF_MAIN,(t=>o+t)));break;default:t=t.replace(e,(t=>t+o))}}return t=t.replace(DECLARATION_INJECT_MARKER,""),i&&(t=t.replace(/\}\s*$/,(t=>t+MODULE_INJECTORS[e]))),t}function combineInjects(t){const e={};return assert$7(Array.isArray(t)&&t.length>1),t.forEach((t=>{for(const n in t)e[n]=e[n]?"".concat(e[n],"\n").concat(t[n]):t[n]})),e}function testVariable(t){return new RegExp("\\b".concat(t,"[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)"),"g")}const ES300_REPLACEMENTS=[[/^(#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("]],ES300_VERTEX_REPLACEMENTS=[...ES300_REPLACEMENTS,[testVariable("attribute"),"in $1"],[testVariable("varying"),"out $1"]],ES300_FRAGMENT_REPLACEMENTS=[...ES300_REPLACEMENTS,[testVariable("varying"),"in $1"]],ES100_REPLACEMENTS=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],ES100_VERTEX_REPLACEMENTS=[...ES100_REPLACEMENTS,[testVariable("in"),"attribute $1"],[testVariable("out"),"varying $1"]],ES100_FRAGMENT_REPLACEMENTS=[...ES100_REPLACEMENTS,[testVariable("in"),"varying $1"]],ES100_FRAGMENT_OUTPUT_NAME="gl_FragColor",ES300_FRAGMENT_OUTPUT_REGEX=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,REGEX_START_OF_MAIN=/void\s+main\s*\([^)]*\)\s*\{\n?/;function transpileShader(t,e,n){switch(e){case 300:return n?convertShader(t,ES300_VERTEX_REPLACEMENTS):convertFragmentShaderTo300(t);case 100:return n?convertShader(t,ES100_VERTEX_REPLACEMENTS):convertFragmentShaderTo100(t);default:throw new Error("unknown GLSL version ".concat(e))}}function convertShader(t,e){for(const[n,i]of e)t=t.replace(n,i);return t}function convertFragmentShaderTo300(t){const e=(t=convertShader(t,ES300_FRAGMENT_REPLACEMENTS)).match(ES300_FRAGMENT_OUTPUT_REGEX);if(e){const n=e[1];t=t.replace(new RegExp("\\b".concat(ES100_FRAGMENT_OUTPUT_NAME,"\\b"),"g"),n)}else{const e="fragmentColor";t=t.replace(REGEX_START_OF_MAIN,(t=>"out vec4 ".concat(e,";\n").concat(t))).replace(new RegExp("\\b".concat(ES100_FRAGMENT_OUTPUT_NAME,"\\b"),"g"),e)}return t}function convertFragmentShaderTo100(t){const e=(t=convertShader(t,ES100_FRAGMENT_REPLACEMENTS)).match(ES300_FRAGMENT_OUTPUT_REGEX);if(e){const n=e[1];t=t.replace(ES300_FRAGMENT_OUTPUT_REGEX,"").replace(new RegExp("\\b".concat(n,"\\b"),"g"),ES100_FRAGMENT_OUTPUT_NAME)}return t}const INJECT_SHADER_DECLARATIONS="\n\n".concat(DECLARATION_INJECT_MARKER,"\n\n"),SHADER_TYPE={[VERTEX_SHADER$1]:"vertex",[FRAGMENT_SHADER$1]:"fragment"},FRAGMENT_SHADER_PROLOGUE="precision highp float;\n\n";function assembleShaders(t,e){const{vs:n,fs:i}=e,r=resolveModules(e.modules||[]);return{gl:t,vs:assembleShader(t,Object.assign({},e,{source:n,type:VERTEX_SHADER$1,modules:r})),fs:assembleShader(t,Object.assign({},e,{source:i,type:FRAGMENT_SHADER$1,modules:r})),getUniforms:assembleGetUniforms(r)}}function assembleShader(t,e){let{id:n,source:i,type:r,modules:o,defines:s={},hookFunctions:a=[],inject:l={},transpileToGLSL100:c=!1,prologue:u=!0,log:h}=e;assert$7("string"==typeof i,"shader source must be a string");const d=r===VERTEX_SHADER$1,p=i.split("\n");let f=100,m="",g=i;0===p[0].indexOf("#version ")?(f=300,m=p[0],g=p.slice(1).join("\n")):m="#version ".concat(f);const _={};o.forEach((t=>{Object.assign(_,t.getDefines())})),Object.assign(_,s);let y=u?"".concat(m,"\n").concat(getShaderName({id:n,source:i,type:r}),"\n").concat(getShaderType({type:r}),"\n").concat(getPlatformShaderDefines(t),"\n").concat(getVersionDefines(t),"\n").concat(getApplicationDefines(_),"\n").concat(d?"":FRAGMENT_SHADER_PROLOGUE,"\n"):"".concat(m,"\n");const v=normalizeHookFunctions(a),x={},b={},T={};for(const t in l){const e="string"==typeof l[t]?{injection:l[t],order:0}:l[t],n=t.match(/^(v|f)s:(#)?([\w-]+)$/);if(n){n[2]?"decl"===n[3]?b[t]=[e]:T[t]=[e]:x[t]=[e]}else T[t]=[e]}for(const t of o){h&&t.checkDeprecations(g,h);y+=t.getModuleSource(r,f);const e=t.injections[r];for(const t in e){const n=t.match(/^(v|f)s:#([\w-]+)$/);if(n){const i="decl"===n[2]?b:T;i[t]=i[t]||[],i[t].push(e[t])}else x[t]=x[t]||[],x[t].push(e[t])}}return y+=INJECT_SHADER_DECLARATIONS,y=injectShader(y,r,b),y+=getHookFunctions(v[r],x),y+=g,y=injectShader(y,r,T),y=transpileShader(y,c?100:f,d),y}function assembleGetUniforms(t){return function(e){const n={};for(const i of t){const t=i.getUniforms(e,n);Object.assign(n,t)}return n}}function getShaderType(t){let{type:e}=t;return"\n#define SHADER_TYPE_".concat(SHADER_TYPE[e].toUpperCase(),"\n")}function getShaderName(t){let{id:e,source:n,type:i}=t;return e&&"string"==typeof e&&-1===n.indexOf("SHADER_NAME")?"\n#define SHADER_NAME ".concat(e,"_").concat(SHADER_TYPE[i],"\n\n"):""}function getApplicationDefines(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=0,n="";for(const i in t){0===e&&(n+="\n// APPLICATION DEFINES\n"),e++;const r=t[i];(r||Number.isFinite(r))&&(n+="#define ".concat(i.toUpperCase()," ").concat(t[i],"\n"))}return 0===e&&(n+="\n"),n}function getHookFunctions(t,e){let n="";for(const i in t){const r=t[i];if(n+="void ".concat(r.signature," {\n"),r.header&&(n+="  ".concat(r.header)),e[i]){const t=e[i];t.sort(((t,e)=>t.order-e.order));for(const e of t)n+="  ".concat(e.injection,"\n")}r.footer&&(n+="  ".concat(r.footer)),n+="}\n"}return n}function normalizeHookFunctions(t){const e={vs:{},fs:{}};return t.forEach((t=>{let n;"string"!=typeof t?(n=t,t=n.hook):n={},t=t.trim();const[i,r]=t.split(":"),o=t.replace(/\(.+/,"");e[i][o]=Object.assign(n,{signature:r})})),e}const FS100="void main() {gl_FragColor = vec4(0);}",FS_GLES="out vec4 transform_output;\nvoid main() {\n  transform_output = vec4(0);\n}",FS300="#version 300 es\n".concat(FS_GLES);function getQualifierDetails(t,e){e=Array.isArray(e)?e:[e];const n=t.replace(/^\s+/,"").split(/\s+/),[i,r,o]=n;if(!e.includes(i)||!r||!o)return null;return{qualifier:i,type:r,name:o.split(";")[0]}}function getPassthroughFS(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{version:e=100,input:n,inputType:i,output:r}=t;if(!n)return 300===e?FS300:e>300?"#version ".concat(e,"\n").concat(FS_GLES):FS100;const o=convertToVec4(n,i);return e>=300?"#version ".concat(e," ").concat(300===e?"es":"","\nin ").concat(i," ").concat(n,";\nout vec4 ").concat(r,";\nvoid main() {\n  ").concat(r," = ").concat(o,";\n}"):"varying ".concat(i," ").concat(n,";\nvoid main() {\n  gl_FragColor = ").concat(o,";\n}")}function typeToChannelSuffix(t){switch(t){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:return assert$7(!1),null}}function typeToChannelCount(t){switch(t){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:return assert$7(!1),null}}function convertToVec4(t,e){switch(e){case"float":return"vec4(".concat(t,", 0.0, 0.0, 1.0)");case"vec2":return"vec4(".concat(t,", 0.0, 1.0)");case"vec3":return"vec4(".concat(t,", 1.0)");case"vec4":return t;default:return assert$7(!1),null}}const fp32shader="#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",fp32={name:"fp32",vs:fp32shader,fs:null};function assert$6(t,e){if(!t)throw new Error("math.gl assertion ".concat(e))}const RADIANS_TO_DEGREES$1=1/Math.PI*180,DEGREES_TO_RADIANS$4=1/180*Math.PI,config={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0};function formatValue(t,{precision:e=config.precision}={}){return t=round(t),"".concat(parseFloat(t.toPrecision(e)))}function isArray$1(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function toRadians(t){return radians(t)}function toDegrees(t){return degrees(t)}function radians(t,e){return map(t,(t=>t*DEGREES_TO_RADIANS$4),e)}function degrees(t,e){return map(t,(t=>t*RADIANS_TO_DEGREES$1),e)}function clamp$2(t,e,n){return map(t,(t=>Math.max(e,Math.min(n,t))))}function lerp$4(t,e,n){return isArray$1(t)?t.map(((t,i)=>lerp$4(t,e[i],n))):n*e+(1-n)*t}function equals$1(t,e,n){const i=config.EPSILON;n&&(config.EPSILON=n);try{if(t===e)return!0;if(isArray$1(t)&&isArray$1(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;++n)if(!equals$1(t[n],e[n]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):"number"==typeof t&&"number"==typeof e&&Math.abs(t-e)<=config.EPSILON*Math.max(1,Math.abs(t),Math.abs(e))}finally{config.EPSILON=i}}function round(t){return Math.round(t/config.EPSILON)*config.EPSILON}function duplicateArray(t){return t.clone?t.clone():new Array(t.length)}function map(t,e,n){if(isArray$1(t)){const i=t;n=n||duplicateArray(i);for(let r=0;r<n.length&&r<i.length;++r)n[r]=e(t[r],r,n);return n}return e(t)}function _extendableBuiltin(t){function e(){var e=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(e,Object.getPrototypeOf(this)),e}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}class MathArray extends(_extendableBuiltin(Array)){clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+e];return this.check()}toArray(t=[],e=0){for(let n=0;n<this.ELEMENTS;++n)t[e+n]=this[n];return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:isArray$1(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(config)}formatString(t){let e="";for(let n=0;n<this.ELEMENTS;++n)e+=(n>0?", ":"")+formatValue(this[n],t);return"".concat(t.printTypes?this.constructor.name:"","[").concat(e,"]")}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!equals$1(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,n){if(void 0===n)return this.lerp(this,t,e);for(let i=0;i<this.ELEMENTS;++i){const r=t[i];this[i]=r+n*(e[i]-r)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),e[n]);return this.check()}add(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]+=e[t];return this.check()}subtract(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]-=e[t];return this.check()}scale(t){if("number"==typeof t)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}check(){if(config.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t),e);return this.check()}get elements(){return this}}function validateVector(t,e){if(t.length!==e)return!1;for(let e=0;e<t.length;++e)if(!Number.isFinite(t[e]))return!1;return!0}function checkNumber(t){if(!Number.isFinite(t))throw new Error("Invalid number ".concat(t));return t}function checkVector(t,e,n=""){if(config.debug&&!validateVector(t,e))throw new Error("math.gl: ".concat(n," some fields set to invalid numbers'"));return t}class Vector extends MathArray{get x(){return this[0]}set x(t){this[0]=checkNumber(t)}get y(){return this[1]}set y(t){this[1]=checkNumber(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let n=0;n<this.ELEMENTS;++n){const i=this[n]-t[n];e+=i*i}return checkNumber(e)}dot(t){let e=0;for(let n=0;n<this.ELEMENTS;++n)e+=this[n]*t[n];return checkNumber(e)}normalize(){const t=this.magnitude();if(0!==t)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e[t];return this.check()}divide(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e[t];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return assert$6(t>=0&&t<this.ELEMENTS,"index is out of range"),checkNumber(this[t])}setComponent(t,e){return assert$6(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}}var EPSILON$1=1e-6,ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,vec;function create$4(){var t=new ARRAY_TYPE(2);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function add$3(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}function negate$1(t,e){return t[0]=-e[0],t[1]=-e[1],t}function lerp$3(t,e,n,i){var r=e[0],o=e[1];return t[0]=r+i*(n[0]-r),t[1]=o+i*(n[1]-o),t}function transformMat2(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r,t[1]=n[1]*i+n[3]*r,t}function transformMat2d(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r+n[4],t[1]=n[1]*i+n[3]*r+n[5],t}function transformMat3$1(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[3]*r+n[6],t[1]=n[1]*i+n[4]*r+n[7],t}function transformMat4$2(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[4]*r+n[12],t[1]=n[1]*i+n[5]*r+n[13],t}function vec2_transformMat4AsVector(t,e,n){const i=e[0],r=e[1],o=n[3]*i+n[7]*r||1;return t[0]=(n[0]*i+n[4]*r)/o,t[1]=(n[1]*i+n[5]*r)/o,t}function vec3_transformMat4AsVector(t,e,n){const i=e[0],r=e[1],o=e[2],s=n[3]*i+n[7]*r+n[11]*o||1;return t[0]=(n[0]*i+n[4]*r+n[8]*o)/s,t[1]=(n[1]*i+n[5]*r+n[9]*o)/s,t[2]=(n[2]*i+n[6]*r+n[10]*o)/s,t}function vec3_transformMat2(t,e,n){const i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r,t[1]=n[1]*i+n[3]*r,t[2]=e[2],t}function vec4_transformMat2(t,e,n){const i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r,t[1]=n[1]*i+n[3]*r,t[2]=e[2],t[3]=e[3],t}function vec4_transformMat3(t,e,n){const i=e[0],r=e[1],o=e[2];return t[0]=n[0]*i+n[3]*r+n[6]*o,t[1]=n[1]*i+n[4]*r+n[7]*o,t[2]=n[2]*i+n[5]*r+n[8]*o,t[3]=e[3],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),vec=create$4();let Vector2$1=class extends Vector{constructor(t=0,e=0){super(2),isArray$1(t)&&1===arguments.length?this.copy(t):(config.debug&&(checkNumber(t),checkNumber(e)),this[0]=t,this[1]=e)}set(t,e){return this[0]=t,this[1]=e,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this.check()}fromObject(t){return config.debug&&(checkNumber(t.x),checkNumber(t.y)),this[0]=t.x,this[1]=t.y,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return transformMat4$2(this,this,t),this.check()}transformAsVector(t){return vec2_transformMat4AsVector(this,this,t),this.check()}transformByMatrix3(t){return transformMat3$1(this,this,t),this.check()}transformByMatrix2x3(t){return transformMat2d(this,this,t),this.check()}transformByMatrix2(t){return transformMat2(this,this,t),this.check()}};function create$3(){var t=new ARRAY_TYPE(3);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function length$2(t){return Math.hypot(t[0],t[1],t[2])}function fromValues(t,e,n){var i=new ARRAY_TYPE(3);return i[0]=t,i[1]=e,i[2]=n,i}function subtract(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function negate(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function normalize$4(t,e){var n=e[0],i=e[1],r=e[2],o=n*n+i*i+r*r;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function dot$2(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function cross(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[0],a=n[1],l=n[2];return t[0]=r*l-o*a,t[1]=o*s-i*l,t[2]=i*a-r*s,t}function transformMat4$1(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[3]*i+n[7]*r+n[11]*o+n[15];return t[0]=(n[0]*i+n[4]*r+n[8]*o+n[12])/(s=s||1),t[1]=(n[1]*i+n[5]*r+n[9]*o+n[13])/s,t[2]=(n[2]*i+n[6]*r+n[10]*o+n[14])/s,t}function transformMat3(t,e,n){var i=e[0],r=e[1],o=e[2];return t[0]=i*n[0]+r*n[3]+o*n[6],t[1]=i*n[1]+r*n[4]+o*n[7],t[2]=i*n[2]+r*n[5]+o*n[8],t}function transformQuat$1(t,e,n){var i=n[0],r=n[1],o=n[2],s=e[0],a=e[1],l=e[2],c=r*l-o*a,u=o*s-i*l,h=i*a-r*s,d=r*h-o*u,p=o*c-i*h,f=i*u-r*c,m=2*n[3];return u*=m,h*=m,p*=2,f*=2,t[0]=s+(c*=m)+(d*=2),t[1]=a+u+p,t[2]=l+h+f,t}function rotateX$2(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[0],o[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),o[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function rotateY$2(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),o[1]=r[1],o[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function rotateZ$2(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),o[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),o[2]=r[2],t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function angle(t,e){var n=t[0],i=t[1],r=t[2],o=e[0],s=e[1],a=e[2],l=Math.sqrt(n*n+i*i+r*r)*Math.sqrt(o*o+s*s+a*a),c=l&&dot$2(t,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))}var sub=subtract,len=length$2;!function(){var t=create$3()}();const ORIGIN=[0,0,0];let ZERO$3,Vector3$1=class t extends Vector{static get ZERO(){return ZERO$3||(ZERO$3=new t(0,0,0),Object.freeze(ZERO$3)),ZERO$3}constructor(t=0,e=0,n=0){super(-0,-0,-0),1===arguments.length&&isArray$1(t)?this.copy(t):(config.debug&&(checkNumber(t),checkNumber(e),checkNumber(n)),this[0]=t,this[1]=e,this[2]=n)}set(t,e,n){return this[0]=t,this[1]=e,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return config.debug&&(checkNumber(t.x),checkNumber(t.y),checkNumber(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=checkNumber(t)}angle(t){return angle(this,t)}cross(t){return cross(this,this,t),this.check()}rotateX({radians:t,origin:e=ORIGIN}){return rotateX$2(this,this,e,t),this.check()}rotateY({radians:t,origin:e=ORIGIN}){return rotateY$2(this,this,e,t),this.check()}rotateZ({radians:t,origin:e=ORIGIN}){return rotateZ$2(this,this,e,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return transformMat4$1(this,this,t),this.check()}transformAsVector(t){return vec3_transformMat4AsVector(this,this,t),this.check()}transformByMatrix3(t){return transformMat3(this,this,t),this.check()}transformByMatrix2(t){return vec3_transformMat2(this,this,t),this.check()}transformByQuaternion(t){return transformQuat$1(this,this,t),this.check()}},ZERO$2,Vector4$1=class t extends Vector{static get ZERO(){return ZERO$2||(ZERO$2=new t(0,0,0,0),Object.freeze(ZERO$2)),ZERO$2}constructor(t=0,e=0,n=0,i=0){super(-0,-0,-0,-0),isArray$1(t)&&1===arguments.length?this.copy(t):(config.debug&&(checkNumber(t),checkNumber(e),checkNumber(n),checkNumber(i)),this[0]=t,this[1]=e,this[2]=n,this[3]=i)}set(t,e,n,i){return this[0]=t,this[1]=e,this[2]=n,this[3]=i,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return config.debug&&(checkNumber(t.x),checkNumber(t.y),checkNumber(t.z),checkNumber(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=checkNumber(t)}get w(){return this[3]}set w(t){this[3]=checkNumber(t)}transform(t){return transformMat4$1(this,this,t),this.check()}transformByMatrix3(t){return vec4_transformMat3(this,this,t),this.check()}transformByMatrix2(t){return vec4_transformMat2(this,this,t),this.check()}transformByQuaternion(t){return transformQuat$1(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};class Matrix extends MathArray{toString(){let t="[";if(config.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let n=0;n<this.RANK;++n)t+=" ".concat(this[n*this.RANK+e])}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=" ".concat(this[e])}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,n){return this[e*this.RANK+t]=checkNumber(n),this}getColumn(t,e=new Array(this.RANK).fill(-0)){const n=t*this.RANK;for(let t=0;t<this.RANK;++t)e[t]=this[n+t];return e}setColumn(t,e){const n=t*this.RANK;for(let t=0;t<this.RANK;++t)this[n+t]=e[t];return this}}function create$2(){var t=new ARRAY_TYPE(9);return ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function transpose$1(t,e){if(t===e){var n=e[1],i=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=n,t[5]=e[7],t[6]=i,t[7]=r}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function invert$2(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*s-a*c,d=-u*o+a*l,p=c*o-s*l,f=n*h+i*d+r*p;return f?(t[0]=h*(f=1/f),t[1]=(-u*i+r*c)*f,t[2]=(a*i-r*s)*f,t[3]=d*f,t[4]=(u*n-r*l)*f,t[5]=(-a*n+r*o)*f,t[6]=p*f,t[7]=(-c*n+i*l)*f,t[8]=(s*n-i*o)*f,t):null}function determinant$1(t){var e=t[3],n=t[4],i=t[5],r=t[6],o=t[7],s=t[8];return t[0]*(s*n-i*o)+t[1]*(-s*e+i*r)+t[2]*(o*e-n*r)}function multiply$2(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=n[0],p=n[1],f=n[2],m=n[3],g=n[4],_=n[5],y=n[6],v=n[7],x=n[8];return t[0]=d*i+p*s+f*c,t[1]=d*r+p*a+f*u,t[2]=d*o+p*l+f*h,t[3]=m*i+g*s+_*c,t[4]=m*r+g*a+_*u,t[5]=m*o+g*l+_*h,t[6]=y*i+v*s+x*c,t[7]=y*r+v*a+x*u,t[8]=y*o+v*l+x*h,t}function translate$2(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=n[0],p=n[1];return t[0]=i,t[1]=r,t[2]=o,t[3]=s,t[4]=a,t[5]=l,t[6]=d*i+p*s+c,t[7]=d*r+p*a+u,t[8]=d*o+p*l+h,t}function rotate$1(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=Math.sin(n),p=Math.cos(n);return t[0]=p*i+d*s,t[1]=p*r+d*a,t[2]=p*o+d*l,t[3]=p*s-d*i,t[4]=p*a-d*r,t[5]=p*l-d*o,t[6]=c,t[7]=u,t[8]=h,t}function scale$3(t,e,n){var i=n[0],r=n[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=r*e[3],t[4]=r*e[4],t[5]=r*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function fromQuat$1(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n+n,a=i+i,l=r+r,c=n*s,u=i*s,h=i*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;return t[0]=1-h-f,t[3]=u-_,t[6]=d+g,t[1]=u+_,t[4]=1-c-f,t[7]=p-m,t[2]=d-g,t[5]=p+m,t[8]=1-c-h,t}var INDICES$1;!function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"}(INDICES$1||(INDICES$1={}));const IDENTITY_MATRIX$2=Object.freeze([1,0,0,0,1,0,0,0,1]);let Matrix3$1=class extends Matrix{static get IDENTITY(){return getIdentityMatrix$1()}static get ZERO(){return getZeroMatrix$1()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return INDICES$1}constructor(t,...e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(t)?this.copy(t):e.length>0?this.copy([t,...e]):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this.check()}identity(){return this.copy(IDENTITY_MATRIX$2)}fromObject(t){return this.check()}fromQuaternion(t){return fromQuat$1(this,t),this.check()}set(t,e,n,i,r,o,s,a,l){return this[0]=t,this[1]=e,this[2]=n,this[3]=i,this[4]=r,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this.check()}setRowMajor(t,e,n,i,r,o,s,a,l){return this[0]=t,this[1]=i,this[2]=s,this[3]=e,this[4]=r,this[5]=a,this[6]=n,this[7]=o,this[8]=l,this.check()}determinant(){return determinant$1(this)}transpose(){return transpose$1(this,this),this.check()}invert(){return invert$2(this,this),this.check()}multiplyLeft(t){return multiply$2(this,t,this),this.check()}multiplyRight(t){return multiply$2(this,this,t),this.check()}rotate(t){return rotate$1(this,this,t),this.check()}scale(t){return Array.isArray(t)?scale$3(this,this,t):scale$3(this,this,[t,t]),this.check()}translate(t){return translate$2(this,this,t),this.check()}transform(t,e){let n;switch(t.length){case 2:n=transformMat3$1(e||[-0,-0],t,this);break;case 3:n=transformMat3(e||[-0,-0,-0],t,this);break;case 4:n=vec4_transformMat3(e||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return checkVector(n,t.length),n}transformVector(t,e){return this.transform(t,e)}transformVector2(t,e){return this.transform(t,e)}transformVector3(t,e){return this.transform(t,e)}},ZERO_MATRIX3,IDENTITY_MATRIX3;function getZeroMatrix$1(){return ZERO_MATRIX3||(ZERO_MATRIX3=new Matrix3$1([0,0,0,0,0,0,0,0,0]),Object.freeze(ZERO_MATRIX3)),ZERO_MATRIX3}function getIdentityMatrix$1(){return IDENTITY_MATRIX3||(IDENTITY_MATRIX3=new Matrix3$1,Object.freeze(IDENTITY_MATRIX3)),IDENTITY_MATRIX3}function identity$2(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function transpose(t,e){if(t===e){var n=e[1],i=e[2],r=e[3],o=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=o,t[11]=e[14],t[12]=r,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function invert$1(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=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],m=e[13],g=e[14],_=e[15],y=n*a-i*s,v=n*l-r*s,x=n*c-o*s,b=i*l-r*a,T=i*c-o*a,E=r*c-o*l,S=u*m-h*f,w=u*g-d*f,A=u*_-p*f,M=h*g-d*m,C=h*_-p*m,I=d*_-p*g,P=y*I-v*C+x*M+b*A-T*w+E*S;return P?(t[0]=(a*I-l*C+c*M)*(P=1/P),t[1]=(r*C-i*I-o*M)*P,t[2]=(m*E-g*T+_*b)*P,t[3]=(d*T-h*E-p*b)*P,t[4]=(l*A-s*I-c*w)*P,t[5]=(n*I-r*A+o*w)*P,t[6]=(g*x-f*E-_*v)*P,t[7]=(u*E-d*x+p*v)*P,t[8]=(s*C-a*A+c*S)*P,t[9]=(i*A-n*C-o*S)*P,t[10]=(f*T-m*x+_*y)*P,t[11]=(h*x-u*T-p*y)*P,t[12]=(a*w-s*M-l*S)*P,t[13]=(n*M-i*w+r*S)*P,t[14]=(m*v-f*b-g*y)*P,t[15]=(u*b-h*v+d*y)*P,t):null}function determinant(t){var e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15];return(e*s-n*o)*(h*g-d*m)-(e*a-i*o)*(u*g-d*f)+(e*l-r*o)*(u*m-h*f)+(n*a-i*s)*(c*g-d*p)-(n*l-r*s)*(c*m-h*p)+(i*l-r*a)*(c*f-u*p)}function multiply$1(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],y=e[15],v=n[0],x=n[1],b=n[2],T=n[3];return t[0]=v*i+x*a+b*h+T*m,t[1]=v*r+x*l+b*d+T*g,t[2]=v*o+x*c+b*p+T*_,t[3]=v*s+x*u+b*f+T*y,t[4]=(v=n[4])*i+(x=n[5])*a+(b=n[6])*h+(T=n[7])*m,t[5]=v*r+x*l+b*d+T*g,t[6]=v*o+x*c+b*p+T*_,t[7]=v*s+x*u+b*f+T*y,t[8]=(v=n[8])*i+(x=n[9])*a+(b=n[10])*h+(T=n[11])*m,t[9]=v*r+x*l+b*d+T*g,t[10]=v*o+x*c+b*p+T*_,t[11]=v*s+x*u+b*f+T*y,t[12]=(v=n[12])*i+(x=n[13])*a+(b=n[14])*h+(T=n[15])*m,t[13]=v*r+x*l+b*d+T*g,t[14]=v*o+x*c+b*p+T*_,t[15]=v*s+x*u+b*f+T*y,t}function translate$1(t,e,n){var i,r,o,s,a,l,c,u,h,d,p,f,m=n[0],g=n[1],_=n[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*_+e[12],t[13]=e[1]*m+e[5]*g+e[9]*_+e[13],t[14]=e[2]*m+e[6]*g+e[10]*_+e[14],t[15]=e[3]*m+e[7]*g+e[11]*_+e[15]):(r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],d=e[9],p=e[10],f=e[11],t[0]=i=e[0],t[1]=r,t[2]=o,t[3]=s,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]=i*m+a*g+h*_+e[12],t[13]=r*m+l*g+d*_+e[13],t[14]=o*m+c*g+p*_+e[14],t[15]=s*m+u*g+f*_+e[15]),t}function scale$2(t,e,n){var i=n[0],r=n[1],o=n[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function rotate(t,e,n,i){var r,o,s,a,l,c,u,h,d,p,f,m,g,_,y,v,x,b,T,E,S,w,A,M,C=i[0],I=i[1],P=i[2],L=Math.hypot(C,I,P);return L<EPSILON$1?null:(C*=L=1/L,I*=L,P*=L,r=Math.sin(n),o=Math.cos(n),l=e[1],c=e[2],u=e[3],d=e[5],p=e[6],f=e[7],g=e[9],_=e[10],y=e[11],T=C*I*(s=1-o)-P*r,E=I*I*s+o,S=P*I*s+C*r,w=C*P*s+I*r,A=I*P*s-C*r,M=P*P*s+o,t[0]=(a=e[0])*(v=C*C*s+o)+(h=e[4])*(x=I*C*s+P*r)+(m=e[8])*(b=P*C*s-I*r),t[1]=l*v+d*x+g*b,t[2]=c*v+p*x+_*b,t[3]=u*v+f*x+y*b,t[4]=a*T+h*E+m*S,t[5]=l*T+d*E+g*S,t[6]=c*T+p*E+_*S,t[7]=u*T+f*E+y*S,t[8]=a*w+h*A+m*M,t[9]=l*w+d*A+g*M,t[10]=c*w+p*A+_*M,t[11]=u*w+f*A+y*M,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function rotateX$1(t,e,n){var i=Math.sin(n),r=Math.cos(n),o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*r+c*i,t[5]=s*r+u*i,t[6]=a*r+h*i,t[7]=l*r+d*i,t[8]=c*r-o*i,t[9]=u*r-s*i,t[10]=h*r-a*i,t[11]=d*r-l*i,t}function rotateY$1(t,e,n){var i=Math.sin(n),r=Math.cos(n),o=e[0],s=e[1],a=e[2],l=e[3],c=e[8],u=e[9],h=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r-c*i,t[1]=s*r-u*i,t[2]=a*r-h*i,t[3]=l*r-d*i,t[8]=o*i+c*r,t[9]=s*i+u*r,t[10]=a*i+h*r,t[11]=l*i+d*r,t}function rotateZ$1(t,e,n){var i=Math.sin(n),r=Math.cos(n),o=e[0],s=e[1],a=e[2],l=e[3],c=e[4],u=e[5],h=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r+c*i,t[1]=s*r+u*i,t[2]=a*r+h*i,t[3]=l*r+d*i,t[4]=c*r-o*i,t[5]=u*r-s*i,t[6]=h*r-a*i,t[7]=d*r-l*i,t}function getScaling(t,e){var n=e[4],i=e[5],r=e[6],o=e[8],s=e[9],a=e[10];return t[0]=Math.hypot(e[0],e[1],e[2]),t[1]=Math.hypot(n,i,r),t[2]=Math.hypot(o,s,a),t}function fromQuat(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n+n,a=i+i,l=r+r,c=n*s,u=i*s,h=i*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;return t[0]=1-h-f,t[1]=u+_,t[2]=d-g,t[3]=0,t[4]=u-_,t[5]=1-c-f,t[6]=p+m,t[7]=0,t[8]=d+g,t[9]=p-m,t[10]=1-c-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function frustum(t,e,n,i,r,o,s){var a=1/(n-e),l=1/(r-i),c=1/(o-s);return t[0]=2*o*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*l,t[6]=0,t[7]=0,t[8]=(n+e)*a,t[9]=(r+i)*l,t[10]=(s+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*o*2*c,t[15]=0,t}function perspectiveNO(t,e,n,i,r){var o,s=1/Math.tan(e/2);return t[0]=s/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=r&&r!==1/0?(t[10]=(r+i)*(o=1/(i-r)),t[14]=2*r*i*o):(t[10]=-1,t[14]=-2*i),t}var perspective=perspectiveNO;function orthoNO(t,e,n,i,r,o,s){var a=1/(e-n),l=1/(i-r),c=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*a,t[13]=(r+i)*l,t[14]=(s+o)*c,t[15]=1,t}var ortho=orthoNO,INDICES;function lookAt(t,e,n,i){var r,o,s,a,l,c,u,h,d,p,f=e[0],m=e[1],g=e[2],_=i[0],y=i[1],v=i[2],x=n[0],b=n[1],T=n[2];return Math.abs(f-x)<EPSILON$1&&Math.abs(m-b)<EPSILON$1&&Math.abs(g-T)<EPSILON$1?identity$2(t):(u=f-x,h=m-b,d=g-T,r=y*(d*=p=1/Math.hypot(u,h,d))-v*(h*=p),o=v*(u*=p)-_*d,s=_*h-y*u,(p=Math.hypot(r,o,s))?(r*=p=1/p,o*=p,s*=p):(r=0,o=0,s=0),a=h*s-d*o,l=d*r-u*s,c=u*o-h*r,(p=Math.hypot(a,l,c))?(a*=p=1/p,l*=p,c*=p):(a=0,l=0,c=0),t[0]=r,t[1]=a,t[2]=u,t[3]=0,t[4]=o,t[5]=l,t[6]=h,t[7]=0,t[8]=s,t[9]=c,t[10]=d,t[11]=0,t[12]=-(r*f+o*m+s*g),t[13]=-(a*f+l*m+c*g),t[14]=-(u*f+h*m+d*g),t[15]=1,t)}function create$1(){var t=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function add$2(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t}function scale$1(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t}function length$1(t){return Math.hypot(t[0],t[1],t[2],t[3])}function squaredLength$1(t){var e=t[0],n=t[1],i=t[2],r=t[3];return e*e+n*n+i*i+r*r}function normalize$3(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n*n+i*i+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=n*s,t[1]=i*s,t[2]=r*s,t[3]=o*s,t}function dot$1(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function lerp$2(t,e,n,i){var r=e[0],o=e[1],s=e[2],a=e[3];return t[0]=r+i*(n[0]-r),t[1]=o+i*(n[1]-o),t[2]=s+i*(n[2]-s),t[3]=a+i*(n[3]-a),t}function transformMat4(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3];return t[0]=n[0]*i+n[4]*r+n[8]*o+n[12]*s,t[1]=n[1]*i+n[5]*r+n[9]*o+n[13]*s,t[2]=n[2]*i+n[6]*r+n[10]*o+n[14]*s,t[3]=n[3]*i+n[7]*r+n[11]*o+n[15]*s,t}function transformQuat(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[0],a=n[1],l=n[2],c=n[3],u=c*i+a*o-l*r,h=c*r+l*i-s*o,d=c*o+s*r-a*i,p=-s*i-a*r-l*o;return t[0]=u*c+p*-s+h*-l-d*-a,t[1]=h*c+p*-a+d*-s-u*-l,t[2]=d*c+p*-l+u*-a-h*-s,t[3]=e[3],t}!function(){var t=create$1()}(),function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"}(INDICES||(INDICES={}));const DEFAULT_FOVY=45*Math.PI/180,DEFAULT_ASPECT=1,DEFAULT_NEAR=.1,DEFAULT_FAR=500,IDENTITY_MATRIX$1=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);let Matrix4$1=class extends Matrix{static get IDENTITY(){return getIdentityMatrix()}static get ZERO(){return getZeroMatrix()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return INDICES}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m){return this[0]=t,this[1]=e,this[2]=n,this[3]=i,this[4]=r,this[5]=o,this[6]=s,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(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m){return this[0]=t,this[1]=r,this[2]=l,this[3]=d,this[4]=e,this[5]=o,this[6]=c,this[7]=p,this[8]=n,this[9]=s,this[10]=u,this[11]=f,this[12]=i,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(IDENTITY_MATRIX$1)}fromObject(t){return this.check()}fromQuaternion(t){return fromQuat(this,t),this.check()}frustum(t){const{left:e,right:n,bottom:i,top:r,near:o=DEFAULT_NEAR,far:s=DEFAULT_FAR}=t;return s===1/0?computeInfinitePerspectiveOffCenter(this,e,n,i,r,o):frustum(this,e,n,i,r,o,s),this.check()}lookAt(t){const{eye:e,center:n=[0,0,0],up:i=[0,1,0]}=t;return lookAt(this,e,n,i),this.check()}ortho(t){const{left:e,right:n,bottom:i,top:r,near:o=DEFAULT_NEAR,far:s=DEFAULT_FAR}=t;return ortho(this,e,n,i,r,o,s),this.check()}orthographic(t){const{fovy:e=DEFAULT_FOVY,aspect:n=DEFAULT_ASPECT,focalDistance:i=1,near:r=DEFAULT_NEAR,far:o=DEFAULT_FAR}=t;checkRadians(e);const s=i*Math.tan(e/2),a=s*n;return this.ortho({left:-a,right:a,bottom:-s,top:s,near:r,far:o})}perspective(t){const{fovy:e=45*Math.PI/180,aspect:n=1,near:i=.1,far:r=500}=t;return checkRadians(e),perspective(this,e,n,i,r),this.check()}determinant(){return determinant(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0];const n=this.getScale(e=e||[-0,-0,-0]),i=1/n[0],r=1/n[1],o=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*r,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*r,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*r,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0];const n=this.getScale(e=e||[-0,-0,-0]),i=1/n[0],r=1/n[1],o=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*r,t[2]=this[2]*o,t[3]=this[4]*i,t[4]=this[5]*r,t[5]=this[6]*o,t[6]=this[8]*i,t[7]=this[9]*r,t[8]=this[10]*o,t}transpose(){return transpose(this,this),this.check()}invert(){return invert$1(this,this),this.check()}multiplyLeft(t){return multiply$1(this,t,this),this.check()}multiplyRight(t){return multiply$1(this,this,t),this.check()}rotateX(t){return rotateX$1(this,this,t),this.check()}rotateY(t){return rotateY$1(this,this,t),this.check()}rotateZ(t){return rotateZ$1(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return rotate(this,this,t,e),this.check()}scale(t){return scale$2(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return translate$1(this,this,t),this.check()}transform(t,e){return 4===t.length?(checkVector(e=transformMat4(e||[-0,-0,-0,-0],t,this),4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){const{length:n}=t;let i;switch(n){case 2:i=transformMat4$2(e||[-0,-0],t,this);break;case 3:i=transformMat4$1(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return checkVector(i,t.length),i}transformAsVector(t,e){let n;switch(t.length){case 2:n=vec2_transformMat4AsVector(e||[-0,-0],t,this);break;case 3:n=vec3_transformMat4AsVector(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return checkVector(n,t.length),n}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,n){return this.identity().translate([t,e,n])}},ZERO$1,IDENTITY$1;function getZeroMatrix(){return ZERO$1||(ZERO$1=new Matrix4$1([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(ZERO$1)),ZERO$1}function getIdentityMatrix(){return IDENTITY$1||(IDENTITY$1=new Matrix4$1,Object.freeze(IDENTITY$1)),IDENTITY$1}function checkRadians(t){if(t>2*Math.PI)throw Error("expected radians")}function computeInfinitePerspectiveOffCenter(t,e,n,i,r,o){const s=2*o/(r-i),a=(n+e)/(n-e),l=(r+i)/(r-i),c=-2*o;return t[0]=2*o/(n-e),t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=a,t[9]=l,t[10]=-1,t[11]=-1,t[12]=0,t[13]=0,t[14]=c,t[15]=0,t}function create(){var t=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function identity$1(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function setAxisAngle(t,e,n){n*=.5;var i=Math.sin(n);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(n),t}function multiply(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=n[0],l=n[1],c=n[2],u=n[3];return t[0]=i*u+s*a+r*c-o*l,t[1]=r*u+s*l+o*a-i*c,t[2]=o*u+s*c+i*l-r*a,t[3]=s*u-i*a-r*l-o*c,t}function rotateX(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),l=Math.cos(n);return t[0]=i*l+s*a,t[1]=r*l+o*a,t[2]=o*l-r*a,t[3]=s*l-i*a,t}function rotateY(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),l=Math.cos(n);return t[0]=i*l-o*a,t[1]=r*l+s*a,t[2]=o*l+i*a,t[3]=s*l-r*a,t}function rotateZ(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),l=Math.cos(n);return t[0]=i*l+r*a,t[1]=r*l-i*a,t[2]=o*l+s*a,t[3]=s*l-o*a,t}function calculateW(t,e){var n=e[0],i=e[1],r=e[2];return t[0]=n,t[1]=i,t[2]=r,t[3]=Math.sqrt(Math.abs(1-n*n-i*i-r*r)),t}function slerp(t,e,n,i){var r,o,s,a,l,c=e[0],u=e[1],h=e[2],d=e[3],p=n[0],f=n[1],m=n[2],g=n[3];return(o=c*p+u*f+h*m+d*g)<0&&(o=-o,p=-p,f=-f,m=-m,g=-g),1-o>EPSILON$1?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-i)*r)/s,l=Math.sin(i*r)/s):(a=1-i,l=i),t[0]=a*c+l*p,t[1]=a*u+l*f,t[2]=a*h+l*m,t[3]=a*d+l*g,t}function invert(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n*n+i*i+r*r+o*o,a=s?1/s:0;return t[0]=-n*a,t[1]=-i*a,t[2]=-r*a,t[3]=o*a,t}function conjugate(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function fromMat3(t,e){var n,i=e[0]+e[4]+e[8];if(i>0)n=Math.sqrt(i+1),t[3]=.5*n,t[0]=(e[5]-e[7])*(n=.5/n),t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var r=0;e[4]>e[0]&&(r=1),e[8]>e[3*r+r]&&(r=2);var o=(r+1)%3,s=(r+2)%3;n=Math.sqrt(e[3*r+r]-e[3*o+o]-e[3*s+s]+1),t[r]=.5*n,t[3]=(e[3*o+s]-e[3*s+o])*(n=.5/n),t[o]=(e[3*o+r]+e[3*r+o])*n,t[s]=(e[3*s+r]+e[3*r+s])*n}return t}var add$1=add$2,scale=scale$1,dot=dot$1,lerp$1=lerp$2,length=length$1,squaredLength=squaredLength$1,normalize$2=normalize$3,rotationTo=(tmpvec3=create$3(),xUnitVec3=fromValues(1,0,0),yUnitVec3=fromValues(0,1,0),function(t,e,n){var i=dot$2(e,n);return i<-.999999?(cross(tmpvec3,xUnitVec3,e),len(tmpvec3)<1e-6&&cross(tmpvec3,yUnitVec3,e),normalize$4(tmpvec3,tmpvec3),setAxisAngle(t,tmpvec3,Math.PI),t):i>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(cross(tmpvec3,e,n),t[0]=tmpvec3[0],t[1]=tmpvec3[1],t[2]=tmpvec3[2],t[3]=1+i,normalize$2(t,t))}),tmpvec3,xUnitVec3,yUnitVec3,temp1,temp2,matr;temp1=create(),temp2=create(),matr=create$2();const IDENTITY_QUATERNION=[0,0,0,1];let Quaternion$1=class extends MathArray{constructor(t=0,e=0,n=0,i=1){super(-0,-0,-0,-0),Array.isArray(t)&&1===arguments.length?this.copy(t):this.set(t,e,n,i)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,e,n,i){return this[0]=t,this[1]=e,this[2]=n,this[3]=i,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return fromMat3(this,t),this.check()}fromAxisRotation(t,e){return setAxisAngle(this,t,e),this.check()}identity(){return identity$1(this),this.check()}setAxisAngle(t,e){return this.fromAxisRotation(t,e)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=checkNumber(t)}get y(){return this[1]}set y(t){this[1]=checkNumber(t)}get z(){return this[2]}set z(t){this[2]=checkNumber(t)}get w(){return this[3]}set w(t){this[3]=checkNumber(t)}len(){return length(this)}lengthSquared(){return squaredLength(this)}dot(t){return dot(this,t)}rotationTo(t,e){return rotationTo(this,t,e),this.check()}add(t){return add$1(this,this,t),this.check()}calculateW(){return calculateW(this,this),this.check()}conjugate(){return conjugate(this,this),this.check()}invert(){return invert(this,this),this.check()}lerp(t,e,n){return void 0===n?this.lerp(this,t,e):(lerp$1(this,t,e,n),this.check())}multiplyRight(t){return multiply(this,this,t),this.check()}multiplyLeft(t){return multiply(this,t,this),this.check()}normalize(){const t=this.len(),e=t>0?1/t:0;return this[0]=this[0]*e,this[1]=this[1]*e,this[2]=this[2]*e,this[3]=this[3]*e,0===t&&(this[3]=1),this.check()}rotateX(t){return rotateX(this,this,t),this.check()}rotateY(t){return rotateY(this,this,t),this.check()}rotateZ(t){return rotateZ(this,this,t),this.check()}scale(t){return scale(this,this,t),this.check()}slerp(t,e,n){let i,r,o;switch(arguments.length){case 1:({start:i=IDENTITY_QUATERNION,target:r,ratio:o}=t);break;case 2:i=this,r=t,o=e;break;default:i=t,r=e,o=n}return slerp(this,i,r,o),this.check()}transformVector4(t,e=new Vector4$1){return transformQuat(e,t,this),checkVector(e,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,e){return this.setAxisAngle(t,e)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var _MathUtils={EPSILON1:.1,EPSILON2:.01,EPSILON3:.001,EPSILON4:1e-4,EPSILON5:1e-5,EPSILON6:1e-6,EPSILON7:1e-7,EPSILON8:1e-8,EPSILON9:1e-9,EPSILON10:1e-10,EPSILON11:1e-11,EPSILON12:1e-12,EPSILON13:1e-13,EPSILON14:1e-14,EPSILON15:1e-15,EPSILON16:1e-16,EPSILON17:1e-17,EPSILON18:1e-18,EPSILON19:1e-19,EPSILON20:1e-20,PI_OVER_TWO:Math.PI/2,PI_OVER_FOUR:Math.PI/4,PI_OVER_SIX:Math.PI/6,TWO_PI:2*Math.PI},lightingShader$1="#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 INITIAL_MODULE_OPTIONS$2={lightSources:{}};function convertColor(){let{color:t=[0,0,0],intensity:e=1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t.map((t=>t*e/255))}function getLightSourceUniforms(t){let{ambientLight:e,pointLights:n=[],directionalLights:i=[]}=t;const r={};return r["lighting_uAmbientLight.color"]=e?convertColor(e):[0,0,0],n.forEach(((t,e)=>{r["lighting_uPointLight[".concat(e,"].color")]=convertColor(t),r["lighting_uPointLight[".concat(e,"].position")]=t.position,r["lighting_uPointLight[".concat(e,"].attenuation")]=t.attenuation||[1,0,0]})),r.lighting_uPointLightCount=n.length,i.forEach(((t,e)=>{r["lighting_uDirectionalLight[".concat(e,"].color")]=convertColor(t),r["lighting_uDirectionalLight[".concat(e,"].direction")]=t.direction})),r.lighting_uDirectionalLightCount=i.length,r}function getUniforms$3(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:INITIAL_MODULE_OPTIONS$2;if("lightSources"in t){const{ambientLight:e,pointLights:n,directionalLights:i}=t.lightSources||{};return e||n&&n.length>0||i&&i.length>0?Object.assign({},getLightSourceUniforms({ambientLight:e,pointLights:n,directionalLights:i}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){const e={pointLights:[],directionalLights:[]};for(const n of t.lights||[])switch(n.type){case"ambient":e.ambientLight=n;break;case"directional":e.directionalLights.push(n);break;case"point":e.pointLights.push(n)}return getUniforms$3({lightSources:e})}return{}}const lights={name:"lights",vs:lightingShader$1,fs:lightingShader$1,getUniforms:getUniforms$3,defines:{MAX_LIGHTS:3}},DEFAULT_HIGHLIGHT_COLOR=new Uint8Array([0,255,255,255]),DEFAULT_MODULE_OPTIONS={pickingSelectedColor:null,pickingHighlightColor:DEFAULT_HIGHLIGHT_COLOR,pickingActive:!1,pickingAttribute:!1};function getUniforms$2(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:DEFAULT_MODULE_OPTIONS;const e={};if(void 0!==t.pickingSelectedColor)if(t.pickingSelectedColor){const n=t.pickingSelectedColor.slice(0,3);e.picking_uSelectedColorValid=1,e.picking_uSelectedColor=n}else e.picking_uSelectedColorValid=0;if(t.pickingHighlightColor){const n=Array.from(t.pickingHighlightColor,(t=>t/255));Number.isFinite(n[3])||(n[3]=1),e.picking_uHighlightColor=n}return void 0!==t.pickingActive&&(e.picking_uActive=Boolean(t.pickingActive),e.picking_uAttribute=Boolean(t.pickingAttribute)),e}const vs$f="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$e="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",picking$1={name:"picking",vs:vs$f,fs:fs$e,getUniforms:getUniforms$2};var lightingShader="\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 INITIAL_MODULE_OPTIONS$1={};function getMaterialUniforms(t){const{ambient:e=.35,diffuse:n=.6,shininess:i=32,specularColor:r=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:n,lighting_uShininess:i,lighting_uSpecularColor:r.map((t=>t/255))}}function getUniforms$1(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:INITIAL_MODULE_OPTIONS$1;if(!("material"in t))return{};const{material:e}=t;return e?getMaterialUniforms(e):{lighting_uEnabled:!1}}const gouraudLighting={name:"gouraud-lighting",dependencies:[lights],vs:lightingShader,defines:{LIGHTING_VERTEX:1},getUniforms:getUniforms$1},phongLighting={name:"phong-lighting",dependencies:[lights],fs:lightingShader,defines:{LIGHTING_FRAGMENT:1},getUniforms:getUniforms$1};var vs$e="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$d="#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";const pbr={name:"pbr",vs:vs$e,fs:fs$d,defines:{LIGHTING_FRAGMENT:1},dependencies:[lights]},vs$d="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",transform={name:"transform",vs:vs$d,fs:null};class ProgramManager{static getDefaultProgramManager(t){return t.luma=t.luma||{},t.luma.defaultProgramManager=t.luma.defaultProgramManager||new ProgramManager(t),t.luma.defaultProgramManager}constructor(t){this.gl=t,this._programCache={},this._getUniforms={},this._registeredModules={},this._hookFunctions=[],this._defaultModules=[],this._hashes={},this._hashCounter=0,this.stateHash=0,this._useCounts={}}addDefaultModule(t){this._defaultModules.find((e=>e.name===t.name))||this._defaultModules.push(t),this.stateHash++}removeDefaultModule(t){const e="string"==typeof t?t:t.name;this._defaultModules=this._defaultModules.filter((t=>t.name!==e)),this.stateHash++}addShaderHook(t,e){e&&(t=Object.assign(e,{hook:t})),this._hookFunctions.push(t),this.stateHash++}get(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{vs:e="",fs:n="",defines:i={},inject:r={},varyings:o=[],bufferMode:s=35981,transpileToGLSL100:a=!1}=t,l=this._getModuleList(t.modules),c=this._getHash(e),u=this._getHash(n),h=l.map((t=>this._getHash(t.name))).sort(),d=o.map((t=>this._getHash(t))),p=Object.keys(i).sort(),f=Object.keys(r).sort(),m=[],g=[];for(const t of p)m.push(this._getHash(t)),m.push(this._getHash(i[t]));for(const t of f)g.push(this._getHash(t)),g.push(this._getHash(r[t]));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(s).concat(a?"T":"");if(!this._programCache[_]){const t=assembleShaders(this.gl,{vs:e,fs:n,modules:l,inject:r,defines:i,hookFunctions:this._hookFunctions,transpileToGLSL100:a});this._programCache[_]=new Program(this.gl,{hash:_,vs:t.vs,fs:t.fs,varyings:o,bufferMode:s}),this._getUniforms[_]=t.getUniforms,this._useCounts[_]=0}return this._useCounts[_]++,this._programCache[_]}getUniforms(t){return this._getUniforms[t.hash]||null}release(t){const e=t.hash;this._useCounts[e]--,0===this._useCounts[e]&&(this._programCache[e].delete(),delete this._programCache[e],delete this._getUniforms[e],delete this._useCounts[e])}_getHash(t){return void 0===this._hashes[t]&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}_getModuleList(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=new Array(this._defaultModules.length+t.length),n={};let i=0;for(let t=0,r=this._defaultModules.length;t<r;++t){const r=this._defaultModules[t],o=r.name;e[i++]=r,n[o]=!0}for(let r=0,o=t.length;r<o;++r){const o=t[r],s=o.name;n[s]||(e[i++]=o,n[s]=!0)}return e.length=i,e}}const GLTF_TO_LUMA_ATTRIBUTE_MAP={POSITION:"positions",NORMAL:"normals",COLOR_0:"colors",TEXCOORD_0:"texCoords",TEXCOORD_1:"texCoords1",TEXCOORD_2:"texCoords2"};function getBuffersFromGeometry(t,e,n){const i={};let r=e.indices;for(const n in e.attributes){const o=e.attributes[n],s=mapAttributeName(n);if("indices"===n)r=o;else if(o.constant)i[s]=o.value;else{const e=o.value,r={...o};delete r.value,i[s]=[new Buffer(t,e),r],inferAttributeAccessor(n,r)}}if(r){const e=r.value||r;assert$8(e instanceof Uint16Array||e instanceof Uint32Array,'attribute array for "indices" must be of integer type');const n={size:1,isIndexed:void 0===r.isIndexed||r.isIndexed};i.indices=[new Buffer(t,{data:e,target:34963}),n]}return i}function mapAttributeName(t,e){const{attributeMap:n=GLTF_TO_LUMA_ATTRIBUTE_MAP}={};return n&&n[t]||t}function inferAttributeAccessor(t,e){let n;switch(t){case"texCoords":case"texCoord1":case"texCoord2":case"texCoord3":n="uvs";break;case"vertices":case"positions":case"normals":case"pickingColors":n="vectors"}switch(n){case"vectors":e.size=e.size||3;break;case"uvs":e.size=e.size||2}assert$8(Number.isFinite(e.size),"attribute ".concat(t," needs size"))}const LOG_DRAW_PRIORITY=2,LOG_DRAW_TIMEOUT=1e4,ERR_MODEL_PARAMS="Model needs drawMode and vertexCount",NOOP=()=>{},DRAW_PARAMS={};class Model{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{id:n=uid("model")}=e;assert$8(isWebGL(t)),this.id=n,this.gl=t,this.id=e.id||uid("Model"),this.lastLogTime=0,this.animated=!1,this.initialize(e)}initialize(t){this.props={},this.programManager=t.programManager||ProgramManager.getDefaultProgramManager(this.gl),this._programManagerState=-1,this._managedProgram=!1;const{program:e=null,vs:n,fs:i,modules:r,defines:o,inject:s,varyings:a,bufferMode:l,transpileToGLSL100:c}=t;this.programProps={program:e,vs:n,fs:i,modules:r,defines:o,inject:s,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(t.moduleSettings))),this.drawMode=void 0!==t.drawMode?t.drawMode:4,this.vertexCount=t.vertexCount||0,this.geometryBuffers={},this.isInstanced=t.isInstanced||t.instanced||t.instanceCount>0,this._setModelProps(t),this.geometry={},assert$8(void 0!==this.drawMode&&Number.isFinite(this.vertexCount),ERR_MODEL_PARAMS)}setProps(t){this._setModelProps(t)}delete(){for(const t in this._attributes)this._attributes[t]!==this.attributes[t]&&this._attributes[t].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(t){const{program:e,vs:n,fs:i,modules:r,defines:o,inject:s,varyings:a,bufferMode:l,transpileToGLSL100:c}=t;this.programProps={program:e,vs:n,fs:i,modules:r,defines:o,inject:s,varyings:a,bufferMode:l,transpileToGLSL100:c},this._programDirty=!0}getUniforms(){return this.uniforms}setDrawMode(t){return this.drawMode=t,this}setVertexCount(t){return assert$8(Number.isFinite(t)),this.vertexCount=t,this}setInstanceCount(t){return assert$8(Number.isFinite(t)),this.instanceCount=t,this}setGeometry(t){return this.drawMode=t.drawMode,this.vertexCount=t.getVertexCount(),this._deleteGeometryBuffers(),this.geometryBuffers=getBuffersFromGeometry(this.gl,t),this.vertexArray.setAttributes(this.geometryBuffers),this}setAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(isObjectEmpty(t))return this;const e={};for(const n in t){const i=t[n];e[n]=i.getValue?i.getValue():i}return this.vertexArray.setAttributes(e),this}setUniforms(){return Object.assign(this.uniforms,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this}getModuleUniforms(t){this._checkProgram();const e=this.programManager.getUniforms(this.program);return e?e(t):{}}updateModuleSettings(t){const e=this.getModuleUniforms(t||{});return this.setUniforms(e)}clear(t){return clear(this.program.gl,t),this}draw(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._checkProgram();const{moduleSettings:e=null,framebuffer:n,uniforms:i={},attributes:r={},transformFeedback:o=this.transformFeedback,parameters:s={},vertexArray:a=this.vertexArray}=t;let l;this.setAttributes(r),this.updateModuleSettings(e),this.setUniforms(i),log$1.priority>=LOG_DRAW_PRIORITY&&(l=this._logDrawCallStart(LOG_DRAW_PRIORITY));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&&log$1.warn("Found instanced attributes on non-instanced model",this.id)();const{isInstanced:f,instanceCount:m}=this,{onBeforeRender:g=NOOP,onAfterRender:_=NOOP}=this.props;g(),this.program.setUniforms(this.uniforms);const y=this.program.draw(Object.assign(DRAW_PARAMS,t,{logPriority:l,uniforms:null,framebuffer:n,parameters:s,drawMode:this.getDrawMode(),vertexCount:this.getVertexCount(),vertexArray:a,transformFeedback:o,isIndexed:u,indexType:h,isInstanced:f,instanceCount:m,offset:u?d:0}));return _(),log$1.priority>=LOG_DRAW_PRIORITY&&this._logDrawCallEnd(l,a,n),y}transform(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{discard:e=!0,feedbackBuffers:n,unbindModels:i=[]}=t;let{parameters:r}=t;n&&this._setFeedbackBuffers(n),e&&(r=Object.assign({},r,{35977:e})),i.forEach((t=>t.vertexArray.unbindBuffers()));try{this.draw(Object.assign({},t,{parameters:r}))}finally{i.forEach((t=>t.vertexArray.bindBuffers()))}return this}render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return log$1.warn("Model.render() is deprecated. Use Model.setUniforms() and Model.draw()")(),this.setUniforms(t).draw()}_setModelProps(t){Object.assign(this.props,t),"uniforms"in t&&this.setUniforms(t.uniforms),"pickable"in t&&(this.pickable=t.pickable),"instanceCount"in t&&(this.instanceCount=t.instanceCount),"geometry"in t&&this.setGeometry(t.geometry),"attributes"in t&&this.setAttributes(t.attributes),"_feedbackBuffers"in t&&this._setFeedbackBuffers(t._feedbackBuffers)}_checkProgram(){if(!(this._programDirty||this.programManager.stateHash!==this._programManagerState))return;let{program:t}=this.programProps;if(t)this._managedProgram=!1;else{const{vs:e,fs:n,modules:i,inject:r,defines:o,varyings:s,bufferMode:a,transpileToGLSL100:l}=this.programProps;t=this.programManager.get({vs:e,fs:n,modules:i,inject:r,defines:o,varyings:s,bufferMode:a,transpileToGLSL100:l}),this.program&&this._managedProgram&&this.programManager.release(this.program),this._programManagerState=this.programManager.stateHash,this._managedProgram=!0}assert$8(t instanceof Program,"Model needs a program"),this._programDirty=!1,t!==this.program&&(this.program=t,this.vertexArray?this.vertexArray.setProps({program:this.program,attributes:this.vertexArray.attributes}):this.vertexArray=new VertexArray(this.gl,{program:this.program}),this.setUniforms(Object.assign({},this.getModuleUniforms())))}_deleteGeometryBuffers(){for(const t in this.geometryBuffers){const e=this.geometryBuffers[t][0]||this.geometryBuffers[t];e instanceof Buffer&&e.delete()}}_setAnimationProps(t){this.animated&&assert$8(t,"Model.draw(): animated uniforms but no animationProps")}_setFeedbackBuffers(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(isObjectEmpty(t))return this;const{gl:e}=this.program;return this.transformFeedback=this.transformFeedback||new TransformFeedback(e,{program:this.program}),this.transformFeedback.setBuffers(t),this}_logDrawCallStart(t){const e=t>3?0:LOG_DRAW_TIMEOUT;if(!(Date.now()-this.lastLogTime<e))return this.lastLogTime=Date.now(),log$1.group(LOG_DRAW_PRIORITY,">>> DRAWING MODEL ".concat(this.id),{collapsed:log$1.level<=2})(),t}_logDrawCallEnd(t,e,n,i){if(void 0===t)return;const r=getDebugTableForVertexArray({vertexArray:e,header:"".concat(this.id," attributes"),attributes:this._attributes}),{table:o,unusedTable:s,unusedCount:a}=getDebugTableForUniforms({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,n)}),{table:l,count:c}=getDebugTableForUniforms({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,n),undefinedOnly:!0});c>0&&log$1.log("MISSING UNIFORMS",Object.keys(l))(),a>0&&log$1.log("UNUSED UNIFORMS",Object.keys(s))();const u=getDebugTableForProgramConfiguration(this.vertexArray.configuration);log$1.table(t,r)(),log$1.table(t,o)(),log$1.table(t+1,u)(),i&&i.log({logLevel:LOG_DRAW_PRIORITY,message:"Rendered to ".concat(i.id)}),log$1.groupEnd(LOG_DRAW_PRIORITY)()}}class BufferTransform{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.currentIndex=0,this.feedbackMap={},this.varyings=null,this.bindings=[],this.resources={},this._initialize(e),Object.seal(this)}setupResources(t){for(const e of this.bindings)this._setupTransformFeedback(e,t)}updateModelProps(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{varyings:e}=this;return e.length>0&&(t=Object.assign({},t,{varyings:e})),t}getDrawOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this.bindings[this.currentIndex],{sourceBuffers:n,transformFeedback:i}=e;return{attributes:Object.assign({},n,t.attributes),transformFeedback:i}}swap(){return!!this.feedbackMap&&(this.currentIndex=this._getNextIndex(),!0)}update(){this._setupBuffers(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}getBuffer(t){const{feedbackBuffers:e}=this.bindings[this.currentIndex],n=t?e[t]:null;return n?n instanceof Buffer?n:n.buffer:null}getData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{varyingName:e}=t,n=this.getBuffer(e);return n?n.getData():null}delete(){for(const t in this.resources)this.resources[t].delete()}_initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupBuffers(t),this.varyings=t.varyings||Object.keys(this.bindings[this.currentIndex].feedbackBuffers),this.varyings.length>0&&assert$8(isWebGL2$1(this.gl))}_getFeedbackBuffers(t){const{sourceBuffers:e={}}=t,n={};if(this.bindings[this.currentIndex]&&Object.assign(n,this.bindings[this.currentIndex].feedbackBuffers),this.feedbackMap)for(const t in this.feedbackMap){t in e&&(n[this.feedbackMap[t]]=t)}Object.assign(n,t.feedbackBuffers);for(const t in n){const i=n[t];if("string"==typeof i){const r=e[i],{byteLength:o,usage:s,accessor:a}=r;n[t]=this._createNewBuffer(t,{byteLength:o,usage:s,accessor:a})}}return n}_setupBuffers(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:e=null}=t;Object.assign(this.feedbackMap,t.feedbackMap);const n=this._getFeedbackBuffers(t);this._updateBindings({sourceBuffers:e,feedbackBuffers:n})}_setupTransformFeedback(t,e){let{model:n}=e;const{program:i}=n;t.transformFeedback=new TransformFeedback(this.gl,{program:i,buffers:t.feedbackBuffers})}_updateBindings(t){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],t),this.feedbackMap){const{sourceBuffers:t,feedbackBuffers:e}=this._swapBuffers(this.bindings[this.currentIndex]),n=this._getNextIndex();this.bindings[n]=this._updateBinding(this.bindings[n],{sourceBuffers:t,feedbackBuffers:e})}}_updateBinding(t,e){return t?(Object.assign(t.sourceBuffers,e.sourceBuffers),Object.assign(t.feedbackBuffers,e.feedbackBuffers),t.transformFeedback&&t.transformFeedback.setBuffers(t.feedbackBuffers),t):{sourceBuffers:Object.assign({},e.sourceBuffers),feedbackBuffers:Object.assign({},e.feedbackBuffers)}}_swapBuffers(t){if(!this.feedbackMap)return null;const e=Object.assign({},t.sourceBuffers),n=Object.assign({},t.feedbackBuffers);for(const i in this.feedbackMap){const r=this.feedbackMap[i];e[i]=t.feedbackBuffers[r],n[r]=t.sourceBuffers[i],assert$8(n[r]instanceof Buffer)}return{sourceBuffers:e,feedbackBuffers:n}}_createNewBuffer(t,e){const n=new Buffer(this.gl,e);return this.resources[t]&&this.resources[t].delete(),this.resources[t]=n,n}_getNextIndex(){return(this.currentIndex+1)%2}}const SAMPLER_UNIFORM_PREFIX="transform_uSampler_",SIZE_UNIFORM_PREFIX="transform_uSize_",VS_POS_VARIABLE="transform_position";function updateForTextures(t){let{vs:e,sourceTextureMap:n,targetTextureVarying:i,targetTexture:r}=t;let o=Object.keys(n).length,s=null;const a={};let l=e,c={};if(o>0||i){const t=l.split("\n"),e=t.slice();if(t.forEach(((t,r,l)=>{if(o>0){const i=processAttributeDefinition(t,n);if(i){const{updatedLine:t,inject:n}=i;e[r]=t,c=combineInjects([c,n]),Object.assign(a,i.samplerTextureMap),o--}}i&&!s&&(s=getVaryingType(t,i))})),i){assert$8(r);const t="".concat(SIZE_UNIFORM_PREFIX).concat(i),e="uniform vec2 ".concat(t,";\n"),n="     vec2 ".concat(VS_POS_VARIABLE," = transform_getPos(").concat(t,");\n     gl_Position = vec4(").concat(VS_POS_VARIABLE,", 0, 1.);\n");c=combineInjects([c,{"vs:#decl":e,"vs:#main-start":n}])}l=e.join("\n")}return{vs:l,targetTextureType:s,inject:c,samplerTextureMap:a}}function getSizeUniforms(t){let{sourceTextureMap:e,targetTextureVarying:n,targetTexture:i}=t;const r={};let o,s;n&&(({width:o,height:s}=i),r["".concat(SIZE_UNIFORM_PREFIX).concat(n)]=[o,s]);for(const t in e)({width:o,height:s}=e[t]),r["".concat(SIZE_UNIFORM_PREFIX).concat(t)]=[o,s];return r}function getAttributeDefinition(t){return getQualifierDetails(t,["attribute","in"])}function getSamplerDeclerations(t){const e="".concat(SAMPLER_UNIFORM_PREFIX).concat(t),n="".concat(SIZE_UNIFORM_PREFIX).concat(t);return{samplerName:e,sizeName:n,uniformDeclerations:"  uniform sampler2D ".concat(e,";\n  uniform vec2 ").concat(n,";")}}function getVaryingType(t,e){const n=getQualifierDetails(t,["varying","out"]);return n&&n.name===e?n.type:null}function processAttributeDefinition(t,e){const n={},i=getAttributeDefinition(t);if(!i)return null;const{type:r,name:o}=i;if(o&&e[o]){const e="// ".concat(t," => Replaced by Transform with a sampler"),{samplerName:i,sizeName:s,uniformDeclerations:a}=getSamplerDeclerations(o),l=typeToChannelSuffix(r),c="  ".concat(r," ").concat(o," = transform_getInput(").concat(i,", ").concat(s,").").concat(l,";\n");n[i]=o;return{updatedLine:e,inject:{"vs:#decl":a,"vs:#main-start":c},samplerTextureMap:n}}return null}const SRC_TEX_PARAMETER_OVERRIDES={10241:9728,10240:9728,10242:33071,10243:33071},FS_OUTPUT_VARIABLE="transform_output";class TextureTransform{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.id=this.currentIndex=0,this._swapTexture=null,this.targetTextureVarying=null,this.targetTextureType=null,this.samplerTextureMap=null,this.bindings=[],this.resources={},this._initialize(e),Object.seal(this)}updateModelProps(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this._processVertexShader(t);return Object.assign({},t,e)}getDrawOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:e,sourceTextures:n,framebuffer:i,targetTexture:r}=this.bindings[this.currentIndex],o=Object.assign({},e,t.attributes),s=Object.assign({},t.uniforms),a=Object.assign({},t.parameters);let l=t.discard;if(this.hasSourceTextures||this.hasTargetTexture){o.transform_elementID=this.elementIDBuffer;for(const t in this.samplerTextureMap){s[t]=n[this.samplerTextureMap[t]]}this._setSourceTextureParameters();const t=getSizeUniforms({sourceTextureMap:n,targetTextureVarying:this.targetTextureVarying,targetTexture:r});Object.assign(s,t)}return this.hasTargetTexture&&(l=!1,a.viewport=[0,0,i.width,i.height]),{attributes:o,framebuffer:i,uniforms:s,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:t}=this.bindings[this.currentIndex];return t}getData(){let{packed:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{framebuffer:e}=this.bindings[this.currentIndex],n=readPixelsToArray(e);if(!t)return n;const i=n.constructor,r=typeToChannelCount(this.targetTextureType),o=new i(n.length*r/4);let s=0;for(let t=0;t<n.length;t+=4)for(let e=0;e<r;e++)o[s++]=n[t+e];return o}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}delete(){this.ownTexture&&this.ownTexture.delete(),this.elementIDBuffer&&this.elementIDBuffer.delete()}_initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{_targetTextureVarying:e,_swapTexture:n}=t;this._swapTexture=n,this.targetTextureVarying=e,this.hasTargetTexture=e,this._setupTextures(t)}_createTargetTexture(t){const{sourceTextures:e,textureOrReference:n}=t;if(n instanceof Texture2D)return n;const i=e[n];return i?(this._targetRefTexName=n,this._createNewTexture(i)):null}_setupTextures(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:e,_sourceTextures:n={},_targetTexture:i}=t,r=this._createTargetTexture({sourceTextures:n,textureOrReference:i});this.hasSourceTextures=this.hasSourceTextures||n&&Object.keys(n).length>0,this._updateBindings({sourceBuffers:e,sourceTextures:n,targetTexture:r}),"elementCount"in t&&this._updateElementIDBuffer(t.elementCount)}_updateElementIDBuffer(t){if("number"!=typeof t||this.elementCount>=t)return;const e=new Float32Array(t);e.forEach(((t,e,n)=>{n[e]=e})),this.elementIDBuffer?this.elementIDBuffer.setData({data:e}):this.elementIDBuffer=new Buffer(this.gl,{data:e,accessor:{size:1}}),this.elementCount=t}_updateBindings(t){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],t),this._swapTexture){const{sourceTextures:t,targetTexture:e}=this._swapTextures(this.bindings[this.currentIndex]),n=this._getNextIndex();this.bindings[n]=this._updateBinding(this.bindings[n],{sourceTextures:t,targetTexture:e})}}_updateBinding(t,e){const{sourceBuffers:n,sourceTextures:i,targetTexture:r}=e;if(t||(t={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(t.sourceTextures,i),Object.assign(t.sourceBuffers,n),r){t.targetTexture=r;const{width:e,height:n}=r,{framebuffer:i}=t;i?(i.update({attachments:{36064:r},resizeAttachments:!1}),i.resize({width:e,height:n})):t.framebuffer=new Framebuffer(this.gl,{id:"transform-framebuffer",width:e,height:n,attachments:{36064:r}})}return t}_setSourceTextureParameters(){const t=this.currentIndex,{sourceTextures:e}=this.bindings[t];for(const t in e)e[t].setParameters(SRC_TEX_PARAMETER_OVERRIDES)}_swapTextures(t){if(!this._swapTexture)return null;const e=Object.assign({},t.sourceTextures);e[this._swapTexture]=t.targetTexture;return{sourceTextures:e,targetTexture:t.sourceTextures[this._swapTexture]}}_createNewTexture(t){const e=cloneTextureFrom(t,{parameters:{10241:9728,10240:9728,10242:33071,10243:33071},pixelStore:{37440:!1}});return this.ownTexture&&this.ownTexture.delete(),this.ownTexture=e,e}_getNextIndex(){return(this.currentIndex+1)%2}_processVertexShader(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceTextures:e,targetTexture:n}=this.bindings[this.currentIndex],{vs:i,uniforms:r,targetTextureType:o,inject:s,samplerTextureMap:a}=updateForTextures({vs:t.vs,sourceTextureMap:e,targetTextureVarying:this.targetTextureVarying,targetTexture:n}),l=combineInjects([t.inject||{},s]);this.targetTextureType=o,this.samplerTextureMap=a;return{vs:i,fs:t._fs||getPassthroughFS({version:getShaderVersion(i),input:this.targetTextureVarying,inputType:o,output:FS_OUTPUT_VARIABLE}),modules:this.hasSourceTextures||this.targetTextureVarying?[transform].concat(t.modules||[]):t.modules,uniforms:r,inject:l}}}class Transform{static isSupported(t){return isWebGL2$1(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.model=null,this.elementCount=0,this.bufferTransform=null,this.textureTransform=null,this.elementIDBuffer=null,this._initialize(e),Object.seal(this)}delete(){const{model:t,bufferTransform:e,textureTransform:n}=this;t&&t.delete(),e&&e.delete(),n&&n.delete()}run(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{clearRenderTarget:e=!0}=t,n=this._updateDrawOptions(t);e&&n.framebuffer&&n.framebuffer.clear({color:!0}),this.model.transform(n)}swap(){let t=!1;const e=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const n of e)t=t||n.swap();assert$8(t,"Nothing to swap")}getBuffer(){return this.bufferTransform&&this.bufferTransform.getBuffer(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)}getData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const n of e){const e=n.getData(t);if(e)return e}return null}getFramebuffer(){return this.textureTransform&&this.textureTransform.getFramebuffer()}update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"elementCount"in t&&this.model.setVertexCount(t.elementCount);const e=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const n of e)n.update(t)}_initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{gl:e}=this;this._buildResourceTransforms(e,t),t=this._updateModelProps(t),this.model=new Model(e,Object.assign({},t,{fs:t.fs||getPassthroughFS({version:getShaderVersion(t.vs)}),id:t.id||"transform-model",drawMode:t.drawMode||0,vertexCount:t.elementCount})),this.bufferTransform&&this.bufferTransform.setupResources({model:this.model})}_updateModelProps(t){let e=Object.assign({},t);const n=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const t of n)e=t.updateModelProps(e);return e}_buildResourceTransforms(t,e){canCreateBufferTransform(e)&&(this.bufferTransform=new BufferTransform(t,e)),canCreateTextureTransform(e)&&(this.textureTransform=new TextureTransform(t,e)),assert$8(this.bufferTransform||this.textureTransform,"must provide source/feedback buffers or source/target textures")}_updateDrawOptions(t){let e=Object.assign({},t);const n=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const t of n)e=Object.assign(e,t.getDrawOptions(e));return e}}function canCreateBufferTransform(t){return!(isObjectEmpty(t.feedbackBuffers)&&isObjectEmpty(t.feedbackMap)&&!(t.varyings&&t.varyings.length>0))}function canCreateTextureTransform(t){return!(isObjectEmpty(t._sourceTextures)&&!t._targetTexture&&!t._targetTextureVarying)}const DRAW_MODE={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Geometry{static get DRAW_MODE(){return DRAW_MODE}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:e=uid("geometry"),drawMode:n=DRAW_MODE.TRIANGLES,attributes:i={},indices:r=null,vertexCount:o=null}=t;this.id=e,this.drawMode=0|n,this.attributes={},this.userData={},this._setAttributes(i,r),this.vertexCount=o||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(t){return"Geometry ".concat(this.id," attribute ").concat(t)}_setAttributes(t,e){e&&(this.indices=ArrayBuffer.isView(e)?{value:e,size:1}:e);for(const e in t){let n=t[e];n=ArrayBuffer.isView(n)?{value:n}:n,assert$8(ArrayBuffer.isView(n.value),"".concat(this._print(e),": must be typed array or object with value as typed array")),"POSITION"!==e&&"positions"!==e||n.size||(n.size=3),"indices"===e?(assert$8(!this.indices),this.indices=n):this.attributes[e]=n}return this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this}_calculateVertexCount(t,e){if(e)return e.value.length;let n=1/0;for(const e in t){const i=t[e],{value:r,size:o,constant:s}=i;!s&&r&&o>=1&&(n=Math.min(n,r.length/o))}return assert$8(Number.isFinite(n)),n}}let channelHandles=1,animationHandles=1;class Timeline{constructor(){this.time=0,this.channels=new Map,this.animations=new Map,this.playing=!1,this.lastEngineTime=-1}addChannel(t){const{delay:e=0,duration:n=Number.POSITIVE_INFINITY,rate:i=1,repeat:r=1}=t,o=channelHandles++,s={time:0,delay:e,duration:n,rate:i,repeat:r};return this._setChannelTime(s,this.time),this.channels.set(o,s),o}removeChannel(t){this.channels.delete(t);for(const[e,n]of this.animations)n.channel===t&&this.detachAnimation(e)}isFinished(t){const e=this.channels.get(t);return void 0!==e&&this.time>=e.delay+e.duration*e.repeat}getTime(t){if(void 0===t)return this.time;const e=this.channels.get(t);return void 0===e?-1:e.time}setTime(t){this.time=Math.max(0,t);const e=this.channels.values();for(const t of e)this._setChannelTime(t,this.time);const n=this.animations.values();for(const t of n){const{animation:e,channel:n}=t;e.setTime(this.getTime(n))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(t,e){const n=animationHandles++;return this.animations.set(n,{animation:t,channel:e}),t.setTime(this.getTime(e)),n}detachAnimation(t){this.animations.delete(t)}update(t){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=t),this.setTime(this.time+(t-this.lastEngineTime)),this.lastEngineTime=t)}_setChannelTime(t,e){const n=e-t.delay;n>=t.duration*t.repeat?t.time=t.duration*t.rate:(t.time=Math.max(0,n)%t.duration,t.time*=t.rate)}}const DEFAULT_LIGHT_COLOR$1=[255,255,255],DEFAULT_LIGHT_INTENSITY$1=1;let idCount$1=0,AmbientLight$1=class{constructor(t={}){_defineProperty(this,"id",void 0),_defineProperty(this,"color",void 0),_defineProperty(this,"intensity",void 0),_defineProperty(this,"type","ambient");const{color:e=DEFAULT_LIGHT_COLOR$1}=t,{intensity:n=DEFAULT_LIGHT_INTENSITY$1}=t;this.id=t.id||"ambient-".concat(idCount$1++),this.color=e,this.intensity=n}};const DEFAULT_LIGHT_COLOR=[255,255,255],DEFAULT_LIGHT_INTENSITY=1,DEFAULT_LIGHT_DIRECTION=[0,0,-1];let idCount=0,DirectionalLight$1=class{constructor(t={}){_defineProperty(this,"id",void 0),_defineProperty(this,"color",void 0),_defineProperty(this,"intensity",void 0),_defineProperty(this,"type","directional"),_defineProperty(this,"direction",void 0),_defineProperty(this,"shadow",void 0);const{color:e=DEFAULT_LIGHT_COLOR}=t,{intensity:n=DEFAULT_LIGHT_INTENSITY}=t,{direction:i=DEFAULT_LIGHT_DIRECTION}=t,{_shadow:r=!1}=t;this.id=t.id||"directional-".concat(idCount++),this.color=e,this.intensity=n,this.type="directional",this.direction=new Vector3$1(i).normalize().toArray(),this.shadow=r}getProjectedLight(t){return this}};class Pass{constructor(t,e={id:"pass"}){_defineProperty(this,"id",void 0),_defineProperty(this,"gl",void 0),_defineProperty(this,"props",void 0);const{id:n}=e;this.id=n,this.gl=t,this.props={...e}}setProps(t){Object.assign(this.props,t)}render(t){}cleanup(){}}class LayersPass extends Pass{constructor(...t){super(...t),_defineProperty(this,"_lastRenderIndex",-1)}render(t){return setParameters(this.gl,{framebuffer:t.target}),this._drawLayers(t)}_drawLayers(t){const{target:e,moduleParameters:n,viewports:i,views:r,onViewportActive:o,clearStack:s=!0,clearCanvas:a=!0}=t;t.pass=t.pass||"unknown";const l=this.gl;a&&clearGLCanvas(l,e),s&&(this._lastRenderIndex=-1);const c=[];for(const s of i){const i=r&&r[s.id];null==o||o(s);const a=this._getDrawLayerParams(s,t),u=s.subViewports||[s];for(const r of u){const o=this._drawLayersInViewport(l,{target:e,moduleParameters:n,viewport:r,view:i,pass:t.pass,layers:t.layers},a);c.push(o)}}return c}_getDrawLayerParams(t,{layers:e,pass:n,isPicking:i=!1,layerFilter:r,cullRect:o,effects:s,moduleParameters:a},l=!1){const c=[],u=layerIndexResolver(this._lastRenderIndex+1),h={layer:e[0],viewport:t,isPicking:i,renderPass:n,cullRect:o},d={};for(let i=0;i<e.length;i++){const o=e[i],p=this._shouldDrawLayer(o,h,r,d),f={shouldDrawLayer:p};p&&!l&&(f.layerRenderIndex=u(o,p),f.moduleParameters=this._getModuleParameters(o,s,n,a),f.layerParameters=this.getLayerParameters(o,i,t)),c[i]=f}return c}_drawLayersInViewport(t,{layers:e,moduleParameters:n,pass:i,target:r,viewport:o,view:s},a){const l=getGLViewport(t,{moduleParameters:n,target:r,viewport:o});if(s&&s.props.clear){const e=!0===s.props.clear?{color:!0,depth:!0}:s.props.clear;withParameters(t,{scissorTest:!0,scissor:l},(()=>clear(t,e)))}const c={totalCount:e.length,visibleCount:0,compositeCount:0,pickableCount:0};setParameters(t,{viewport:l});for(let t=0;t<e.length;t++){const n=e[t],{shouldDrawLayer:r,layerRenderIndex:s,moduleParameters:l,layerParameters:u}=a[t];if(r&&n.props.pickable&&c.pickableCount++,n.isComposite)c.compositeCount++;else if(r){c.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,s),l.viewport=o;try{n._drawLayer({moduleParameters:l,uniforms:{layerIndex:s},parameters:u})}catch(t){n.raiseError(t,"drawing ".concat(n," to ").concat(i))}}}return c}shouldDrawLayer(t){return!0}getModuleParameters(t,e){return null}getLayerParameters(t,e,n){return t.props.parameters}_shouldDrawLayer(t,e,n,i){if(!(t.props.visible&&this.shouldDrawLayer(t)))return!1;e.layer=t;let r=t.parent;for(;r;){if(!r.props.visible||!r.filterSubLayer(e))return!1;e.layer=r,r=r.parent}if(n){const t=e.layer.id;if(t in i||(i[t]=n(e)),!i[t])return!1}return t.activateViewport(e.viewport),!0}_getModuleParameters(t,e,n,i){var r;const o=Object.assign(Object.create((null===(r=t.internalState)||void 0===r?void 0:r.propsInTransition)||t.props),{autoWrapLongitude:t.wrapLongitude,viewport:t.context.viewport,mousePosition:t.context.mousePosition,pickingActive:0,devicePixelRatio:cssToDeviceRatio(this.gl)});if(e)for(const n of e){var s;Object.assign(o,null===(s=n.getModuleParameters)||void 0===s?void 0:s.call(n,t))}return Object.assign(o,this.getModuleParameters(t,e),i)}}function layerIndexResolver(t=0,e={}){const n={},i=(r,o)=>{const s=r.props._offset,a=r.id,l=r.parent&&r.parent.id;let c;if(l&&!(l in e)&&i(r.parent,!1),l in n){const t=n[l]=n[l]||layerIndexResolver(e[l],e);c=t(r,o),n[a]=t}else Number.isFinite(s)?(c=s+(e[l]||0),n[a]=null):c=t;return o&&c>=t&&(t=c+1),e[a]=c,c};return i}function getGLViewport(t,{moduleParameters:e,target:n,viewport:i}){const r=n&&"default-framebuffer"!==n.id,o=e&&e.devicePixelRatio||cssToDeviceRatio(t);return[i.x*o,(r?n.height:t.drawingBufferHeight)-(i.y+i.height)*o,i.width*o,i.height*o]}function clearGLCanvas(t,e){setParameters(t,{viewport:[0,0,e?e.width:t.drawingBufferWidth,e?e.height:t.drawingBufferHeight]}),t.clear(16640)}class ShadowPass extends LayersPass{constructor(t,e){super(t,e),_defineProperty(this,"shadowMap",void 0),_defineProperty(this,"depthBuffer",void 0),_defineProperty(this,"fbo",void 0),this.shadowMap=new Texture2D(t,{width:1,height:1,parameters:{10241:9729,10240:9729,10242:33071,10243:33071}}),this.depthBuffer=new Renderbuffer(t,{format:33189,width:1,height:1}),this.fbo=new Framebuffer(t,{id:"shadowmap",width:1,height:1,attachments:{36064:this.shadowMap,36096:this.depthBuffer}})}render(t){const e=this.fbo;withParameters(this.gl,{depthRange:[0,1],depthTest:!0,blend:!1,clearColor:[1,1,1,1]},(()=>{const n=t.viewports[0],i=cssToDeviceRatio(this.gl),r=n.width*i,o=n.height*i;r===e.width&&o===e.height||e.resize({width:r,height:o}),super.render({...t,target:e,pass:"shadow"})}))}shouldDrawLayer(t){return!1!==t.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 defines="#define SMOOTH_EDGE_RADIUS 0.5",vs$c="\n".concat(defines,"\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$c="\n".concat(defines,"\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");var geometry={name:"geometry",vs:vs$c,fs:fs$c};const COORDINATE_SYSTEM_GLSL_CONSTANTS=Object.keys(COORDINATE_SYSTEM).map((t=>"const int COORDINATE_SYSTEM_".concat(t," = ").concat(COORDINATE_SYSTEM[t],";"))).join(""),PROJECTION_MODE_GLSL_CONSTANTS=Object.keys(PROJECTION_MODE).map((t=>"const int PROJECTION_MODE_".concat(t," = ").concat(PROJECTION_MODE[t],";"))).join(""),UNIT_GLSL_CONSTANTS=Object.keys(UNIT).map((t=>"const int UNIT_".concat(t.toUpperCase()," = ").concat(UNIT[t],";"))).join("");var projectShader="".concat(COORDINATE_SYSTEM_GLSL_CONSTANTS,"\n").concat(PROJECTION_MODE_GLSL_CONSTANTS,"\n").concat(UNIT_GLSL_CONSTANTS,"\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 isEqual(t,e){if(t===e)return!0;if(Array.isArray(t)){const n=t.length;if(!e||e.length!==n)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}return!1}function memoize(t){let e,n={};return i=>{for(const r in i)if(!isEqual(i[r],n[r])){e=t(i),n=i;break}return e}}const ZERO_VECTOR$1=[0,0,0,0],VECTOR_TO_POINT_MATRIX$1=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],IDENTITY_MATRIX=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],DEFAULT_PIXELS_PER_UNIT2=[0,0,0],DEFAULT_COORDINATE_ORIGIN$1=[0,0,0],getMemoizedViewportUniforms=memoize(calculateViewportUniforms);function getOffsetOrigin(t,e,n=DEFAULT_COORDINATE_ORIGIN$1){n.length<3&&(n=[n[0],n[1],0]);let i,r=n,o=!0;switch(i=e===COORDINATE_SYSTEM.LNGLAT_OFFSETS||e===COORDINATE_SYSTEM.METER_OFFSETS?n:t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case PROJECTION_MODE.WEB_MERCATOR:e!==COORDINATE_SYSTEM.LNGLAT&&e!==COORDINATE_SYSTEM.CARTESIAN||(i=[0,0,0],o=!1);break;case PROJECTION_MODE.WEB_MERCATOR_AUTO_OFFSET:e===COORDINATE_SYSTEM.LNGLAT?r=i:e===COORDINATE_SYSTEM.CARTESIAN&&(r=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],i=t.unprojectPosition(r),r[0]-=n[0],r[1]-=n[1],r[2]-=n[2]);break;case PROJECTION_MODE.IDENTITY:r=t.position.map(Math.fround),r[2]=r[2]||0;break;case PROJECTION_MODE.GLOBE:o=!1,i=null;break;default:o=!1}return{geospatialOrigin:i,shaderCoordinateOrigin:r,offsetMode:o}}function calculateMatrixAndOffset(t,e,n){const{viewMatrixUncentered:i,projectionMatrix:r}=t;let{viewMatrix:o,viewProjectionMatrix:s}=t,a=ZERO_VECTOR$1,l=ZERO_VECTOR$1,c=t.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=getOffsetOrigin(t,e,n);return d&&(l=t.projectPosition(u||h),c=[c[0]-l[0],c[1]-l[1],c[2]-l[2]],l[3]=1,a=transformMat4([],l,s),o=i||o,s=multiply$1([],r,o),s=multiply$1([],s,VECTOR_TO_POINT_MATRIX$1)),{viewMatrix:o,viewProjectionMatrix:s,projectionCenter:a,originCommon:l,cameraPosCommon:c,shaderCoordinateOrigin:h,geospatialOrigin:u}}function getUniformsFromViewport({viewport:t,devicePixelRatio:e=1,modelMatrix:n=null,coordinateSystem:i=COORDINATE_SYSTEM.DEFAULT,coordinateOrigin:r=DEFAULT_COORDINATE_ORIGIN$1,autoWrapLongitude:o=!1}){i===COORDINATE_SYSTEM.DEFAULT&&(i=t.isGeospatial?COORDINATE_SYSTEM.LNGLAT:COORDINATE_SYSTEM.CARTESIAN);const s=getMemoizedViewportUniforms({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:r});return s.project_uWrapLongitude=o,s.project_uModelMatrix=n||IDENTITY_MATRIX,s}function calculateViewportUniforms({viewport:t,devicePixelRatio:e,coordinateSystem:n,coordinateOrigin:i}){const{projectionCenter:r,viewProjectionMatrix:o,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:l,geospatialOrigin:c}=calculateMatrixAndOffset(t,n,i),u=t.getDistanceScales(),h=[t.width*e,t.height*e],d=transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,p={project_uCoordinateSystem:n,project_uProjectionMode:t.projectionMode,project_uCoordinateOrigin:l,project_uCommonOrigin:s.slice(0,3),project_uCenter:r,project_uPseudoMeters:Boolean(t._pseudoMeters),project_uViewportSize:h,project_uDevicePixelRatio:e,project_uFocalDistance:d,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:DEFAULT_PIXELS_PER_UNIT2,project_uScale:t.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:o,project_uModelMatrix:IDENTITY_MATRIX,project_uCameraPosition:a};if(c){const e=t.getDistanceScales(c);switch(n){case COORDINATE_SYSTEM.METER_OFFSETS:p.project_uCommonUnitsPerWorldUnit=e.unitsPerMeter,p.project_uCommonUnitsPerWorldUnit2=e.unitsPerMeter2;break;case COORDINATE_SYSTEM.LNGLAT:case COORDINATE_SYSTEM.LNGLAT_OFFSETS:t._pseudoMeters||(p.project_uCommonUnitsPerMeter=e.unitsPerMeter),p.project_uCommonUnitsPerWorldUnit=e.unitsPerDegree,p.project_uCommonUnitsPerWorldUnit2=e.unitsPerDegree2;break;case COORDINATE_SYSTEM.CARTESIAN:p.project_uCommonUnitsPerWorldUnit=[1,1,e.unitsPerMeter[2]],p.project_uCommonUnitsPerWorldUnit2=[0,0,e.unitsPerMeter2[2]]}}return p}const INITIAL_MODULE_OPTIONS={};function getUniforms(t=INITIAL_MODULE_OPTIONS){return"viewport"in t?getUniformsFromViewport(t):{}}var project={name:"project",dependencies:[fp32,geometry],vs:projectShader,getUniforms:getUniforms};function createMat4$1(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function transformVector(t,e){const n=transformMat4([],e,t);return scale$1(n,n,1/n[3]),n}function mod(t,e){const n=t%e;return n<0?e+n:n}function clamp$1(t,e,n){return t<e?e:t>n?n:t}function ieLog2(t){return Math.log(t)*Math.LOG2E}const log2=Math.log2||ieLog2;function assert$5(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}const PI=Math.PI,PI_4=PI/4,DEGREES_TO_RADIANS$3=PI/180,RADIANS_TO_DEGREES=180/PI,TILE_SIZE$2=512,EARTH_CIRCUMFERENCE=4003e4,MAX_LATITUDE=85.051129,DEFAULT_ALTITUDE=1.5;function scaleToZoom(t){return log2(t)}function lngLatToWorld(t){const[e,n]=t;assert$5(Number.isFinite(e)),assert$5(Number.isFinite(n)&&n>=-90&&n<=90,"invalid latitude");return[TILE_SIZE$2*(e*DEGREES_TO_RADIANS$3+PI)/(2*PI),TILE_SIZE$2*(PI+Math.log(Math.tan(PI_4+.5*(n*DEGREES_TO_RADIANS$3))))/(2*PI)]}function worldToLngLat(t){const[e,n]=t,i=e/TILE_SIZE$2*(2*PI)-PI,r=2*(Math.atan(Math.exp(n/TILE_SIZE$2*(2*PI)-PI))-PI_4);return[i*RADIANS_TO_DEGREES,r*RADIANS_TO_DEGREES]}function getMeterZoom(t){const{latitude:e}=t;assert$5(Number.isFinite(e));const n=Math.cos(e*DEGREES_TO_RADIANS$3);return scaleToZoom(EARTH_CIRCUMFERENCE*n)-9}function unitsPerMeter(t){const e=Math.cos(t*DEGREES_TO_RADIANS$3);return TILE_SIZE$2/EARTH_CIRCUMFERENCE/e}function getDistanceScales(t){const{latitude:e,longitude:n,highPrecision:i=!1}=t;assert$5(Number.isFinite(e)&&Number.isFinite(n));const r=TILE_SIZE$2,o=Math.cos(e*DEGREES_TO_RADIANS$3),s=r/360,a=s/o,l=r/EARTH_CIRCUMFERENCE/o,c={unitsPerMeter:[l,l,l],metersPerUnit:[1/l,1/l,1/l],unitsPerDegree:[s,a,l],degreesPerUnit:[1/s,1/a,1/l]};if(i){const t=DEGREES_TO_RADIANS$3*Math.tan(e*DEGREES_TO_RADIANS$3)/o,n=r/EARTH_CIRCUMFERENCE*t,i=n/a*l;c.unitsPerDegree2=[0,s*t/2,n],c.unitsPerMeter2=[i,0,i]}return c}function addMetersToLngLat(t,e){const[n,i,r]=t,[o,s,a]=e,{unitsPerMeter:l,unitsPerMeter2:c}=getDistanceScales({longitude:n,latitude:i,highPrecision:!0}),u=lngLatToWorld(t);u[0]+=o*(l[0]+c[0]*s),u[1]+=s*(l[1]+c[1]*s);const h=worldToLngLat(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[h[0],h[1],d]:h}function getViewMatrix(t){const{height:e,pitch:n,bearing:i,altitude:r,scale:o,center:s}=t,a=createMat4$1();translate$1(a,a,[0,0,-r]),rotateX$1(a,a,-n*DEGREES_TO_RADIANS$3),rotateZ$1(a,a,i*DEGREES_TO_RADIANS$3);const l=o/e;return scale$2(a,a,[l,l,l]),s&&translate$1(a,a,negate([],s)),a}function getProjectionParameters(t){const{width:e,height:n,altitude:i,pitch:r=0,offset:o,center:s,scale:a,nearZMultiplier:l=1,farZMultiplier:c=1,unitsPerMeter:u}=t;let{fovy:h=altitudeToFovy(DEFAULT_ALTITUDE)}=t;void 0!==i&&(h=altitudeToFovy(i));const d=h*DEGREES_TO_RADIANS$3,p=r*DEGREES_TO_RADIANS$3,f=fovyToAltitude(h);let m=f;s&&(m+=s[2]*a/Math.cos(p)/n);return{fov:d,aspect:e/n,focalDistance:f,near:l,far:Math.max(10*m,m+1e3*u/Math.cos(p))}}function altitudeToFovy(t){return 2*Math.atan(.5/t)*RADIANS_TO_DEGREES}function fovyToAltitude(t){return.5/Math.tan(.5*t*DEGREES_TO_RADIANS$3)}function worldToPixels(t,e){const[n,i,r=0]=t;return assert$5(Number.isFinite(n)&&Number.isFinite(i)&&Number.isFinite(r)),transformVector(e,[n,i,r,1])}function pixelsToWorld(t,e,n=0){const[i,r,o]=t;if(assert$5(Number.isFinite(i)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(o)){return transformVector(e,[i,r,o,1])}const s=transformVector(e,[i,r,0,1]),a=transformVector(e,[i,r,1,1]),l=s[2],c=a[2];return lerp$3([],s,a,l===c?0:((n||0)-l)/(c-l))}function fitBounds(t){const{width:e,height:n,bounds:i,minExtent:r=0,maxZoom:o=24,offset:s=[0,0]}=t,[[a,l],[c,u]]=i,h=getPaddingObject(t.padding),d=lngLatToWorld([a,clamp$1(u,-MAX_LATITUDE,MAX_LATITUDE)]),p=lngLatToWorld([c,clamp$1(l,-MAX_LATITUDE,MAX_LATITUDE)]),f=[Math.max(Math.abs(p[0]-d[0]),r),Math.max(Math.abs(p[1]-d[1]),r)],m=[e-h.left-h.right-2*Math.abs(s[0]),n-h.top-h.bottom-2*Math.abs(s[1])];assert$5(m[0]>0&&m[1]>0);const g=m[0]/f[0],_=m[1]/f[1],y=worldToLngLat([(p[0]+d[0])/2+(h.right-h.left)/2/g,(p[1]+d[1])/2+(h.top-h.bottom)/2/_]),v=Math.min(o,log2(Math.abs(Math.min(g,_))));return assert$5(Number.isFinite(v)),{longitude:y[0],latitude:y[1],zoom:v}}function getPaddingObject(t=0){return"number"==typeof t?{top:t,bottom:t,left:t,right:t}:(assert$5(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}const DEGREES_TO_RADIANS$2=Math.PI/180;function getBounds(t,e=0){const{width:n,height:i,unproject:r}=t,o={targetZ:e},s=r([0,i],o),a=r([n,i],o);let l,c;return(t.fovy?.5*t.fovy*DEGREES_TO_RADIANS$2:Math.atan(.5/t.altitude))>(90-t.pitch)*DEGREES_TO_RADIANS$2-.01?(l=unprojectOnFarPlane(t,0,e),c=unprojectOnFarPlane(t,n,e)):(l=r([0,0],o),c=r([n,0],o)),[s,a,c,l]}function unprojectOnFarPlane(t,e,n){const{pixelUnprojectionMatrix:i}=t,r=transformVector(i,[e,0,1,1]),o=transformVector(i,[e,t.height,1,1]),s=worldToLngLat(lerp$3([],r,o,(n*t.distanceScales.unitsPerMeter[2]-r[2])/(o[2]-r[2])));return s.push(n),s}const TILE_SIZE$1=512;function normalizeViewportProps(t){const{width:e,height:n,pitch:i=0}=t;let{longitude:r,latitude:o,zoom:s,bearing:a=0}=t;(r<-180||r>180)&&(r=mod(r+180,360)-180),(a<-180||a>180)&&(a=mod(a+180,360)-180);const l=log2(n/TILE_SIZE$1);if(s<=l)s=l,o=0;else{const t=n/2/Math.pow(2,s),e=worldToLngLat([0,t])[1];if(o<e)o=e;else{const e=worldToLngLat([0,TILE_SIZE$1-t])[1];o>e&&(o=e)}}return{width:e,height:n,longitude:r,latitude:o,zoom:s,pitch:i,bearing:a}}const vs$b="\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$b="\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",getMemoizedViewportCenterPosition=memoize(getViewportCenterPosition),getMemoizedViewProjectionMatrices=memoize(getViewProjectionMatrices),DEFAULT_SHADOW_COLOR$1=[0,0,0,1],VECTOR_TO_POINT_MATRIX=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function screenToCommonSpace(t,e){const[n,i,r]=t,o=pixelsToWorld([n,i,r],e);return Number.isFinite(r)?o:[o[0],o[1],0]}function getViewportCenterPosition({viewport:t,center:e}){return new Matrix4$1(t.viewProjectionMatrix).invert().transform(e)}function getViewProjectionMatrices({viewport:t,shadowMatrices:e}){const n=[],i=t.pixelUnprojectionMatrix,r=t.isGeospatial?void 0:1,o=[[0,0,r],[t.width,0,r],[0,t.height,r],[t.width,t.height,r],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map((t=>screenToCommonSpace(t,i)));for(const i of e){const e=i.clone().translate(new Vector3$1(t.center).negate()),r=o.map((t=>e.transform(t))),s=(new Matrix4$1).ortho({left:Math.min(...r.map((t=>t[0]))),right:Math.max(...r.map((t=>t[0]))),bottom:Math.min(...r.map((t=>t[1]))),top:Math.max(...r.map((t=>t[1]))),near:Math.min(...r.map((t=>-t[2]))),far:Math.max(...r.map((t=>-t[2])))});n.push(s.multiplyRight(i))}return n}function createShadowUniforms(t,e){const{shadowEnabled:n=!0}=t;if(!n||!t.shadowMatrices||!t.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1};const i={shadow_uDrawShadowMap:Boolean(t.drawToShadowMap),shadow_uUseShadowMap:!!t.shadowMaps&&t.shadowMaps.length>0,shadow_uColor:t.shadowColor||DEFAULT_SHADOW_COLOR$1,shadow_uLightId:t.shadowLightId||0,shadow_uLightCount:t.shadowMatrices.length},r=getMemoizedViewportCenterPosition({viewport:t.viewport,center:e.project_uCenter}),o=[],s=getMemoizedViewProjectionMatrices({shadowMatrices:t.shadowMatrices,viewport:t.viewport}).slice();for(let n=0;n<t.shadowMatrices.length;n++){const i=s[n],a=i.clone().translate(new Vector3$1(t.viewport.center).negate());e.project_uCoordinateSystem===COORDINATE_SYSTEM.LNGLAT&&e.project_uProjectionMode===PROJECTION_MODE.WEB_MERCATOR?(s[n]=a,o[n]=r):(s[n]=i.clone().multiplyRight(VECTOR_TO_POINT_MATRIX),o[n]=a.transform(r))}for(let e=0;e<s.length;e++)i["shadow_uViewProjectionMatrices[".concat(e,"]")]=s[e],i["shadow_uProjectCenters[".concat(e,"]")]=o[e],i["shadow_uShadowMap".concat(e)]=t.shadowMaps&&t.shadowMaps.length>0?t.shadowMaps[e]:t.dummyShadowMap;return i}var shadow={name:"shadow",dependencies:[project],vs:vs$b,fs:fs$b,inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n    position = shadow_setVertexPosition(geometry.position);\n    ","fs:DECKGL_FILTER_COLOR":"\n    color = shadow_filterShadowColor(color);\n    "},getUniforms:(t={},e={})=>"viewport"in t&&(t.drawToShadowMap||t.shadowMaps&&t.shadowMaps.length>0)?createShadowUniforms(t,e):{}};const DEFAULT_AMBIENT_LIGHT_PROPS={color:[255,255,255],intensity:1},DEFAULT_DIRECTIONAL_LIGHT_PROPS=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],DEFAULT_SHADOW_COLOR=[0,0,0,200/255];class LightingEffect{constructor(t={}){_defineProperty(this,"id","lighting-effect"),_defineProperty(this,"props",void 0),_defineProperty(this,"shadowColor",DEFAULT_SHADOW_COLOR),_defineProperty(this,"shadow",void 0),_defineProperty(this,"ambientLight",void 0),_defineProperty(this,"directionalLights",void 0),_defineProperty(this,"pointLights",void 0),_defineProperty(this,"shadowPasses",[]),_defineProperty(this,"shadowMaps",[]),_defineProperty(this,"dummyShadowMap",null),_defineProperty(this,"programManager",void 0),_defineProperty(this,"shadowMatrices",void 0),this.setProps(t)}setProps(t){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(const e in t){const n=t[e];switch(n.type){case"ambient":this.ambientLight=n;break;case"directional":this.directionalLights.push(n);break;case"point":this.pointLights.push(n)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some((t=>t.shadow)),this.props=t}preRender(t,{layers:e,layerFilter:n,viewports:i,onViewportActive:r,views:o}){if(this.shadow){this.shadowMatrices=this._calculateMatrices(),0===this.shadowPasses.length&&this._createShadowPasses(t),this.programManager||(this.programManager=ProgramManager.getDefaultProgramManager(t),this.programManager.addDefaultModule(shadow)),this.dummyShadowMap||(this.dummyShadowMap=new Texture2D(t,{width:1,height:1}));for(let t=0;t<this.shadowPasses.length;t++){this.shadowPasses[t].render({layers:e,layerFilter:n,viewports:i,onViewportActive:r,views:o,moduleParameters:{shadowLightId:t,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}})}}}getModuleParameters(t){const e=this.shadow?{shadowMaps:this.shadowMaps,dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{};return e.lightSources={ambientLight:this.ambientLight,directionalLights:this.directionalLights.map((e=>e.getProjectedLight({layer:t}))),pointLights:this.pointLights.map((e=>e.getProjectedLight({layer:t})))},e}cleanup(){for(const t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.delete(),this.dummyShadowMap=null),this.shadow&&this.programManager&&(this.programManager.removeDefaultModule(shadow),this.programManager=null)}_calculateMatrices(){const t=[];for(const e of this.directionalLights){const n=(new Matrix4$1).lookAt({eye:new Vector3$1(e.direction).negate()});t.push(n)}return t}_createShadowPasses(t){for(let e=0;e<this.directionalLights.length;e++){const n=new ShadowPass(t);this.shadowPasses[e]=n,this.shadowMaps[e]=n.shadowMap}}_applyDefaultLights(){const{ambientLight:t,pointLights:e,directionalLights:n}=this;t||0!==e.length||0!==n.length||(this.ambientLight=new AmbientLight$1(DEFAULT_AMBIENT_LIGHT_PROPS),this.directionalLights.push(new DirectionalLight$1(DEFAULT_DIRECTIONAL_LIGHT_PROPS[0]),new DirectionalLight$1(DEFAULT_DIRECTIONAL_LIGHT_PROPS[1])))}}class TypedArrayManager{constructor(t={}){_defineProperty(this,"_pool",[]),_defineProperty(this,"opts",{overAlloc:2,poolSize:100}),this.setOptions(t)}setOptions(t){Object.assign(this.opts,t)}allocate(t,e,{size:n=1,type:i,padding:r=0,copy:o=!1,initialize:s=!1,maxCount:a}){const l=i||t&&t.constructor||Float32Array,c=e*n+r;if(ArrayBuffer.isView(t)){if(c<=t.length)return t;if(c*t.BYTES_PER_ELEMENT<=t.buffer.byteLength)return new l(t.buffer,0,c)}let u=1/0;a&&(u=a*n+r);const h=this._allocate(l,c,s,u);return t&&o?h.set(t):s||h.fill(0,0,4),this._release(t),h}release(t){this._release(t)}_allocate(t,e,n,i){let r=Math.max(Math.ceil(e*this.opts.overAlloc),1);r>i&&(r=i);const o=this._pool,s=t.BYTES_PER_ELEMENT*r,a=o.findIndex((t=>t.byteLength>=s));if(a>=0){const e=new t(o.splice(a,1)[0],0,r);return n&&e.fill(0),e}return new t(r)}_release(t){if(!ArrayBuffer.isView(t))return;const e=this._pool,{buffer:n}=t,{byteLength:i}=n,r=e.findIndex((t=>t.byteLength>=i));r<0?e.push(n):(r>0||e.length<this.opts.poolSize)&&e.splice(r,0,n),e.length>this.opts.poolSize&&e.shift()}}var defaultTypedArrayManager=new TypedArrayManager;function createMat4(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function getCameraPosition(t){return[t[12],t[13],t[14]]}function getFrustumPlanes(t){return{left:getFrustumPlane(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:getFrustumPlane(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:getFrustumPlane(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:getFrustumPlane(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:getFrustumPlane(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:getFrustumPlane(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}const scratchVector$7=new Vector3$1;function getFrustumPlane(t,e,n,i){scratchVector$7.set(t,e,n);const r=scratchVector$7.len();return{distance:i/r,normal:new Vector3$1(-t/r,-e/r,-n/r)}}function fp64LowPart(t){return t-Math.fround(t)}let scratchArray;function toDoublePrecisionArray(t,e){const{size:n=1,startIndex:i=0}=e,r=void 0!==e.endIndex?e.endIndex:t.length,o=(r-i)/n;scratchArray=defaultTypedArrayManager.allocate(scratchArray,o,{type:Float32Array,size:2*n});let s=i,a=0;for(;s<r;){for(let e=0;e<n;e++){const i=t[s++];scratchArray[a+e]=i,scratchArray[a+e+n]=fp64LowPart(i)}a+=2*n}return scratchArray.subarray(0,o*n*2)}function mergeBounds(t){let e=null,n=!1;for(const i of t)i&&(e?(n||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],n=!0),e[0][0]=Math.min(e[0][0],i[0][0]),e[0][1]=Math.min(e[0][1],i[0][1]),e[1][0]=Math.max(e[1][0],i[1][0]),e[1][1]=Math.max(e[1][1],i[1][1])):e=i);return e}const DEGREES_TO_RADIANS$1=Math.PI/180,IDENTITY=createMat4(),ZERO_VECTOR=[0,0,0],DEFAULT_DISTANCE_SCALES={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function createProjectionMatrix({width:t,height:e,orthographic:n,fovyRadians:i,focalDistance:r,padding:o,near:s,far:a}){const l=t/e,c=n?(new Matrix4$1).orthographic({fovy:i,aspect:l,focalDistance:r,near:s,far:a}):(new Matrix4$1).perspective({fovy:i,aspect:l,near:s,far:a});if(o){const{left:n=0,right:i=0,top:r=0,bottom:s=0}=o,a=clamp$2((n+t-i)/2,0,t)-t/2,l=clamp$2((r+e-s)/2,0,e)-e/2;c[8]-=2*a/t,c[9]+=2*l/e}return c}class Viewport{constructor(t={}){_defineProperty(this,"id",void 0),_defineProperty(this,"x",void 0),_defineProperty(this,"y",void 0),_defineProperty(this,"width",void 0),_defineProperty(this,"height",void 0),_defineProperty(this,"padding",void 0),_defineProperty(this,"isGeospatial",void 0),_defineProperty(this,"zoom",void 0),_defineProperty(this,"focalDistance",void 0),_defineProperty(this,"position",void 0),_defineProperty(this,"modelMatrix",void 0),_defineProperty(this,"distanceScales",void 0),_defineProperty(this,"scale",void 0),_defineProperty(this,"center",void 0),_defineProperty(this,"cameraPosition",void 0),_defineProperty(this,"projectionMatrix",void 0),_defineProperty(this,"viewMatrix",void 0),_defineProperty(this,"viewMatrixUncentered",void 0),_defineProperty(this,"viewMatrixInverse",void 0),_defineProperty(this,"viewProjectionMatrix",void 0),_defineProperty(this,"pixelProjectionMatrix",void 0),_defineProperty(this,"pixelUnprojectionMatrix",void 0),_defineProperty(this,"resolution",void 0),_defineProperty(this,"_frustumPlanes",{}),this.id=t.id||this.constructor.displayName||"viewport",this.x=t.x||0,this.y=t.y||0,this.width=t.width||1,this.height=t.height||1,this.zoom=t.zoom||0,this.padding=t.padding,this.distanceScales=t.distanceScales||DEFAULT_DISTANCE_SCALES,this.focalDistance=t.focalDistance||1,this.position=t.position||ZERO_VECTOR,this.modelMatrix=t.modelMatrix||null;const{longitude:e,latitude:n}=t;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(e),this._initProps(t),this._initMatrices(t),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?PROJECTION_MODE.WEB_MERCATOR:PROJECTION_MODE.WEB_MERCATOR_AUTO_OFFSET:PROJECTION_MODE.IDENTITY}equals(t){return t instanceof Viewport&&(this===t||t.width===this.width&&t.height===this.height&&t.scale===this.scale&&equals$1(t.projectionMatrix,this.projectionMatrix)&&equals$1(t.viewMatrix,this.viewMatrix))}project(t,{topLeft:e=!0}={}){const n=worldToPixels(this.projectPosition(t),this.pixelProjectionMatrix),[i,r]=n,o=e?r:this.height-r;return 2===t.length?[i,o]:[i,o,n[2]]}unproject(t,{topLeft:e=!0,targetZ:n}={}){const[i,r,o]=t,s=pixelsToWorld([i,e?r:this.height-r,o],this.pixelUnprojectionMatrix,n&&n*this.distanceScales.unitsPerMeter[2]),[a,l,c]=this.unprojectPosition(s);return Number.isFinite(o)?[a,l,c]:Number.isFinite(n)?[a,l,n]:[a,l]}projectPosition(t){const[e,n]=this.projectFlat(t);return[e,n,(t[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(t){const[e,n]=this.unprojectFlat(t);return[e,n,(t[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(t){if(this.isGeospatial){const e=lngLatToWorld(t);return e[1]=clamp$2(e[1],-318,830),e}return t}unprojectFlat(t){return this.isGeospatial?worldToLngLat(t):t}getBounds(t={}){const e={targetZ:t.z||0},n=this.unproject([0,0],e),i=this.unproject([this.width,0],e),r=this.unproject([0,this.height],e),o=this.unproject([this.width,this.height],e);return[Math.min(n[0],i[0],r[0],o[0]),Math.min(n[1],i[1],r[1],o[1]),Math.max(n[0],i[0],r[0],o[0]),Math.max(n[1],i[1],r[1],o[1])]}getDistanceScales(t){return t?getDistanceScales({longitude:t[0],latitude:t[1],highPrecision:!0}):this.distanceScales}containsPixel({x:t,y:e,width:n=1,height:i=1}){return t<this.x+this.width&&this.x<t+n&&e<this.y+this.height&&this.y<e+i}getFrustumPlanes(){return this._frustumPlanes.near||Object.assign(this._frustumPlanes,getFrustumPlanes(this.viewProjectionMatrix)),this._frustumPlanes}panByPosition(t,e){return null}_initProps(t){const e=t.longitude,n=t.latitude;this.isGeospatial&&(Number.isFinite(t.zoom)||(this.zoom=getMeterZoom({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=t.distanceScales||getDistanceScales({latitude:n,longitude:e}));const i=Math.pow(2,this.zoom);this.scale=i;const{position:r,modelMatrix:o}=t;let s=ZERO_VECTOR;if(r&&(s=o?new Matrix4$1(o).transformAsVector(r,[]):r),this.isGeospatial){const t=this.projectPosition([e,n,0]);this.center=new Vector3$1(s).scale(this.distanceScales.unitsPerMeter).add(t)}else this.center=this.projectPosition(s)}_initMatrices(t){const{viewMatrix:e=IDENTITY,projectionMatrix:n=null,orthographic:i=!1,fovyRadians:r,fovy:o=75,near:s=.1,far:a=1e3,padding:l=null,focalDistance:c=1}=t;this.viewMatrixUncentered=e,this.viewMatrix=(new Matrix4$1).multiplyRight(e).translate(new Vector3$1(this.center).negate()),this.projectionMatrix=n||createProjectionMatrix({width:this.width,height:this.height,orthographic:i,fovyRadians:r||o*DEGREES_TO_RADIANS$1,focalDistance:c,padding:l,near:s,far:a});const u=createMat4();multiply$1(u,u,this.projectionMatrix),multiply$1(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=invert$1([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=getCameraPosition(this.viewMatrixInverse);const h=createMat4(),d=createMat4();scale$2(h,h,[this.width/2,-this.height/2,1]),translate$1(h,h,[1,-1,0]),multiply$1(d,h,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=invert$1(createMat4(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||log$2.warn("Pixel project matrix not invertible")()}}_defineProperty(Viewport,"displayName","Viewport");class WebMercatorViewport extends Viewport{constructor(t={}){const{latitude:e=0,longitude:n=0,zoom:i=0,pitch:r=0,bearing:o=0,nearZMultiplier:s=.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}=t;let{width:_,height:y,altitude:v=1.5}=t;const x=Math.pow(2,i);let b;_=_||1,y=y||1;let T=null;if(h)v=h[5]/2,b=altitudeToFovy(v);else{let n;if(t.fovy?(b=t.fovy,v=fovyToAltitude(b)):b=altitudeToFovy(v),m){const{top:t=0,bottom:e=0}=m;n=[0,clamp$2((t+y-e)/2,0,y)-y/2]}T=getProjectionParameters({width:_,height:y,scale:x,center:f&&[0,0,f[2]*unitsPerMeter(e)],offset:n,pitch:r,fovy:b,nearZMultiplier:s,farZMultiplier:a,unitsPerMeter:x*unitsPerMeter(e)/y}),Number.isFinite(l)&&(T.near=l),Number.isFinite(c)&&(T.far=c)}let E=getViewMatrix({height:y,pitch:r,bearing:o,scale:x,altitude:v});if(p){E=(new Matrix4$1).translate([512*p,0,0]).multiplyLeft(E)}super({...t,width:_,height:y,viewMatrix:E,longitude:n,latitude:e,zoom:i,...T,fovy:b,focalDistance:v}),_defineProperty(this,"longitude",void 0),_defineProperty(this,"latitude",void 0),_defineProperty(this,"pitch",void 0),_defineProperty(this,"bearing",void 0),_defineProperty(this,"altitude",void 0),_defineProperty(this,"fovy",void 0),_defineProperty(this,"orthographic",void 0),_defineProperty(this,"_subViewports",void 0),_defineProperty(this,"_pseudoMeters",void 0),this.latitude=e,this.longitude=n,this.zoom=i,this.pitch=r,this.bearing=o,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 t=this.getBounds(),e=Math.floor((t[0]+180)/360),n=Math.ceil((t[2]-180)/360);for(let t=e;t<=n;t++){const e=t?new WebMercatorViewport({...this,worldOffset:t}):this;this._subViewports.push(e)}}return this._subViewports}projectPosition(t){if(this._pseudoMeters)return super.projectPosition(t);const[e,n]=this.projectFlat(t);return[e,n,(t[2]||0)*unitsPerMeter(t[1])]}unprojectPosition(t){if(this._pseudoMeters)return super.unprojectPosition(t);const[e,n]=this.unprojectFlat(t);return[e,n,(t[2]||0)/unitsPerMeter(n)]}addMetersToLngLat(t,e){return addMetersToLngLat(t,e)}panByPosition(t,e){const n=pixelsToWorld(e,this.pixelUnprojectionMatrix),i=add$3([],this.projectFlat(t),negate$1([],n)),r=add$3([],this.center,i),[o,s]=this.unprojectFlat(r);return{longitude:o,latitude:s}}getBounds(t={}){const e=getBounds(this,t.z||0);return[Math.min(e[0][0],e[1][0],e[2][0],e[3][0]),Math.min(e[0][1],e[1][1],e[2][1],e[3][1]),Math.max(e[0][0],e[1][0],e[2][0],e[3][0]),Math.max(e[0][1],e[1][1],e[2][1],e[3][1])]}fitBounds(t,e={}){const{width:n,height:i}=this,{longitude:r,latitude:o,zoom:s}=fitBounds({width:n,height:i,bounds:t,...e});return new WebMercatorViewport({width:n,height:i,longitude:r,latitude:o,zoom:s})}}_defineProperty(WebMercatorViewport,"displayName","WebMercatorViewport");const DEFAULT_COORDINATE_ORIGIN=[0,0,0];function lngLatZToWorldPosition(t,e,n=!1){const i=e.projectPosition(t);if(n&&e instanceof WebMercatorViewport){const[n,r,o=0]=t,s=e.getDistanceScales([n,r]);i[2]=o*s.unitsPerMeter[2]}return i}function normalizeParameters(t){const{viewport:e,modelMatrix:n,coordinateOrigin:i}=t;let{coordinateSystem:r,fromCoordinateSystem:o,fromCoordinateOrigin:s}=t;return r===COORDINATE_SYSTEM.DEFAULT&&(r=e.isGeospatial?COORDINATE_SYSTEM.LNGLAT:COORDINATE_SYSTEM.CARTESIAN),void 0===o&&(o=r),void 0===s&&(s=i),{viewport:e,coordinateSystem:r,coordinateOrigin:i,modelMatrix:n,fromCoordinateSystem:o,fromCoordinateOrigin:s}}function getWorldPosition(t,{viewport:e,modelMatrix:n,coordinateSystem:i,coordinateOrigin:r,offsetMode:o}){let[s,a,l=0]=t;switch(n&&([s,a,l]=transformMat4([],[s,a,l,1],n)),i){case COORDINATE_SYSTEM.LNGLAT:return lngLatZToWorldPosition([s,a,l],e,o);case COORDINATE_SYSTEM.LNGLAT_OFFSETS:return lngLatZToWorldPosition([s+r[0],a+r[1],l+(r[2]||0)],e,o);case COORDINATE_SYSTEM.METER_OFFSETS:return lngLatZToWorldPosition(addMetersToLngLat(r,[s,a,l]),e,o);default:return e.isGeospatial?[s+r[0],a+r[1],l+r[2]]:e.projectPosition([s,a,l])}}function projectPosition(t,e){const{viewport:n,coordinateSystem:i,coordinateOrigin:r,modelMatrix:o,fromCoordinateSystem:s,fromCoordinateOrigin:a}=normalizeParameters(e),{autoOffset:l=!0}=e,{geospatialOrigin:c=DEFAULT_COORDINATE_ORIGIN,shaderCoordinateOrigin:u=DEFAULT_COORDINATE_ORIGIN,offsetMode:h=!1}=l?getOffsetOrigin(n,i,r):{},d=getWorldPosition(t,{viewport:n,modelMatrix:o,coordinateSystem:s,coordinateOrigin:a,offsetMode:h});if(h){const t=n.projectPosition(c||u);sub(d,d,t)}return d}const PICKING_PARAMETERS={blendFunc:[1,0,32771,0],blendEquation:32774};class PickLayersPass extends LayersPass{constructor(...t){super(...t),_defineProperty(this,"pickZ",void 0),_defineProperty(this,"_colorEncoderState",null)}render(t){return"pickingFBO"in t?this._drawPickingBuffer(t):super.render(t)}_drawPickingBuffer({layers:t,layerFilter:e,views:n,viewports:i,onViewportActive:r,pickingFBO:o,deviceRect:{x:s,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),_=withParameters(m,{scissorTest:!0,scissor:[s,a,l,c],clearColor:[0,0,0,0],depthMask:!0,depthTest:!0,depthRange:[0,1],colorMask:[!0,!0,!0,!0],...PICKING_PARAMETERS,blend:!p},(()=>super.render({target:o,layers:t,layerFilter:e,views:n,viewports:i,onViewportActive:r,cullRect:u,effects:null==h?void 0:h.filter((t=>t.useInPicking)),pass:d,isPicking:!0,moduleParameters:f})));this._colorEncoderState=null;return{decodePickingColor:g&&decodeColor.bind(null,g),stats:_}}shouldDrawLayer(t){const{pickable:e,operation:n}=t.props;return e&&n.includes("draw")||n.includes("terrain")||n.includes("mask")}getModuleParameters(){return{pickingActive:1,pickingAttribute:this.pickZ,lightSources:{}}}getLayerParameters(t,e,n){const i={...t.props.parameters},{pickable:r,operation:o}=t.props;return this._colorEncoderState?r&&o.includes("draw")&&(Object.assign(i,PICKING_PARAMETERS),i.blend=!0,i.blendColor=encodeColor(this._colorEncoderState,t,n)):i.blend=!1,o.includes("terrain")&&(i.blend=!1),i}_resetColorEncoder(t){return this._colorEncoderState=t?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function encodeColor(t,e,n){const{byLayer:i,byAlpha:r}=t;let o,s=i.get(e);return s?(s.viewports.push(n),o=s.a):(o=i.size+1,o<=255?(s={a:o,layer:e,viewports:[n]},i.set(e,s),r[o]=s):(log$2.warn("Too many pickable layers, only picking the first 255")(),o=0)),[0,0,0,o/255]}function decodeColor(t,e){const n=t.byAlpha[e[3]];return n&&{pickedLayer:n.layer,pickedViewports:n.viewports,pickedObjectIndex:n.layer.decodePickingColor(e)}}const LIFECYCLE={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},COMPONENT_SYMBOL=Symbol.for("component"),PROP_TYPES_SYMBOL=Symbol.for("propTypes"),DEPRECATED_PROPS_SYMBOL=Symbol.for("deprecatedProps"),ASYNC_DEFAULTS_SYMBOL=Symbol.for("asyncPropDefaults"),ASYNC_ORIGINAL_SYMBOL=Symbol.for("asyncPropOriginal"),ASYNC_RESOLVED_SYMBOL=Symbol.for("asyncPropResolved");function flatten$1(t,e=()=>!0){return Array.isArray(t)?flattenArray(t,e,[]):e(t)?[t]:[]}function flattenArray(t,e,n){let i=-1;for(;++i<t.length;){const r=t[i];Array.isArray(r)?flattenArray(r,e,n):e(r)&&n.push(r)}return n}function fillArray({target:t,source:e,start:n=0,count:i=1}){const r=e.length,o=i*r;let s=0;for(let i=n;s<r;s++)t[i++]=e[s];for(;s<o;)s<o-s?(t.copyWithin(n+s,n,n+s),s*=2):(t.copyWithin(n+s,n,n+o-s),s=o);return t}class Resource{constructor(t,e,n){_defineProperty(this,"id",void 0),_defineProperty(this,"context",void 0),_defineProperty(this,"isLoaded",void 0),_defineProperty(this,"persistent",void 0),_defineProperty(this,"_loadCount",0),_defineProperty(this,"_subscribers",new Set),_defineProperty(this,"_data",void 0),_defineProperty(this,"_loader",void 0),_defineProperty(this,"_error",void 0),_defineProperty(this,"_content",void 0),this.id=t,this.context=n,this.setData(e)}subscribe(t){this._subscribers.add(t)}unsubscribe(t){this._subscribers.delete(t)}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(t,e){if(t===this._data&&!e)return;this._data=t;const n=++this._loadCount;let i=t;"string"==typeof t&&(i=load(t)),i instanceof Promise?(this.isLoaded=!1,this._loader=i.then((t=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=t)})).catch((t=>{this._loadCount===n&&(this.isLoaded=!0,this._error=t||!0)}))):(this.isLoaded=!0,this._error=void 0,this._content=t);for(const t of this._subscribers)t.onChange(this.getData())}}class ResourceManager{constructor({gl:t,protocol:e}){_defineProperty(this,"protocol",void 0),_defineProperty(this,"_context",void 0),_defineProperty(this,"_resources",void 0),_defineProperty(this,"_consumers",void 0),_defineProperty(this,"_pruneRequest",void 0),this.protocol=e||"resource://",this._context={gl:t,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(t){return!!t.startsWith(this.protocol)||t in this._resources}add({resourceId:t,data:e,forceUpdate:n=!1,persistent:i=!0}){let r=this._resources[t];r?r.setData(e,n):(r=new Resource(t,e,this._context),this._resources[t]=r),r.persistent=i}remove(t){const e=this._resources[t];e&&(e.delete(),delete this._resources[t])}unsubscribe({consumerId:t}){const e=this._consumers[t];if(e){for(const t in e){const n=e[t],i=this._resources[n.resourceId];i&&i.unsubscribe(n)}delete this._consumers[t],this.prune()}}subscribe({resourceId:t,onChange:e,consumerId:n,requestId:i="default"}){const{_resources:r,protocol:o}=this;t.startsWith(o)&&(r[t=t.replace(o,"")]||this.add({resourceId:t,data:null,persistent:!1}));const s=r[t];if(this._track(n,i,s,e),s)return s.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout((()=>this._prune()),0))}finalize(){for(const t in this._resources)this._resources[t].delete()}_track(t,e,n,i){const r=this._consumers,o=r[t]=r[t]||{},s=o[e]||{},a=s.resourceId&&this._resources[s.resourceId];a&&(a.unsubscribe(s),this.prune()),n&&(o[e]=s,s.onChange=i,s.resourceId=n.id,n.subscribe(s))}_prune(){this._pruneRequest=null;for(const t of Object.keys(this._resources)){const e=this._resources[t];e.persistent||e.inUse()||(e.delete(),delete this._resources[t])}}}const vs$a="\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";var project32={name:"project32",dependencies:[project],vs:vs$a},picking={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    "}},...picking$1};const DEFAULT_MODULES=[project],SHADER_HOOKS=["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 createProgramManager(t){const e=ProgramManager.getDefaultProgramManager(t);for(const t of DEFAULT_MODULES)e.addDefaultModule(t);for(const t of SHADER_HOOKS)e.addShaderHook(t);return e}const TRACE_SET_LAYERS="layerManager.setLayers",TRACE_ACTIVATE_VIEWPORT="layerManager.activateViewport";class LayerManager{constructor(t,{deck:e,stats:n,viewport:i,timeline:r}={}){_defineProperty(this,"layers",void 0),_defineProperty(this,"context",void 0),_defineProperty(this,"resourceManager",void 0),_defineProperty(this,"_lastRenderedLayers",[]),_defineProperty(this,"_needsRedraw",!1),_defineProperty(this,"_needsUpdate",!1),_defineProperty(this,"_nextLayers",null),_defineProperty(this,"_debug",!1),_defineProperty(this,"activateViewport",(t=>{debug(TRACE_ACTIVATE_VIEWPORT,this,t),t&&(this.context.viewport=t)})),this.layers=[],this.resourceManager=new ResourceManager({gl:t,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,gl:t,deck:e,programManager:t&&createProgramManager(t),stats:n||new Stats({id:"deck.gl"}),viewport:i||new Viewport({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:r||new Timeline,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const t of this.layers)this._finalizeLayer(t)}needsRedraw(t={clearRedrawFlags:!1}){let e=this._needsRedraw;t.clearRedrawFlags&&(this._needsRedraw=!1);for(const n of this.layers){const i=n.getNeedsRedraw(t);e=e||i}return e}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._needsUpdate}setNeedsRedraw(t){this._needsRedraw=this._needsRedraw||t}setNeedsUpdate(t){this._needsUpdate=this._needsUpdate||t}getLayers({layerIds:t}={}){return t?this.layers.filter((e=>t.find((t=>0===e.id.indexOf(t))))):this.layers}setProps(t){"debug"in t&&(this._debug=t.debug),"userData"in t&&(this.context.userData=t.userData),"layers"in t&&(this._nextLayers=t.layers),"onError"in t&&(this.context.onError=t.onError)}setLayers(t,e){debug(TRACE_SET_LAYERS,this,e,t),this._lastRenderedLayers=t;const n=flatten$1(t,Boolean);for(const t of n)t.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){const t=this.needsUpdate();t&&(this.setNeedsRedraw("updating layers: ".concat(t)),this.setLayers(this._nextLayers||this._lastRenderedLayers,t)),this._nextLayers=null}_handleError(t,e,n){n.raiseError(e,"".concat(t," of ").concat(n))}_updateLayers(t,e){const n={};for(const e of t)n[e.id]?log$2.warn("Multiple old layers with same id ".concat(e.id))():n[e.id]=e;const i=[];this._updateSublayersRecursively(e,n,i),this._finalizeOldLayers(n);let r=!1;for(const t of i)if(t.hasUniformTransition()){r="Uniform transition in ".concat(t);break}this._needsUpdate=r,this.layers=i}_updateSublayersRecursively(t,e,n){for(const i of t){i.context=this.context;const t=e[i.id];null===t&&log$2.warn("Multiple new layers with same id ".concat(i.id))(),e[i.id]=null;let r=null;try{this._debug&&t!==i&&i.validateProps(),t?(this._transferLayerState(t,i),this._updateLayer(i)):this._initializeLayer(i),n.push(i),r=i.isComposite?i.getSubLayers():null}catch(t){this._handleError("matching",t,i)}r&&this._updateSublayersRecursively(r,e,n)}}_finalizeOldLayers(t){for(const e in t){const n=t[e];n&&this._finalizeLayer(n)}}_initializeLayer(t){try{t._initialize(),t.lifecycle=LIFECYCLE.INITIALIZED}catch(e){this._handleError("initialization",e,t)}}_transferLayerState(t,e){e._transferState(t),e.lifecycle=LIFECYCLE.MATCHED,e!==t&&(t.lifecycle=LIFECYCLE.AWAITING_GC)}_updateLayer(t){try{t._update()}catch(e){this._handleError("update",e,t)}}_finalizeLayer(t){this._needsRedraw=this._needsRedraw||"finalized ".concat(t),t.lifecycle=LIFECYCLE.AWAITING_FINALIZATION;try{t._finalize(),t.lifecycle=LIFECYCLE.FINALIZED}catch(e){this._handleError("finalization",e,t)}}}function deepEqual(t,e,n){if(t===e)return!0;if(!n||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!deepEqual(t[i],e[i],n-1))return!1;return!0}if(Array.isArray(e))return!1;if("object"==typeof t&&"object"==typeof e){const i=Object.keys(t),r=Object.keys(e);if(i.length!==r.length)return!1;for(const r of i){if(!e.hasOwnProperty(r))return!1;if(!deepEqual(t[r],e[r],n-1))return!1}return!0}return!1}class ViewManager{constructor(t){_defineProperty(this,"width",void 0),_defineProperty(this,"height",void 0),_defineProperty(this,"views",void 0),_defineProperty(this,"viewState",void 0),_defineProperty(this,"controllers",void 0),_defineProperty(this,"timeline",void 0),_defineProperty(this,"_viewports",void 0),_defineProperty(this,"_viewportMap",void 0),_defineProperty(this,"_isUpdating",void 0),_defineProperty(this,"_needsRedraw",void 0),_defineProperty(this,"_needsUpdate",void 0),_defineProperty(this,"_eventManager",void 0),_defineProperty(this,"_eventCallbacks",void 0),this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=t.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=t.eventManager,this._eventCallbacks={onViewStateChange:t.onViewStateChange,onInteractionStateChange:t.onInteractionStateChange},Object.seal(this),this.setProps(t)}finalize(){for(const t in this.controllers){const e=this.controllers[t];e&&e.finalize()}this.controllers={}}needsRedraw(t={clearRedrawFlags:!1}){const e=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),e}setNeedsUpdate(t){this._needsUpdate=this._needsUpdate||t,this._needsRedraw=this._needsRedraw||t}updateViewStates(){for(const t in this.controllers){const e=this.controllers[t];e&&e.updateTransition()}}getViewports(t){return t?this._viewports.filter((e=>e.containsPixel(t))):this._viewports}getViews(){const t={};return this.views.forEach((e=>{t[e.id]=e})),t}getView(t){return this.views.find((e=>e.id===t))}getViewState(t){const e="string"==typeof t?this.getView(t):t,n=e&&this.viewState[e.getViewStateId()]||this.viewState;return e?e.filterViewState(n):n}getViewport(t){return this._viewportMap[t]}unproject(t,e){const n=this.getViewports(),i={x:t[0],y:t[1]};for(let r=n.length-1;r>=0;--r){const o=n[r];if(o.containsPixel(i)){const n=t.slice();return n[0]-=o.x,n[1]-=o.y,o.unproject(n,e)}}return null}setProps(t){t.views&&this._setViews(t.views),t.viewState&&this._setViewState(t.viewState),("width"in t||"height"in t)&&this._setSize(t.width,t.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(t,e){t===this.width&&e===this.height||(this.width=t,this.height=e,this.setNeedsUpdate("Size changed"))}_setViews(t){t=flatten$1(t,Boolean);this._diffViews(t,this.views)&&this.setNeedsUpdate("views changed"),this.views=t}_setViewState(t){if(t){!deepEqual(t,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=t}else log$2.warn("missing `viewState` or `initialViewState`")()}_onViewStateChange(t,e){this._eventCallbacks.onViewStateChange&&this._eventCallbacks.onViewStateChange({...e,viewId:t})}_createController(t,e){return new(0,e.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._onViewStateChange.bind(this,e.id),onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:e=>{var n;return null===(n=this.getView(t.id))||void 0===n?void 0:n.makeViewport({viewState:e,width:this.width,height:this.height})}})}_updateController(t,e,n,i){const r=t.controller;if(r&&n){const o={...e,...r,id:t.id,x:n.x,y:n.y,width:n.width,height:n.height};return i&&i.constructor===r.type||(i=this._createController(t,o)),i&&i.setProps(o),i}return null}_rebuildViewports(){const{views:t}=this,e=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let i=t.length;i--;){const r=t[i],o=this.getViewState(r),s=r.makeViewport({viewState:o,width:this.width,height:this.height});let a=e[r.id];const l=Boolean(r.controller);l&&!a&&(n=!0),!n&&l||!a||(a.finalize(),a=null),this.controllers[r.id]=this._updateController(r,o,s,a),s&&this._viewports.unshift(s)}for(const t in e){const n=e[t];n&&!this.controllers[t]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach((t=>{t.id&&(this._viewportMap[t.id]=this._viewportMap[t.id]||t)}))}_diffViews(t,e){return t.length!==e.length||t.some(((n,i)=>!t[i].equals(e[i])))}}const PERCENT_OR_PIXELS_REGEX=/([0-9]+\.?[0-9]*)(%|px)/;function parsePosition(t){switch(typeof t){case"number":return{position:t,relative:!1};case"string":const e=PERCENT_OR_PIXELS_REGEX.exec(t);if(e&&e.length>=3){const t="%"===e[2],n=parseFloat(e[1]);return{position:t?n/100:n,relative:t}}default:throw new Error("Could not parse position string ".concat(t))}}function getPosition(t,e){return t.relative?Math.round(t.position*e):t.position}function assert$4(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}class View{constructor(t){_defineProperty(this,"id",void 0),_defineProperty(this,"viewportInstance",void 0),_defineProperty(this,"_x",void 0),_defineProperty(this,"_y",void 0),_defineProperty(this,"_width",void 0),_defineProperty(this,"_height",void 0),_defineProperty(this,"_padding",void 0),_defineProperty(this,"props",void 0);const{id:e,x:n=0,y:i=0,width:r="100%",height:o="100%",padding:s=null,viewportInstance:a}=t||{};assert$4(!a||a instanceof Viewport),this.viewportInstance=a,this.id=e||this.constructor.displayName||"view",this.props={...t,id:this.id},this._x=parsePosition(n),this._y=parsePosition(i),this._width=parsePosition(r),this._height=parsePosition(o),this._padding=s&&{left:parsePosition(s.left||0),right:parsePosition(s.right||0),top:parsePosition(s.top||0),bottom:parsePosition(s.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(t){return this===t||(this.viewportInstance?!!t.viewportInstance&&this.viewportInstance.equals(t.viewportInstance):this.ViewportType===t.ViewportType&&deepEqual(this.props,t.props,2))}makeViewport({width:t,height:e,viewState:n}){if(this.viewportInstance)return this.viewportInstance;n=this.filterViewState(n);const i=this.getDimensions({width:t,height:e});return i.height&&i.width?new this.ViewportType({...n,...this.props,...i}):null}getViewStateId(){const{viewState:t}=this.props;return"string"==typeof t?t:(null==t?void 0:t.id)||this.id}filterViewState(t){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const e={...t};for(const t in this.props.viewState)"id"!==t&&(e[t]=this.props.viewState[t]);return e}return t}getDimensions({width:t,height:e}){const n={x:getPosition(this._x,t),y:getPosition(this._y,e),width:getPosition(this._width,t),height:getPosition(this._height,e)};return this._padding&&(n.padding={left:getPosition(this._padding.left,t),top:getPosition(this._padding.top,e),right:getPosition(this._padding.right,t),bottom:getPosition(this._padding.bottom,e)}),n}get controller(){const t=this.props.controller;return t?!0===t?{type:this.ControllerType}:"function"==typeof t?{type:t}:{type:this.ControllerType,...t}:null}}class Transition{constructor(t){_defineProperty(this,"_inProgress",void 0),_defineProperty(this,"_handle",void 0),_defineProperty(this,"_timeline",void 0),_defineProperty(this,"time",void 0),_defineProperty(this,"settings",void 0),this._inProgress=!1,this._handle=null,this._timeline=t,this.time=0,this.settings={duration:0}}get inProgress(){return this._inProgress}start(t){var e,n;this.cancel(),this.settings=t,this._inProgress=!0,null===(e=(n=this.settings).onStart)||void 0===e||e.call(n,this)}end(){var t,e;this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,null===(t=(e=this.settings).onEnd)||void 0===t||t.call(e,this))}cancel(){var t,e;this._inProgress&&(null===(t=(e=this.settings).onInterrupt)||void 0===t||t.call(e,this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){var t,e;if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:t,settings:e}=this;this._handle=t.addChannel({delay:t.getTime(),duration:e.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),null===(t=(e=this.settings).onUpdate)||void 0===t||t.call(e,this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const noop$2=()=>{},TRANSITION_EVENTS={BREAK:1,SNAP_TO_END:2,IGNORE:3},DEFAULT_EASING=t=>t,DEFAULT_INTERRUPTION=TRANSITION_EVENTS.BREAK;class TransitionManager{constructor(t){_defineProperty(this,"getControllerState",void 0),_defineProperty(this,"props",void 0),_defineProperty(this,"propsInTransition",void 0),_defineProperty(this,"transition",void 0),_defineProperty(this,"onViewStateChange",void 0),_defineProperty(this,"onStateChange",void 0),_defineProperty(this,"_onTransitionUpdate",(t=>{const{time:e,settings:{interpolator:n,startProps:i,endProps:r,duration:o,easing:s}}=t,a=s(e/o),l=n.interpolateProps(i,r,a);this.propsInTransition=this.getControllerState({...this.props,...l}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})})),this.getControllerState=t.getControllerState,this.propsInTransition=null,this.transition=new Transition(t.timeline),this.onViewStateChange=t.onViewStateChange||noop$2,this.onStateChange=t.onStateChange||noop$2}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(t){let e=!1;const n=this.props;if(this.props=t,!n||this._shouldIgnoreViewportChange(n,t))return!1;if(this._isTransitionEnabled(t)){let i=n;if(this.transition.inProgress){const{interruption:t,endProps:e}=this.transition.settings;i={...n,...t===TRANSITION_EVENTS.SNAP_TO_END?e:this.propsInTransition||n}}this._triggerTransition(i,t),e=!0}else this.transition.cancel();return e}updateTransition(){this.transition.update()}_isTransitionEnabled(t){const{transitionDuration:e,transitionInterpolator:n}=t;return(e>0||"auto"===e)&&Boolean(n)}_isUpdateDueToCurrentTransition(t){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(t,this.propsInTransition)}_shouldIgnoreViewportChange(t,e){return this.transition.inProgress?this.transition.settings.interruption===TRANSITION_EVENTS.IGNORE||this._isUpdateDueToCurrentTransition(e):!this._isTransitionEnabled(e)||e.transitionInterpolator.arePropsEqual(t,e)}_triggerTransition(t,e){const n=this.getControllerState(t),i=this.getControllerState(e).shortestPathFrom(n),r=e.transitionInterpolator,o=r.getDuration?r.getDuration(t,e):e.transitionDuration;if(0===o)return;const s=r.initializeProps(t,i);this.propsInTransition={};const a={duration:o,easing:e.transitionEasing||DEFAULT_EASING,interpolator:r,interruption:e.transitionInterruption||DEFAULT_INTERRUPTION,startProps:s.start,endProps:s.end,onStart:e.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(e.onTransitionInterrupt),onEnd:this._onTransitionEnd(e.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(t){return e=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),null==t||t(e)}}}class TransitionInterpolator{constructor(t){_defineProperty(this,"_propsToCompare",void 0),_defineProperty(this,"_propsToExtract",void 0),_defineProperty(this,"_requiredProps",void 0);const{compare:e,extract:n,required:i}=t;this._propsToCompare=e,this._propsToExtract=n||e,this._requiredProps=i}arePropsEqual(t,e){for(const n of this._propsToCompare)if(!(n in t)||!(n in e)||!equals$1(t[n],e[n]))return!1;return!0}initializeProps(t,e){const n={},i={};for(const r of this._propsToExtract)(r in t||r in e)&&(n[r]=t[r],i[r]=e[r]);return this._checkRequiredProps(n),this._checkRequiredProps(i),{start:n,end:i}}getDuration(t,e){return e.transitionDuration}_checkRequiredProps(t){this._requiredProps&&this._requiredProps.forEach((e=>{const n=t[e];assert$4(Number.isFinite(n)||Array.isArray(n),"".concat(e," is required for transition"))}))}}const DEFAULT_PROPS$2=["longitude","latitude","zoom","bearing","pitch"],DEFAULT_REQUIRED_PROPS=["longitude","latitude","zoom"];class LinearInterpolator extends TransitionInterpolator{constructor(t={}){const e=Array.isArray(t)?t:t.transitionProps,n=Array.isArray(t)?{}:t;n.transitionProps=Array.isArray(e)?{compare:e,required:e}:e||{compare:DEFAULT_PROPS$2,required:DEFAULT_REQUIRED_PROPS},super(n.transitionProps),_defineProperty(this,"opts",void 0),this.opts=n}initializeProps(t,e){const n=super.initializeProps(t,e),{makeViewport:i,around:r}=this.opts;if(i&&r){const o=i(t),s=i(e),a=o.unproject(r);n.start.around=r,Object.assign(n.end,{around:s.project(a),aroundPosition:a,width:e.width,height:e.height})}return n}interpolateProps(t,e,n){const i={};for(const r of this._propsToExtract)i[r]=lerp$4(t[r]||0,e[r]||0,n);if(e.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...e,...i});Object.assign(i,r.panByPosition(e.aroundPosition,lerp$4(t.around,e.around,n)))}return i}}const NO_TRANSITION_PROPS={transitionDuration:0},DEFAULT_INERTIA=300,INERTIA_EASING=t=>1-(1-t)*(1-t),EVENT_TYPES={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},pinchEventWorkaround={};class Controller{constructor(t){_defineProperty(this,"props",void 0),_defineProperty(this,"state",{}),_defineProperty(this,"transitionManager",void 0),_defineProperty(this,"eventManager",void 0),_defineProperty(this,"onViewStateChange",void 0),_defineProperty(this,"onStateChange",void 0),_defineProperty(this,"makeViewport",void 0),_defineProperty(this,"_controllerState",void 0),_defineProperty(this,"_events",{}),_defineProperty(this,"_interactionState",{isDragging:!1}),_defineProperty(this,"_customEvents",[]),_defineProperty(this,"_eventStartBlocked",null),_defineProperty(this,"_panMove",!1),_defineProperty(this,"invertPan",!1),_defineProperty(this,"dragMode","rotate"),_defineProperty(this,"inertia",0),_defineProperty(this,"scrollZoom",!0),_defineProperty(this,"dragPan",!0),_defineProperty(this,"dragRotate",!0),_defineProperty(this,"doubleClickZoom",!0),_defineProperty(this,"touchZoom",!0),_defineProperty(this,"touchRotate",!1),_defineProperty(this,"keyboard",!0),this.transitionManager=new TransitionManager({...t,getControllerState:t=>new this.ControllerState(t),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=t.eventManager,this.onViewStateChange=t.onViewStateChange||(()=>{}),this.onStateChange=t.onStateChange||(()=>{}),this.makeViewport=t.makeViewport}set events(t){this.toggleEvents(this._customEvents,!1),this.toggleEvents(t,!0),this._customEvents=t,this.props&&this.setProps(this.props)}finalize(){for(const e in this._events){var t;if(this._events[e])null===(t=this.eventManager)||void 0===t||t.off(e,this.handleEvent)}this.transitionManager.finalize()}handleEvent(t){this._controllerState=void 0;const e=this._eventStartBlocked;switch(t.type){case"panstart":return!e&&this._onPanStart(t);case"panmove":return this._onPan(t);case"panend":return this._onPanEnd(t);case"pinchstart":return!e&&this._onPinchStart(t);case"pinchmove":return this._onPinch(t);case"pinchend":return this._onPinchEnd(t);case"tripanstart":return!e&&this._onTriplePanStart(t);case"tripanmove":return this._onTriplePan(t);case"tripanend":return this._onTriplePanEnd(t);case"doubletap":return this._onDoubleTap(t);case"wheel":return this._onWheel(t);case"keydown":return this._onKeyDown(t);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(t){const{x:e,y:n}=this.props,{offsetCenter:i}=t;return[i.x-e,i.y-n]}isPointInBounds(t,e){const{width:n,height:i}=this.props;if(e&&e.handled)return!1;const r=t[0]>=0&&t[0]<=n&&t[1]>=0&&t[1]<=i;return r&&e&&e.stopPropagation(),r}isFunctionKeyPressed(t){const{srcEvent:e}=t;return Boolean(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(t){const e=setTimeout((()=>{this._eventStartBlocked===e&&(this._eventStartBlocked=null)}),t);this._eventStartBlocked=e}setProps(t){t.dragMode&&(this.dragMode=t.dragMode),this.props=t,"transitionInterpolator"in t||(t.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(t);const{inertia:e}=t;this.inertia=Number.isFinite(e)?e:!0===e?DEFAULT_INERTIA:0;const{scrollZoom:n=!0,dragPan:i=!0,dragRotate:r=!0,doubleClickZoom:o=!0,touchZoom:s=!0,touchRotate:a=!1,keyboard:l=!0}=t,c=Boolean(this.onViewStateChange);this.toggleEvents(EVENT_TYPES.WHEEL,c&&n),this.toggleEvents(EVENT_TYPES.PAN,c),this.toggleEvents(EVENT_TYPES.PINCH,c&&(s||a)),this.toggleEvents(EVENT_TYPES.TRIPLE_PAN,c&&a),this.toggleEvents(EVENT_TYPES.DOUBLE_TAP,c&&o),this.toggleEvents(EVENT_TYPES.KEYBOARD,c&&l),this.scrollZoom=n,this.dragPan=i,this.dragRotate=r,this.doubleClickZoom=o,this.touchZoom=s,this.touchRotate=a,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(t,e){this.eventManager&&t.forEach((t=>{this._events[t]!==e&&(this._events[t]=e,e?this.eventManager.on(t,this.handleEvent):this.eventManager.off(t,this.handleEvent))}))}updateViewport(t,e=null,n={}){const i={...t.getViewportProps(),...e},r=this.controllerState!==t;if(this.state=t.getState(),this._setInteractionState(n),r){const t=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:i,interactionState:this._interactionState,oldViewState:t})}}_onTransition(t){this.onViewStateChange({...t,interactionState:this._interactionState})}_setInteractionState(t){Object.assign(this._interactionState,t),this.onStateChange(this._interactionState)}_onPanStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;let n=this.isFunctionKeyPressed(t)||t.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(n=!n);const i=this.controllerState[n?"panStart":"rotateStart"]({pos:e});return this._panMove=n,this.updateViewport(i,NO_TRANSITION_PROPS,{isDragging:!0}),!0}_onPan(t){return!!this.isDragging()&&(this._panMove?this._onPanMove(t):this._onPanRotate(t))}_onPanEnd(t){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(t):this._onPanRotateEnd(t))}_onPanMove(t){if(!this.dragPan)return!1;const e=this.getCenter(t),n=this.controllerState.pan({pos:e});return this.updateViewport(n,NO_TRANSITION_PROPS,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(t){const{inertia:e}=this;if(this.dragPan&&e&&t.velocity){const n=this.getCenter(t),i=this.controllerState.pan({pos:[n[0]+t.velocityX*e/2,n[1]+t.velocityY*e/2]}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:INERTIA_EASING},{isDragging:!1,isPanning:!0})}else{const t=this.controllerState.panEnd();this.updateViewport(t,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(t){if(!this.dragRotate)return!1;const e=this.getCenter(t),n=this.controllerState.rotate({pos:e});return this.updateViewport(n,NO_TRANSITION_PROPS,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(t){const{inertia:e}=this;if(this.dragRotate&&e&&t.velocity){const n=this.getCenter(t),i=this.controllerState.rotate({pos:[n[0]+t.velocityX*e/2,n[1]+t.velocityY*e/2]}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:INERTIA_EASING},{isDragging:!1,isRotating:!0})}else{const t=this.controllerState.rotateEnd();this.updateViewport(t,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(t){if(!this.scrollZoom)return!1;const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;t.srcEvent.preventDefault();const{speed:n=.01,smooth:i=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:r}=t;let o=2/(1+Math.exp(-Math.abs(r*n)));r<0&&0!==o&&(o=1/o);const s=this.controllerState.zoom({pos:e,scale:o});return this.updateViewport(s,{...this._getTransitionProps({around:e}),transitionDuration:i?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const n=this.controllerState.rotateStart({pos:e});return this.updateViewport(n,NO_TRANSITION_PROPS,{isDragging:!0}),!0}_onTriplePan(t){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const e=this.getCenter(t);e[0]-=t.deltaX;const n=this.controllerState.rotate({pos:e});return this.updateViewport(n,NO_TRANSITION_PROPS,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(t){if(!this.isDragging())return!1;const{inertia:e}=this;if(this.touchRotate&&e&&t.velocityY){const n=this.getCenter(t),i=[n[0],n[1]+=t.velocityY*e/2],r=this.controllerState.rotate({pos:i});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:INERTIA_EASING},{isDragging:!1,isRotating:!0}),this.blockEvents(e)}else{const t=this.controllerState.rotateEnd();this.updateViewport(t,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const n=this.controllerState.zoomStart({pos:e}).rotateStart({pos:e});return pinchEventWorkaround._startPinchRotation=t.rotation,pinchEventWorkaround._lastPinchEvent=t,this.updateViewport(n,NO_TRANSITION_PROPS,{isDragging:!0}),!0}_onPinch(t){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let e=this.controllerState;if(this.touchZoom){const{scale:n}=t,i=this.getCenter(t);e=e.zoom({pos:i,scale:n})}if(this.touchRotate){const{rotation:n}=t;e=e.rotate({deltaAngleX:pinchEventWorkaround._startPinchRotation-n})}return this.updateViewport(e,NO_TRANSITION_PROPS,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),pinchEventWorkaround._lastPinchEvent=t,!0}_onPinchEnd(t){if(!this.isDragging())return!1;const{inertia:e}=this,{_lastPinchEvent:n}=pinchEventWorkaround;if(this.touchZoom&&e&&n&&t.scale!==n.scale){const i=this.getCenter(t);let r=this.controllerState.rotateEnd();const o=Math.log2(t.scale),s=(o-Math.log2(n.scale))/(t.deltaTime-n.deltaTime),a=Math.pow(2,o+s*e/2);r=r.zoom({pos:i,scale:a}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:i}),transitionDuration:e,transitionEasing:INERTIA_EASING},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(e)}else{const t=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(t,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return pinchEventWorkaround._startPinchRotation=null,pinchEventWorkaround._lastPinchEvent=null,!0}_onDoubleTap(t){if(!this.doubleClickZoom)return!1;const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const n=this.isFunctionKeyPressed(t),i=this.controllerState.zoom({pos:e,scale:n?.5:2});return this.updateViewport(i,this._getTransitionProps({around:e}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(t){if(!this.keyboard)return!1;const e=this.isFunctionKeyPressed(t),{zoomSpeed:n,moveSpeed:i,rotateSpeedX:r,rotateSpeedY:o}=!0===this.keyboard?{}:this.keyboard,{controllerState:s}=this;let a;const l={};switch(t.srcEvent.code){case"Minus":a=e?s.zoomOut(n).zoomOut(n):s.zoomOut(n),l.isZooming=!0;break;case"Equal":a=e?s.zoomIn(n).zoomIn(n):s.zoomIn(n),l.isZooming=!0;break;case"ArrowLeft":e?(a=s.rotateLeft(r),l.isRotating=!0):(a=s.moveLeft(i),l.isPanning=!0);break;case"ArrowRight":e?(a=s.rotateRight(r),l.isRotating=!0):(a=s.moveRight(i),l.isPanning=!0);break;case"ArrowUp":e?(a=s.rotateUp(o),l.isRotating=!0):(a=s.moveUp(i),l.isPanning=!0);break;case"ArrowDown":e?(a=s.rotateDown(o),l.isRotating=!0):(a=s.moveDown(i),l.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),l),!0}_getTransitionProps(t){const{transition:e}=this;return e&&e.transitionInterpolator?t?{...e,transitionInterpolator:new LinearInterpolator({...t,...e.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:e:NO_TRANSITION_PROPS}}class ViewState{constructor(t,e){_defineProperty(this,"_viewportProps",void 0),_defineProperty(this,"_state",void 0),this._viewportProps=this.applyConstraints(t),this._state=e}getViewportProps(){return this._viewportProps}getState(){return this._state}}const PITCH_MOUSE_THRESHOLD=5,PITCH_ACCEL=1.2;class MapState extends ViewState{constructor(t){const{width:e,height:n,latitude:i,longitude:r,zoom:o,bearing:s=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}=t;assert$4(Number.isFinite(r)),assert$4(Number.isFinite(i)),assert$4(Number.isFinite(o)),super({width:e,height:n,latitude:i,longitude:r,zoom:o,bearing:s,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}),_defineProperty(this,"makeViewport",void 0),this.makeViewport=t.makeViewport}panStart({pos:t}){return this._getUpdatedState({startPanLngLat:this._unproject(t)})}pan({pos:t,startPos:e}){const n=this.getState().startPanLngLat||this._unproject(e);if(!n)return this;const i=this.makeViewport(this.getViewportProps()).panByPosition(n,t);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:t}){return this._getUpdatedState({startRotatePos:t,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:t,deltaAngleX:e=0,deltaAngleY:n=0}){const{startRotatePos:i,startBearing:r,startPitch:o}=this.getState();if(!i||void 0===r||void 0===o)return this;let s;return s=t?this._getNewRotation(t,i,o,r):{bearing:r+e,pitch:o+n},this._getUpdatedState(s)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:t}){return this._getUpdatedState({startZoomLngLat:this._unproject(t),startZoom:this.getViewportProps().zoom})}zoom({pos:t,startPos:e,scale:n}){let{startZoom:i,startZoomLngLat:r}=this.getState();if(r||(i=this.getViewportProps().zoom,r=this._unproject(e)||this._unproject(t)),!r)return this;const{maxZoom:o,minZoom:s}=this.getViewportProps();let a=i+Math.log2(n);a=clamp$2(a,s,o);const l=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...l.panByPosition(r,t)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(t=2){return this._zoomFromCenter(t)}zoomOut(t=2){return this._zoomFromCenter(1/t)}moveLeft(t=100){return this._panFromCenter([t,0])}moveRight(t=100){return this._panFromCenter([-t,0])}moveUp(t=100){return this._panFromCenter([0,t])}moveDown(t=100){return this._panFromCenter([0,-t])}rotateLeft(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-t})}rotateRight(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+t})}rotateUp(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+t})}rotateDown(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-t})}shortestPathFrom(t){const e=t.getViewportProps(),n={...this.getViewportProps()},{bearing:i,longitude:r}=n;return Math.abs(i-e.bearing)>180&&(n.bearing=i<0?i+360:i-360),Math.abs(r-e.longitude)>180&&(n.longitude=r<0?r+360:r-360),n}applyConstraints(t){const{maxZoom:e,minZoom:n,zoom:i}=t;t.zoom=clamp$2(i,n,e);const{maxPitch:r,minPitch:o,pitch:s}=t;t.pitch=clamp$2(s,o,r);const{normalize:a=!0}=t;return a&&Object.assign(t,normalizeViewportProps(t)),t}_zoomFromCenter(t){const{width:e,height:n}=this.getViewportProps();return this.zoom({pos:[e/2,n/2],scale:t})}_panFromCenter(t){const{width:e,height:n}=this.getViewportProps();return this.pan({startPos:[e/2,n/2],pos:[e/2+t[0],n/2+t[1]]})}_getUpdatedState(t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}_unproject(t){const e=this.makeViewport(this.getViewportProps());return t&&e.unproject(t)}_getNewRotation(t,e,n,i){const r=t[0]-e[0],o=t[1]-e[1],s=t[1],a=e[1],{width:l,height:c}=this.getViewportProps(),u=r/l;let h=0;o>0?Math.abs(c-a)>PITCH_MOUSE_THRESHOLD&&(h=o/(a-c)*PITCH_ACCEL):o<0&&a>PITCH_MOUSE_THRESHOLD&&(h=1-s/a),h=clamp$2(h,-1,1);const{minPitch:d,maxPitch:p}=this.getViewportProps();let f=n;return h>0?f=n+h*(p-n):h<0&&(f=n-h*(d-n)),{pitch:f,bearing:i+180*u}}}class MapController extends Controller{constructor(...t){super(...t),_defineProperty(this,"ControllerState",MapState),_defineProperty(this,"transition",{transitionDuration:300,transitionInterpolator:new LinearInterpolator({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})}),_defineProperty(this,"dragMode","pan")}setProps(t){t.position=t.position||[0,0,0];const e=this.props;super.setProps(t);(!e||e.height!==t.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...t,...this.state}))}}class MapView extends View{get ViewportType(){return WebMercatorViewport}get ControllerType(){return MapController}}_defineProperty(MapView,"displayName","MapView");const DEFAULT_LIGHTING_EFFECT=new LightingEffect;function compareEffects(t,e){var n,i;return(null!==(n=t.order)&&void 0!==n?n:1/0)-(null!==(i=e.order)&&void 0!==i?i:1/0)}class EffectManager{constructor(){_defineProperty(this,"effects",void 0),_defineProperty(this,"_resolvedEffects",[]),_defineProperty(this,"_defaultEffects",[]),_defineProperty(this,"_needsRedraw",void 0),this.effects=[],this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(t){const e=this._defaultEffects;if(!e.find((e=>e.id===t.id))){const n=e.findIndex((e=>compareEffects(e,t)>0));n<0?e.push(t):e.splice(n,0,t),this._setEffects(this.effects)}}setProps(t){"effects"in t&&(deepEqual(t.effects,this.effects,1)||this._setEffects(t.effects))}needsRedraw(t={clearRedrawFlags:!1}){const e=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),e}getEffects(){return this._resolvedEffects}_setEffects(t){const e={};for(const t of this.effects)e[t.id]=t;const n=[];for(const i of t){const t=e[i.id];t&&t!==i?t.setProps?(t.setProps(i.props),n.push(t)):(t.cleanup(),n.push(i)):n.push(i),delete e[i.id]}for(const t in e)e[t].cleanup();this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),t.some((t=>t instanceof LightingEffect))||this._resolvedEffects.push(DEFAULT_LIGHTING_EFFECT),this._needsRedraw="effects changed"}finalize(){for(const t of this._resolvedEffects)t.cleanup();this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class DrawLayersPass extends LayersPass{shouldDrawLayer(t){const{operation:e}=t.props;return e.includes("draw")||e.includes("terrain")}}const TRACE_RENDER_LAYERS$1="deckRenderer.renderLayers";class DeckRenderer{constructor(t){_defineProperty(this,"gl",void 0),_defineProperty(this,"layerFilter",void 0),_defineProperty(this,"drawPickingColors",void 0),_defineProperty(this,"drawLayersPass",void 0),_defineProperty(this,"pickLayersPass",void 0),_defineProperty(this,"renderCount",void 0),_defineProperty(this,"_needsRedraw",void 0),_defineProperty(this,"renderBuffers",void 0),_defineProperty(this,"lastPostProcessEffect",void 0),this.gl=t,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new DrawLayersPass(t),this.pickLayersPass=new PickLayersPass(t),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(t){this.layerFilter!==t.layerFilter&&(this.layerFilter=t.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==t.drawPickingColors&&(this.drawPickingColors=t.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(t){if(!t.viewports.length)return;const e=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...t,target:t.target||Framebuffer.getDefaultFramebuffer(this.gl)};n.effects&&this._preRender(n.effects,n);const i=this.lastPostProcessEffect?this.renderBuffers[0]:n.target,r=e.render({...n,target:i});n.effects&&this._postRender(n.effects,n),this.renderCount++,debug(TRACE_RENDER_LAYERS$1,this,r,t)}needsRedraw(t={clearRedrawFlags:!1}){const e=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),e}finalize(){const{renderBuffers:t}=this;for(const e of t)e.delete();t.length=0}_preRender(t,e){this.lastPostProcessEffect=null,e.preRenderStats=e.preRenderStats||{};for(const n of t)e.preRenderStats[n.id]=n.preRender(this.gl,e),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:t}=this;0===t.length&&t.push(new Framebuffer(this.gl),new Framebuffer(this.gl));for(const e of t)e.resize()}_postRender(t,e){const{renderBuffers:n}=this,i={...e,inputBuffer:n[0],swapBuffer:n[1],target:null};for(const r of t)if(r.postRender){if(r.id===this.lastPostProcessEffect){i.target=e.target,r.postRender(this.gl,i);break}const t=r.postRender(this.gl,i);i.inputBuffer=t,i.swapBuffer=t===n[0]?n[1]:n[0]}}}const NO_PICKED_OBJECT={pickedColor:null,pickedObjectIndex:-1};function getClosestObject({pickedColors:t,decodePickingColor:e,deviceX:n,deviceY:i,deviceRadius:r,deviceRect:o}){const{x:s,y:a,width:l,height:c}=o;let u=r*r,h=-1,d=0;for(let e=0;e<c;e++){const r=e+a-i,o=r*r;if(o>u)d+=4*l;else for(let e=0;e<l;e++){if(t[d+3]-1>=0){const t=e+s-n,i=t*t+o;i<=u&&(u=i,h=d)}d+=4}}if(h>=0){const n=t.slice(h,h+4),i=e(n);if(i){const t=Math.floor(h/4/l),e=h/4-t*l;return{...i,pickedColor:n,pickedX:s+e,pickedY:a+t}}}return NO_PICKED_OBJECT}function getUniqueObjects({pickedColors:t,decodePickingColor:e}){const n=new Map;if(t)for(let i=0;i<t.length;i+=4){if(t[i+3]-1>=0){const r=t.slice(i,i+4),o=r.join(",");if(!n.has(o)){const t=e(r);t&&n.set(o,{...t,color:r})}}}return Array.from(n.values())}function getEmptyPickingInfo({pickInfo:t,viewports:e,pixelRatio:n,x:i,y:r,z:o}){let s,a=e[0];if(e.length>1&&(a=getViewportFromCoordinates((null==t?void 0:t.pickedViewports)||e,{x:i,y:r})),a){const t=[i-a.x,r-a.y];void 0!==o&&(t[2]=o),s=a.unproject(t)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:i,y:r,pixel:[i,r],coordinate:s,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:n}}function processPickInfo(t){const{pickInfo:e,lastPickedInfo:n,mode:i,layers:r}=t,{pickedColor:o,pickedLayer:s,pickedObjectIndex:a}=e,l=s?[s]:[];if("hover"===i){const t=n.layerId,e=s?s.props.id:null;if(e!==t||a!==n.index){if(e!==t){const e=r.find((e=>e.props.id===t));e&&l.unshift(e)}n.layerId=e,n.index=a,n.info=null}}const c=getEmptyPickingInfo(t),u=new Map;return u.set(null,c),l.forEach((t=>{let e={...c};t===s&&(e.color=o,e.index=a,e.picked=!0),e=getLayerPickingInfo({layer:t,info:e,mode:i});const r=e.layer;t===s&&"hover"===i&&(n.info=e),u.set(r.id,e),"hover"===i&&r.updateAutoHighlight(e)})),u}function getLayerPickingInfo({layer:t,info:e,mode:n}){for(;t&&e;){const i=e.layer||null;e.sourceLayer=i,e.layer=t,e=t.getPickingInfo({info:e,mode:n,sourceLayer:i}),t=t.parent}return e}function getViewportFromCoordinates(t,e){for(let n=t.length-1;n>=0;n--){const i=t[n];if(i.containsPixel(e))return i}return t[0]}class DeckPicker{constructor(t){_defineProperty(this,"gl",void 0),_defineProperty(this,"pickingFBO",void 0),_defineProperty(this,"depthFBO",void 0),_defineProperty(this,"pickLayersPass",void 0),_defineProperty(this,"layerFilter",void 0),_defineProperty(this,"lastPickedInfo",void 0),_defineProperty(this,"_pickable",!0),this.gl=t,this.pickLayersPass=new PickLayersPass(t),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(t){"layerFilter"in t&&(this.layerFilter=t.layerFilter),"_pickable"in t&&(this._pickable=t._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.delete(),this.depthFBO&&(this.depthFBO.color.delete(),this.depthFBO.delete())}pickObject(t){return this._pickClosestObject(t)}pickObjects(t){return this._pickVisibleObjects(t)}getLastPickedObject({x:t,y:e,layers:n,viewports:i},r=this.lastPickedInfo.info){const o=r&&r.layer&&r.layer.id,s=r&&r.viewport&&r.viewport.id,a=o?n.find((t=>t.id===o)):null,l=s&&i.find((t=>t.id===s))||i[0],c=l&&l.unproject([t-l.x,e-l.y]),u={x:t,y:e,viewport:l,coordinate:c,layer:a};return{...r,...u}}_resizeBuffer(){var t,e;const{gl:n}=this;if(!this.pickingFBO&&(this.pickingFBO=new Framebuffer(n),Framebuffer.isSupported(n,{colorBufferFloat:!0}))){const t=new Framebuffer(n);t.attach({36064:new Texture2D(n,{format:isWebGL2$1(n)?34836:6408,type:5126})}),this.depthFBO=t}null===(t=this.pickingFBO)||void 0===t||t.resize({width:n.canvas.width,height:n.canvas.height}),null===(e=this.depthFBO)||void 0===e||e.resize({width:n.canvas.width,height:n.canvas.height})}_getPickable(t){if(!1===this._pickable)return null;const e=t.filter((t=>this.pickLayersPass.shouldDrawLayer(t)&&!t.isComposite));return e.length?e:null}_pickClosestObject({layers:t,views:e,viewports:n,x:i,y:r,radius:o=0,depth:s=1,mode:a="query",unproject3D:l,onViewportActive:c,effects:u}){const h=this._getPickable(t),d=cssToDeviceRatio(this.gl);if(!h)return{result:[],emptyInfo:getEmptyPickingInfo({viewports:n,x:i,y:r,pixelRatio:d})};this._resizeBuffer();const p=cssToDevicePixels(this.gl,[i,r],!0),f=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(o*d),{width:g,height:_}=this.pickingFBO,y=this._getPickingRect({deviceX:f[0],deviceY:f[1],deviceRadius:m,deviceWidth:g,deviceHeight:_}),v={x:i-o,y:r-o,width:2*o+1,height:2*o+1};let x;const b=[],T=new Set;for(let t=0;t<s;t++){let o,p;if(y){o=getClosestObject({...this._drawAndSample({layers:h,views:e,viewports:n,onViewportActive:c,deviceRect:y,cullRect:v,effects:u,pass:"picking:".concat(a)}),deviceX:f[0],deviceY:f[1],deviceRadius:m,deviceRect:y})}else o={pickedColor:null,pickedObjectIndex:-1};if(o.pickedLayer&&l&&this.depthFBO){const{pickedColors:t}=this._drawAndSample({layers:[o.pickedLayer],views:e,viewports:n,onViewportActive:c,deviceRect:{x:o.pickedX,y:o.pickedY,width:1,height:1},cullRect:v,effects:u,pass:"picking:".concat(a,":z")},!0);t[3]&&(p=t[0])}o.pickedLayer&&t+1<s&&(T.add(o.pickedLayer),o.pickedLayer.disablePickingIndex(o.pickedObjectIndex)),x=processPickInfo({pickInfo:o,lastPickedInfo:this.lastPickedInfo,mode:a,layers:h,viewports:n,x:i,y:r,z:p,pixelRatio:d});for(const t of x.values())t.layer&&b.push(t);if(!o.pickedColor)break}for(const t of T)t.restorePickingColors();return{result:b,emptyInfo:x.get(null)}}_pickVisibleObjects({layers:t,views:e,viewports:n,x:i,y:r,width:o=1,height:s=1,mode:a="query",maxObjects:l=null,onViewportActive:c,effects:u}){const h=this._getPickable(t);if(!h)return[];this._resizeBuffer();const d=cssToDeviceRatio(this.gl),p=cssToDevicePixels(this.gl,[i,r],!0),f=p.x,m=p.y+p.height,g=cssToDevicePixels(this.gl,[i+o,r+s],!0),_=g.y,y=getUniqueObjects(this._drawAndSample({layers:h,views:e,viewports:n,onViewportActive:c,deviceRect:{x:f,y:_,width:g.x+g.width-f,height:m-_},cullRect:{x:i,y:r,width:o,height:s},effects:u,pass:"picking:".concat(a)})),v=new Map,x=Number.isFinite(l);for(let t=0;t<y.length;t++){var b;if(x&&l&&v.size>=l)break;const e=y[t];let n={color:e.pickedColor,layer:null,index:e.pickedObjectIndex,picked:!0,x:i,y:r,pixelRatio:d};n=getLayerPickingInfo({layer:e.pickedLayer,info:n,mode:a});const o=null!==(b=n.object)&&void 0!==b?b:"".concat(n.layer.id,"[").concat(n.index,"]");v.has(o)||v.set(o,n)}return Array.from(v.values())}_drawAndSample({layers:t,views:e,viewports:n,onViewportActive:i,deviceRect:r,cullRect:o,effects:s,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,u={layers:t,layerFilter:this.layerFilter,views:e,viewports:n,onViewportActive:i,pickingFBO:c,deviceRect:r,cullRect:o,effects:s,pass:a,pickZ:l,preRenderStats:{}};for(const t of s)t.useInPicking&&(u.preRenderStats[t.id]=t.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 readPixelsToArray(c,{sourceX:d,sourceY:p,sourceWidth:f,sourceHeight:m,target:g}),{pickedColors:g,decodePickingColor:h}}_getPickingRect({deviceX:t,deviceY:e,deviceRadius:n,deviceWidth:i,deviceHeight:r}){const o=Math.max(0,t-n),s=Math.max(0,e-n),a=Math.min(i,t+n+1)-o,l=Math.min(r,e+n+1)-s;return a<=0||l<=0?null:{x:o,y:s,width:a,height:l}}}const defaultStyle={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class Tooltip{constructor(t){_defineProperty(this,"el",null),_defineProperty(this,"isVisible",!1);const e=t.parentElement;e&&(this.el=document.createElement("div"),this.el.className="deck-tooltip",Object.assign(this.el.style,defaultStyle),e.appendChild(this.el))}setTooltip(t,e,n){const i=this.el;if(i){if("string"==typeof t)i.innerText=t;else{if(!t)return this.isVisible=!1,void(i.style.display="none");t.text&&(i.innerText=t.text),t.html&&(i.innerHTML=t.html),t.className&&(i.className=t.className)}this.isVisible=!0,i.style.display="block",i.style.transform="translate(".concat(e,"px, ").concat(n,"px)"),t&&"object"==typeof t&&"style"in t&&Object.assign(i.style,t.style)}}remove(){this.el&&(this.el.remove(),this.el=null)}}var hammer$1={exports:{}},hasRequiredHammer;
/*! Hammer.JS - v2.0.7 - 2016-04-22
 * http://hammerjs.github.io/
 *
 * Copyright (c) 2016 Jorik Tangelder;
 * Licensed under the MIT license */function requireHammer(){return hasRequiredHammer||(hasRequiredHammer=1,function(t){!function(e,n,i,r){var o,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,u=Date.now;function h(t,e,n){return setTimeout(y(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(p(t,n[e],n),!0)}function p(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==r)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function f(t,n,i){var r="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=e.console&&(e.console.warn||e.console.log);return o&&o.call(e.console,r,i),t.apply(this,arguments)}}o="function"!=typeof Object.assign?function(t){if(t===r||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==r&&null!==i)for(var o in i)i.hasOwnProperty(o)&&(e[o]=i[o])}return e}:Object.assign;var m=f((function(t,e,n){for(var i=Object.keys(e),o=0;o<i.length;)(!n||n&&t[i[o]]===r)&&(t[i[o]]=e[i[o]]),o++;return t}),"extend","Use `assign`."),g=f((function(t,e){return m(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var i,r=e.prototype;(i=t.prototype=Object.create(r)).constructor=t,i._super=r,n&&o(i,n)}function y(t,e){return function(){return t.apply(e,arguments)}}function v(t,e){return"function"==typeof t?t.apply(e&&e[0]||r,e):t}function x(t,e){return t===r?e:t}function b(t,e,n){p(w(e),(function(e){t.addEventListener(e,n,!1)}))}function T(t,e,n){p(w(e),(function(e){t.removeEventListener(e,n,!1)}))}function E(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function w(t){return t.trim().split(/\s+/g)}function A(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}function M(t){return Array.prototype.slice.call(t,0)}function C(t,e,n){for(var i=[],r=[],o=0;o<t.length;){var s=t[o][e];A(r,s)<0&&i.push(t[o]),r[o]=s,o++}return i=i.sort((function(t,n){return t[e]>n[e]})),i}function I(t,e){for(var n,i,o=e[0].toUpperCase()+e.slice(1),a=0;a<s.length;){if((i=(n=s[a])?n+o:e)in t)return i;a++}return r}var P=1;function L(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}var R="ontouchstart"in e,O=I(e,"PointerEvent")!==r,D=R&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),B="touch",N="mouse",F=24,U=["x","y"],k=["clientX","clientY"];function z(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){v(t.options.enable,[t])&&n.handler(e)},this.init()}function G(t,e,n){var i=n.pointers.length,o=n.changedPointers.length,s=1&e&&i-o==0,a=12&e&&i-o==0;n.isFirst=!!s,n.isFinal=!!a,s&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,i=e.pointers,o=i.length;n.firstInput||(n.firstInput=V(e));o>1&&!n.firstMultiple?n.firstMultiple=V(e):1===o&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,h=e.center=j(i);e.timeStamp=u(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=q(l,h),e.distance=W(l,h),function(t,e){var n=e.center,i=t.offsetDelta||{},r=t.prevDelta||{},o=t.prevInput||{};1!==e.eventType&&4!==o.eventType||(r=t.prevDelta={x:o.deltaX||0,y:o.deltaY||0},i=t.offsetDelta={x:n.x,y:n.y});e.deltaX=r.x+(n.x-i.x),e.deltaY=r.y+(n.y-i.y)}(n,e),e.offsetDirection=H(e.deltaX,e.deltaY);var d=$(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=c(d.x)>c(d.y)?d.x:d.y,e.scale=a?(p=a.pointers,f=i,W(f[0],f[1],k)/W(p[0],p[1],k)):1,e.rotation=a?function(t,e){return q(e[1],e[0],k)+q(t[1],t[0],k)}(a.pointers,i):0,e.maxPointers=n.prevInput?e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers:e.pointers.length,function(t,e){var n,i,o,s,a=t.lastInterval||e,l=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(l>25||a.velocity===r)){var u=e.deltaX-a.deltaX,h=e.deltaY-a.deltaY,d=$(l,u,h);i=d.x,o=d.y,n=c(d.x)>c(d.y)?d.x:d.y,s=H(u,h),t.lastInterval=e}else n=a.velocity,i=a.velocityX,o=a.velocityY,s=a.direction;e.velocity=n,e.velocityX=i,e.velocityY=o,e.direction=s}(n,e);var p,f;var m=t.element;E(e.srcEvent.target,m)&&(m=e.srcEvent.target);e.target=m}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function V(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:l(t.pointers[n].clientX),clientY:l(t.pointers[n].clientY)},n++;return{timeStamp:u(),pointers:e,center:j(e),deltaX:t.deltaX,deltaY:t.deltaY}}function j(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,i=0,r=0;r<e;)n+=t[r].clientX,i+=t[r].clientY,r++;return{x:l(n/e),y:l(i/e)}}function $(t,e,n){return{x:e/t||0,y:n/t||0}}function H(t,e){return t===e?1:c(t)>=c(e)?t<0?2:4:e<0?8:16}function W(t,e,n){n||(n=U);var i=e[n[0]]-t[n[0]],r=e[n[1]]-t[n[1]];return Math.sqrt(i*i+r*r)}function q(t,e,n){return n||(n=U),180*Math.atan2(e[n[1]]-t[n[1]],e[n[0]]-t[n[0]])/Math.PI}z.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&&T(this.element,this.evEl,this.domHandler),this.evTarget&&T(this.target,this.evTarget,this.domHandler),this.evWin&&T(L(this.element),this.evWin,this.domHandler)}};var X={mousedown:1,mousemove:2,mouseup:4},Y="mousedown",Z="mousemove mouseup";function J(){this.evEl=Y,this.evWin=Z,this.pressed=!1,z.apply(this,arguments)}_(J,z,{handler:function(t){var e=X[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:N,srcEvent:t}))}});var K={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:B,3:"pen",4:N,5:"kinect"},tt="pointerdown",et="pointermove pointerup pointercancel";function nt(){this.evEl=tt,this.evWin=et,z.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(tt="MSPointerDown",et="MSPointerMove MSPointerUp MSPointerCancel"),_(nt,z,{handler:function(t){var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),r=K[i],o=Q[t.pointerType]||t.pointerType,s=o==B,a=A(e,t.pointerId,"pointerId");1&r&&(0===t.button||s)?a<0&&(e.push(t),a=e.length-1):12&r&&(n=!0),a<0||(e[a]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:o,srcEvent:t}),n&&e.splice(a,1))}});var it={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function rt(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,z.apply(this,arguments)}function ot(t,e){var n=M(t.touches),i=M(t.changedTouches);return 12&e&&(n=C(n.concat(i),"identifier")),[n,i]}_(rt,z,{handler:function(t){var e=it[t.type];if(1===e&&(this.started=!0),this.started){var n=ot.call(this,t,e);12&e&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:B,srcEvent:t})}}});var st={touchstart:1,touchmove:2,touchend:4,touchcancel:8},at="touchstart touchmove touchend touchcancel";function lt(){this.evTarget=at,this.targetIds={},z.apply(this,arguments)}function ct(t,e){var n=M(t.touches),i=this.targetIds;if(3&e&&1===n.length)return i[n[0].identifier]=!0,[n,n];var r,o,s=M(t.changedTouches),a=[],l=this.target;if(o=n.filter((function(t){return E(t.target,l)})),1===e)for(r=0;r<o.length;)i[o[r].identifier]=!0,r++;for(r=0;r<s.length;)i[s[r].identifier]&&a.push(s[r]),12&e&&delete i[s[r].identifier],r++;return a.length?[C(o.concat(a),"identifier"),a]:void 0}_(lt,z,{handler:function(t){var e=st[t.type],n=ct.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:B,srcEvent:t})}});function ut(){z.apply(this,arguments);var t=y(this.handler,this);this.touch=new lt(this.manager,t),this.mouse=new J(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}function ht(t,e){1&t?(this.primaryTouch=e.changedPointers[0].identifier,dt.call(this,e)):12&t&&dt.call(this,e)}function dt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={x:e.clientX,y:e.clientY};this.lastTouches.push(n);var i=this.lastTouches;setTimeout((function(){var t=i.indexOf(n);t>-1&&i.splice(t,1)}),2500)}}function pt(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var r=this.lastTouches[i],o=Math.abs(e-r.x),s=Math.abs(n-r.y);if(o<=25&&s<=25)return!0}return!1}_(ut,z,{handler:function(t,e,n){var i=n.pointerType==N;if(!(i&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(n.pointerType==B)ht.call(this,e,n);else if(i&&pt.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var ft=I(a.style,"touchAction"),mt=ft!==r,gt="compute",_t="auto",yt="manipulation",vt="none",xt="pan-x",bt="pan-y",Tt=function(){if(!mt)return!1;var t={},n=e.CSS&&e.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach((function(i){t[i]=!n||e.CSS.supports("touch-action",i)})),t}();function Et(t,e){this.manager=t,this.set(e)}Et.prototype={set:function(t){t==gt&&(t=this.compute()),mt&&this.manager.element.style&&Tt[t]&&(this.manager.element.style[ft]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return p(this.manager.recognizers,(function(e){v(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))})),function(t){if(S(t,vt))return vt;var e=S(t,xt),n=S(t,bt);if(e&&n)return vt;if(e||n)return e?xt:bt;if(S(t,yt))return yt;return _t}(t.join(" "))},preventDefaults:function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var i=this.actions,r=S(i,vt)&&!Tt[vt],o=S(i,bt)&&!Tt[bt],s=S(i,xt)&&!Tt[xt];if(r)if(1===t.pointers.length&&t.distance<2&&t.deltaTime<250)return;if(!s||!o)return r||o&&6&n||s&&n&F?this.preventSrc(e):void 0}},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var St=32;function wt(t){this.options=o({},this.defaults,t||{}),this.id=P++,this.manager=null,this.options.enable=x(this.options.enable,!0),this.state=1,this.simultaneous={},this.requireFail=[]}function At(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}function Mt(t){return 16==t?"down":8==t?"up":2==t?"left":4==t?"right":""}function Ct(t,e){var n=e.manager;return n?n.get(t):t}function It(){wt.apply(this,arguments)}function Pt(){It.apply(this,arguments),this.pX=null,this.pY=null}function Lt(){It.apply(this,arguments)}function Rt(){wt.apply(this,arguments),this._timer=null,this._input=null}function Ot(){It.apply(this,arguments)}function Dt(){It.apply(this,arguments)}function Bt(){wt.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Nt(t,e){return(e=e||{}).recognizers=x(e.recognizers,Nt.defaults.preset),new Ft(t,e)}wt.prototype={defaults:{},set:function(t){return o(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(d(t,"recognizeWith",this))return this;var e=this.simultaneous;return e[(t=Ct(t,this)).id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return d(t,"dropRecognizeWith",this)||(t=Ct(t,this),delete this.simultaneous[t.id]),this},requireFailure:function(t){if(d(t,"requireFailure",this))return this;var e=this.requireFail;return-1===A(e,t=Ct(t,this))&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(d(t,"dropRequireFailure",this))return this;t=Ct(t,this);var e=A(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function i(n){e.manager.emit(n,t)}n<8&&i(e.options.event+At(n)),i(e.options.event),t.additionalEvent&&i(t.additionalEvent),n>=8&&i(e.options.event+At(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=St},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(33&this.requireFail[t].state))return!1;t++}return!0},recognize:function(t){var e=o({},t);if(!v(this.options.enable,[this,e]))return this.reset(),void(this.state=St);56&this.state&&(this.state=1),this.state=this.process(e),30&this.state&&this.tryEmit(e)},process:function(t){},getTouchAction:function(){},reset:function(){}},_(It,wt,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,n=t.eventType,i=6&e,r=this.attrTest(t);return i&&(8&n||!r)?16|e:i||r?4&n?8|e:2&e?4|e:2:St}}),_(Pt,It,{defaults:{event:"pan",threshold:10,pointers:1,direction:30},getTouchAction:function(){var t=this.options.direction,e=[];return 6&t&&e.push(bt),t&F&&e.push(xt),e},directionTest:function(t){var e=this.options,n=!0,i=t.distance,r=t.direction,o=t.deltaX,s=t.deltaY;return r&e.direction||(6&e.direction?(r=0===o?1:o<0?2:4,n=o!=this.pX,i=Math.abs(t.deltaX)):(r=0===s?1:s<0?8:16,n=s!=this.pY,i=Math.abs(t.deltaY))),t.direction=r,n&&i>e.threshold&&r&e.direction},attrTest:function(t){return It.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Mt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),_(Lt,It,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[vt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){1!==t.scale&&(t.additionalEvent=this.options.event+(t.scale<1?"in":"out"));this._super.emit.call(this,t)}}),_(Rt,wt,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[_t]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,r=t.deltaTime>e.time;if(this._input=t,!i||!n||12&t.eventType&&!r)this.reset();else if(1&t.eventType)this.reset(),this._timer=h((function(){this.state=8,this.tryEmit()}),e.time,this);else if(4&t.eventType)return 8;return St},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=u(),this.manager.emit(this.options.event,this._input)))}}),_(Ot,It,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[vt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),_(Dt,It,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Pt.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:n&F&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&c(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=Mt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),_(Bt,wt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[yt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,r=t.deltaTime<e.time;if(this.reset(),1&t.eventType&&0===this.count)return this.failTimeout();if(i&&r&&n){if(4!=t.eventType)return this.failTimeout();var o=!this.pTime||t.timeStamp-this.pTime<e.interval,s=!this.pCenter||W(this.pCenter,t.center)<e.posThreshold;if(this.pTime=t.timeStamp,this.pCenter=t.center,s&&o?this.count+=1:this.count=1,this._input=t,0===this.count%e.taps)return this.hasRequireFailures()?(this._timer=h((function(){this.state=8,this.tryEmit()}),e.interval,this),2):8}return St},failTimeout:function(){return this._timer=h((function(){this.state=St}),this.options.interval,this),St},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Nt.VERSION="2.0.7",Nt.defaults={domEvents:!1,touchAction:gt,enable:!0,inputTarget:null,inputClass:null,preset:[[Ot,{enable:!1}],[Lt,{enable:!1},["rotate"]],[Dt,{direction:6}],[Pt,{direction:6},["swipe"]],[Bt],[Bt,{event:"doubletap",taps:2},["tap"]],[Rt]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Ft(t,e){var n;this.options=o({},Nt.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((n=this).options.inputClass||(O?nt:D?lt:R?ut:J))(n,G),this.touchAction=new Et(this,this.options.touchAction),Ut(this,!0),p(this.options.recognizers,(function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])}),this)}function Ut(t,e){var n,i=t.element;i.style&&(p(t.options.cssProps,(function(r,o){n=I(i.style,o),e?(t.oldCssProps[n]=i.style[n],i.style[n]=r):i.style[n]=t.oldCssProps[n]||""})),e||(t.oldCssProps={}))}Ft.prototype={set:function(t){return o(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?2:1},recognize:function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var i=this.recognizers,r=e.curRecognizer;(!r||r&&8&r.state)&&(r=e.curRecognizer=null);for(var o=0;o<i.length;)n=i[o],2===e.stopped||r&&n!=r&&!n.canRecognizeWith(r)?n.reset():n.recognize(t),!r&&14&n.state&&(r=e.curRecognizer=n),o++}},get:function(t){if(t instanceof wt)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event==t)return e[n];return null},add:function(t){if(d(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){if(d(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,n=A(e,t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this},on:function(t,e){if(t!==r&&e!==r){var n=this.handlers;return p(w(t),(function(t){n[t]=n[t]||[],n[t].push(e)})),this}},off:function(t,e){if(t!==r){var n=this.handlers;return p(w(t),(function(t){e?n[t]&&n[t].splice(A(n[t],e),1):delete n[t]})),this}},emit:function(t,e){this.options.domEvents&&function(t,e){var i=n.createEvent("Event");i.initEvent(t,!0,!0),i.gesture=e,e.target.dispatchEvent(i)}(t,e);var i=this.handlers[t]&&this.handlers[t].slice();if(i&&i.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var r=0;r<i.length;)i[r](e),r++}},destroy:function(){this.element&&Ut(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},o(Nt,{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:St,DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:F,DIRECTION_ALL:30,Manager:Ft,Input:z,TouchAction:Et,TouchInput:lt,MouseInput:J,PointerEventInput:nt,TouchMouseInput:ut,SingleTouchInput:rt,Recognizer:wt,AttrRecognizer:It,Tap:Bt,Pan:Pt,Swipe:Dt,Pinch:Lt,Rotate:Ot,Press:Rt,on:b,off:T,each:p,merge:g,extend:m,assign:o,inherit:_,bindFn:y,prefixed:I}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Nt,t.exports?t.exports=Nt:e.Hammer=Nt}(window,document)}(hammer$1)),hammer$1.exports}var hammerExports=requireHammer(),hammer=getDefaultExportFromCjs(hammerExports),hammerjs=_mergeNamespaces({__proto__:null,default:hammer},[hammerExports]);const INPUT_START=1,INPUT_MOVE=2,INPUT_END=4,MOUSE_INPUT_MAP={mousedown:INPUT_START,mousemove:INPUT_MOVE,mouseup:INPUT_END};function some(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return!0;return!1}function enhancePointerEventInput(t){const e=t.prototype.handler;t.prototype.handler=function(t){const n=this.store;t.button>0&&"pointerdown"===t.type&&(some(n,(e=>e.pointerId===t.pointerId))||n.push(t)),e.call(this,t)}}function enhanceMouseInput(t){t.prototype.handler=function(t){let e=MOUSE_INPUT_MAP[t.type];e&INPUT_START&&t.button>=0&&(this.pressed=!0),e&INPUT_MOVE&&0===t.buttons&&(e=INPUT_END),this.pressed&&(e&INPUT_END&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:"mouse",srcEvent:t}))}}enhancePointerEventInput(hammerExports.PointerEventInput),enhanceMouseInput(hammerExports.MouseInput);const Manager=hammerExports.Manager;class Input{constructor(t,e,n){this.element=t,this.callback=e,this.options={enable:!0,...n}}}const RECOGNIZERS=hammerjs?[[hammerjs.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[hammerjs.Rotate,{enable:!1}],[hammerjs.Pinch,{enable:!1}],[hammerjs.Swipe,{enable:!1}],[hammerjs.Pan,{threshold:0,enable:!1}],[hammerjs.Press,{enable:!1}],[hammerjs.Tap,{event:"doubletap",taps:2,enable:!1}],[hammerjs.Tap,{event:"anytap",enable:!1}],[hammerjs.Tap,{enable:!1}]]:null,RECOGNIZER_COMPATIBLE_MAP={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},RECOGNIZER_FALLBACK_MAP={doubletap:["tap"]},BASIC_EVENT_ALIASES={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},INPUT_EVENT_TYPES={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},EVENT_RECOGNIZER_MAP={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"},GESTURE_EVENT_ALIASES={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},userAgent="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",window_="undefined"!=typeof window?window:global;let passiveSupported=!1;try{const t={get passive(){return passiveSupported=!0,!0}};window_.addEventListener("test",null,t),window_.removeEventListener("test",null)}catch(err){passiveSupported=!1}const firefox=-1!==userAgent.indexOf("firefox"),{WHEEL_EVENTS:WHEEL_EVENTS}=INPUT_EVENT_TYPES,EVENT_TYPE$1="wheel",WHEEL_DELTA_MAGIC_SCALER=4.000244140625,WHEEL_DELTA_PER_LINE=40,SHIFT_MULTIPLIER=.25;class WheelInput extends Input{constructor(t,e,n){super(t,e,n),this.handleEvent=t=>{if(!this.options.enable)return;let e=t.deltaY;window_.WheelEvent&&(firefox&&t.deltaMode===window_.WheelEvent.DOM_DELTA_PIXEL&&(e/=window_.devicePixelRatio),t.deltaMode===window_.WheelEvent.DOM_DELTA_LINE&&(e*=WHEEL_DELTA_PER_LINE)),0!==e&&e%WHEEL_DELTA_MAGIC_SCALER==0&&(e=Math.floor(e/WHEEL_DELTA_MAGIC_SCALER)),t.shiftKey&&e&&(e*=SHIFT_MULTIPLIER),this.callback({type:EVENT_TYPE$1,center:{x:t.clientX,y:t.clientY},delta:-e,srcEvent:t,pointerType:"mouse",target:t.target})},this.events=(this.options.events||[]).concat(WHEEL_EVENTS),this.events.forEach((e=>t.addEventListener(e,this.handleEvent,!!passiveSupported&&{passive:!1})))}destroy(){this.events.forEach((t=>this.element.removeEventListener(t,this.handleEvent)))}enableEventType(t,e){t===EVENT_TYPE$1&&(this.options.enable=e)}}const{MOUSE_EVENTS:MOUSE_EVENTS$1}=INPUT_EVENT_TYPES,MOVE_EVENT_TYPE="pointermove",OVER_EVENT_TYPE="pointerover",OUT_EVENT_TYPE="pointerout",ENTER_EVENT_TYPE="pointerenter",LEAVE_EVENT_TYPE="pointerleave";class MoveInput extends Input{constructor(t,e,n){super(t,e,n),this.handleEvent=t=>{this.handleOverEvent(t),this.handleOutEvent(t),this.handleEnterEvent(t),this.handleLeaveEvent(t),this.handleMoveEvent(t)},this.pressed=!1;const{enable:i}=this.options;this.enableMoveEvent=i,this.enableLeaveEvent=i,this.enableEnterEvent=i,this.enableOutEvent=i,this.enableOverEvent=i,this.events=(this.options.events||[]).concat(MOUSE_EVENTS$1),this.events.forEach((e=>t.addEventListener(e,this.handleEvent)))}destroy(){this.events.forEach((t=>this.element.removeEventListener(t,this.handleEvent)))}enableEventType(t,e){t===MOVE_EVENT_TYPE&&(this.enableMoveEvent=e),t===OVER_EVENT_TYPE&&(this.enableOverEvent=e),t===OUT_EVENT_TYPE&&(this.enableOutEvent=e),t===ENTER_EVENT_TYPE&&(this.enableEnterEvent=e),t===LEAVE_EVENT_TYPE&&(this.enableLeaveEvent=e)}handleOverEvent(t){this.enableOverEvent&&"mouseover"===t.type&&this._emit(OVER_EVENT_TYPE,t)}handleOutEvent(t){this.enableOutEvent&&"mouseout"===t.type&&this._emit(OUT_EVENT_TYPE,t)}handleEnterEvent(t){this.enableEnterEvent&&"mouseenter"===t.type&&this._emit(ENTER_EVENT_TYPE,t)}handleLeaveEvent(t){this.enableLeaveEvent&&"mouseleave"===t.type&&this._emit(LEAVE_EVENT_TYPE,t)}handleMoveEvent(t){if(this.enableMoveEvent)switch(t.type){case"mousedown":t.button>=0&&(this.pressed=!0);break;case"mousemove":0===t.buttons&&(this.pressed=!1),this.pressed||this._emit(MOVE_EVENT_TYPE,t);break;case"mouseup":this.pressed=!1}}_emit(t,e){this.callback({type:t,center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:"mouse",target:e.target})}}const{KEY_EVENTS:KEY_EVENTS}=INPUT_EVENT_TYPES,DOWN_EVENT_TYPE="keydown",UP_EVENT_TYPE="keyup";class KeyInput extends Input{constructor(t,e,n){super(t,e,n),this.handleEvent=t=>{const e=t.target||t.srcElement;"INPUT"===e.tagName&&"text"===e.type||"TEXTAREA"===e.tagName||(this.enableDownEvent&&"keydown"===t.type&&this.callback({type:DOWN_EVENT_TYPE,srcEvent:t,key:t.key,target:t.target}),this.enableUpEvent&&"keyup"===t.type&&this.callback({type:UP_EVENT_TYPE,srcEvent:t,key:t.key,target:t.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(KEY_EVENTS),t.tabIndex=this.options.tabIndex||0,t.style.outline="none",this.events.forEach((e=>t.addEventListener(e,this.handleEvent)))}destroy(){this.events.forEach((t=>this.element.removeEventListener(t,this.handleEvent)))}enableEventType(t,e){t===DOWN_EVENT_TYPE&&(this.enableDownEvent=e),t===UP_EVENT_TYPE&&(this.enableUpEvent=e)}}const EVENT_TYPE="contextmenu";class ContextmenuInput extends Input{constructor(t,e,n){super(t,e,n),this.handleEvent=t=>{this.options.enable&&this.callback({type:EVENT_TYPE,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})},t.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(t,e){t===EVENT_TYPE&&(this.options.enable=e)}}const DOWN_EVENT=1,MOVE_EVENT=2,UP_EVENT=4,MOUSE_EVENTS={pointerdown:DOWN_EVENT,pointermove:MOVE_EVENT,pointerup:UP_EVENT,mousedown:DOWN_EVENT,mousemove:MOVE_EVENT,mouseup:UP_EVENT},MOUSE_EVENT_BUTTON_LEFT=0,MOUSE_EVENT_BUTTON_MIDDLE=1,MOUSE_EVENT_BUTTON_RIGHT=2,MOUSE_EVENT_BUTTONS_LEFT_MASK=1,MOUSE_EVENT_BUTTONS_RIGHT_MASK=2,MOUSE_EVENT_BUTTONS_MIDDLE_MASK=4;function whichButtons(t){const e=MOUSE_EVENTS[t.srcEvent.type];if(!e)return null;const{buttons:n,button:i}=t.srcEvent;let r=!1,o=!1,s=!1;return e===MOVE_EVENT?(r=Boolean(n&MOUSE_EVENT_BUTTONS_LEFT_MASK),o=Boolean(n&MOUSE_EVENT_BUTTONS_MIDDLE_MASK),s=Boolean(n&MOUSE_EVENT_BUTTONS_RIGHT_MASK)):(r=i===MOUSE_EVENT_BUTTON_LEFT,o=i===MOUSE_EVENT_BUTTON_MIDDLE,s=i===MOUSE_EVENT_BUTTON_RIGHT),{leftButton:r,middleButton:o,rightButton:s}}function getOffsetPosition(t,e){const n=t.center;if(!n)return null;const i=e.getBoundingClientRect();return{center:n,offsetCenter:{x:(n.x-i.left-e.clientLeft)/(i.width/e.offsetWidth||1),y:(n.y-i.top-e.clientTop)/(i.height/e.offsetHeight||1)}}}const DEFAULT_OPTIONS$2={srcElement:"root",priority:0};class EventRegistrar{constructor(t){this.handleEvent=t=>{if(this.isEmpty())return;const e=this._normalizeEvent(t);let n=t.srcEvent.target;for(;n&&n!==e.rootElement;){if(this._emit(e,n),e.handled)return;n=n.parentNode}this._emit(e,"root")},this.eventManager=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(t,e,n,i=!1,r=!1){const{handlers:o,handlersByElement:s}=this;let a=DEFAULT_OPTIONS$2;"string"==typeof n||n&&n.addEventListener?a={...DEFAULT_OPTIONS$2,srcElement:n}:n&&(a={...DEFAULT_OPTIONS$2,...n});let l=s.get(a.srcElement);l||(l=[],s.set(a.srcElement,l));const c={type:t,handler:e,srcElement:a.srcElement,priority:a.priority};i&&(c.once=!0),r&&(c.passive=!0),o.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(t,e){const{handlers:n,handlersByElement:i}=this;for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.type===t&&o.handler===e){n.splice(r,1);const t=i.get(o.srcElement);t.splice(t.indexOf(o),1),0===t.length&&i.delete(o.srcElement)}}this._active=n.some((t=>!t.passive))}_emit(t,e){const n=this.handlersByElement.get(e);if(n){let e=!1;const i=()=>{t.handled=!0},r=()=>{t.handled=!0,e=!0},o=[];for(let s=0;s<n.length;s++){const{type:a,handler:l,once:c}=n[s];if(l({...t,type:a,stopPropagation:i,stopImmediatePropagation:r}),c&&o.push(n[s]),e)break}for(let t=0;t<o.length;t++){const{type:e,handler:n}=o[t];this.remove(e,n)}}}_normalizeEvent(t){const e=this.eventManager.getElement();return{...t,...whichButtons(t),...getOffsetPosition(t,e),preventDefault:()=>{t.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:e}}}const DEFAULT_OPTIONS$1={events:null,recognizers:null,recognizerOptions:{},Manager:Manager,touchAction:"none",tabIndex:0};class EventManager{constructor(t=null,e){this._onBasicInput=t=>{const{srcEvent:e}=t,n=BASIC_EVENT_ALIASES[e.type];n&&this.manager.emit(n,t)},this._onOtherEvent=t=>{this.manager.emit(t.type,t)},this.options={...DEFAULT_OPTIONS$1,...e},this.events=new Map,this.setElement(t);const{events:n}=this.options;n&&this.on(n)}getElement(){return this.element}setElement(t){if(this.element&&this.destroy(),this.element=t,!t)return;const{options:e}=this;this.manager=new(0,e.Manager)(t,{touchAction:e.touchAction,recognizers:e.recognizers||RECOGNIZERS}).on("hammer.input",this._onBasicInput),e.recognizers||Object.keys(RECOGNIZER_COMPATIBLE_MAP).forEach((t=>{const e=this.manager.get(t);e&&RECOGNIZER_COMPATIBLE_MAP[t].forEach((t=>{e.recognizeWith(t)}))}));for(const t in e.recognizerOptions){const n=this.manager.get(t);if(n){const i=e.recognizerOptions[t];delete i.enable,n.set(i)}}this.wheelInput=new WheelInput(t,this._onOtherEvent,{enable:!1}),this.moveInput=new MoveInput(t,this._onOtherEvent,{enable:!1}),this.keyInput=new KeyInput(t,this._onOtherEvent,{enable:!1,tabIndex:e.tabIndex}),this.contextmenuInput=new ContextmenuInput(t,this._onOtherEvent,{enable:!1});for(const[t,e]of this.events)e.isEmpty()||(this._toggleRecognizer(e.recognizerName,!0),this.manager.on(t,e.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(t,e,n){this._addEventHandler(t,e,n,!1)}once(t,e,n){this._addEventHandler(t,e,n,!0)}watch(t,e,n){this._addEventHandler(t,e,n,!1,!0)}off(t,e){this._removeEventHandler(t,e)}_toggleRecognizer(t,e){const{manager:n}=this;if(!n)return;const i=n.get(t);if(i&&i.options.enable!==e){i.set({enable:e});const r=RECOGNIZER_FALLBACK_MAP[t];r&&!this.options.recognizers&&r.forEach((r=>{const o=n.get(r);e?(o.requireFailure(t),i.dropRequireFailure(r)):o.dropRequireFailure(t)}))}this.wheelInput.enableEventType(t,e),this.moveInput.enableEventType(t,e),this.keyInput.enableEventType(t,e),this.contextmenuInput.enableEventType(t,e)}_addEventHandler(t,e,n,i,r){if("string"!=typeof t){n=e;for(const e in t)this._addEventHandler(e,t[e],n,i,r);return}const{manager:o,events:s}=this,a=GESTURE_EVENT_ALIASES[t]||t;let l=s.get(a);l||(l=new EventRegistrar(this),s.set(a,l),l.recognizerName=EVENT_RECOGNIZER_MAP[a]||a,o&&o.on(a,l.handleEvent)),l.add(t,e,n,i,r),l.isEmpty()||this._toggleRecognizer(l.recognizerName,!0)}_removeEventHandler(t,e){if("string"!=typeof t){for(const e in t)this._removeEventHandler(e,t[e]);return}const{events:n}=this,i=n.get(GESTURE_EVENT_ALIASES[t]||t);if(i&&(i.remove(t,e),i.isEmpty())){const{recognizerName:t}=i;let e=!1;for(const i of n.values())if(i.recognizerName===t&&!i.isEmpty()){e=!0;break}e||this._toggleRecognizer(t,!1)}}}function noop$1(){}const getCursor=({isDragging:t})=>t?"grabbing":"grab",defaultProps$e={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:noop$1,onResize:noop$1,onViewStateChange:noop$1,onInteractionStateChange:noop$1,onBeforeRender:noop$1,onAfterRender:noop$1,onLoad:noop$1,onError:t=>{},onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:getCursor,getTooltip:null,debug:!1,drawPickingColors:!1};class Deck{constructor(t){_defineProperty(this,"props",void 0),_defineProperty(this,"width",0),_defineProperty(this,"height",0),_defineProperty(this,"userData",{}),_defineProperty(this,"canvas",null),_defineProperty(this,"viewManager",null),_defineProperty(this,"layerManager",null),_defineProperty(this,"effectManager",null),_defineProperty(this,"deckRenderer",null),_defineProperty(this,"deckPicker",null),_defineProperty(this,"eventManager",null),_defineProperty(this,"tooltip",null),_defineProperty(this,"metrics",void 0),_defineProperty(this,"animationLoop",void 0),_defineProperty(this,"stats",void 0),_defineProperty(this,"viewState",void 0),_defineProperty(this,"cursorState",void 0),_defineProperty(this,"_needsRedraw",void 0),_defineProperty(this,"_pickRequest",void 0),_defineProperty(this,"_lastPointerDownInfo",null),_defineProperty(this,"_metricsCounter",void 0),_defineProperty(this,"_onPointerMove",(t=>{const{_pickRequest:e}=this;if("pointerleave"===t.type)e.x=-1,e.y=-1,e.radius=0;else{if(t.leftButton||t.rightButton)return;{const n=t.offsetCenter;if(!n)return;e.x=n.x,e.y=n.y,e.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:e.x,y:e.y}),e.event=t})),_defineProperty(this,"_onEvent",(t=>{const e=EVENTS[t.type],n=t.offsetCenter;if(!e||!n||!this.layerManager)return;const i=this.layerManager.getLayers(),r=this.deckPicker.getLastPickedObject({x:n.x,y:n.y,layers:i,viewports:this.getViewports(n)},this._lastPointerDownInfo),{layer:o}=r,s=o&&(o[e.handler]||o.props[e.handler]),a=this.props[e.handler];let l=!1;s&&(l=s.call(o,r,t)),!l&&a&&a(r,t)})),_defineProperty(this,"_onPointerDown",(t=>{const e=t.offsetCenter,n=this._pick("pickObject","pickObject Time",{x:e.x,y:e.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=n.result[0]||n.emptyInfo})),this.props={...defaultProps$e,...t},t=this.props,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this.cursorState={isHovering:!1,isDragging:!1},t.viewState&&t.initialViewState&&log$2.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),"IE"===getBrowser$1()&&log$2.warn("IE 11 is not supported")(),this.viewState=t.initialViewState,t.gl||"undefined"!=typeof document&&(this.canvas=this._createCanvas(t)),this.animationLoop=this._createAnimationLoop(t),this.stats=new Stats({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(t),t._typedArrayManagerProps&&defaultTypedArrayManager.setOptions(t._typedArrayManagerProps),this.animationLoop.start()}finalize(){var t,e,n,i,r,o,s,a,l;(null===(t=this.animationLoop)||void 0===t||t.stop(),this.animationLoop=null,this._lastPointerDownInfo=null,null===(e=this.layerManager)||void 0===e||e.finalize(),this.layerManager=null,null===(n=this.viewManager)||void 0===n||n.finalize(),this.viewManager=null,null===(i=this.effectManager)||void 0===i||i.finalize(),this.effectManager=null,null===(r=this.deckRenderer)||void 0===r||r.finalize(),this.deckRenderer=null,null===(o=this.deckPicker)||void 0===o||o.finalize(),this.deckPicker=null,null===(s=this.eventManager)||void 0===s||s.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(t){this.stats.get("setProps Time").timeStart(),"onLayerHover"in t&&log$2.removed("onLayerHover","onHover")(),"onLayerClick"in t&&log$2.removed("onLayerClick","onClick")(),t.initialViewState&&!deepEqual(this.props.initialViewState,t.initialViewState,3)&&(this.viewState=t.initialViewState),Object.assign(this.props,t),this._setCanvasSize(this.props);const e=Object.create(this.props);Object.assign(e,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop.setProps(e),this.layerManager&&(this.viewManager.setProps(e),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(e),this.effectManager.setProps(e),this.deckRenderer.setProps(e),this.deckPicker.setProps(e)),this.stats.get("setProps Time").timeEnd()}needsRedraw(t={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let e=this._needsRedraw;t.clearRedrawFlags&&(this._needsRedraw=!1);const n=this.viewManager.needsRedraw(t),i=this.layerManager.needsRedraw(t),r=this.effectManager.needsRedraw(t),o=this.deckRenderer.needsRedraw(t);return e=e||n||i||r||o,e}redraw(t){if(!this.layerManager)return;let e=this.needsRedraw({clearRedrawFlags:!0});e=t||e,e&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(e):this._drawLayers(e))}get isInitialized(){return null!==this.viewManager}getViews(){return assert$4(this.viewManager),this.viewManager.views}getViewports(t){return assert$4(this.viewManager),this.viewManager.getViewports(t)}getCanvas(){return this.canvas}pickObject(t){const e=this._pick("pickObject","pickObject Time",t).result;return e.length?e[0]:null}pickMultipleObjects(t){return t.depth=t.depth||10,this._pick("pickObject","pickMultipleObjects Time",t).result}pickObjects(t){return this._pick("pickObjects","pickObjects Time",t)}_addResources(t,e=!1){for(const n in t)this.layerManager.resourceManager.add({resourceId:n,data:t[n],forceUpdate:e})}_removeResources(t){for(const e of t)this.layerManager.resourceManager.remove(e)}_addDefaultEffect(t){this.effectManager.addDefaultEffect(t)}_pick(t,e,n){assert$4(this.deckPicker);const{stats:i}=this;i.get("Pick Count").incrementCount(),i.get(e).timeStart();const r=this.deckPicker[t]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return i.get(e).timeEnd(),r}_createCanvas(t){let e=t.canvas;if("string"==typeof e&&(e=document.getElementById(e),assert$4(e)),!e){e=document.createElement("canvas"),e.id=t.id||"deckgl-overlay";(t.parent||document.body).appendChild(e)}return Object.assign(e.style,t.style),e}_setCanvasSize(t){if(!this.canvas)return;const{width:e,height:n}=t;if(e||0===e){const t=Number.isFinite(e)?"".concat(e,"px"):e;this.canvas.style.width=t}if(n||0===n){var i;const e=Number.isFinite(n)?"".concat(n,"px"):n;this.canvas.style.position=(null===(i=t.style)||void 0===i?void 0:i.position)||"absolute",this.canvas.style.height=e}}_updateCanvasSize(){var t,e;const{canvas:n}=this;if(!n)return;const i=null!==(t=n.clientWidth)&&void 0!==t?t:n.width,r=null!==(e=n.clientHeight)&&void 0!==e?e:n.height;var o,s;i===this.width&&r===this.height||(this.width=i,this.height=r,null===(o=this.viewManager)||void 0===o||o.setProps({width:i,height:r}),null===(s=this.layerManager)||void 0===s||s.activateViewport(this.getViewports()[0]),this.props.onResize({width:i,height:r}))}_createAnimationLoop(t){const{width:e,height:n,gl:i,glOptions:r,debug:o,onError:s,onBeforeRender:a,onAfterRender:l,useDevicePixels:c}=t;return new AnimationLoop({width:e,height:n,useDevicePixels:c,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,gl:i,onCreateContext:t=>createGLContext({...r,...t,canvas:this.canvas,debug:o,onContextLost:()=>this._onContextLost()}),onInitialize:t=>this._setGLContext(t.gl),onRender:this._onRenderFrame.bind(this),onBeforeRender:a,onAfterRender:l,onError:s})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let t=this.props.views||[new MapView({id:"default-view"})];return t=Array.isArray(t)?t:[t],t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){const{onError:t}=this.props;this.animationLoop&&t&&t(new Error("WebGL context is lost"))}_pickAndCallback(){const{_pickRequest:t}=this;if(t.event){const{result:n,emptyInfo:i}=this._pick("pickObject","pickObject Time",t);this.cursorState.isHovering=n.length>0;let r=i,o=!1;for(const i of n){var e;r=i,o=(null===(e=i.layer)||void 0===e?void 0:e.onHover(i,t.event))||o}if(!o&&this.props.onHover&&this.props.onHover(r,t.event),this.props.getTooltip&&this.tooltip){const t=this.props.getTooltip(r);this.tooltip.setTooltip(t,r.x,r.y)}t.event=null}}_updateCursor(){const t=this.props.parent||this.canvas;t&&(t.style.cursor=this.props.getCursor(this.cursorState))}_setGLContext(t){if(this.layerManager)return;this.canvas||(this.canvas=t.canvas,instrumentGLContext(t,{enable:!0,copyState:!0})),this.tooltip=new Tooltip(this.canvas),setParameters(t,{blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onWebGLInitialized(t);const e=new Timeline;e.play(),this.animationLoop.attachTimeline(e),this.eventManager=new EventManager(this.props.parent||t.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const t in EVENTS)this.eventManager.on(t,this._onEvent);this.viewManager=new ViewManager({timeline:e,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 n=this.viewManager.getViewports()[0];this.layerManager=new LayerManager(t,{deck:this,stats:this.stats,viewport:n,timeline:e}),this.effectManager=new EffectManager,this.deckRenderer=new DeckRenderer(t),this.deckPicker=new DeckPicker(t),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(t,e){const{gl:n}=this.layerManager.context;setParameters(n,this.props.parameters),this.props.onBeforeRender({gl:n}),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(),...e}),this.props.onAfterRender({gl:n})}_onRenderFrame(t){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),log$2.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(t){const e=this.props.onViewStateChange(t)||t.viewState;this.viewState&&(this.viewState={...this.viewState,[t.viewId]:e},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(t){this.cursorState.isDragging=t.isDragging||!1,this.props.onInteractionStateChange(t)}_getFrameStats(){const{stats:t}=this;t.get("frameRate").timeEnd(),t.get("frameRate").timeStart();const e=this.animationLoop.stats;t.get("GPU Time").addTime(e.get("GPU Time").lastTiming),t.get("CPU Time").addTime(e.get("CPU Time").lastTiming)}_getMetrics(){const{metrics:t,stats:e}=this;t.fps=e.get("frameRate").getHz(),t.setPropsTime=e.get("setProps Time").time,t.updateAttributesTime=e.get("Update Attributes").time,t.framesRedrawn=e.get("Redraw Count").count,t.pickTime=e.get("pickObject Time").time+e.get("pickMultipleObjects Time").time+e.get("pickObjects Time").time,t.pickCount=e.get("Pick Count").count,t.gpuTime=e.get("GPU Time").time,t.cpuTime=e.get("CPU Time").time,t.gpuTimePerFrame=e.get("GPU Time").getAverageTime(),t.cpuTimePerFrame=e.get("CPU Time").getAverageTime();const n=lumaStats.get("Memory Usage");t.bufferMemory=n.get("Buffer Memory").count,t.textureMemory=n.get("Texture Memory").count,t.renderbufferMemory=n.get("Renderbuffer Memory").count,t.gpuMemory=n.get("GPU Memory").count}}_defineProperty(Deck,"defaultProps",defaultProps$e),_defineProperty(Deck,"VERSION",VERSION$6);class ShaderAttribute{constructor(t,e){_defineProperty(this,"opts",void 0),_defineProperty(this,"source",void 0),this.opts=e,this.source=t}get value(){return this.source.value}getValue(){const t=this.source.getBuffer(),e=this.getAccessor();if(t)return[t,e];const{value:n}=this.source,{size:i}=e;let r=n;if(n&&n.length!==i){r=new Float32Array(i);const t=e.elementOffset||0;for(let e=0;e<i;++e)r[e]=n[t+e]}return r}getAccessor(){return{...this.source.getAccessor(),...this.opts}}}function glArrayFromType(t){switch(t){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")}}function getStride(t){return t.stride||t.size*t.bytesPerElement}function resolveShaderAttribute(t,e){e.offset&&log$2.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const n=getStride(t),i=(void 0!==e.vertexOffset?e.vertexOffset:t.vertexOffset||0)*n+(e.elementOffset||0)*t.bytesPerElement+(t.offset||0);return{...e,offset:i,stride:n}}function resolveDoublePrecisionShaderAttributes(t,e){const n=resolveShaderAttribute(t,e);return{high:n,low:{...n,offset:n.offset+4*t.size}}}class DataColumn{constructor(t,e,n){_defineProperty(this,"gl",void 0),_defineProperty(this,"id",void 0),_defineProperty(this,"size",void 0),_defineProperty(this,"settings",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"doublePrecision",void 0),_defineProperty(this,"_buffer",void 0),_defineProperty(this,"state",void 0),this.gl=t,this.id=e.id||"",this.size=e.size||1;const i=e.logicalType||e.type,r=5130===i;let o,{defaultValue:s}=e;s=Number.isFinite(s)?[s]:s||new Array(this.size).fill(0),o=r?5126:!i&&e.isIndexed?t&&hasFeature(t,FEATURES$1.ELEMENT_INDEX_UINT32)?5125:5123:i||5126;let a=glArrayFromType(i||o||5126);this.doublePrecision=r,r&&!1===e.fp64&&(a=Float32Array),this.value=null,this.settings={...e,defaultType:a,defaultValue:s,logicalType:i,type:o,size:this.size,bytesPerElement:a.BYTES_PER_ELEMENT},this.state={...n,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:t,type:e}=this.settings;this._buffer=new Buffer(this.gl,{id:this.id,target:t?34963:34962,accessor:{type:e}})}return this._buffer}get byteOffset(){const t=this.getAccessor();return t.vertexOffset?t.vertexOffset*getStride(t):0}get numInstances(){return this.state.numInstances}set numInstances(t){this.state.numInstances=t}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),defaultTypedArrayManager.release(this.state.allocatedValue)}getShaderAttributes(t,e){if(this.doublePrecision){const n={},i=this.value instanceof Float64Array,r=resolveDoublePrecisionShaderAttributes(this.getAccessor(),e||{});return n[t]=new ShaderAttribute(this,r.high),n["".concat(t,"64Low")]=i?new ShaderAttribute(this,r.low):new Float32Array(this.size),n}if(e){const n=resolveShaderAttribute(this.getAccessor(),e);return{[t]:new ShaderAttribute(this,n)}}return{[t]: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 t=null;if(this.state.constant&&this.value){const e=Array.from(this.value);t=[e,e]}else{const{value:e,numInstances:n,size:i}=this,r=n*i;if(e&&r&&e.length>=r){const n=new Array(i).fill(1/0),o=new Array(i).fill(-1/0);for(let t=0;t<r;)for(let r=0;r<i;r++){const i=e[t++];i<n[r]&&(n[r]=i),i>o[r]&&(o[r]=i)}t=[n,o]}}return this.state.bounds=t,t}setData(t){const{state:e}=this;let n;n=ArrayBuffer.isView(t)?{value:t}:t instanceof Buffer?{buffer:t}:t;const i={...this.settings,...n};if(e.bufferAccessor=i,e.bounds=null,n.constant){let t=n.value;t=this._normalizeValue(t,[],0),this.settings.normalized&&(t=this.normalizeConstant(t));if(!(!e.constant||!this._areValuesEqual(t,this.value)))return!1;e.externalBuffer=null,e.constant=!0,this.value=t}else if(n.buffer){const t=n.buffer;e.externalBuffer=t,e.constant=!1,this.value=n.value||null;const r=n.value instanceof Float64Array;i.type=n.type||t.accessor.type,i.bytesPerElement=t.accessor.BYTES_PER_ELEMENT*(r?2:1),i.stride=getStride(i)}else if(n.value){this._checkExternalBuffer(n);let t=n.value;e.externalBuffer=null,e.constant=!1,this.value=t,i.bytesPerElement=t.BYTES_PER_ELEMENT,i.stride=getStride(i);const{buffer:r,byteOffset:o}=this;this.doublePrecision&&t instanceof Float64Array&&(t=toDoublePrecisionArray(t,i));const s=t.byteLength+o+2*i.stride;r.byteLength<s&&r.reallocate(s),r.setAccessor(null),r.subData({data:t,offset:o}),i.type=n.type||r.accessor.type}return!0}updateSubBuffer(t={}){this.state.bounds=null;const e=this.value,{startOffset:n=0,endOffset:i}=t;this.buffer.subData({data:this.doublePrecision&&e instanceof Float64Array?toDoublePrecisionArray(e,{size:this.size,startIndex:n,endIndex:i}):e.subarray(n,i),offset:n*e.BYTES_PER_ELEMENT+this.byteOffset})}allocate(t,e=!1){const{state:n}=this,i=n.allocatedValue,r=defaultTypedArrayManager.allocate(i,t+1,{size:this.size,type:this.settings.defaultType,copy:e});this.value=r;const{buffer:o,byteOffset:s}=this;return o.byteLength<r.byteLength+s&&(o.reallocate(r.byteLength+s),e&&i&&o.subData({data:i instanceof Float64Array?toDoublePrecisionArray(i,this):i,offset:s})),n.allocatedValue=r,n.constant=!1,n.externalBuffer=null,n.bufferAccessor=this.settings,!0}_checkExternalBuffer(t){const{value:e}=t;if(!ArrayBuffer.isView(e))throw new Error("Attribute ".concat(this.id," value is not TypedArray"));const n=this.settings.defaultType;let i=!1;if(this.doublePrecision&&(i=e.BYTES_PER_ELEMENT<4),i)throw new Error("Attribute ".concat(this.id," does not support ").concat(e.constructor.name));e instanceof n||!this.settings.normalized||"normalized"in t||log$2.warn("Attribute ".concat(this.id," is normalized"))()}normalizeConstant(t){switch(this.settings.type){case 5120:return new Float32Array(t).map((t=>(t+128)/255*2-1));case 5122:return new Float32Array(t).map((t=>(t+32768)/65535*2-1));case 5121:return new Float32Array(t).map((t=>t/255));case 5123:return new Float32Array(t).map((t=>t/65535));default:return t}}_normalizeValue(t,e,n){const{defaultValue:i,size:r}=this.settings;if(Number.isFinite(t))return e[n]=t,e;if(!t){let t=r;for(;--t>=0;)e[n+t]=i[t];return e}switch(r){case 4:e[n+3]=Number.isFinite(t[3])?t[3]:i[3];case 3:e[n+2]=Number.isFinite(t[2])?t[2]:i[2];case 2:e[n+1]=Number.isFinite(t[1])?t[1]:i[1];case 1:e[n+0]=Number.isFinite(t[0])?t[0]:i[0];break;default:let o=r;for(;--o>=0;)e[n+o]=Number.isFinite(t[o])?t[o]:i[o]}return e}_areValuesEqual(t,e){if(!t||!e)return!1;const{size:n}=this;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}}const EMPTY_ARRAY$2=[],placeholderArray=[];function createIterable(t,e=0,n=1/0){let i=EMPTY_ARRAY$2;const r={index:-1,data:t,target:[]};return t?"function"==typeof t[Symbol.iterator]?i=t:t.length>0&&(placeholderArray.length=t.length,i=placeholderArray):i=EMPTY_ARRAY$2,(e>0||Number.isFinite(n))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,n),r.index=e-1),{iterable:i,objectInfo:r}}function isAsyncIterable(t){return t&&t[Symbol.asyncIterator]}function getAccessorFromBuffer(t,e){const{size:n,stride:i,offset:r,startIndices:o,nested:s}=e,a=t.BYTES_PER_ELEMENT,l=i?i/a:n,c=r?r/a:0,u=Math.floor((t.length-c)/l);return(e,{index:i,target:r})=>{if(!o){const e=i*l+c;for(let i=0;i<n;i++)r[i]=t[e+i];return r}const a=o[i],h=o[i+1]||u;let d;if(s){d=new Array(h-a);for(let e=a;e<h;e++){const i=e*l+c;r=new Array(n);for(let e=0;e<n;e++)r[e]=t[i+e];d[e-a]=r}}else if(l===n)d=t.subarray(a*n+c,h*n+c);else{d=new t.constructor((h-a)*n);let e=0;for(let i=a;i<h;i++){const r=i*l+c;for(let i=0;i<n;i++)d[e++]=t[r+i]}}return d}}const EMPTY=[],FULL=[[0,1/0]];function add(t,e){if(t===FULL)return t;if(e[0]<0&&(e[0]=0),e[0]>=e[1])return t;const n=[],i=t.length;let r=0;for(let o=0;o<i;o++){const i=t[o];i[1]<e[0]?(n.push(i),r=o+1):i[0]>e[1]?n.push(i):e=[Math.min(i[0],e[0]),Math.max(i[1],e[1])]}return n.splice(r,0,e),n}function padArrayChunk(t){const{source:e,target:n,start:i=0,size:r,getData:o}=t,s=e.length,a=(t.end||n.length)-i;if(s>a)return void n.set(e.subarray(0,a),i);if(n.set(e,i),!o)return;let l=s;for(;l<a;){const t=o(l,e);for(let e=0;e<r;e++)n[i+l]=t[e]||0,l++}}function padArray({source:t,target:e,size:n,getData:i,sourceStartIndices:r,targetStartIndices:o}){if(!Array.isArray(o))return padArrayChunk({source:t,target:e,size:n,getData:i}),e;let s=0,a=0;const l=i&&((t,e)=>i(t+a,e)),c=Math.min(r.length,o.length);for(let i=1;i<c;i++){const c=r[i]*n,u=o[i]*n;padArrayChunk({source:t.subarray(s,c),target:e,start:a,end:u,size:n,getData:l}),s=c,a=u}return a<e.length&&padArrayChunk({source:[],target:e,start:a,size:n,getData:l}),e}const DEFAULT_TRANSITION_SETTINGS={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function normalizeTransitionSettings(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});const n=t.type||"interpolation";return{...DEFAULT_TRANSITION_SETTINGS[n],...e,...t,type:n}}function getSourceBufferAttribute(t,e){const n=e.getBuffer();return n?[n,{divisor:0,size:e.size,normalized:e.settings.normalized}]:e.value}function getAttributeTypeFromSize(t){switch(t){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(t,'"'))}}function cycleBuffers(t){t.push(t.shift())}function getAttributeBufferLength(t,e){const{doublePrecision:n,settings:i,value:r,size:o}=t,s=n&&r instanceof Float64Array?2:1;return(i.noAlloc?r.length:e*o)*s}function padBuffer({buffer:t,numInstances:e,attribute:n,fromLength:i,fromStartIndices:r,getData:o=t=>t}){const s=n.doublePrecision&&n.value instanceof Float64Array?2:1,a=n.size*s,l=n.byteOffset,c=n.startIndices,u=r&&c,h=getAttributeBufferLength(n,e),d=n.isConstant;if(!u&&i>=h)return;const p=d?n.value:n.getBuffer().getData({srcByteOffset:l});if(n.settings.normalized&&!d){const t=o;o=(e,i)=>n.normalizeConstant(t(e,i))}const f=d?(t,e)=>o(p,e):(t,e)=>o(p.subarray(t,t+a),e),m=t.getData({length:i}),g=new Float32Array(h);padArray({source:m,target:g,sourceStartIndices:r,targetStartIndices:c,size:a,getData:f}),t.byteLength<g.byteLength+l&&t.reallocate(g.byteLength+l),t.subData({data:g,offset:l})}class Attribute extends DataColumn{constructor(t,e){super(t,e,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,updateRanges:FULL}),_defineProperty(this,"constant",!1),this.settings.update=e.update||(e.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(t){this.state.startIndices=t}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:t=!1}={}){const e=this.state.needsRedraw;return this.state.needsRedraw=e&&!t,e}getUpdateTriggers(){const{accessor:t}=this.settings;return[this.id].concat("function"!=typeof t&&t||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(t){if(!t||!this.supportsTransition())return null;const{accessor:e}=this.settings,n=this.settings.transition,i=Array.isArray(e)?t[e.find((e=>t[e]))]:t[e];return normalizeTransitionSettings(i,n)}setNeedsUpdate(t=this.id,e){if(this.state.needsUpdate=this.state.needsUpdate||t,this.setNeedsRedraw(t),e){const{startRow:t=0,endRow:n=1/0}=e;this.state.updateRanges=add(this.state.updateRanges,[t,n])}else this.state.updateRanges=FULL}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=EMPTY}setNeedsRedraw(t=this.id){this.state.needsRedraw=this.state.needsRedraw||t}allocate(t){const{state:e,settings:n}=this;return!n.noAlloc&&(!!n.update&&(super.allocate(t,e.updateRanges!==FULL),!0))}updateBuffer({numInstances:t,data:e,props:n,context:i}){if(!this.needsUpdate())return!1;const{state:{updateRanges:r},settings:{update:o,noAlloc:s}}=this;let a=!0;if(o){for(const[s,a]of r)o.call(i,this,{data:e,startRow:s,endRow:a,props:n,numInstances:t});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[e,n]of r){const i=Number.isFinite(e)?this.getVertexOffset(e):0,r=Number.isFinite(n)?this.getVertexOffset(n):s||!Number.isFinite(t)?this.value.length:t*this.size;super.updateSubBuffer({startOffset:i,endOffset:r})}else;this._checkAttributeArray()}else a=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),a}setConstantValue(t){if(void 0===t||"function"==typeof t)return!1;return this.setData({constant:!0,value:t})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setExternalBuffer(t){const{state:e}=this;return t?(this.clearNeedsUpdate(),e.lastExternalBuffer===t||(e.lastExternalBuffer=t,this.setNeedsRedraw(),this.setData(t)),!0):(e.lastExternalBuffer=null,!1)}setBinaryValue(t,e=null){const{state:n,settings:i}=this;if(!t)return n.binaryValue=null,n.binaryAccessor=null,!1;if(i.noAlloc)return!1;if(n.binaryValue===t)return this.clearNeedsUpdate(),!0;n.binaryValue=t,this.setNeedsRedraw();if(i.transform||e!==this.startIndices){ArrayBuffer.isView(t)&&(t={value:t});const r=t;assert$4(ArrayBuffer.isView(r.value),"invalid ".concat(i.accessor));const o=Boolean(r.size)&&r.size!==this.size;return n.binaryAccessor=getAccessorFromBuffer(r.value,{size:r.size||this.size,stride:r.stride,offset:r.offset,startIndices:e,nested:o}),!1}return this.clearNeedsUpdate(),this.setData(t),!0}getVertexOffset(t){const{startIndices:e}=this;return(e?t<e.length?e[t]:this.numInstances:t)*this.size}getShaderAttributes(){const t=this.settings.shaderAttributes||{[this.id]:null},e={};for(const n in t)Object.assign(e,super.getShaderAttributes(n,t[n]));return e}_autoUpdater(t,{data:e,startRow:n,endRow:i,props:r,numInstances:o}){if(t.constant)return;const{settings:s,state:a,value:l,size:c,startIndices:u}=t,{accessor:h,transform:d}=s,p=a.binaryAccessor||("function"==typeof h?h:r[h]);assert$4("function"==typeof p,'accessor "'.concat(h,'" is not a function'));let f=t.getVertexOffset(n);const{iterable:m,objectInfo:g}=createIterable(e,n,i);for(const e of m){g.index++;let n=p(e,g);if(d&&(n=d.call(this,n)),u){const e=(g.index<u.length-1?u[g.index+1]:o)-u[g.index];if(n&&Array.isArray(n[0])){let e=f;for(const i of n)t._normalizeValue(i,l,e),e+=c}else n&&n.length>c?l.set(n,f):(t._normalizeValue(n,g.target,0),fillArray({target:l,source:g.target,start:f,count:e}));f+=e*c}else t._normalizeValue(n,l,f),f+=c}}_validateAttributeUpdaters(){const{settings:t}=this;if(!(t.noAlloc||"function"==typeof t.update))throw new Error("Attribute ".concat(this.id," missing update or accessor"))}_checkAttributeArray(){const{value:t}=this,e=Math.min(4,this.size);if(t&&t.length>=e){let n=!0;switch(e){case 4:n=n&&Number.isFinite(t[3]);case 3:n=n&&Number.isFinite(t[2]);case 2:n=n&&Number.isFinite(t[1]);case 1:n=n&&Number.isFinite(t[0]);break;default:n=!1}if(!n)throw new Error("Illegal attribute generated for ".concat(this.id))}}}class GPUInterpolationTransition{constructor({gl:t,attribute:e,timeline:n}){_defineProperty(this,"gl",void 0),_defineProperty(this,"type","interpolation"),_defineProperty(this,"attributeInTransition",void 0),_defineProperty(this,"settings",void 0),_defineProperty(this,"attribute",void 0),_defineProperty(this,"transition",void 0),_defineProperty(this,"currentStartIndices",void 0),_defineProperty(this,"currentLength",void 0),_defineProperty(this,"transform",void 0),_defineProperty(this,"buffers",void 0),this.gl=t,this.transition=new Transition(n),this.attribute=e,this.attributeInTransition=new Attribute(t,e.settings),this.currentStartIndices=e.startIndices,this.currentLength=0,this.transform=getTransform$1(t,e);const i={byteLength:0,usage:35050};this.buffers=[new Buffer(t,i),new Buffer(t,i)]}get inProgress(){return this.transition.inProgress}start(t,e){if(t.duration<=0)return void this.transition.cancel();this.settings=t;const{gl:n,buffers:i,attribute:r}=this;cycleBuffers(i);const o={numInstances:e,attribute:r,fromLength:this.currentLength,fromStartIndices:this.currentStartIndices,getData:t.enter};for(const t of i)padBuffer({buffer:t,...o});this.currentStartIndices=r.startIndices,this.currentLength=getAttributeBufferLength(r,e),this.attributeInTransition.setData({buffer:i[1],value:r.value}),this.transition.start(t),this.transform.update({elementCount:Math.floor(this.currentLength/r.size),sourceBuffers:{aFrom:i[0],aTo:getSourceBufferAttribute(n,r)},feedbackBuffers:{vCurrent:i[1]}})}update(){const t=this.transition.update();if(t){const{duration:t,easing:e}=this.settings,{time:n}=this.transition;let i=n/t;e&&(i=e(i)),this.transform.run({uniforms:{time:i}})}return t}cancel(){this.transition.cancel(),this.transform.delete();for(const t of this.buffers)t.delete();this.buffers.length=0}}const vs$9="\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";function getTransform$1(t,e){const n=getAttributeTypeFromSize(e.size);return new Transform(t,{vs:vs$9,defines:{ATTRIBUTE_TYPE:n},varyings:["vCurrent"]})}class GPUSpringTransition{constructor({gl:t,attribute:e,timeline:n}){_defineProperty(this,"gl",void 0),_defineProperty(this,"type","spring"),_defineProperty(this,"attributeInTransition",void 0),_defineProperty(this,"settings",void 0),_defineProperty(this,"attribute",void 0),_defineProperty(this,"transition",void 0),_defineProperty(this,"currentStartIndices",void 0),_defineProperty(this,"currentLength",void 0),_defineProperty(this,"texture",void 0),_defineProperty(this,"framebuffer",void 0),_defineProperty(this,"transform",void 0),_defineProperty(this,"buffers",void 0),this.gl=t,this.type="spring",this.transition=new Transition(n),this.attribute=e,this.attributeInTransition=new Attribute(t,{...e.settings,normalized:!1}),this.currentStartIndices=e.startIndices,this.currentLength=0,this.texture=getTexture(t),this.framebuffer=getFramebuffer(t,this.texture),this.transform=getTransform(t,e,this.framebuffer);const i={byteLength:0,usage:35050};this.buffers=[new Buffer(t,i),new Buffer(t,i),new Buffer(t,i)]}get inProgress(){return this.transition.inProgress}start(t,e){const{gl:n,buffers:i,attribute:r}=this,o={numInstances:e,attribute:r,fromLength:this.currentLength,fromStartIndices:this.currentStartIndices,getData:t.enter};for(const t of i)padBuffer({buffer:t,...o});this.settings=t,this.currentStartIndices=r.startIndices,this.currentLength=getAttributeBufferLength(r,e),this.attributeInTransition.setData({buffer:i[1],value:r.value}),this.transition.start({...t,duration:1/0}),this.transform.update({elementCount:Math.floor(this.currentLength/r.size),sourceBuffers:{aTo:getSourceBufferAttribute(n,r)}})}update(){const{buffers:t,transform:e,framebuffer:n,transition:i}=this;if(!i.update())return!1;const r=this.settings;e.update({sourceBuffers:{aPrev:t[0],aCur:t[1]},feedbackBuffers:{vNext:t[2]}}),e.run({framebuffer:n,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]}}),cycleBuffers(t),this.attributeInTransition.setData({buffer:t[1],value:this.attribute.value});return readPixelsToArray(n)[0]>0||i.end(),!0}cancel(){this.transition.cancel(),this.transform.delete();for(const t of this.buffers)t.delete();this.buffers.length=0,this.texture.delete(),this.framebuffer.delete()}}function getTransform(t,e,n){const i=getAttributeTypeFromSize(e.size);return new Transform(t,{framebuffer:n,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:i},varyings:["vNext"]})}function getTexture(t){return new Texture2D(t,{data:new Uint8Array(4),format:6408,type:5121,border:0,mipmaps:!1,dataFormat:6408,width:1,height:1})}function getFramebuffer(t,e){return new Framebuffer(t,{id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,attachments:{36064:e}})}const TRANSITION_TYPES$1={interpolation:GPUInterpolationTransition,spring:GPUSpringTransition};class AttributeTransitionManager{constructor(t,{id:e,timeline:n}){_defineProperty(this,"id",void 0),_defineProperty(this,"isSupported",void 0),_defineProperty(this,"gl",void 0),_defineProperty(this,"timeline",void 0),_defineProperty(this,"transitions",void 0),_defineProperty(this,"needsRedraw",void 0),_defineProperty(this,"numInstances",void 0),this.id=e,this.gl=t,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1,this.isSupported=Transform.isSupported(t)}finalize(){for(const t in this.transitions)this._removeTransition(t)}update({attributes:t,transitions:e,numInstances:n}){this.numInstances=n||1;for(const n in t){const i=t[n],r=i.getTransitionSetting(e);r&&this._updateAttribute(n,i,r)}for(const n in this.transitions){const i=t[n];i&&i.getTransitionSetting(e)||this._removeTransition(n)}}hasAttribute(t){const e=this.transitions[t];return e&&e.inProgress}getAttributes(){const t={};for(const e in this.transitions){const n=this.transitions[e];n.inProgress&&(t[e]=n.attributeInTransition)}return t}run(){if(!this.isSupported||0===this.numInstances)return!1;for(const t in this.transitions){this.transitions[t].update()&&(this.needsRedraw=!0)}const t=this.needsRedraw;return this.needsRedraw=!1,t}_removeTransition(t){this.transitions[t].cancel(),delete this.transitions[t]}_updateAttribute(t,e,n){const i=this.transitions[t];let r=!i||i.type!==n.type;if(r){if(!this.isSupported)return void log$2.warn("WebGL2 not supported by this browser. Transition for ".concat(t," is disabled."))();i&&this._removeTransition(t);const o=TRANSITION_TYPES$1[n.type];o?this.transitions[t]=new o({attribute:e,timeline:this.timeline,gl:this.gl}):(("unsupported transition type '".concat(n.type,"'"),()=>{})(),r=!1)}(r||e.needsRedraw())&&(this.needsRedraw=!0,this.transitions[t].start(n,this.numInstances))}}const TRACE_INVALIDATE="attributeManager.invalidate",TRACE_UPDATE_START="attributeManager.updateStart",TRACE_UPDATE_END="attributeManager.updateEnd",TRACE_ATTRIBUTE_UPDATE_START="attribute.updateStart",TRACE_ATTRIBUTE_ALLOCATE="attribute.allocate",TRACE_ATTRIBUTE_UPDATE_END="attribute.updateEnd";class AttributeManager{constructor(t,{id:e="attribute-manager",stats:n,timeline:i}={}){_defineProperty(this,"id",void 0),_defineProperty(this,"gl",void 0),_defineProperty(this,"attributes",void 0),_defineProperty(this,"updateTriggers",void 0),_defineProperty(this,"needsRedraw",void 0),_defineProperty(this,"userData",void 0),_defineProperty(this,"stats",void 0),_defineProperty(this,"attributeTransitionManager",void 0),_defineProperty(this,"mergeBoundsMemoized",memoize(mergeBounds)),this.id=e,this.gl=t,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new AttributeTransitionManager(t,{id:"".concat(e,"-transitions"),timeline:i}),Object.seal(this)}finalize(){for(const t in this.attributes)this.attributes[t].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(t={clearRedrawFlags:!1}){const e=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!t.clearRedrawFlags,e&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(t){this._add(t)}addInstanced(t){this._add(t,{instanced:1})}remove(t){for(const e of t)void 0!==this.attributes[e]&&(this.attributes[e].delete(),delete this.attributes[e])}invalidate(t,e){const n=this._invalidateTrigger(t,e);debug(TRACE_INVALIDATE,this,t,n)}invalidateAll(t){for(const e in this.attributes)this.attributes[e].setNeedsUpdate(e,t);debug(TRACE_INVALIDATE,this,"all")}update({data:t,numInstances:e,startIndices:n=null,transitions:i,props:r={},buffers:o={},context:s={}}){let a=!1;debug(TRACE_UPDATE_START,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const i in this.attributes){const l=this.attributes[i],c=l.settings.accessor;l.startIndices=n,l.numInstances=e,r[i]&&log$2.removed("props.".concat(i),"data.attributes.".concat(i))(),l.setExternalBuffer(o[i])||l.setBinaryValue("string"==typeof c?o[c]:void 0,t.startIndices)||"string"==typeof c&&!o[c]&&l.setConstantValue(r[c])||l.needsUpdate()&&(a=!0,this._updateAttribute({attribute:l,numInstances:e,data:t,props:r,context:s})),this.needsRedraw=this.needsRedraw||l.needsRedraw()}a&&debug(TRACE_UPDATE_END,this,e),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:e,transitions:i})}updateTransition(){const{attributeTransitionManager:t}=this,e=t.run();return this.needsRedraw=this.needsRedraw||e,e}getAttributes(){return this.attributes}getBounds(t){const e=t.map((t=>{var e;return null===(e=this.attributes[t])||void 0===e?void 0:e.getBounds()}));return this.mergeBoundsMemoized(e)}getChangedAttributes(t={clearChangedFlags:!1}){const{attributes:e,attributeTransitionManager:n}=this,i={...n.getAttributes()};for(const r in e){const o=e[r];o.needsRedraw(t)&&!n.hasAttribute(r)&&(i[r]=o)}return i}getShaderAttributes(t,e={}){t||(t=this.getAttributes());const n={};for(const i in t)e[i]||Object.assign(n,t[i].getShaderAttributes());return n}_add(t,e={}){for(const n in t){this.attributes[n]=this._createAttribute(n,t[n],e)}this._mapUpdateTriggersToAttributes()}_createAttribute(t,e,n){const i={...e,id:t,size:(e.isIndexed?1:e.size)||1,divisor:n.instanced?1:e.divisor||0};return new Attribute(this.gl,i)}_mapUpdateTriggersToAttributes(){const t={};for(const e in this.attributes){this.attributes[e].getUpdateTriggers().forEach((n=>{t[n]||(t[n]=[]),t[n].push(e)}))}this.updateTriggers=t}_invalidateTrigger(t,e){const{attributes:n,updateTriggers:i}=this,r=i[t];return r&&r.forEach((t=>{const i=n[t];i&&i.setNeedsUpdate(i.id,e)})),r}_updateAttribute(t){const{attribute:e,numInstances:n}=t;if(debug(TRACE_ATTRIBUTE_UPDATE_START,e),e.constant)return void e.setConstantValue(e.value);e.allocate(n)&&debug(TRACE_ATTRIBUTE_ALLOCATE,e,n);e.updateBuffer(t)&&(this.needsRedraw=!0,debug(TRACE_ATTRIBUTE_UPDATE_END,e,n))}}class CPUInterpolationTransition extends Transition{get value(){return this._value}_onUpdate(){const{time:t,settings:{fromValue:e,toValue:n,duration:i,easing:r}}=this,o=r(t/i);this._value=lerp$4(e,n,o)}}const EPSILON=1e-5;function updateSpringElement(t,e,n,i,r){const o=e-t;return(n-e)*r+-o*i+o+e}function updateSpring(t,e,n,i,r){if(Array.isArray(n)){const o=[];for(let s=0;s<n.length;s++)o[s]=updateSpringElement(t[s],e[s],n[s],i,r);return o}return updateSpringElement(t,e,n,i,r)}function distance(t,e){if(Array.isArray(t)){let n=0;for(let i=0;i<t.length;i++){const r=t[i]-e[i];n+=r*r}return Math.sqrt(n)}return Math.abs(t-e)}class CPUSpringTransition extends Transition{get value(){return this._currValue}_onUpdate(){const{fromValue:t,toValue:e,damping:n,stiffness:i}=this.settings,{_prevValue:r=t,_currValue:o=t}=this;let s=updateSpring(r,o,e,n,i);const a=distance(s,e),l=distance(s,o);a<EPSILON&&l<EPSILON&&(s=e,this.end()),this._prevValue=o,this._currValue=s}}const TRANSITION_TYPES={interpolation:CPUInterpolationTransition,spring:CPUSpringTransition};class UniformTransitionManager{constructor(t){this.transitions=new Map,this.timeline=t}get active(){return this.transitions.size>0}add(t,e,n,i){const{transitions:r}=this;if(r.has(t)){const n=r.get(t),{value:i=n.settings.fromValue}=n;e=i,this.remove(t)}if(!(i=normalizeTransitionSettings(i)))return;const o=TRANSITION_TYPES[i.type];if(!o)return void("unsupported transition type '".concat(i.type,"'"),()=>{})();const s=new o(this.timeline);s.start({...i,fromValue:e,toValue:n}),r.set(t,s)}remove(t){const{transitions:e}=this;e.has(t)&&(e.get(t).cancel(),e.delete(t))}update(){const t={};for(const[e,n]of this.transitions)n.update(),t[e]=n.value,n.inProgress||this.remove(e);return t}clear(){for(const t of this.transitions.keys())this.remove(t)}}function validateProps(t){const e=t[PROP_TYPES_SYMBOL];for(const n in e){const i=e[n],{validate:r}=i;if(r&&!r(t[n],i))throw new Error("Invalid prop ".concat(n,": ").concat(t[n]))}}function diffProps(t,e){const n=compareProps({newProps:t,oldProps:e,propTypes:t[PROP_TYPES_SYMBOL],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=diffDataProps(t,e);let r=!1;return i||(r=diffUpdateTriggers(t,e)),{dataChanged:i,propsChanged:n,updateTriggersChanged:r,extensionsChanged:diffExtensions(t,e),transitionsChanged:diffTransitions(t,e)}}function diffTransitions(t,e){if(!t.transitions)return!1;const n={},i=t[PROP_TYPES_SYMBOL];let r=!1;for(const o in t.transitions){const s=i[o],a=s&&s.type;("number"===a||"color"===a||"array"===a)&&comparePropValues(t[o],e[o],s)&&(n[o]=!0,r=!0)}return!!r&&n}function compareProps({newProps:t,oldProps:e,ignoreProps:n={},propTypes:i={},triggerName:r="props"}){if(e===t)return!1;if("object"!=typeof t||null===t)return"".concat(r," changed shallowly");if("object"!=typeof e||null===e)return"".concat(r," changed shallowly");for(const o of Object.keys(t))if(!(o in n)){if(!(o in e))return"".concat(r,".").concat(o," added");const n=comparePropValues(t[o],e[o],i[o]);if(n)return"".concat(r,".").concat(o," ").concat(n)}for(const o of Object.keys(e))if(!(o in n)){if(!(o in t))return"".concat(r,".").concat(o," dropped");if(!Object.hasOwnProperty.call(t,o)){const n=comparePropValues(t[o],e[o],i[o]);if(n)return"".concat(r,".").concat(o," ").concat(n)}}return!1}function comparePropValues(t,e,n){let i=n&&n.equal;return i&&!i(t,e,n)?"changed deeply":i||(i=t&&e&&t.equals,!i||i.call(t,e))?i||e===t?null:"changed shallowly":"changed deeply"}function diffDataProps(t,e){if(null===e)return"oldProps is null, initial diff";let n=!1;const{dataComparator:i,_dataDiff:r}=t;return i?i(t.data,e.data)||(n="Data comparator detected a change"):t.data!==e.data&&(n="A new data container was supplied"),n&&r&&(n=r(t.data,e.data)||n),n}function diffUpdateTriggers(t,e){if(null===e)return{all:!0};if("all"in t.updateTriggers){if(diffUpdateTrigger(t,e,"all"))return{all:!0}}const n={};let i=!1;for(const r in t.updateTriggers)if("all"!==r){diffUpdateTrigger(t,e,r)&&(n[r]=!0,i=!0)}return!!i&&n}function diffExtensions(t,e){if(null===e)return!0;const n=e.extensions,{extensions:i}=t;if(i===n)return!1;if(!n||!i)return!0;if(i.length!==n.length)return!0;for(let t=0;t<i.length;t++)if(!i[t].equals(n[t]))return!0;return!1}function diffUpdateTrigger(t,e,n){let i=t.updateTriggers[n];i=null==i?{}:i;let r=e.updateTriggers[n];r=null==r?{}:r;return compareProps({oldProps:r,newProps:i,triggerName:n})}const ERR_NOT_OBJECT="count(): argument not an object",ERR_NOT_CONTAINER="count(): argument not a container";function count(t){if(!isObject$3(t))throw new Error(ERR_NOT_OBJECT);if("function"==typeof t.count)return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(isPlainObject(t))return Object.keys(t).length;throw new Error(ERR_NOT_CONTAINER)}function isPlainObject(t){return null!==t&&"object"==typeof t&&t.constructor===Object}function isObject$3(t){return null!==t&&"object"==typeof t}function mergeShaders(t,e){if(!e)return t;const n={...t,...e};if("defines"in e&&(n.defines={...t.defines,...e.defines}),"modules"in e&&(n.modules=(t.modules||[]).concat(e.modules),e.modules.some((t=>"project64"===t.name)))){const t=n.modules.findIndex((t=>"project32"===t.name));t>=0&&n.modules.splice(t,1)}if("inject"in e)if(t.inject){const i={...t.inject};for(const t in e.inject)i[t]=(i[t]||"")+e.inject[t];n.inject=i}else n.inject=e.inject;return n}const DEFAULT_TEXTURE_PARAMETERS$1={10241:9987,10240:9729,10242:33071,10243:33071},internalTextures={};function createTexture(t,e,n,i){if(n instanceof Texture2D)return n;n.constructor&&"Object"!==n.constructor.name&&(n={data:n});let r=null;n.compressed&&(r={10241:n.data.length>1?9985:9729});const o=new Texture2D(e,{...n,parameters:{...DEFAULT_TEXTURE_PARAMETERS$1,...r,...i}});return internalTextures[o.id]=t,o}function destroyTexture(t,e){e&&e instanceof Texture2D&&internalTextures[e.id]===t&&(e.delete(),delete internalTextures[e.id])}const TYPE_DEFINITIONS={boolean:{validate:(t,e)=>!0,equal:(t,e,n)=>Boolean(t)===Boolean(e)},number:{validate:(t,e)=>Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)},color:{validate:(t,e)=>e.optional&&!t||isArray(t)&&(3===t.length||4===t.length),equal:(t,e,n)=>deepEqual(t,e,1)},accessor:{validate(t,e){const n=getTypeOf(t);return"function"===n||n===getTypeOf(e.value)},equal:(t,e,n)=>"function"==typeof e||deepEqual(t,e,1)},array:{validate:(t,e)=>e.optional&&!t||isArray(t),equal(t,e,n){const{compare:i}=n,r=Number.isInteger(i)?i:i?1:0;return i?deepEqual(t,e,r):t===e}},object:{equal(t,e,n){if(n.ignore)return!0;const{compare:i}=n,r=Number.isInteger(i)?i:i?1:0;return i?deepEqual(t,e,r):t===e}},function:{validate:(t,e)=>e.optional&&!t||"function"==typeof t,equal:(t,e,n)=>!n.compare&&!1!==n.ignore||t===e},data:{transform:(t,e,n)=>{const{dataTransform:i}=n.props;return i&&t?i(t):t}},image:{transform:(t,e,n)=>{const i=n.context;return i&&i.gl?createTexture(n.id,i.gl,t,{...e.parameters,...n.props.textureParameters}):null},release:(t,e,n)=>{destroyTexture(n.id,t)}}};function parsePropTypes(t){const e={},n={},i={};for(const[r,o]of Object.entries(t)){const t=null==o?void 0:o.deprecatedFor;if(t)i[r]=Array.isArray(t)?t:[t];else{const t=parsePropType(r,o);e[r]=t,n[r]=t.value}}return{propTypes:e,defaultProps:n,deprecatedProps:i}}function parsePropType(t,e){switch(getTypeOf(e)){case"object":return normalizePropDefinition(t,e);case"array":return normalizePropDefinition(t,{type:"array",value:e,compare:!1});case"boolean":return normalizePropDefinition(t,{type:"boolean",value:e});case"number":return normalizePropDefinition(t,{type:"number",value:e});case"function":return normalizePropDefinition(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function normalizePropDefinition(t,e){return"type"in e?{name:t,...TYPE_DEFINITIONS[e.type],...e}:"value"in e?{name:t,type:getTypeOf(e.value),...e}:{name:t,type:"object",value:e}}function isArray(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function getTypeOf(t){return isArray(t)?"array":null===t?"null":typeof t}function createProps(t,e){let n;for(let t=e.length-1;t>=0;t--){const i=e[t];"extensions"in i&&(n=i.extensions)}const i=getPropsPrototype(t.constructor,n),r=Object.create(i);r[COMPONENT_SYMBOL]=t,r[ASYNC_ORIGINAL_SYMBOL]={},r[ASYNC_RESOLVED_SYMBOL]={};for(let t=0;t<e.length;++t){const n=e[t];for(const t in n)r[t]=n[t]}return Object.freeze(r),r}const MergedDefaultPropsCacheKey="_mergedDefaultProps";function getPropsPrototype(t,e){let n=MergedDefaultPropsCacheKey;if(e)for(const t of e){const e=t.constructor;e&&(n+=":".concat(e.extensionName||e.name))}const i=getOwnProperty(t,n);return i||(t[n]=createPropsPrototypeAndTypes(t,e||[]))}function createPropsPrototypeAndTypes(t,e){if(!t.prototype)return null;const n=getPropsPrototype(Object.getPrototypeOf(t)),i=parsePropTypes(getOwnProperty(t,"defaultProps")||{}),r=Object.assign(Object.create(null),n,i.defaultProps),o=Object.assign(Object.create(null),null==n?void 0:n[PROP_TYPES_SYMBOL],i.propTypes),s=Object.assign(Object.create(null),null==n?void 0:n[DEPRECATED_PROPS_SYMBOL],i.deprecatedProps);for(const t of e){const e=getPropsPrototype(t.constructor);e&&(Object.assign(r,e),Object.assign(o,e[PROP_TYPES_SYMBOL]),Object.assign(s,e[DEPRECATED_PROPS_SYMBOL]))}return createPropsPrototype(r,t),addAsyncPropsToPropPrototype(r,o),addDeprecatedPropsToPropPrototype(r,s),r[PROP_TYPES_SYMBOL]=o,r[DEPRECATED_PROPS_SYMBOL]=s,0!==e.length||hasOwnProperty(t,"_propTypes")||(t._propTypes=o),r}function createPropsPrototype(t,e){const n=getComponentName(e);Object.defineProperties(t,{id:{writable:!0,value:n}})}function addDeprecatedPropsToPropPrototype(t,e){for(const n in e)Object.defineProperty(t,n,{enumerable:!1,set(t){const i="".concat(this.id,": ").concat(n);for(const i of e[n])hasOwnProperty(this,i)||(this[i]=t);log$2.deprecated(i,e[n].join("/"))()}})}function addAsyncPropsToPropPrototype(t,e){const n={},i={};for(const t in e){const r=e[t],{name:o,value:s}=r;r.async&&(n[o]=s,i[o]=getDescriptorForAsyncProp(o))}t[ASYNC_DEFAULTS_SYMBOL]=n,t[ASYNC_ORIGINAL_SYMBOL]={},Object.defineProperties(t,i)}function getDescriptorForAsyncProp(t){return{enumerable:!0,set(e){"string"==typeof e||e instanceof Promise||isAsyncIterable(e)?this[ASYNC_ORIGINAL_SYMBOL][t]=e:this[ASYNC_RESOLVED_SYMBOL][t]=e},get(){if(this[ASYNC_RESOLVED_SYMBOL]){if(t in this[ASYNC_RESOLVED_SYMBOL]){return this[ASYNC_RESOLVED_SYMBOL][t]||this[ASYNC_DEFAULTS_SYMBOL][t]}if(t in this[ASYNC_ORIGINAL_SYMBOL]){const e=this[COMPONENT_SYMBOL]&&this[COMPONENT_SYMBOL].internalState;if(e&&e.hasAsyncProp(t))return e.getAsyncProp(t)||this[ASYNC_DEFAULTS_SYMBOL][t]}}return this[ASYNC_DEFAULTS_SYMBOL][t]}}}function hasOwnProperty(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function getOwnProperty(t,e){return hasOwnProperty(t,e)&&t[e]}function getComponentName(t){const e=t.componentName;return e||log$2.warn("".concat(t.name,".componentName not specified"))(),e||t.name}let counter=0;class Component{constructor(...t){_defineProperty(this,"id",void 0),_defineProperty(this,"props",void 0),_defineProperty(this,"count",void 0),this.props=createProps(this,t),this.id=this.props.id,this.count=counter++}clone(t){const{props:e}=this,n={};for(const t in e[ASYNC_DEFAULTS_SYMBOL])t in e[ASYNC_RESOLVED_SYMBOL]?n[t]=e[ASYNC_RESOLVED_SYMBOL][t]:t in e[ASYNC_ORIGINAL_SYMBOL]&&(n[t]=e[ASYNC_ORIGINAL_SYMBOL][t]);return new this.constructor({...e,...n,...t})}}_defineProperty(Component,"componentName","Component"),_defineProperty(Component,"defaultProps",{});const EMPTY_PROPS=Object.freeze({});class ComponentState{constructor(t){_defineProperty(this,"component",void 0),_defineProperty(this,"onAsyncPropUpdated",void 0),_defineProperty(this,"asyncProps",void 0),_defineProperty(this,"oldProps",void 0),_defineProperty(this,"oldAsyncProps",void 0),this.component=t,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const t in this.asyncProps){const e=this.asyncProps[t];e&&e.type&&e.type.release&&e.type.release(e.resolvedValue,e.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||EMPTY_PROPS}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(t){return t in this.asyncProps}getAsyncProp(t){const e=this.asyncProps[t];return e&&e.resolvedValue}isAsyncPropLoading(t){if(t){const e=this.asyncProps[t];return Boolean(e&&e.pendingLoadCount>0&&e.pendingLoadCount!==e.resolvedLoadCount)}for(const t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(t,e){this._watchPromise(t,Promise.resolve(e))}setAsyncProps(t){this.component=t[COMPONENT_SYMBOL]||this.component;const e=t[ASYNC_RESOLVED_SYMBOL]||{},n=t[ASYNC_ORIGINAL_SYMBOL]||t,i=t[ASYNC_DEFAULTS_SYMBOL]||{};for(const t in e){const n=e[t];this._createAsyncPropData(t,i[t]),this._updateAsyncProp(t,n),e[t]=this.getAsyncProp(t)}for(const t in n){const e=n[t];this._createAsyncPropData(t,i[t]),this._updateAsyncProp(t,e)}}_fetch(t,e){return null}_onResolve(t,e){}_onError(t,e){}_updateAsyncProp(t,e){this._didAsyncInputValueChange(t,e)&&("string"==typeof e&&(e=this._fetch(t,e)),e instanceof Promise?this._watchPromise(t,e):isAsyncIterable(e)?this._resolveAsyncIterable(t,e):this._setPropValue(t,e))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const t in this.asyncProps)Object.defineProperty(this.oldAsyncProps,t,{enumerable:!0,value:this.oldProps[t]})}}_didAsyncInputValueChange(t,e){const n=this.asyncProps[t];return e!==n.resolvedValue&&e!==n.lastValue&&(n.lastValue=e,!0)}_setPropValue(t,e){this._freezeAsyncOldProps();const n=this.asyncProps[t];n&&(e=this._postProcessValue(n,e),n.resolvedValue=e,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(t,e,n){const i=this.asyncProps[t];i&&n>=i.resolvedLoadCount&&void 0!==e&&(this._freezeAsyncOldProps(),i.resolvedValue=e,i.resolvedLoadCount=n,this.onAsyncPropUpdated(t,e))}_watchPromise(t,e){const n=this.asyncProps[t];if(n){n.pendingLoadCount++;const i=n.pendingLoadCount;e.then((e=>{this.component&&(e=this._postProcessValue(n,e),this._setAsyncPropValue(t,e,i),this._onResolve(t,e))})).catch((e=>{this._onError(t,e)}))}}async _resolveAsyncIterable(t,e){if("data"!==t)return void this._setPropValue(t,e);const n=this.asyncProps[t];if(!n)return;n.pendingLoadCount++;const i=n.pendingLoadCount;let r=[],o=0;for await(const n of e){if(!this.component)return;const{dataTransform:e}=this.component.props;r=e?e(n,r):r.concat(n),Object.defineProperty(r,"__diff",{enumerable:!1,value:[{startRow:o,endRow:r.length}]}),o=r.length,this._setAsyncPropValue(t,r,i)}this._onResolve(t,r)}_postProcessValue(t,e){const n=t.type;return n&&this.component&&(n.release&&n.release(t.resolvedValue,n,this.component),n.transform)?n.transform(e,n,this.component):e}_createAsyncPropData(t,e){if(!this.asyncProps[t]){const n=this.component&&this.component.props[PROP_TYPES_SYMBOL];this.asyncProps[t]={type:n&&n[t],lastValue:null,resolvedValue:e,pendingLoadCount:0,resolvedLoadCount:0}}}}class LayerState extends ComponentState{constructor({attributeManager:t,layer:e}){super(e),_defineProperty(this,"attributeManager",void 0),_defineProperty(this,"needsRedraw",void 0),_defineProperty(this,"needsUpdate",void 0),_defineProperty(this,"subLayers",void 0),_defineProperty(this,"usesPickingColorCache",void 0),_defineProperty(this,"hasPickingBuffer",void 0),_defineProperty(this,"changeFlags",void 0),_defineProperty(this,"viewport",void 0),_defineProperty(this,"uniformTransitions",void 0),_defineProperty(this,"propsInTransition",void 0),this.attributeManager=t,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(t,e){const n=this.layer,i=null==n?void 0:n.props.fetch;return i?i(e,{propName:t,layer:n}):super._fetch(t,e)}_onResolve(t,e){const n=this.layer;if(n){const i=n.props.onDataLoad;"data"===t&&i&&i(e,{propName:t,layer:n})}}_onError(t,e){const n=this.layer;n&&n.raiseError(e,"loading ".concat(t," of ").concat(this.layer))}}const TRACE_CHANGE_FLAG="layer.changeFlag",TRACE_INITIALIZE="layer.initialize",TRACE_UPDATE="layer.update",TRACE_FINALIZE="layer.finalize",TRACE_MATCHED="layer.matched",MAX_PICKING_COLOR_CACHE_SIZE=2**24-1,EMPTY_ARRAY$1=Object.freeze([]),areViewportsEqual=memoize((({oldViewport:t,viewport:e})=>t.equals(e)));let pickingColorCache=new Uint8ClampedArray(0);const defaultProps$d={data:{type:"data",value:EMPTY_ARRAY$1,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:n,loaders:i,loadOptions:r,signal:o})=>{const{resourceManager:s}=n.context;var a;(r=r||n.getLoadOptions(),i=i||n.props.loaders,o)&&(r={...r,fetch:{...null===(a=r)||void 0===a?void 0:a.fetch,signal:o}});let l=s.contains(t);return l||r||(s.add({resourceId:t,data:load(t,i),persistent:!1}),l=!0),l?s.subscribe({resourceId:t,onChange:t=>{var i;return null===(i=n.internalState)||void 0===i?void 0:i.reloadAsyncProp(e,t)},consumerId:n.id,requestId:e}):load(t,i,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:COORDINATE_SYSTEM.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,100*-t]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class Layer extends Component{constructor(...t){super(...t),_defineProperty(this,"internalState",null),_defineProperty(this,"lifecycle",LIFECYCLE.NO_STATE),_defineProperty(this,"context",void 0),_defineProperty(this,"state",void 0),_defineProperty(this,"parent",null)}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let t=this;for(;t.parent;)t=t.parent;return t}toString(){return"".concat(this.constructor.layerName||this.constructor.name,"({id: '").concat(this.props.id,"'})")}project(t){assert$4(this.internalState);const e=this.internalState.viewport||this.context.viewport,n=getWorldPosition(t,{viewport:e,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[i,r,o]=worldToPixels(n,e.pixelProjectionMatrix);return 2===t.length?[i,r]:[i,r,o]}unproject(t){assert$4(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(t)}projectPosition(t,e){assert$4(this.internalState);return projectPosition(t,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...e})}get isComposite(){return!1}setState(t){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,t),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(t){for(const e of this.getModels())e.updateModuleSettings(t)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:t}=this.props;return t===COORDINATE_SYSTEM.DEFAULT||t===COORDINATE_SYSTEM.LNGLAT||t===COORDINATE_SYSTEM.CARTESIAN}onHover(t,e){return this.props.onHover&&this.props.onHover(t,e)||!1}onClick(t,e){return this.props.onClick&&this.props.onClick(t,e)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(t,e=[]){return e[0]=t+1&255,e[1]=t+1>>8&255,e[2]=t+1>>8>>8&255,e}decodePickingColor(t){assert$4(t instanceof Uint8Array);const[e,n,i]=t;return e+256*n+65536*i-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:count(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){var t;return null===(t=this.getAttributeManager())||void 0===t?void 0:t.getBounds(["positions","instancePositions"])}getShaders(t){for(const e of this.props.extensions)t=mergeShaders(t,e.getShaders.call(this,e));return t}shouldUpdateState(t){return t.changeFlags.propsOrDataChanged}updateState(t){const e=this.getAttributeManager(),{dataChanged:n}=t.changeFlags;if(n&&e)if(Array.isArray(n))for(const t of n)e.invalidateAll(t);else e.invalidateAll();if(e){const{props:n}=t,i=this.internalState.hasPickingBuffer,r=Number.isInteger(n.highlightedObjectIndex)||n.pickable||n.extensions.some((t=>t.getNeedsPickingBuffer.call(this,t)));if(i!==r){this.internalState.hasPickingBuffer=r;const{pickingColors:t,instancePickingColors:n}=e.attributes,i=t||n;i&&(r&&i.constant&&(i.constant=!1,e.invalidate(i.id)),i.value||r||(i.constant=!0,i.value=[0,0,0]))}}}finalizeState(t){for(const t of this.getModels())t.delete();const e=this.getAttributeManager();e&&e.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(t){for(const e of this.getModels())e.draw(t)}getPickingInfo({info:t}){const{index:e}=t;return e>=0&&Array.isArray(this.props.data)&&(t.object=this.props.data[e]),t}raiseError(t,e){var n,i,r,o;(e&&(t=new Error("".concat(e,": ").concat(t.message),{cause:t})),null!==(n=(i=this.props).onError)&&void 0!==n&&n.call(i,t))||(null===(r=this.context)||void 0===r||null===(o=r.onError)||void 0===o||o.call(r,t,this))}getNeedsRedraw(t={clearRedrawFlags:!1}){return this._getNeedsRedraw(t)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){var t;return(null===(t=this.internalState)||void 0===t?void 0:t.uniformTransitions.active)||!1}activateViewport(t){if(!this.internalState)return;const e=this.internalState.viewport;this.internalState.viewport=t,e&&areViewportsEqual({oldViewport:e,viewport:t})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(t="all"){const e=this.getAttributeManager();e&&("all"===t?e.invalidateAll():e.invalidate(t))}updateAttributes(t){for(const e of this.getModels())this._setModelAttributes(e,t)}_updateAttributes(){const t=this.getAttributeManager();if(!t)return;const e=this.props,n=this.getNumInstances(),i=this.getStartIndices();t.update({data:e.data,numInstances:n,startIndices:i,props:e,transitions:e.transitions,buffers:e.data.attributes,context:this});const r=t.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(r)}_updateAttributeTransition(){const t=this.getAttributeManager();t&&t.updateTransition()}_updateUniformTransition(){const{uniformTransitions:t}=this.internalState;if(t.active){const e=t.update(),n=Object.create(this.props);for(const t in e)Object.defineProperty(n,t,{value:e[t]});return n}return this.props}calculateInstancePickingColors(t,{numInstances:e}){if(t.constant)return;const n=Math.floor(pickingColorCache.length/3);if(this.internalState.usesPickingColorCache=!0,n<e){e>MAX_PICKING_COLOR_CACHE_SIZE&&log$2.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),pickingColorCache=defaultTypedArrayManager.allocate(pickingColorCache,e,{size:3,copy:!0,maxCount:Math.max(e,MAX_PICKING_COLOR_CACHE_SIZE)});const t=Math.floor(pickingColorCache.length/3),i=[];for(let e=n;e<t;e++)this.encodePickingColor(e,i),pickingColorCache[3*e+0]=i[0],pickingColorCache[3*e+1]=i[1],pickingColorCache[3*e+2]=i[2]}t.value=pickingColorCache.subarray(0,3*e)}_setModelAttributes(t,e){const n=this.getAttributeManager().getShaderAttributes(e,t.userData.excludeAttributes||{});t.setAttributes(n)}disablePickingIndex(t){const e=this.props.data;if(!("attributes"in e))return void this._disablePickingIndex(t);const{pickingColors:n,instancePickingColors:i}=this.getAttributeManager().attributes,r=n||i,o=r&&e.attributes&&e.attributes[r.id];if(o&&o.value){const n=o.value,i=this.encodePickingColor(t);for(let t=0;t<e.length;t++){const e=r.getVertexOffset(t);n[e]===i[0]&&n[e+1]===i[1]&&n[e+2]===i[2]&&this._disablePickingIndex(t)}}else this._disablePickingIndex(t)}_disablePickingIndex(t){const{pickingColors:e,instancePickingColors:n}=this.getAttributeManager().attributes,i=e||n;if(!i)return;const r=i.getVertexOffset(t),o=i.getVertexOffset(t+1);i.buffer.subData({data:new Uint8Array(o-r),offset:r})}restorePickingColors(){const{pickingColors:t,instancePickingColors:e}=this.getAttributeManager().attributes,n=t||e;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==pickingColorCache.buffer&&(n.value=pickingColorCache.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){assert$4(!this.internalState),assert$4(Number.isFinite(this.props.coordinateSystem)),debug(TRACE_INITIALIZE,this);const t=this._getAttributeManager();t&&t.addInstanced({instancePickingColors:{type:5121,size:3,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new LayerState({attributeManager:t,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(log$2.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),t)}),this.internalState.uniformTransitions=new UniformTransitionManager(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(t){debug(TRACE_MATCHED,this,this===t);const{state:e,internalState:n}=t;this!==t&&(this.internalState=n,this.state=e,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const t=this.needsUpdate();if(debug(TRACE_UPDATE,this,t),!t)return;const e=this.props,n=this.context,i=this.internalState,r=n.viewport,o=this._updateUniformTransition();i.propsInTransition=o,n.viewport=i.viewport||r,this.props=o;try{const t=this._getUpdateParams(),e=this.getModels();if(n.gl)this.updateState(t);else try{this.updateState(t)}catch(t){}for(const e of this.props.extensions)e.updateState.call(this,t,e);const i=this.getModels()[0]!==e[0];this._postUpdate(t,i)}finally{n.viewport=r,this.props=e,this._clearChangeFlags(),i.needsUpdate=!1,i.resetOldProps()}}_finalize(){debug(TRACE_FINALIZE,this),this.finalizeState(this.context);for(const t of this.props.extensions)t.finalizeState.call(this,this.context,t)}_drawLayer({moduleParameters:t=null,uniforms:e={},parameters:n={}}){this._updateAttributeTransition();const i=this.props,r=this.context;this.props=this.internalState.propsInTransition||i;e.opacity=Math.pow(this.props.opacity,1/2.2);try{t&&this.setModuleParameters(t);const{getPolygonOffset:i}=this.props,o=i&&i(e)||[0,0];setParameters(r.gl,{polygonOffset:o}),withParameters(r.gl,n,(()=>{const i={moduleParameters:t,uniforms:e,parameters:n,context:r};for(const t of this.props.extensions)t.draw.call(this,i,t);this.draw(i)}))}finally{this.props=i}}getChangeFlags(){var t;return null===(t=this.internalState)||void 0===t?void 0:t.changeFlags}setChangeFlags(t){if(!this.internalState)return;const{changeFlags:e}=this.internalState;for(const n in t)if(t[n]){let i=!1;if("dataChanged"===n){const r=t[n],o=e[n];r&&Array.isArray(o)&&(e.dataChanged=Array.isArray(r)?o.concat(r):r,i=!0)}e[n]||(e[n]=t[n],i=!0),i&&debug(TRACE_CHANGE_FLAG,this,n,t)}const n=Boolean(e.dataChanged||e.updateTriggersChanged||e.propsChanged||e.extensionsChanged);e.propsOrDataChanged=n,e.somethingChanged=n||e.viewportChanged||e.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(t,e){const n=diffProps(t,e);if(n.updateTriggersChanged)for(const t in n.updateTriggersChanged)n.updateTriggersChanged[t]&&this.invalidateAttribute(t);if(n.transitionsChanged)for(const r in n.transitionsChanged){var i;this.internalState.uniformTransitions.add(r,e[r],t[r],null===(i=t.transitions)||void 0===i?void 0:i[r])}return this.setChangeFlags(n)}validateProps(){validateProps(this.props)}updateAutoHighlight(t){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(t)}_updateAutoHighlight(t){const e={pickingSelectedColor:t.picked?t.color:null},{highlightColor:n}=this.props;t.picked&&"function"==typeof n&&(e.pickingHighlightColor=n(t)),this.setModuleParameters(e),this.setNeedsRedraw()}_getAttributeManager(){const t=this.context;return new AttributeManager(t.gl,{id:this.props.id,stats:t.stats,timeline:t.timeline})}_postUpdate(t,e){const{props:n,oldProps:i}=t;this.setNeedsRedraw(),this._updateAttributes();const{model:r}=this.state;null==r||r.setInstanceCount(this.getNumInstances());const{autoHighlight:o,highlightedObjectIndex:s,highlightColor:a}=n;if(e||i.autoHighlight!==o||i.highlightedObjectIndex!==s||i.highlightColor!==a){const t={};o||(t.pickingSelectedColor=null),Array.isArray(a)&&(t.pickingHighlightColor=a),(e||s!==i.highlightedObjectIndex)&&(t.pickingSelectedColor=Number.isFinite(s)&&s>=0?this.encodePickingColor(s):null),this.setModuleParameters(t)}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(t){if(!this.internalState)return!1;let e=!1;e=e||this.internalState.needsRedraw&&this.id;const n=this.getAttributeManager(),i=!!n&&n.getNeedsRedraw(t);if(e=e||i,e)for(const t of this.props.extensions)t.onNeedsRedraw.call(this,t);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!t.clearRedrawFlags,e}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}_defineProperty(Layer,"defaultProps",defaultProps$d),_defineProperty(Layer,"layerName","Layer");const TRACE_RENDER_LAYERS="compositeLayer.renderLayers";class CompositeLayer extends Layer{get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every((t=>t.isLoaded))}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(t){}setState(t){super.setState(t),this.setNeedsUpdate()}getPickingInfo({info:t}){const{object:e}=t;return e&&e.__source&&e.__source.parent&&e.__source.parent.id===this.id?(t.object=e.__source.object,t.index=e.__source.index,t):t}filterSubLayer(t){return!0}shouldRenderSubLayer(t,e){return e&&e.length}getSubLayerClass(t,e){const{_subLayerProps:n}=this.props;return n&&n[t]&&n[t].type||e}getSubLayerRow(t,e,n){return t.__source={parent:this,object:e,index:n},t}getSubLayerAccessor(t){if("function"==typeof t){const e={index:-1,data:this.props.data,target:[]};return(n,i)=>n&&n.__source?(e.index=n.__source.index,t(n.__source.object,e)):t(n,i)}return t}getSubLayerProps(t={}){var e;const{opacity:n,pickable:i,visible:r,parameters:o,getPolygonOffset:s,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:n,pickable:i,visible:r,parameters:o,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:l,highlightColor:c,coordinateSystem:u,coordinateOrigin:h,wrapLongitude:d,positionFormat:p,modelMatrix:f,extensions:m,fetch:g,operation:_},x=y&&t.id&&y[t.id],b=x&&x.updateTriggers,T=t.id||"sublayer";if(x){const e=this.props[PROP_TYPES_SYMBOL],n=t.type?t.type._propTypes:{};for(const t in x){const i=n[t]||e[t];i&&"accessor"===i.type&&(x[t]=this.getSubLayerAccessor(x[t]))}}Object.assign(v,t,x),v.id="".concat(this.props.id,"-").concat(T),v.updateTriggers={all:null===(e=this.props.updateTriggers)||void 0===e?void 0:e.all,...t.updateTriggers,...b};for(const t of m){const e=t.getSubLayerProps.call(this,t);e&&Object.assign(v,e,{updateTriggers:Object.assign(v.updateTriggers,e.updateTriggers)})}return v}_updateAutoHighlight(t){for(const e of this.getSubLayers())e.updateAutoHighlight(t)}_getAttributeManager(){return null}_postUpdate(t,e){let n=this.internalState.subLayers;const i=!n||this.needsUpdate();if(i){n=flatten$1(this.renderLayers(),Boolean),this.internalState.subLayers=n}debug(TRACE_RENDER_LAYERS,this,i,n);for(const t of n)t.parent=this}}_defineProperty(CompositeLayer,"layerName","CompositeLayer");class Tesselator{constructor(t){_defineProperty(this,"opts",void 0),_defineProperty(this,"typedArrayManager",void 0),_defineProperty(this,"indexStarts",[0]),_defineProperty(this,"vertexStarts",[0]),_defineProperty(this,"vertexCount",0),_defineProperty(this,"instanceCount",0),_defineProperty(this,"attributes",void 0),_defineProperty(this,"_attributeDefs",void 0),_defineProperty(this,"data",void 0),_defineProperty(this,"getGeometry",void 0),_defineProperty(this,"geometryBuffer",void 0),_defineProperty(this,"buffers",void 0),_defineProperty(this,"positionSize",void 0),_defineProperty(this,"normalize",void 0);const{attributes:e={}}=t;this.typedArrayManager=defaultTypedArrayManager,this.attributes={},this._attributeDefs=e,this.opts=t,this.updateGeometry(t)}updateGeometry(t){Object.assign(this.opts,t);const{data:e,buffers:n={},getGeometry:i,geometryBuffer:r,positionFormat:o,dataChanged:s,normalize:a=!0}=this.opts;if(this.data=e,this.getGeometry=i,this.positionSize=r&&r.size||("XY"===o?2:3),this.buffers=n,this.normalize=a,r&&(assert$4(e.startIndices),this.getGeometry=this.getGeometryFromBuffer(r),a||(n.positions=r)),this.geometryBuffer=n.positions,Array.isArray(s))for(const t of s)this._rebuildGeometry(t);else this._rebuildGeometry()}updatePartialGeometry({startRow:t,endRow:e}){this._rebuildGeometry({startRow:t,endRow:e})}getGeometryFromBuffer(t){const e=t.value||t;return ArrayBuffer.isView(e)?getAccessorFromBuffer(e,{size:this.positionSize,offset:t.offset,stride:t.stride,startIndices:this.data.startIndices}):null}_allocate(t,e){const{attributes:n,buffers:i,_attributeDefs:r,typedArrayManager:o}=this;for(const s in r)if(s in i)o.release(n[s]),n[s]=null;else{const i=r[s];i.copy=e,n[s]=o.allocate(n[s],t,i)}}_forEachGeometry(t,e,n){const{data:i,getGeometry:r}=this,{iterable:o,objectInfo:s}=createIterable(i,e,n);for(const e of o){s.index++;t(r?r(e,s):null,s.index)}}_rebuildGeometry(t){if(!this.data)return;let{indexStarts:e,vertexStarts:n,instanceCount:i}=this;const{data:r,geometryBuffer:o}=this,{startRow:s=0,endRow:a=1/0}=t||{},l={};if(t||(e=[0],n=[0]),this.normalize||!o)this._forEachGeometry(((t,e)=>{const i=t&&this.normalizeGeometry(t);l[e]=i,n[e+1]=n[e]+(i?this.getGeometrySize(i):0)}),s,a),i=n[n.length-1];else if(n=r.startIndices,i=n[r.length]||0,ArrayBuffer.isView(o))i=i||o.length/this.positionSize;else if(o instanceof Buffer){i=i||o.byteLength/(o.accessor.stride||4*this.positionSize)}else if(o.buffer){i=i||o.buffer.byteLength/(o.stride||4*this.positionSize)}else if(o.value){const t=o.value;i=i||t.length/(o.stride/t.BYTES_PER_ELEMENT||this.positionSize)}this._allocate(i,Boolean(t)),this.indexStarts=e,this.vertexStarts=n,this.instanceCount=i;const c={};this._forEachGeometry(((t,r)=>{const o=l[r]||t;c.vertexStart=n[r],c.indexStart=e[r];c.geometrySize=(r<n.length-1?n[r+1]:i)-n[r],c.geometryIndex=r,this.updateGeometryAttributes(o,c)}),s,a),this.vertexCount=e[e.length-1]}}var vs$8="#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$a="#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";const DEFAULT_CANVAS_WIDTH=1024,DEFAULT_BUFFER$1=4,noop=()=>{},DEFAULT_TEXTURE_PARAMETERS={10241:9987,10240:9729,10242:33071,10243:33071};function nextPowOfTwo$1(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function resizeImage(t,e,n,i){const r=Math.min(n/e.width,i/e.height),o=Math.floor(e.width*r),s=Math.floor(e.height*r);return 1===r?{data:e,width:o,height:s}:(t.canvas.height=s,t.canvas.width=o,t.clearRect(0,0,o,s),t.drawImage(e,0,0,e.width,e.height,0,0,o,s),{data:t.canvas,width:o,height:s})}function getIconId(t){return t&&(t.id||t.url)}function resizeTexture(t,e,n,i){const r=t.width,o=t.height,s=new Texture2D(t.gl,{width:e,height:n,parameters:i});return copyToTexture(t,s,{targetY:0,width:r,height:o}),t.delete(),s}function buildRowMapping(t,e,n){for(let i=0;i<e.length;i++){const{icon:r,xOffset:o}=e[i];t[getIconId(r)]={...r,x:o,y:n}}}function buildMapping$1({icons:t,buffer:e,mapping:n={},xOffset:i=0,yOffset:r=0,rowHeight:o=0,canvasWidth:s}){let a=[];for(let l=0;l<t.length;l++){const c=t[l];if(!n[getIconId(c)]){const{height:t,width:l}=c;i+l+e>s&&(buildRowMapping(n,a,r),i=0,r=o+r+e,o=0,a=[]),a.push({icon:c,xOffset:i}),i=i+l+e,o=Math.max(o,t)}}return a.length>0&&buildRowMapping(n,a,r),{mapping:n,rowHeight:o,xOffset:i,yOffset:r,canvasWidth:s,canvasHeight:nextPowOfTwo$1(o+r+e)}}function getDiffIcons(t,e,n){if(!t||!e)return null;n=n||{};const i={},{iterable:r,objectInfo:o}=createIterable(t);for(const t of r){o.index++;const r=e(t,o),s=getIconId(r);if(!r)throw new Error("Icon is missing.");if(!r.url)throw new Error("Icon url is missing.");i[s]||n[s]&&r.url===n[s].url||(i[s]={...r,source:t,sourceIndex:o.index})}return i}class IconManager{constructor(t,{onUpdate:e=noop,onError:n=noop}){_defineProperty(this,"gl",void 0),_defineProperty(this,"onUpdate",void 0),_defineProperty(this,"onError",void 0),_defineProperty(this,"_loadOptions",null),_defineProperty(this,"_texture",null),_defineProperty(this,"_externalTexture",null),_defineProperty(this,"_mapping",{}),_defineProperty(this,"_textureParameters",null),_defineProperty(this,"_pendingCount",0),_defineProperty(this,"_autoPacking",!1),_defineProperty(this,"_xOffset",0),_defineProperty(this,"_yOffset",0),_defineProperty(this,"_rowHeight",0),_defineProperty(this,"_buffer",DEFAULT_BUFFER$1),_defineProperty(this,"_canvasWidth",DEFAULT_CANVAS_WIDTH),_defineProperty(this,"_canvasHeight",0),_defineProperty(this,"_canvas",null),this.gl=t,this.onUpdate=e,this.onError=n}finalize(){var t;null===(t=this._texture)||void 0===t||t.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(t){const e=this._autoPacking?getIconId(t):t;return this._mapping[e]||{}}setProps({loadOptions:t,autoPacking:e,iconAtlas:n,iconMapping:i,textureParameters:r}){var o;(t&&(this._loadOptions=t),void 0!==e&&(this._autoPacking=e),i&&(this._mapping=i),n)&&(null===(o=this._texture)||void 0===o||o.delete(),this._texture=null,this._externalTexture=n);r&&(this._textureParameters=r)}get isLoaded(){return 0===this._pendingCount}packIcons(t,e){if(!this._autoPacking||"undefined"==typeof document)return;const n=Object.values(getDiffIcons(t,e,this._mapping)||{});if(n.length>0){const{mapping:t,xOffset:e,yOffset:i,rowHeight:r,canvasHeight:o}=buildMapping$1({icons:n,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=r,this._mapping=t,this._xOffset=e,this._yOffset=i,this._canvasHeight=o,this._texture||(this._texture=new Texture2D(this.gl,{width:this._canvasWidth,height:this._canvasHeight,parameters:this._textureParameters||DEFAULT_TEXTURE_PARAMETERS})),this._texture.height!==this._canvasHeight&&(this._texture=resizeTexture(this._texture,this._canvasWidth,this._canvasHeight,this._textureParameters||DEFAULT_TEXTURE_PARAMETERS)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(n)}}_loadIcons(t){const e=this._canvas.getContext("2d",{willReadFrequently:!0});for(const n of t)this._pendingCount++,load(n.url,this._loadOptions).then((t=>{const i=getIconId(n),r=this._mapping[i],{x:o,y:s,width:a,height:l}=r,{data:c,width:u,height:h}=resizeImage(e,t,a,l);this._texture.setSubImageData({data:c,x:o+(a-u)/2,y:s+(l-h)/2,width:u,height:h}),r.width=u,r.height=h,this._texture.generateMipmap(),this.onUpdate()})).catch((t=>{this.onError({url:n.url,source:n.source,sourceIndex:n.sourceIndex,loadOptions:this._loadOptions,error:t})})).finally((()=>{this._pendingCount--}))}}const DEFAULT_COLOR$7=[0,0,0,255],defaultProps$c={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:DEFAULT_COLOR$7},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 IconLayer extends Layer{constructor(...t){super(...t),_defineProperty(this,"state",void 0)}getShaders(){return super.getShaders({vs:vs$8,fs:fs$a,modules:[project32,picking]})}initializeState(){this.state={iconManager:new IconManager(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:DEFAULT_COLOR$7},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(t){super.updateState(t);const{props:e,oldProps:n,changeFlags:i}=t,r=this.getAttributeManager(),{iconAtlas:o,iconMapping:s,data:a,getIcon:l,textureParameters:c}=e,{iconManager:u}=this.state,h=o||this.internalState.isAsyncPropLoading("iconAtlas");if(u.setProps({loadOptions:e.loadOptions,autoPacking:!h,iconAtlas:o,iconMapping:h?s:null,textureParameters:c}),h?n.iconMapping!==e.iconMapping&&r.invalidate("getIcon"):(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getIcon))&&u.packIcons(a,l),i.extensionsChanged){var d;const{gl:t}=this.context;null===(d=this.state.model)||void 0===d||d.delete(),this.state.model=this._getModel(t),r.invalidateAll()}}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(t){super.finalizeState(t),this.state.iconManager.finalize()}draw({uniforms:t}){const{sizeScale:e,sizeMinPixels:n,sizeMaxPixels:i,sizeUnits:r,billboard:o,alphaCutoff:s}=this.props,{iconManager:a}=this.state,l=a.getTexture();l&&this.state.model.setUniforms(t).setUniforms({iconsTexture:l,iconsTextureDim:[l.width,l.height],sizeUnits:UNIT[r],sizeScale:e,sizeMinPixels:n,sizeMaxPixels:i,billboard:o,alphaCutoff:s}).draw()}_getModel(t){return new Model(t,{...this.getShaders(),id:this.props.id,geometry:new Geometry({drawMode:6,attributes:{positions:{size:2,value:new Float32Array([-1,-1,-1,1,1,1,1,-1])}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(t){var e;const n=null===(e=this.getCurrentLayer())||void 0===e?void 0:e.props.onIconError;n&&n(t)}getInstanceOffset(t){const{width:e,height:n,anchorX:i=e/2,anchorY:r=n/2}=this.state.iconManager.getIconMapping(t);return[e/2-i,n/2-r]}getInstanceColorMode(t){return this.state.iconManager.getIconMapping(t).mask?1:0}getInstanceIconFrame(t){const{x:e,y:n,width:i,height:r}=this.state.iconManager.getIconMapping(t);return[e,n,i,r]}}_defineProperty(IconLayer,"defaultProps",defaultProps$c),_defineProperty(IconLayer,"layerName","IconLayer");var vs$7="#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$9="#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";const DEFAULT_COLOR$6=[0,0,0,255],DEFAULT_NORMAL=[0,0,1],defaultProps$b={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:DEFAULT_NORMAL},getColor:{type:"accessor",value:DEFAULT_COLOR$6},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function normalizeData(t){const{header:e,attributes:n}=t;e&&n&&(t.length=e.vertexCount,n.POSITION&&(n.instancePositions=n.POSITION),n.NORMAL&&(n.instanceNormals=n.NORMAL),n.COLOR_0&&(n.instanceColors=n.COLOR_0))}class PointCloudLayer extends Layer{getShaders(){return super.getShaders({vs:vs$7,fs:fs$9,modules:[project32,gouraudLighting,picking]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:5130,fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:DEFAULT_NORMAL},instanceColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:!0,accessor:"getColor",defaultValue:DEFAULT_COLOR$6}})}updateState(t){const{changeFlags:e,props:n}=t;if(super.updateState(t),e.extensionsChanged){var i;const{gl:t}=this.context;null===(i=this.state.model)||void 0===i||i.delete(),this.state.model=this._getModel(t),this.getAttributeManager().invalidateAll()}e.dataChanged&&normalizeData(n.data)}draw({uniforms:t}){const{pointSize:e,sizeUnits:n}=this.props;this.state.model.setUniforms(t).setUniforms({sizeUnits:UNIT[n],radiusPixels:e}).draw()}_getModel(t){const e=[];for(let t=0;t<3;t++){const n=t/3*Math.PI*2;e.push(2*Math.cos(n),2*Math.sin(n),0)}return new Model(t,{...this.getShaders(),id:this.props.id,geometry:new Geometry({drawMode:4,attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}}_defineProperty(PointCloudLayer,"layerName","PointCloudLayer"),_defineProperty(PointCloudLayer,"defaultProps",defaultProps$b);var vs$6="#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$8="#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";const DEFAULT_COLOR$5=[0,0,0,255],defaultProps$a={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:DEFAULT_COLOR$5},getLineColor:{type:"accessor",value:DEFAULT_COLOR$5},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class ScatterplotLayer extends Layer{getShaders(){return super.getShaders({vs:vs$6,fs:fs$8,modules:[project32,picking]})}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(t){if(super.updateState(t),t.changeFlags.extensionsChanged){var e;const{gl:t}=this.context;null===(e=this.state.model)||void 0===e||e.delete(),this.state.model=this._getModel(t),this.getAttributeManager().invalidateAll()}}draw({uniforms:t}){const{radiusUnits:e,radiusScale:n,radiusMinPixels:i,radiusMaxPixels:r,stroked:o,filled:s,billboard:a,antialiasing:l,lineWidthUnits:c,lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:d}=this.props;this.state.model.setUniforms(t).setUniforms({stroked:o?1:0,filled:s,billboard:a,antialiasing:l,radiusUnits:UNIT[e],radiusScale:n,radiusMinPixels:i,radiusMaxPixels:r,lineWidthUnits:UNIT[c],lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:d}).draw()}_getModel(t){return new Model(t,{...this.getShaders(),id:this.props.id,geometry:new Geometry({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})}}_defineProperty(ScatterplotLayer,"defaultProps",defaultProps$a),_defineProperty(ScatterplotLayer,"layerName","ScatterplotLayer");const WINDING={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function modifyPolygonWindingDirection(t,e,n={}){return getPolygonWindingDirection(t,n)!==e&&(reversePolygon(t,n),!0)}function getPolygonWindingDirection(t,e={}){return Math.sign(getPolygonSignedArea(t,e))}function getPolygonSignedArea(t,e={}){const{start:n=0,end:i=t.length}=e,r=e.size||2;let o=0;for(let e=n,s=i-r;e<i;e+=r)o+=(t[e]-t[s])*(t[e+1]+t[s+1]),s=e;return o/2}function reversePolygon(t,e){const{start:n=0,end:i=t.length,size:r=2}=e,o=(i-n)/r,s=Math.floor(o/2);for(let e=0;e<s;++e){const i=n+e*r,s=n+(o-1-e)*r;for(let e=0;e<r;++e){const n=t[i+e];t[i+e]=t[s+e],t[s+e]=n}}}function push(t,e){const n=e.length,i=t.length;if(i>0){let r=!0;for(let o=0;o<n;o++)if(t[i-n+o]!==e[o]){r=!1;break}if(r)return!1}for(let r=0;r<n;r++)t[i+r]=e[r];return!0}function copy(t,e){const n=e.length;for(let i=0;i<n;i++)t[i]=e[i]}function getPointAtIndex(t,e,n,i,r=[]){const o=i+e*n;for(let e=0;e<n;e++)r[e]=t[o+e];return r}function intersect$1(t,e,n,i,r=[]){let o,s;if(8&n)o=(i[3]-t[1])/(e[1]-t[1]),s=3;else if(4&n)o=(i[1]-t[1])/(e[1]-t[1]),s=1;else if(2&n)o=(i[2]-t[0])/(e[0]-t[0]),s=2;else{if(!(1&n))return null;o=(i[0]-t[0])/(e[0]-t[0]),s=0}for(let n=0;n<t.length;n++)r[n]=(1&s)===n?i[s]:o*(e[n]-t[n])+t[n];return r}function bitCode(t,e){let n=0;return t[0]<e[0]?n|=1:t[0]>e[2]&&(n|=2),t[1]<e[1]?n|=4:t[1]>e[3]&&(n|=8),n}function cutPolylineByGrid(t,e){const{size:n=2,broken:i=!1,gridResolution:r=10,gridOffset:o=[0,0],startIndex:s=0,endIndex:a=t.length}=e||{},l=(a-s)/n;let c=[];const u=[c],h=getPointAtIndex(t,0,n,s);let d,p;const f=getGridCell(h,r,o,[]),m=[];push(c,h);for(let e=1;e<l;e++){for(d=getPointAtIndex(t,e,n,s,d),p=bitCode(d,f);p;){intersect$1(h,d,p,f,m);const t=bitCode(m,f);t&&(intersect$1(h,m,t,f,m),p=t),push(c,m),copy(h,m),moveToNeighborCell(f,r,p),i&&c.length>n&&(c=[],u.push(c),push(c,h)),p=bitCode(d,f)}push(c,d),copy(h,d)}return i?u:u[0]}const TYPE_INSIDE=0,TYPE_BORDER=1;function concatInPlace(t,e){for(let n=0;n<e.length;n++)t.push(e[n]);return t}function cutPolygonByGrid(t,e=null,n){if(!t.length)return[];const{size:i=2,gridResolution:r=10,gridOffset:o=[0,0],edgeTypes:s=!1}=n||{},a=[],l=[{pos:t,types:s?new Array(t.length/i).fill(TYPE_BORDER):null,holes:e||[]}],c=[[],[]];let u=[];for(;l.length;){const{pos:t,types:e,holes:n}=l.shift();getBoundingBox(t,i,n[0]||t.length,c),u=getGridCell(c[0],r,o,u);const h=bitCode(c[1],u);if(h){let r=bisectPolygon(t,e,i,0,n[0]||t.length,u,h);const o={pos:r[0].pos,types:r[0].types,holes:[]},a={pos:r[1].pos,types:r[1].types,holes:[]};l.push(o,a);for(let l=0;l<n.length;l++)r=bisectPolygon(t,e,i,n[l],n[l+1]||t.length,u,h),r[0]&&(o.holes.push(o.pos.length),o.pos=concatInPlace(o.pos,r[0].pos),s&&(o.types=concatInPlace(o.types,r[0].types))),r[1]&&(a.holes.push(a.pos.length),a.pos=concatInPlace(a.pos,r[1].pos),s&&(a.types=concatInPlace(a.types,r[1].types)))}else{const i={positions:t};s&&(i.edgeTypes=e),n.length&&(i.holeIndices=n),a.push(i)}}return a}function bisectPolygon(t,e,n,i,r,o,s){const a=(r-i)/n,l=[],c=[],u=[],h=[],d=[];let p,f,m;const g=getPointAtIndex(t,a-1,n,i);let _=Math.sign(8&s?g[1]-o[3]:g[0]-o[2]),y=e&&e[a-1],v=0,x=0;for(let r=0;r<a;r++)p=getPointAtIndex(t,r,n,i,p),f=Math.sign(8&s?p[1]-o[3]:p[0]-o[2]),m=e&&e[i/n+r],f&&_&&_!==f&&(intersect$1(g,p,s,o,d),push(l,d)&&u.push(y),push(c,d)&&h.push(y)),f<=0?(push(l,p)&&u.push(m),v-=f):u.length&&(u[u.length-1]=TYPE_INSIDE),f>=0?(push(c,p)&&h.push(m),x+=f):h.length&&(h[h.length-1]=TYPE_INSIDE),copy(g,p),_=f,y=m;return[v?{pos:l,types:e&&u}:null,x?{pos:c,types:e&&h}:null]}function getGridCell(t,e,n,i){const r=Math.floor((t[0]-n[0])/e)*e+n[0],o=Math.floor((t[1]-n[1])/e)*e+n[1];return i[0]=r,i[1]=o,i[2]=r+e,i[3]=o+e,i}function moveToNeighborCell(t,e,n){8&n?(t[1]+=e,t[3]+=e):4&n?(t[1]-=e,t[3]-=e):2&n?(t[0]+=e,t[2]+=e):1&n&&(t[0]-=e,t[2]-=e)}function getBoundingBox(t,e,n,i){let r=1/0,o=-1/0,s=1/0,a=-1/0;for(let i=0;i<n;i+=e){const e=t[i],n=t[i+1];r=e<r?e:r,o=e>o?e:o,s=n<s?n:s,a=n>a?n:a}return i[0][0]=r,i[0][1]=s,i[1][0]=o,i[1][1]=a,i}const DEFAULT_MAX_LATITUDE=85.051129;function cutPolylineByMercatorBounds(t,e){const{size:n=2,startIndex:i=0,endIndex:r=t.length,normalize:o=!0}=e,s=t.slice(i,r);wrapLongitudesForShortestPath(s,n,0,r-i);const a=cutPolylineByGrid(s,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(o)for(const t of a)shiftLongitudesIntoRange(t,n);return a}function cutPolygonByMercatorBounds(t,e=null,n){const{size:i=2,normalize:r=!0,edgeTypes:o=!1}=n;e=e||[];const s=[],a=[];let l=0,c=0;for(let r=0;r<=e.length;r++){const o=e[r]||t.length,u=c,h=findSplitIndex(t,i,l,o);for(let e=h;e<o;e++)s[c++]=t[e];for(let e=l;e<h;e++)s[c++]=t[e];wrapLongitudesForShortestPath(s,i,u,c),insertPoleVertices(s,i,u,c,null==n?void 0:n.maxLatitude),l=o,a[r]=c}a.pop();const u=cutPolygonByGrid(s,a,{size:i,gridResolution:360,gridOffset:[-180,-180],edgeTypes:o});if(r)for(const t of u)shiftLongitudesIntoRange(t.positions,i);return u}function findSplitIndex(t,e,n,i){let r=-1,o=-1;for(let s=n+1;s<i;s+=e){const e=Math.abs(t[s]);e>r&&(r=e,o=s-1)}return o}function insertPoleVertices(t,e,n,i,r=DEFAULT_MAX_LATITUDE){const o=t[n],s=t[i-e];if(Math.abs(o-s)>180){const i=getPointAtIndex(t,0,e,n);i[0]+=360*Math.round((s-o)/360),push(t,i),i[1]=Math.sign(i[1])*r,push(t,i),i[0]=o,push(t,i)}}function wrapLongitudesForShortestPath(t,e,n,i){let r,o=t[0];for(let s=n;s<i;s+=e){r=t[s];const e=r-o;(e>180||e<-180)&&(r-=360*Math.round(e/360)),t[s]=o=r}}function shiftLongitudesIntoRange(t,e){let n;const i=t.length/e;for(let r=0;r<i&&(n=t[r*e],(n+180)%360==0);r++);const r=360*-Math.round(n/360);if(0!==r)for(let n=0;n<i;n++)t[n*e]+=r}function normalizePath(t,e,n,i){let r;if(Array.isArray(t[0])){r=new Array(t.length*e);for(let n=0;n<t.length;n++)for(let i=0;i<e;i++)r[n*e+i]=t[n][i]||0}else r=t;return n?cutPolylineByGrid(r,{size:e,gridResolution:n}):i?cutPolylineByMercatorBounds(r,{size:e}):r}const START_CAP=1,END_CAP=2,INVALID=4;class PathTesselator extends Tesselator{constructor(t){super({...t,attributes:{positions:{size:3,padding:18,initialize:!0,type:t.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(t){return this.attributes[t]}getGeometryFromBuffer(t){return this.normalize?super.getGeometryFromBuffer(t):null}normalizeGeometry(t){return this.normalize?normalizePath(t,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):t}getGeometrySize(t){if(isCut$1(t)){let e=0;for(const n of t)e+=this.getGeometrySize(n);return e}const e=this.getPathLength(t);return e<2?0:this.isClosed(t)?e<3?0:e+2:e}updateGeometryAttributes(t,e){if(0!==e.geometrySize)if(t&&isCut$1(t))for(const n of t){const t=this.getGeometrySize(n);e.geometrySize=t,this.updateGeometryAttributes(n,e),e.vertexStart+=t}else this._updateSegmentTypes(t,e),this._updatePositions(t,e)}_updateSegmentTypes(t,e){const n=this.attributes.segmentTypes,i=!!t&&this.isClosed(t),{vertexStart:r,geometrySize:o}=e;n.fill(0,r,r+o),i?(n[r]=INVALID,n[r+o-2]=INVALID):(n[r]+=START_CAP,n[r+o-2]+=END_CAP),n[r+o-1]=INVALID}_updatePositions(t,e){const{positions:n}=this.attributes;if(!n||!t)return;const{vertexStart:i,geometrySize:r}=e,o=new Array(3);for(let e=i,s=0;s<r;e++,s++)this.getPointOnPath(t,s,o),n[3*e]=o[0],n[3*e+1]=o[1],n[3*e+2]=o[2]}getPathLength(t){return t.length/this.positionSize}getPointOnPath(t,e,n=[]){const{positionSize:i}=this;e*i>=t.length&&(e+=1-t.length/i);const r=e*i;return n[0]=t[r],n[1]=t[r+1],n[2]=3===i&&t[r+2]||0,n}isClosed(t){if(!this.normalize)return Boolean(this.opts.loop);const{positionSize:e}=this,n=t.length-e;return t[0]===t[n]&&t[1]===t[n+1]&&(2===e||t[2]===t[n+2])}}function isCut$1(t){return Array.isArray(t[0])}var vs$5="#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$7="#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";const DEFAULT_COLOR$4=[0,0,0,255],defaultProps$9={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:DEFAULT_COLOR$4},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},ATTRIBUTE_TRANSITION$1={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t};class PathLayer extends Layer{constructor(...t){super(...t),_defineProperty(this,"state",void 0)}getShaders(){return super.getShaders({vs:vs$5,fs:fs$7,modules:[project32,picking]})}get wrapLongitude(){return!1}initializeState(){const t=!0;this.getAttributeManager().addInstanced({positions:{size:3,vertexOffset:1,type:5130,fp64:this.use64bitPositions(),transition:ATTRIBUTE_TRANSITION$1,accessor:"getPath",update:this.calculatePositions,noAlloc:t,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:5121,update:this.calculateSegmentTypes,noAlloc:t},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:ATTRIBUTE_TRANSITION$1,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,accessor:"getColor",transition:ATTRIBUTE_TRANSITION$1,defaultValue:DEFAULT_COLOR$4},instancePickingColors:{size:3,type:5121,accessor:(t,{index:e,target:n})=>this.encodePickingColor(t&&t.__source?t.__source.index:e,n)}}),this.setState({pathTesselator:new PathTesselator({fp64:this.use64bitPositions()})})}updateState(t){super.updateState(t);const{props:e,changeFlags:n}=t,i=this.getAttributeManager();if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPath)){const{pathTesselator:t}=this.state,r=e.data.attributes||{};t.updateGeometry({data:e.data,geometryBuffer:r.getPath,buffers:r,normalize:!e._pathType,loop:"loop"===e._pathType,getGeometry:e.getPath,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:n.dataChanged}),this.setState({numInstances:t.instanceCount,startIndices:t.vertexStarts}),n.dataChanged||i.invalidateAll()}if(n.extensionsChanged){var r;const{gl:t}=this.context;null===(r=this.state.model)||void 0===r||r.delete(),this.state.model=this._getModel(t),i.invalidateAll()}}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n}=e,{data:i}=this.props;return i[0]&&i[0].__source&&(e.object=i.find((t=>t.__source.index===n))),e}disablePickingIndex(t){const{data:e}=this.props;if(e[0]&&e[0].__source)for(let n=0;n<e.length;n++)e[n].__source.index===t&&this._disablePickingIndex(n);else super.disablePickingIndex(t)}draw({uniforms:t}){const{jointRounded:e,capRounded:n,billboard:i,miterLimit:r,widthUnits:o,widthScale:s,widthMinPixels:a,widthMaxPixels:l}=this.props;this.state.model.setUniforms(t).setUniforms({jointType:Number(e),capType:Number(n),billboard:i,widthUnits:UNIT[o],widthScale:s,miterLimit:r,widthMinPixels:a,widthMaxPixels:l}).draw()}_getModel(t){return new Model(t,{...this.getShaders(),id:this.props.id,geometry:new Geometry({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(t){const{pathTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("positions")}calculateSegmentTypes(t){const{pathTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("segmentTypes")}}_defineProperty(PathLayer,"defaultProps",defaultProps$9),_defineProperty(PathLayer,"layerName","PathLayer");var earcut$1={exports:{}},hasRequiredEarcut;function requireEarcut(){if(hasRequiredEarcut)return earcut$1.exports;function t(t,n,r){r=r||2;var o,s,a,u,h,p,f,m=n&&n.length,g=m?n[0]*r:t.length,_=e(t,0,g,r,!0),y=[];if(!_||_.next===_.prev)return y;if(m&&(_=function(t,n,i,r){var o,s,a,u=[];for(o=0,s=n.length;o<s;o++)(a=e(t,n[o]*r,o<s-1?n[o+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),u.push(d(a));for(u.sort(l),o=0;o<u.length;o++)i=c(u[o],i);return i}(t,n,_,r)),t.length>80*r){o=a=t[0],s=u=t[1];for(var v=r;v<g;v+=r)(h=t[v])<o&&(o=h),(p=t[v+1])<s&&(s=p),h>a&&(a=h),p>u&&(u=p);f=0!==(f=Math.max(a-o,u-s))?32767/f:0}return i(_,y,r,o,s,f,0),y}function e(t,e,n,i,r){var o,s;if(r===w(t,e,n,i)>0)for(o=e;o<n;o+=i)s=T(o,t[o],t[o+1],s);else for(o=n-i;o>=e;o-=i)s=T(o,t[o],t[o+1],s);return s&&g(s,s.next)&&(E(s),s=s.next),s}function n(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!g(i,i.next)&&0!==m(i.prev,i,i.next))i=i.next;else{if(E(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function i(t,e,l,c,u,d,p){if(t){!p&&d&&function(t,e,n,i){var r=t;do{0===r.z&&(r.z=h(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,l,c=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ);e++);for(l=c;a>0||l>0&&i;)0!==a&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(s>1)}(r)}(t,c,u,d);for(var f,m,g=t;t.prev!==t.next;)if(f=t.prev,m=t.next,d?o(t,c,u,d):r(t))e.push(f.i/l|0),e.push(t.i/l|0),e.push(m.i/l|0),E(t),t=m.next,g=m.next;else if((t=m)===g){p?1===p?i(t=s(n(t),e,l),e,l,c,u,d,2):2===p&&a(t,e,l,c,u,d):i(n(t),e,l,c,u,d,1);break}}}function r(t){var e=t.prev,n=t,i=t.next;if(m(e,n,i)>=0)return!1;for(var r=e.x,o=n.x,s=i.x,a=e.y,l=n.y,c=i.y,u=r<o?r<s?r:s:o<s?o:s,h=a<l?a<c?a:c:l<c?l:c,d=r>o?r>s?r:s:o>s?o:s,f=a>l?a>c?a:c:l>c?l:c,g=i.next;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=f&&p(r,a,o,l,s,c,g.x,g.y)&&m(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function o(t,e,n,i){var r=t.prev,o=t,s=t.next;if(m(r,o,s)>=0)return!1;for(var a=r.x,l=o.x,c=s.x,u=r.y,d=o.y,f=s.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,_,e,n,i),b=h(y,v,e,n,i),T=t.prevZ,E=t.nextZ;T&&T.z>=x&&E&&E.z<=b;){if(T.x>=g&&T.x<=y&&T.y>=_&&T.y<=v&&T!==r&&T!==s&&p(a,u,l,d,c,f,T.x,T.y)&&m(T.prev,T,T.next)>=0)return!1;if(T=T.prevZ,E.x>=g&&E.x<=y&&E.y>=_&&E.y<=v&&E!==r&&E!==s&&p(a,u,l,d,c,f,E.x,E.y)&&m(E.prev,E,E.next)>=0)return!1;E=E.nextZ}for(;T&&T.z>=x;){if(T.x>=g&&T.x<=y&&T.y>=_&&T.y<=v&&T!==r&&T!==s&&p(a,u,l,d,c,f,T.x,T.y)&&m(T.prev,T,T.next)>=0)return!1;T=T.prevZ}for(;E&&E.z<=b;){if(E.x>=g&&E.x<=y&&E.y>=_&&E.y<=v&&E!==r&&E!==s&&p(a,u,l,d,c,f,E.x,E.y)&&m(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function s(t,e,i){var r=t;do{var o=r.prev,s=r.next.next;!g(o,s)&&_(o,r,r.next,s)&&x(o,s)&&x(s,o)&&(e.push(o.i/i|0),e.push(r.i/i|0),e.push(s.i/i|0),E(r),E(r.next),r=t=s),r=r.next}while(r!==t);return n(r)}function a(t,e,r,o,s,a){var l=t;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=n(l,l.next),u=n(u,u.next),i(l,e,r,o,s,a,0),void i(u,e,r,o,s,a,0)}c=c.next}l=l.next}while(l!==t)}function l(t,e){return t.x-e.x}function c(t,e){var i=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==e);if(!n)return null;var l,c=n,h=n.x,d=n.y,f=1/0;i=n;do{r>=i.x&&i.x>=h&&r!==i.x&&p(o<d?r:s,o,h,d,o<d?s:r,o,i.x,i.y)&&(l=Math.abs(o-i.y)/(r-i.x),x(i,t)&&(l<f||l===f&&(i.x>n.x||i.x===n.x&&u(n,i)))&&(n=i,f=l)),i=i.next}while(i!==c);return n}(t,e);if(!i)return e;var r=b(i,t);return n(r,r.next),n(i,i.next)}function u(t,e){return m(t.prev,t,e.prev)<0&&m(e.next,t,t.next)<0}function h(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function d(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function p(t,e,n,i,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(i-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function f(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&_(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(x(t,e)&&x(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(m(t.prev,t,e.prev)||m(t,e.prev,e))||g(t,e)&&m(t.prev,t,t.next)>0&&m(e.prev,e,e.next)>0)}function m(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function g(t,e){return t.x===e.x&&t.y===e.y}function _(t,e,n,i){var r=v(m(t,e,n)),o=v(m(t,e,i)),s=v(m(n,i,t)),a=v(m(n,i,e));return r!==o&&s!==a||(!(0!==r||!y(t,n,e))||(!(0!==o||!y(t,i,e))||(!(0!==s||!y(n,t,i))||!(0!==a||!y(n,e,i)))))}function y(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function v(t){return t>0?1:t<0?-1:0}function x(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function b(t,e){var n=new S(t.i,t.x,t.y),i=new S(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function T(t,e,n,i){var r=new S(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function E(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function w(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}return hasRequiredEarcut=1,earcut$1.exports=t,earcut$1.exports.default=t,t.deviation=function(t,e,n,i){var r=e&&e.length,o=Math.abs(w(t,0,r?e[0]*n:t.length,n));if(r)for(var s=0,a=e.length;s<a;s++){o-=Math.abs(w(t,e[s]*n,s<a-1?e[s+1]*n:t.length,n))}var l=0;for(s=0;s<i.length;s+=3){var c=i[s]*n,u=i[s+1]*n,h=i[s+2]*n;l+=Math.abs((t[c]-t[h])*(t[u+1]-t[c+1])-(t[c]-t[u])*(t[h+1]-t[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},t.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);r>0&&n.holes.push(i+=t[r-1].length)}return n},earcut$1.exports}var earcutExports=requireEarcut(),earcut=getDefaultExportFromCjs(earcutExports);const OUTER_POLYGON_WINDING=WINDING.CLOCKWISE,HOLE_POLYGON_WINDING=WINDING.COUNTER_CLOCKWISE,windingOptions={isClosed:!0};function validate(t){if(t=t&&t.positions||t,!Array.isArray(t)&&!ArrayBuffer.isView(t))throw new Error("invalid polygon")}function getPositions(t){return"positions"in t?t.positions:t}function getHoleIndices(t){return"holeIndices"in t?t.holeIndices:null}function isNested(t){return Array.isArray(t[0])}function isSimple(t){return t.length>=1&&t[0].length>=2&&Number.isFinite(t[0][0])}function isNestedRingClosed(t){const e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]&&e[2]===n[2]}function isFlatRingClosed(t,e,n,i){for(let r=0;r<e;r++)if(t[n+r]!==t[i-e+r])return!1;return!0}function copyNestedRing(t,e,n,i,r){let o=e;const s=n.length;for(let e=0;e<s;e++)for(let r=0;r<i;r++)t[o++]=n[e][r]||0;if(!isNestedRingClosed(n))for(let e=0;e<i;e++)t[o++]=n[0][e]||0;return windingOptions.start=e,windingOptions.end=o,windingOptions.size=i,modifyPolygonWindingDirection(t,r,windingOptions),o}function copyFlatRing(t,e,n,i,r=0,o,s){const a=(o=o||n.length)-r;if(a<=0)return e;let l=e;for(let e=0;e<a;e++)t[l++]=n[r+e];if(!isFlatRingClosed(n,i,r,o))for(let e=0;e<i;e++)t[l++]=n[r+e];return windingOptions.start=e,windingOptions.end=l,windingOptions.size=i,modifyPolygonWindingDirection(t,s,windingOptions),l}function normalize$1(t,e){validate(t);const n=[],i=[];if("positions"in t){const{positions:r,holeIndices:o}=t;if(o){let t=0;for(let s=0;s<=o.length;s++)t=copyFlatRing(n,t,r,e,o[s-1],o[s],0===s?OUTER_POLYGON_WINDING:HOLE_POLYGON_WINDING),i.push(t);return i.pop(),{positions:n,holeIndices:i}}t=r}if(!isNested(t))return copyFlatRing(n,0,t,e,0,n.length,OUTER_POLYGON_WINDING),n;if(!isSimple(t)){let r=0;for(const[o,s]of t.entries())r=copyNestedRing(n,r,s,e,0===o?OUTER_POLYGON_WINDING:HOLE_POLYGON_WINDING),i.push(r);return i.pop(),{positions:n,holeIndices:i}}return copyNestedRing(n,0,t,e,OUTER_POLYGON_WINDING),n}function getPlaneArea(t,e,n){const i=t.length/3;let r=0;for(let o=0;o<i;o++){const s=(o+1)%i;r+=t[3*o+e]*t[3*s+n],r-=t[3*s+e]*t[3*o+n]}return Math.abs(r/2)}function permutePositions(t,e,n,i){const r=t.length/3;for(let o=0;o<r;o++){const r=3*o,s=t[r+1],a=t[r+2];t[r+e]=t[r+0],t[r+n]=s,t[r+i]=a}}function getSurfaceIndices(t,e,n,i){let r=getHoleIndices(t);r&&(r=r.map((t=>t/e)));let o=getPositions(t);const s=i&&3===e;if(n){const t=o.length;o=o.slice();const i=[];for(let r=0;r<t;r+=e){i[0]=o[r],i[1]=o[r+1],s&&(i[2]=o[r+2]);const t=n(i);o[r]=t[0],o[r+1]=t[1],s&&(o[r+2]=t[2])}}if(s){const t=getPlaneArea(o,0,1),e=getPlaneArea(o,0,2),i=getPlaneArea(o,1,2);if(!t&&!e&&!i)return[];t>e&&t>i||(e>i?(n||(o=o.slice()),permutePositions(o,0,2,1)):(n||(o=o.slice()),permutePositions(o,2,0,1)))}return earcut(o,r,e)}class PolygonTesselator extends Tesselator{constructor(t){const{fp64:e,IndexType:n=Uint32Array}=t;super({...t,attributes:{positions:{size:3,type:e?Float64Array:Float32Array},vertexValid:{type:Uint8ClampedArray,size:1},indices:{type:n,size:1}}})}get(t){const{attributes:e}=this;return"indices"===t?e.indices&&e.indices.subarray(0,this.vertexCount):e[t]}updateGeometry(t){super.updateGeometry(t);const e=this.buffers.indices;if(e)this.vertexCount=(e.value||e).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(t){if(this.normalize){const e=normalize$1(t,this.positionSize);return this.opts.resolution?cutPolygonByGrid(getPositions(e),getHoleIndices(e),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?cutPolygonByMercatorBounds(getPositions(e),getHoleIndices(e),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):e}return t}getGeometrySize(t){if(isCut(t)){let e=0;for(const n of t)e+=this.getGeometrySize(n);return e}return getPositions(t).length/this.positionSize}getGeometryFromBuffer(t){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(t):null}updateGeometryAttributes(t,e){if(t&&isCut(t))for(const n of t){const t=this.getGeometrySize(n);e.geometrySize=t,this.updateGeometryAttributes(n,e),e.vertexStart+=t,e.indexStart=this.indexStarts[e.geometryIndex+1]}else this._updateIndices(t,e),this._updatePositions(t,e),this._updateVertexValid(t,e)}_updateIndices(t,{geometryIndex:e,vertexStart:n,indexStart:i}){const{attributes:r,indexStarts:o,typedArrayManager:s}=this;let a=r.indices;if(!a||!t)return;let l=i;const c=getSurfaceIndices(t,this.positionSize,this.opts.preproject,this.opts.full3d);a=s.allocate(a,i+c.length,{copy:!0});for(let t=0;t<c.length;t++)a[l++]=c[t]+n;o[e+1]=i+c.length,r.indices=a}_updatePositions(t,{vertexStart:e,geometrySize:n}){const{attributes:{positions:i},positionSize:r}=this;if(!i||!t)return;const o=getPositions(t);for(let t=e,s=0;s<n;t++,s++){const e=o[s*r+1],n=r>2?o[s*r+2]:0;i[3*t]=o[s*r],i[3*t+1]=e,i[3*t+2]=n}}_updateVertexValid(t,{vertexStart:e,geometrySize:n}){const{positionSize:i}=this,r=this.attributes.vertexValid,o=t&&getHoleIndices(t);if(t&&t.edgeTypes?r.set(t.edgeTypes,e):r.fill(1,e,e+n),o)for(let t=0;t<o.length;t++)r[e+o[t]/i-1]=0;r[e+n-1]=0}}function isCut(t){return Array.isArray(t)&&t.length>0&&!Number.isFinite(t[0])}var main="\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",vsTop="#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(main,"\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"),vsSide="#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(main,"\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"),fs$6="#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";const DEFAULT_COLOR$3=[0,0,0,255],defaultProps$8={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:DEFAULT_COLOR$3},getLineColor:{type:"accessor",value:DEFAULT_COLOR$3},material:!0},ATTRIBUTE_TRANSITION={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t};class SolidPolygonLayer extends Layer{constructor(...t){super(...t),_defineProperty(this,"state",void 0)}getShaders(t){return super.getShaders({vs:"top"===t?vsTop:vsSide,fs:fs$6,defines:{RING_WINDING_ORDER_CW:this.props._normalize||"CCW"!==this.props._windingOrder?1:0},modules:[project32,gouraudLighting,picking]})}get wrapLongitude(){return!1}initializeState(){const{gl:t,viewport:e}=this.context;let{coordinateSystem:n}=this.props;const{_full3d:i}=this.props;let r;e.isGeospatial&&n===COORDINATE_SYSTEM.DEFAULT&&(n=COORDINATE_SYSTEM.LNGLAT),n===COORDINATE_SYSTEM.LNGLAT&&(r=i?e.projectPosition.bind(e):e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new PolygonTesselator({preproject:r,fp64:this.use64bitPositions(),IndexType:!t||hasFeatures$1(t,FEATURES$1.ELEMENT_INDEX_UINT32)?Uint32Array:Uint16Array})});const o=this.getAttributeManager(),s=!0;o.remove(["instancePickingColors"]),o.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},positions:{size:3,type:5130,fp64:this.use64bitPositions(),transition:ATTRIBUTE_TRANSITION,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,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:s},elevations:{size:1,transition:ATTRIBUTE_TRANSITION,accessor:"getElevation",shaderAttributes:{elevations:{divisor:0},instanceElevations:{divisor:1}}},fillColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:ATTRIBUTE_TRANSITION,accessor:"getFillColor",defaultValue:DEFAULT_COLOR$3,shaderAttributes:{fillColors:{divisor:0},instanceFillColors:{divisor:1}}},lineColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:ATTRIBUTE_TRANSITION,accessor:"getLineColor",defaultValue:DEFAULT_COLOR$3,shaderAttributes:{lineColors:{divisor:0},instanceLineColors:{divisor:1}}},pickingColors:{size:3,type:5121,accessor:(t,{index:e,target:n})=>this.encodePickingColor(t&&t.__source?t.__source.index:e,n),shaderAttributes:{pickingColors:{divisor:0},instancePickingColors:{divisor:1}}}})}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n}=e,{data:i}=this.props;return i[0]&&i[0].__source&&(e.object=i.find((t=>t.__source.index===n))),e}disablePickingIndex(t){const{data:e}=this.props;if(e[0]&&e[0].__source)for(let n=0;n<e.length;n++)e[n].__source.index===t&&this._disablePickingIndex(n);else super.disablePickingIndex(t)}draw({uniforms:t}){const{extruded:e,filled:n,wireframe:i,elevationScale:r}=this.props,{topModel:o,sideModel:s,polygonTesselator:a}=this.state,l={...t,extruded:Boolean(e),elevationScale:r};s&&(s.setInstanceCount(a.instanceCount-1),s.setUniforms(l),i&&(s.setDrawMode(3),s.setUniforms({isWireframe:!0}).draw()),n&&(s.setDrawMode(6),s.setUniforms({isWireframe:!1}).draw())),o&&(o.setVertexCount(a.vertexCount),o.setUniforms(l).draw())}updateState(t){super.updateState(t),this.updateGeometry(t);const{props:e,oldProps:n,changeFlags:i}=t,r=this.getAttributeManager();var o;(i.extensionsChanged||e.filled!==n.filled||e.extruded!==n.extruded)&&(null===(o=this.state.models)||void 0===o||o.forEach((t=>t.delete())),this.setState(this._getModels(this.context.gl)),r.invalidateAll())}updateGeometry({props:t,changeFlags:e}){if(e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon)){const{polygonTesselator:n}=this.state,i=t.data.attributes||{};n.updateGeometry({data:t.data,normalize:t._normalize,geometryBuffer:i.getPolygon,buffers:i,getGeometry:t.getPolygon,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:e.dataChanged,full3d:t._full3d}),this.setState({numInstances:n.instanceCount,startIndices:n.vertexStarts}),e.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(t){const{id:e,filled:n,extruded:i}=this.props;let r,o;if(n){const n=this.getShaders("top");n.defines.NON_INSTANCED_MODEL=1,r=new Model(t,{...n,id:"".concat(e,"-top"),drawMode:4,attributes:{vertexPositions:new Float32Array([0,1])},uniforms:{isWireframe:!1,isSideVertex:!1},vertexCount:0,isIndexed:!0})}return i&&(o=new Model(t,{...this.getShaders("side"),id:"".concat(e,"-side"),geometry:new Geometry({drawMode:1,vertexCount:4,attributes:{vertexPositions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),instanceCount:0,isInstanced:1}),o.userData.excludeAttributes={indices:!0}),{models:[o,r].filter(Boolean),topModel:r,sideModel:o}}calculateIndices(t){const{polygonTesselator:e}=this.state;t.startIndices=e.indexStarts,t.value=e.get("indices")}calculatePositions(t){const{polygonTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("positions")}calculateVertexValid(t){t.value=this.state.polygonTesselator.get("vertexValid")}}function replaceInRange({data:t,getIndex:e,dataRange:n,replace:i}){const{startRow:r=0,endRow:o=1/0}=n,s=t.length;let a=s,l=s;for(let n=0;n<s;n++){const i=e(t[n]);if(a>n&&i>=r&&(a=n),i>=o){l=n;break}}let c=a;const u=l-a!==i.length?t.slice(l):void 0;for(let e=0;e<i.length;e++)t[c++]=i[e];if(u){for(let e=0;e<u.length;e++)t[c++]=u[e];t.length=c}return{startRow:a,endRow:a+i.length}}function binaryToFeatureForAccesor(t,e){if(!t)return null;const n="startIndices"in t?t.startIndices[e]:e;return-1!==n?getPropertiesForIndex(t,t.featureIds.value[n],n):null}function getPropertiesForIndex(t,e,n){const i={properties:{...t.properties[e]}};for(const e in t.numericProps)i.properties[e]=t.numericProps[e].value[n];return i}function calculatePickingColors(t,e){const n={points:null,lines:null,polygons:null};for(const i in n){const r=t[i].globalFeatureIds.value;n[i]=new Uint8ClampedArray(3*r.length);const o=[];for(let t=0;t<r.length;t++)e(r[t],o),n[i][3*t+0]=o[0],n[i][3*t+1]=o[1],n[i][3*t+2]=o[2]}return n}_defineProperty(SolidPolygonLayer,"defaultProps",defaultProps$8),_defineProperty(SolidPolygonLayer,"layerName","SolidPolygonLayer");var fs$5="#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";const DEFAULT_BUFFER=.75,EMPTY_ARRAY=[],defaultProps$7={getIconOffsets:{type:"accessor",value:t=>t.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}};class MultiIconLayer extends IconLayer{constructor(...t){super(...t),_defineProperty(this,"state",void 0)}getShaders(){return{...super.getShaders(),fs:fs$5}}initializeState(){super.initializeState();this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:5121,size:3,accessor:(t,{index:e,target:n})=>this.encodePickingColor(e,n)}})}updateState(t){super.updateState(t);const{props:e,oldProps:n}=t;let{outlineColor:i}=e;i!==n.outlineColor&&(i=i.map((t=>t/255)),i[3]=Number.isFinite(i[3])?i[3]:1,this.setState({outlineColor:i})),!e.sdf&&e.outlineWidth&&log$2.warn("".concat(this.id,": fontSettings.sdf is required to render outline"))()}draw(t){const{sdf:e,smoothing:n,outlineWidth:i}=this.props,{outlineColor:r}=this.state,o=i?Math.max(n,DEFAULT_BUFFER*(1-i)):-1;if(t.uniforms={...t.uniforms,sdfBuffer:DEFAULT_BUFFER,outlineBuffer:o,gamma:n,sdf:Boolean(e),outlineColor:r},super.draw(t),e&&i){const{iconManager:t}=this.state;t.getTexture()&&this.state.model.draw({uniforms:{outlineBuffer:DEFAULT_BUFFER}})}}getInstanceOffset(t){return t?Array.from(t).flatMap((t=>super.getInstanceOffset(t))):EMPTY_ARRAY}getInstanceColorMode(t){return 1}getInstanceIconFrame(t){return t?Array.from(t).flatMap((t=>super.getInstanceIconFrame(t))):EMPTY_ARRAY}}_defineProperty(MultiIconLayer,"defaultProps",defaultProps$7),_defineProperty(MultiIconLayer,"layerName","MultiIconLayer");const INF=1e20;class TinySDF{constructor({fontSize:t=24,buffer:e=3,radius:n=8,cutoff:i=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=i,this.radius=n;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:i,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(n),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(i)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);_.fill(INF,0,h),g.fill(0,0,h);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const n=y.data[4*(t*a+e)+3]/255;if(0===n)continue;const i=(t+m)*c+e+m;if(1===n)_[i]=0,g[i]=INF;else{const t=.5-n;_[i]=t>0?t*t:0,g[i]=t<0?t*t:0}}edt(_,0,0,c,u,c,this.f,this.v,this.z),edt(g,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t<h;t++){const e=Math.sqrt(_[t])-Math.sqrt(g[t]);d[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return p}}function edt(t,e,n,i,r,o,s,a,l){for(let c=e;c<e+i;c++)edt1d(t,n*o+c,o,r,s,a,l);for(let c=n;c<n+r;c++)edt1d(t,c*o+e,1,i,s,a,l)}function edt1d(t,e,n,i,r,o,s){o[0]=0,s[0]=-INF,s[1]=INF,r[0]=t[e];for(let a=1,l=0,c=0;a<i;a++){r[a]=t[e+a*n];const i=a*a;do{const t=o[l];c=(r[a]-r[t]+i-t*t)/(a-t)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=INF}for(let a=0,l=0;a<i;a++){for(;s[l+1]<a;)l++;const i=o[l],c=a-i;t[e+a*n]=r[i]+c*c}}const MISSING_CHAR_WIDTH=32,SINGLE_LINE=[];function nextPowOfTwo(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function buildMapping({characterSet:t,getFontWidth:e,fontHeight:n,buffer:i,maxCanvasWidth:r,mapping:o={},xOffset:s=0,yOffset:a=0}){let l=0,c=s;const u=n+2*i;for(const s of t)if(!o[s]){const t=e(s);c+t+2*i>r&&(c=0,l++),o[s]={x:c+i,y:a+l*u+i,width:t,height:u,layoutWidth:t,layoutHeight:n},c+=t+2*i}return{mapping:o,xOffset:c,yOffset:a+l*u,canvasHeight:nextPowOfTwo(a+(l+1)*u)}}function getTextWidth(t,e,n,i){let r=0;for(let s=e;s<n;s++){var o;r+=(null===(o=i[t[s]])||void 0===o?void 0:o.layoutWidth)||0}return r}function breakAll(t,e,n,i,r,o){let s=e,a=0;for(let l=e;l<n;l++){const e=getTextWidth(t,l,l+1,r);a+e>i&&(s<l&&o.push(l),s=l,a=0),a+=e}return a}function breakWord(t,e,n,i,r,o){let s=e,a=e,l=e,c=0;for(let u=e;u<n;u++)if(" "===t[u]?l=u+1:" "!==t[u+1]&&u+1!==n||(l=u+1),l>a){let e=getTextWidth(t,a,l,r);c+e>i&&(s<a&&(o.push(a),s=a,c=0),e>i&&(e=breakAll(t,a,l,i,r,o),s=o[o.length-1])),a=l,c+=e}return c}function autoWrapping(t,e,n,i,r=0,o){void 0===o&&(o=t.length);const s=[];return"break-all"===e?breakAll(t,r,o,n,i,s):breakWord(t,r,o,n,i,s),s}function transformRow(t,e,n,i,r,o){let s=0,a=0;for(let o=e;o<n;o++){const e=t[o],n=i[e];n?(a||(a=n.layoutHeight),r[o]=s+n.layoutWidth/2,s+=n.layoutWidth):(log$2.warn("Missing character: ".concat(e," (").concat(e.codePointAt(0),")"))(),r[o]=s,s+=MISSING_CHAR_WIDTH)}o[0]=s,o[1]=a}function transformParagraph(t,e,n,i,r){const o=Array.from(t),s=o.length,a=new Array(s),l=new Array(s),c=new Array(s),u=("break-word"===n||"break-all"===n)&&isFinite(i)&&i>0,h=[0,0],d=[0,0];let p=0,f=0,m=0;for(let t=0;t<=s;t++){const _=o[t];if("\n"!==_&&t!==s||(m=t),m>f){const t=u?autoWrapping(o,n,i,r,f,m):SINGLE_LINE;for(let n=0;n<=t.length;n++){const i=0===n?f:t[n-1],s=n<t.length?t[n]:m;transformRow(o,i,s,r,a,d);for(let t=i;t<s;t++){var g;const e=(null===(g=r[o[t]])||void 0===g?void 0:g.layoutOffsetY)||0;l[t]=p+d[1]/2+e,c[t]=d[0]}p+=d[1]*e,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}}function getTextFromBuffer({value:t,length:e,stride:n,offset:i,startIndices:r,characterSet:o}){const s=t.BYTES_PER_ELEMENT,a=n?n/s:1,l=i?i/s:0,c=r[e]||Math.ceil((t.length-l)/a),u=o&&new Set,h=new Array(e);let d=t;if(a>1||l>0){d=new(0,t.constructor)(c);for(let e=0;e<c;e++)d[e]=t[e*a+l]}for(let t=0;t<e;t++){const e=d.subarray(r[t],r[t+1]||c);h[t]=String.fromCodePoint.apply(null,e),u&&e.forEach(u.add,u)}if(u)for(const t of u)o.add(String.fromCodePoint(t));return{texts:h,characterCount:c}}class LRUCache{constructor(t=5){_defineProperty(this,"limit",void 0),_defineProperty(this,"_cache",{}),_defineProperty(this,"_order",[]),this.limit=t}get(t){const e=this._cache[t];return e&&(this._deleteOrder(t),this._appendOrder(t)),e}set(t,e){this._cache[t]?(this.delete(t),this._cache[t]=e,this._appendOrder(t)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[t]=e,this._appendOrder(t))}delete(t){this._cache[t]&&(delete this._cache[t],this._deleteOrder(t))}_deleteOrder(t){const e=this._order.indexOf(t);e>=0&&this._order.splice(e,1)}_appendOrder(t){this._order.push(t)}}function getDefaultCharacterSet(){const t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}const DEFAULT_FONT_SETTINGS={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:getDefaultCharacterSet(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},MAX_CANVAS_WIDTH=1024,BASELINE_SCALE=.9,HEIGHT_SCALE=1.2,CACHE_LIMIT=3;let cache=new LRUCache(CACHE_LIMIT);function getNewChars(t,e){let n;n="string"==typeof e?new Set(Array.from(e)):new Set(e);const i=cache.get(t);if(!i)return n;for(const t in i.mapping)n.has(t)&&n.delete(t);return n}function populateAlphaChannel(t,e){for(let n=0;n<t.length;n++)e.data[4*n+3]=t[n]}function setTextStyle(t,e,n,i){t.font="".concat(i," ").concat(n,"px ").concat(e),t.fillStyle="#000",t.textBaseline="alphabetic",t.textAlign="left"}function setFontAtlasCacheLimit(t){log$2.assert(Number.isFinite(t)&&t>=CACHE_LIMIT,"Invalid cache limit"),cache=new LRUCache(t)}class FontAtlasManager{constructor(){_defineProperty(this,"props",{...DEFAULT_FONT_SETTINGS}),_defineProperty(this,"_key",void 0),_defineProperty(this,"_atlas",void 0)}get texture(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){const{fontSize:t,buffer:e}=this.props;return(t*HEIGHT_SCALE+2*e)/t}setProps(t={}){Object.assign(this.props,t),this._key=this._getKey();const e=getNewChars(this._key,this.props.characterSet),n=cache.get(this._key);if(n&&0===e.size)return void(this._atlas!==n&&(this._atlas=n));const i=this._generateFontAtlas(e,n);this._atlas=i,cache.set(this._key,i)}_generateFontAtlas(t,e){const{fontFamily:n,fontWeight:i,fontSize:r,buffer:o,sdf:s,radius:a,cutoff:l}=this.props;let c=e&&e.data;c||(c=document.createElement("canvas"),c.width=MAX_CANVAS_WIDTH);const u=c.getContext("2d",{willReadFrequently:!0});setTextStyle(u,n,r,i);const{mapping:h,canvasHeight:d,xOffset:p,yOffset:f}=buildMapping({getFontWidth:t=>u.measureText(t).width,fontHeight:r*HEIGHT_SCALE,buffer:o,characterSet:t,maxCanvasWidth:MAX_CANVAS_WIDTH,...e&&{mapping:e.mapping,xOffset:e.xOffset,yOffset:e.yOffset}});if(c.height!==d){const t=u.getImageData(0,0,c.width,c.height);c.height=d,u.putImageData(t,0,0)}if(setTextStyle(u,n,r,i),s){const e=new TinySDF({fontSize:r,buffer:o,radius:a,cutoff:l,fontFamily:n,fontWeight:"".concat(i)});for(const n of t){const{data:t,width:i,height:o,glyphTop:s}=e.draw(n);h[n].width=i,h[n].layoutOffsetY=r*BASELINE_SCALE-s;const a=u.createImageData(i,o);populateAlphaChannel(t,a),u.putImageData(a,h[n].x,h[n].y)}}else for(const e of t)u.fillText(e,h[e].x,h[e].y+o+r*BASELINE_SCALE);return{xOffset:p,yOffset:f,mapping:h,data:c,width:c.width,height:c.height}}_getKey(){const{fontFamily:t,fontWeight:e,fontSize:n,buffer:i,sdf:r,radius:o,cutoff:s}=this.props;return r?"".concat(t," ").concat(e," ").concat(n," ").concat(i," ").concat(o," ").concat(s):"".concat(t," ").concat(e," ").concat(n," ").concat(i)}}var vs$4="#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$4="#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";const defaultProps$6={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}};class TextBackgroundLayer extends Layer{constructor(...t){super(...t),_defineProperty(this,"state",void 0)}getShaders(){return super.getShaders({vs:vs$4,fs:fs$4,modules:[project32,picking]})}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(t){super.updateState(t);const{changeFlags:e}=t;if(e.extensionsChanged){var n;const{gl:t}=this.context;null===(n=this.state.model)||void 0===n||n.delete(),this.state.model=this._getModel(t),this.getAttributeManager().invalidateAll()}}draw({uniforms:t}){const{billboard:e,sizeScale:n,sizeUnits:i,sizeMinPixels:r,sizeMaxPixels:o,getLineWidth:s}=this.props;let{padding:a}=this.props;a.length<4&&(a=[a[0],a[1],a[0],a[1]]),this.state.model.setUniforms(t).setUniforms({billboard:e,stroked:Boolean(s),padding:a,sizeUnits:UNIT[i],sizeScale:n,sizeMinPixels:r,sizeMaxPixels:o}).draw()}_getModel(t){return new Model(t,{...this.getShaders(),id:this.props.id,geometry:new Geometry({drawMode:6,vertexCount:4,attributes:{positions:{size:2,value:new Float32Array([0,0,1,0,1,1,0,1])}}}),isInstanced:!0})}}_defineProperty(TextBackgroundLayer,"defaultProps",defaultProps$6),_defineProperty(TextBackgroundLayer,"layerName","TextBackgroundLayer");const TEXT_ANCHOR={start:1,middle:0,end:-1},ALIGNMENT_BASELINE={top:1,center:0,bottom:-1},DEFAULT_COLOR$2=[0,0,0,255],DEFAULT_LINE_HEIGHT=1,defaultProps$5={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:DEFAULT_COLOR$2},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:DEFAULT_FONT_SETTINGS.characterSet},fontFamily:DEFAULT_FONT_SETTINGS.fontFamily,fontWeight:DEFAULT_FONT_SETTINGS.fontWeight,lineHeight:DEFAULT_LINE_HEIGHT,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:DEFAULT_COLOR$2},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:DEFAULT_COLOR$2},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 TextLayer extends CompositeLayer{constructor(...t){super(...t),_defineProperty(this,"state",void 0),_defineProperty(this,"getBoundingRect",((t,e)=>{let{size:[n,i]}=this.transformParagraph(t,e);const{fontSize:r}=this.state.fontAtlasManager.props;n/=r,i/=r;const{getTextAnchor:o,getAlignmentBaseline:s}=this.props;return[(TEXT_ANCHOR["function"==typeof o?o(t,e):o]-1)*n/2,(ALIGNMENT_BASELINE["function"==typeof s?s(t,e):s]-1)*i/2,n,i]})),_defineProperty(this,"getIconOffsets",((t,e)=>{const{getTextAnchor:n,getAlignmentBaseline:i}=this.props,{x:r,y:o,rowWidth:s,size:[a,l]}=this.transformParagraph(t,e),c=TEXT_ANCHOR["function"==typeof n?n(t,e):n],u=ALIGNMENT_BASELINE["function"==typeof i?i(t,e):i],h=r.length,d=new Array(2*h);let p=0;for(let t=0;t<h;t++){d[p++]=(c-1)*a/2+(1-c)*(a-s[t])/2+r[t],d[p++]=(u-1)*l/2+o[t]}return d}))}initializeState(){this.state={styleVersion:0,fontAtlasManager:new FontAtlasManager},this.props.maxWidth>0&&log$2.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(t){const{props:e,oldProps:n,changeFlags:i}=t;(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getText))&&this._updateText();(this._updateFontAtlas()||e.lineHeight!==n.lineHeight||e.wordBreak!==n.wordBreak||e.maxWidth!==n.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:t}){return t.object=t.index>=0?this.props.data[t.index]:null,t}_updateFontAtlas(){const{fontSettings:t,fontFamily:e,fontWeight:n}=this.props,{fontAtlasManager:i,characterSet:r}=this.state,o={...t,characterSet:r,fontFamily:e,fontWeight:n};if(!i.mapping)return i.setProps(o),!0;for(const t in o)if(o[t]!==i.props[t])return i.setProps(o),!0;return!1}_updateText(){var t;const{data:e,characterSet:n}=this.props,i=null===(t=e.attributes)||void 0===t?void 0:t.getText;let r,{getText:o}=this.props,s=e.startIndices;const a="auto"===n&&new Set;if(i&&s){const{texts:t,characterCount:n}=getTextFromBuffer({...ArrayBuffer.isView(i)?{value:i}:i,length:e.length,startIndices:s,characterSet:a});r=n,o=(e,{index:n})=>t[n]}else{const{iterable:t,objectInfo:n}=createIterable(e);s=[0],r=0;for(const e of t){n.index++;const t=Array.from(o(e,n)||"");a&&t.forEach(a.add,a),r+=t.length,s.push(r)}}this.setState({getText:o,startIndices:s,numInstances:r,characterSet:a||n})}transformParagraph(t,e){const{fontAtlasManager:n}=this.state,i=n.mapping,r=this.state.getText,{wordBreak:o,lineHeight:s,maxWidth:a}=this.props;return transformParagraph(r(t,e)||"",s,o,a*n.props.fontSize,i)}renderLayers(){const{startIndices:t,numInstances:e,getText:n,fontAtlasManager:{scale:i,texture:r,mapping:o},styleVersion:s}=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:T,sizeScale:E,sizeUnits:S,sizeMinPixels:w,sizeMaxPixels:A,transitions:M,updateTriggers:C}=this.props,I=this.getSubLayerClass("characters",MultiIconLayer),P=this.getSubLayerClass("background",TextBackgroundLayer);return[y&&new P({getFillColor:f,getLineColor:m,getLineWidth:g,padding:_,getPosition:c,getSize:h,getAngle:d,getPixelOffset:p,billboard:v,sizeScale:E,sizeUnits:S,sizeMinPixels:w,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:C.getPosition,getAngle:C.getAngle,getSize:C.getSize,getFillColor:C.getBackgroundColor,getLineColor:C.getBorderColor,getLineWidth:C.getBorderWidth,getPixelOffset:C.getPixelOffset,getBoundingRect:{getText:C.getText,getTextAnchor:C.getTextAnchor,getAlignmentBaseline:C.getAlignmentBaseline,styleVersion:s}}}),{data:a.attributes&&a.attributes.background?{length:a.length,attributes:a.attributes.background}:a,_dataDiff:l,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new I({sdf:x.sdf,smoothing:Number.isFinite(x.smoothing)?x.smoothing:DEFAULT_FONT_SETTINGS.smoothing,outlineWidth:b/(x.radius||DEFAULT_FONT_SETTINGS.radius),outlineColor:T,iconAtlas:r,iconMapping:o,getPosition:c,getColor:u,getSize:h,getAngle:d,getPixelOffset:p,billboard:v,sizeScale:E*i,sizeUnits:S,sizeMinPixels:w*i,sizeMaxPixels:A*i,transitions:M&&{getPosition:M.getPosition,getAngle:M.getAngle,getColor:M.getColor,getSize:M.getSize,getPixelOffset:M.getPixelOffset}},this.getSubLayerProps({id:"characters",updateTriggers:{all:C.getText,getPosition:C.getPosition,getAngle:C.getAngle,getColor:C.getColor,getSize:C.getSize,getPixelOffset:C.getPixelOffset,getIconOffsets:{getTextAnchor:C.getTextAnchor,getAlignmentBaseline:C.getAlignmentBaseline,styleVersion:s}}}),{data:a,_dataDiff:l,startIndices:t,numInstances:e,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(t){setFontAtlasCacheLimit(t)}}_defineProperty(TextLayer,"defaultProps",defaultProps$5),_defineProperty(TextLayer,"layerName","TextLayer");const POINT_LAYER={circle:{type:ScatterplotLayer,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:IconLayer,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:TextLayer,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"}}},LINE_LAYER={type:PathLayer,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},POLYGON_LAYER={type:SolidPolygonLayer,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function getDefaultProps({type:t,props:e}){const n={};for(const i in e)n[i]=t.defaultProps[e[i]];return n}function forwardProps(t,e){const{transitions:n,updateTriggers:i}=t.props,r={updateTriggers:{},transitions:n&&{getPosition:n.geometry}};for(const o in e){const s=e[o];let a=t.props[o];o.startsWith("get")&&(a=t.getSubLayerAccessor(a),r.updateTriggers[s]=i[o],n&&(r.transitions[s]=n[o])),r[s]=a}return r}function getGeojsonFeatures(t){if(Array.isArray(t))return t;switch(log$2.assert(t.type,"GeoJSON does not have type"),t.type){case"Feature":return[t];case"FeatureCollection":return log$2.assert(Array.isArray(t.features),"GeoJSON does not have features array"),t.features;default:return[{geometry:t}]}}function separateGeojsonFeatures(t,e,n={}){const i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:r=0,endRow:o=t.length}=n;for(let n=r;n<o;n++){const r=t[n],{geometry:o}=r;if(o)if("GeometryCollection"===o.type){log$2.assert(Array.isArray(o.geometries),"GeoJSON does not have geometries array");const{geometries:t}=o;for(let o=0;o<t.length;o++){separateGeometry(t[o],i,e,r,n)}}else separateGeometry(o,i,e,r,n)}return i}function separateGeometry(t,e,n,i,r){const{type:o,coordinates:s}=t,{pointFeatures:a,lineFeatures:l,polygonFeatures:c,polygonOutlineFeatures:u}=e;if(validateGeometry(o,s))switch(o){case"Point":a.push(n({geometry:t},i,r));break;case"MultiPoint":s.forEach((t=>{a.push(n({geometry:{type:"Point",coordinates:t}},i,r))}));break;case"LineString":l.push(n({geometry:t},i,r));break;case"MultiLineString":s.forEach((t=>{l.push(n({geometry:{type:"LineString",coordinates:t}},i,r))}));break;case"Polygon":c.push(n({geometry:t},i,r)),s.forEach((t=>{u.push(n({geometry:{type:"LineString",coordinates:t}},i,r))}));break;case"MultiPolygon":s.forEach((t=>{c.push(n({geometry:{type:"Polygon",coordinates:t}},i,r)),t.forEach((t=>{u.push(n({geometry:{type:"LineString",coordinates:t}},i,r))}))}))}else log$2.warn("".concat(o," coordinates are malformed"))()}const COORDINATE_NEST_LEVEL={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function validateGeometry(t,e){let n=COORDINATE_NEST_LEVEL[t];for(log$2.assert(n,"Unknown GeoJSON type ".concat(t));e&&--n>0;)e=e[0];return e&&Number.isFinite(e[0])}function createEmptyLayerProps(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function getCoordinates(t){return t.geometry.coordinates}function createLayerPropsFromFeatures(t,e){const n=createEmptyLayerProps(),{pointFeatures:i,lineFeatures:r,polygonFeatures:o,polygonOutlineFeatures:s}=t;return n.points.data=i,n.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),n.points.getPosition=getCoordinates,n.lines.data=r,n.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),n.lines.getPath=getCoordinates,n.polygons.data=o,n.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),n.polygons.getPolygon=getCoordinates,n.polygonsOutline.data=s,n.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),n.polygonsOutline.getPath=getCoordinates,n}function createLayerPropsFromBinary(t,e){const n=createEmptyLayerProps(),{points:i,lines:r,polygons:o}=t,s=calculatePickingColors(t,e);return n.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:3,value:s.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},n.lines.data={length:r.pathIndices.value.length-1,startIndices:r.pathIndices.value,attributes:{...r.attributes,getPath:r.positions,instancePickingColors:{size:3,value:s.lines}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},n.lines._pathType="open",n.polygons.data={length:o.polygonIndices.value.length-1,startIndices:o.polygonIndices.value,attributes:{...o.attributes,getPolygon:o.positions,pickingColors:{size:3,value:s.polygons}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},n.polygons._normalize=!1,o.triangles&&(n.polygons.data.attributes.indices=o.triangles.value),n.polygonsOutline.data={length:o.primitivePolygonIndices.value.length-1,startIndices:o.primitivePolygonIndices.value,attributes:{...o.attributes,getPath:o.positions,instancePickingColors:{size:3,value:s.polygons}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},n.polygonsOutline._pathType="open",n}const FEATURE_TYPES=["points","linestrings","polygons"],defaultProps$4={...getDefaultProps(POINT_LAYER.circle),...getDefaultProps(POINT_LAYER.icon),...getDefaultProps(POINT_LAYER.text),...getDefaultProps(LINE_LAYER),...getDefaultProps(POLYGON_LAYER),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};let GeoJsonLayer$1=class extends CompositeLayer{initializeState(){this.state={layerProps:{},features:{}}}updateState({props:t,changeFlags:e}){if(!e.dataChanged)return;const{data:n}=this.props,i=n&&"points"in n&&"polygons"in n&&"lines"in n;this.setState({binary:i}),i?this._updateStateBinary({props:t,changeFlags:e}):this._updateStateJSON({props:t,changeFlags:e})}_updateStateBinary({props:t}){const e=createLayerPropsFromBinary(t.data,this.encodePickingColor);this.setState({layerProps:e})}_updateStateJSON({props:t,changeFlags:e}){const n=getGeojsonFeatures(t.data),i=this.getSubLayerRow.bind(this);let r={};const o={};if(Array.isArray(e.dataChanged)){const t=this.state.features;for(const e in t)r[e]=t[e].slice(),o[e]=[];for(const s of e.dataChanged){const e=separateGeojsonFeatures(n,i,s);for(const n in t)o[n].push(replaceInRange({data:r[n],getIndex:t=>t.__source.index,dataRange:s,replace:e[n]}))}}else r=separateGeojsonFeatures(n,i);const s=createLayerPropsFromFeatures(r,o);this.setState({features:r,featuresDiff:o,layerProps:s})}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n,sourceLayer:i}=e;return e.featureType=FEATURE_TYPES.find((t=>i.id.startsWith("".concat(this.id,"-").concat(t,"-")))),n>=0&&i.id.startsWith("".concat(this.id,"-points-text"))&&this.state.binary&&(e.index=this.props.data.points.globalFeatureIds.value[n]),e}_updateAutoHighlight(t){const e="".concat(this.id,"-points-"),n="points"===t.featureType;for(const i of this.getSubLayers())i.id.startsWith(e)===n&&i.updateAutoHighlight(t)}_renderPolygonLayer(){const{extruded:t,wireframe:e}=this.props,{layerProps:n}=this.state,i="polygons-fill",r=this.shouldRenderSubLayer(i,n.polygons.data)&&this.getSubLayerClass(i,POLYGON_LAYER.type);if(r){const o=forwardProps(this,POLYGON_LAYER.props),s=t&&e;return s||delete o.getLineColor,o.updateTriggers.lineColors=s,new r(o,this.getSubLayerProps({id:i,updateTriggers:o.updateTriggers}),n.polygons)}return null}_renderLineLayers(){const{extruded:t,stroked:e}=this.props,{layerProps:n}=this.state,i="polygons-stroke",r="linestrings",o=!t&&e&&this.shouldRenderSubLayer(i,n.polygonsOutline.data)&&this.getSubLayerClass(i,LINE_LAYER.type),s=this.shouldRenderSubLayer(r,n.lines.data)&&this.getSubLayerClass(r,LINE_LAYER.type);if(o||s){const t=forwardProps(this,LINE_LAYER.props);return[o&&new o(t,this.getSubLayerProps({id:i,updateTriggers:t.updateTriggers}),n.polygonsOutline),s&&new s(t,this.getSubLayerProps({id:r,updateTriggers:t.updateTriggers}),n.lines)]}return null}_renderPointLayers(){const{pointType:t}=this.props,{layerProps:e,binary:n}=this.state;let{highlightedObjectIndex:i}=this.props;!n&&Number.isFinite(i)&&(i=e.points.data.findIndex((t=>t.__source.index===i)));const r=new Set(t.split("+")),o=[];for(const t of r){const r="points-".concat(t),s=POINT_LAYER[t],a=s&&this.shouldRenderSubLayer(r,e.points.data)&&this.getSubLayerClass(r,s.type);if(a){const l=forwardProps(this,s.props);let c=e.points;if("text"===t&&n){const{instancePickingColors:t,...e}=c.data.attributes;c={...c,data:{...c.data,attributes:e}}}o.push(new a(l,this.getSubLayerProps({id:r,updateTriggers:l.updateTriggers,highlightedObjectIndex:i}),c))}}return o}renderLayers(){const{extruded:t}=this.props,e=this._renderPolygonLayer();return[!t&&e,this._renderLineLayers(),this._renderPointLayers(),t&&e]}getSubLayerAccessor(t){const{binary:e}=this.state;return e&&"function"==typeof t?(e,n)=>{const{data:i,index:r}=n,o=binaryToFeatureForAccesor(i,r);return t(o,n)}:super.getSubLayerAccessor(t)}};_defineProperty(GeoJsonLayer$1,"layerName","GeoJsonLayer"),_defineProperty(GeoJsonLayer$1,"defaultProps",defaultProps$4);const TILE_SIZE=512,DEGREES_TO_RADIANS=Math.PI/180;function getDeckInstance({map:t,gl:e,deck:n}){if(t.__deck)return t.__deck;const i=null==n?void 0:n.props._customRender,r=null==n?void 0:n.props.onLoad,o=getInterleavedProps({...null==n?void 0:n.props,_customRender:()=>{t.triggerRepaint(),null==i||i("")}});let s;return n&&n.props.gl!==e||(Object.assign(o,{gl:e,width:null,height:null,touchAction:"unset",viewState:getViewState(t)}),null!=n&&n.isInitialized?watchMapMove(n,t):o.onLoad=()=>{null==r||r(),watchMapMove(s,t)}),n?(s=n,n.setProps(o),n.userData.isExternal=!0):(s=new Deck(o),t.on("remove",(()=>{removeDeckInstance(t)}))),s.userData.mapboxLayers=new Set,t.__deck=s,t.on("render",(()=>{s.isInitialized&&afterRender(s,t)})),s}function watchMapMove(t,e){const n=()=>{t.isInitialized?onMapMove(t,e):e.off("move",n)};e.on("move",n)}function removeDeckInstance(t){var e;null===(e=t.__deck)||void 0===e||e.finalize(),t.__deck=null}function getInterleavedProps(t){return{...t,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...t.parameters},views:t.views||[new MapView({id:"mapbox"})]}}function addLayer(t,e){t.userData.mapboxLayers.add(e),updateLayers(t)}function removeLayer(t,e){t.userData.mapboxLayers.delete(e),updateLayers(t)}function updateLayer(t,e){updateLayers(t)}function drawLayer(t,e,n){let{currentViewport:i}=t.userData,r=!1;i||(i=getViewport(t,e,!0),t.userData.currentViewport=i,r=!0),t.isInitialized&&t._drawLayers("mapbox-repaint",{viewports:[i],layerFilter:({layer:t})=>n.id===t.id||t.props.operation.includes("terrain"),clearStack:r,clearCanvas:!1})}function getViewState(t){var e;const{lng:n,lat:i}=t.getCenter(),r={longitude:(n+540)%360-180,latitude:i,zoom:t.getZoom(),bearing:t.getBearing(),pitch:t.getPitch(),padding:t.getPadding(),repeat:t.getRenderWorldCopies()};return null!==(e=t.getTerrain)&&void 0!==e&&e.call(t)&&centerCameraOnTerrain(t,r),r}function centerCameraOnTerrain(t,e){if(t.getFreeCameraOptions){const{position:n}=t.getFreeCameraOptions();if(!n||void 0===n.z)return;const i=t.transform.height,{longitude:r,latitude:o,pitch:s}=e,a=n.x*TILE_SIZE,l=(1-n.y)*TILE_SIZE,c=n.z*TILE_SIZE,u=lngLatToWorld([r,o]),h=a-u[0],d=l-u[1],p=Math.sqrt(h*h+d*d),f=s*DEGREES_TO_RADIANS,m=1.5*i,g=f<.001?m*Math.cos(f)/c:m*Math.sin(f)/p;e.zoom=Math.log2(g);const _=m*Math.cos(f)/g;e.position=[0,0,(c-_)/unitsPerMeter(o)]}else"number"==typeof t.transform.elevation&&(e.position=[0,0,t.transform.elevation])}function getViewport(t,e,n=!0){return new WebMercatorViewport({id:"mapbox",x:0,y:0,width:t.width,height:t.height,...getViewState(e),nearZMultiplier:n?.02:.1,nearZ:e.transform._nearZ/e.transform.height,farZ:e.transform._farZ/e.transform.height})}function afterRender(t,e){const{mapboxLayers:n,isExternal:i}=t.userData;if(i){const i=Array.from(n,(t=>t.id)),r=flatten$1(t.props.layers,Boolean).some((t=>t&&!i.includes(t.id)));let o=t.getViewports();const s=o.findIndex((t=>"mapbox"===t.id));(r||(o.length>1||s<0))&&(s>=0&&(o=o.slice(),o[s]=getViewport(t,e,!1)),t._drawLayers("mapbox-repaint",{viewports:o,layerFilter:e=>(!t.props.layerFilter||t.props.layerFilter(e))&&("mapbox"!==e.viewport.id||!i.includes(e.layer.id)),clearCanvas:!1}))}t.userData.currentViewport=null}function onMapMove(t,e){t.setProps({viewState:getViewState(e)}),t.needsRedraw({clearRedrawFlags:!0})}function updateLayers(t){if(t.userData.isExternal)return;const e=[];t.userData.mapboxLayers.forEach((t=>{const n=new(0,t.props.type)(t.props);e.push(n)})),t.setProps({layers:e})}class MapboxLayer{constructor(t){if(_defineProperty(this,"id",void 0),_defineProperty(this,"type",void 0),_defineProperty(this,"renderingMode",void 0),_defineProperty(this,"map",void 0),_defineProperty(this,"deck",void 0),_defineProperty(this,"props",void 0),!t.id)throw new Error("Layer must have an unique id");this.id=t.id,this.type="custom",this.renderingMode=t.renderingMode||"3d",this.map=null,this.deck=null,this.props=t}onAdd(t,e){this.map=t,this.deck=getDeckInstance({map:t,gl:e,deck:this.props.deck}),addLayer(this.deck,this)}onRemove(){this.deck&&removeLayer(this.deck,this)}setProps(t){Object.assign(this.props,t,{id:this.id}),this.deck&&updateLayer(this.deck)}render(){drawLayer(this.deck,this.map,this)}}class GeoJsonLayer{constructor(t){this.implementation=t}onAdd(t,e){const n=this.implementation,i=n.id,r=Object.assign({},n,{type:GeoJsonLayer$1}),o=t.map;this.map=t,delete r.minzoom,delete r.maxzoom,delete r.metadata,o.addLayer(new MapboxLayer(r),e||"poi"),o.setLayerZoomRange(i,n.minzoom,n.maxzoom),o.getLayer(i).metadata=n.metadata}}
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */const REVISION="172",MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},CullFaceNone=0,CullFaceBack=1,CullFaceFront=2,CullFaceFrontBack=3,BasicShadowMap=0,PCFShadowMap=1,PCFSoftShadowMap=2,VSMShadowMap=3,FrontSide=0,BackSide=1,DoubleSide=2,NoBlending=0,NormalBlending=1,AdditiveBlending=2,SubtractiveBlending=3,MultiplyBlending=4,CustomBlending=5,AddEquation=100,SubtractEquation=101,ReverseSubtractEquation=102,MinEquation=103,MaxEquation=104,ZeroFactor=200,OneFactor=201,SrcColorFactor=202,OneMinusSrcColorFactor=203,SrcAlphaFactor=204,OneMinusSrcAlphaFactor=205,DstAlphaFactor=206,OneMinusDstAlphaFactor=207,DstColorFactor=208,OneMinusDstColorFactor=209,SrcAlphaSaturateFactor=210,ConstantColorFactor=211,OneMinusConstantColorFactor=212,ConstantAlphaFactor=213,OneMinusConstantAlphaFactor=214,NeverDepth=0,AlwaysDepth=1,LessDepth=2,LessEqualDepth=3,EqualDepth=4,GreaterEqualDepth=5,GreaterDepth=6,NotEqualDepth=7,MultiplyOperation=0,MixOperation=1,AddOperation=2,NoToneMapping=0,LinearToneMapping=1,ReinhardToneMapping=2,CineonToneMapping=3,ACESFilmicToneMapping=4,CustomToneMapping=5,AgXToneMapping=6,NeutralToneMapping=7,AttachedBindMode="attached",DetachedBindMode="detached",UVMapping=300,CubeReflectionMapping=301,CubeRefractionMapping=302,EquirectangularReflectionMapping=303,EquirectangularRefractionMapping=304,CubeUVReflectionMapping=306,RepeatWrapping=1e3,ClampToEdgeWrapping=1001,MirroredRepeatWrapping=1002,NearestFilter=1003,NearestMipmapNearestFilter=1004,NearestMipMapNearestFilter=1004,NearestMipmapLinearFilter=1005,NearestMipMapLinearFilter=1005,LinearFilter=1006,LinearMipmapNearestFilter=1007,LinearMipMapNearestFilter=1007,LinearMipmapLinearFilter=1008,LinearMipMapLinearFilter=1008,UnsignedByteType=1009,ByteType=1010,ShortType=1011,UnsignedShortType=1012,IntType=1013,UnsignedIntType=1014,FloatType=1015,HalfFloatType=1016,UnsignedShort4444Type=1017,UnsignedShort5551Type=1018,UnsignedInt248Type=1020,UnsignedInt5999Type=35902,AlphaFormat=1021,RGBFormat=1022,RGBAFormat=1023,LuminanceFormat=1024,LuminanceAlphaFormat=1025,DepthFormat=1026,DepthStencilFormat=1027,RedFormat=1028,RedIntegerFormat=1029,RGFormat=1030,RGIntegerFormat=1031,RGBIntegerFormat=1032,RGBAIntegerFormat=1033,RGB_S3TC_DXT1_Format=33776,RGBA_S3TC_DXT1_Format=33777,RGBA_S3TC_DXT3_Format=33778,RGBA_S3TC_DXT5_Format=33779,RGB_PVRTC_4BPPV1_Format=35840,RGB_PVRTC_2BPPV1_Format=35841,RGBA_PVRTC_4BPPV1_Format=35842,RGBA_PVRTC_2BPPV1_Format=35843,RGB_ETC1_Format=36196,RGB_ETC2_Format=37492,RGBA_ETC2_EAC_Format=37496,RGBA_ASTC_4x4_Format=37808,RGBA_ASTC_5x4_Format=37809,RGBA_ASTC_5x5_Format=37810,RGBA_ASTC_6x5_Format=37811,RGBA_ASTC_6x6_Format=37812,RGBA_ASTC_8x5_Format=37813,RGBA_ASTC_8x6_Format=37814,RGBA_ASTC_8x8_Format=37815,RGBA_ASTC_10x5_Format=37816,RGBA_ASTC_10x6_Format=37817,RGBA_ASTC_10x8_Format=37818,RGBA_ASTC_10x10_Format=37819,RGBA_ASTC_12x10_Format=37820,RGBA_ASTC_12x12_Format=37821,RGBA_BPTC_Format=36492,RGB_BPTC_SIGNED_Format=36494,RGB_BPTC_UNSIGNED_Format=36495,RED_RGTC1_Format=36283,SIGNED_RED_RGTC1_Format=36284,RED_GREEN_RGTC2_Format=36285,SIGNED_RED_GREEN_RGTC2_Format=36286,LoopOnce=2200,LoopRepeat=2201,LoopPingPong=2202,InterpolateDiscrete=2300,InterpolateLinear=2301,InterpolateSmooth=2302,ZeroCurvatureEnding=2400,ZeroSlopeEnding=2401,WrapAroundEnding=2402,NormalAnimationBlendMode=2500,AdditiveAnimationBlendMode=2501,TrianglesDrawMode=0,TriangleStripDrawMode=1,TriangleFanDrawMode=2,BasicDepthPacking=3200,RGBADepthPacking=3201,RGBDepthPacking=3202,RGDepthPacking=3203,TangentSpaceNormalMap=0,ObjectSpaceNormalMap=1,NoColorSpace="",SRGBColorSpace="srgb",LinearSRGBColorSpace="srgb-linear",LinearTransfer="linear",SRGBTransfer="srgb",ZeroStencilOp=0,KeepStencilOp=7680,ReplaceStencilOp=7681,IncrementStencilOp=7682,DecrementStencilOp=7683,IncrementWrapStencilOp=34055,DecrementWrapStencilOp=34056,InvertStencilOp=5386,NeverStencilFunc=512,LessStencilFunc=513,EqualStencilFunc=514,LessEqualStencilFunc=515,GreaterStencilFunc=516,NotEqualStencilFunc=517,GreaterEqualStencilFunc=518,AlwaysStencilFunc=519,NeverCompare=512,LessCompare=513,EqualCompare=514,LessEqualCompare=515,GreaterCompare=516,NotEqualCompare=517,GreaterEqualCompare=518,AlwaysCompare=519,StaticDrawUsage=35044,DynamicDrawUsage=35048,StreamDrawUsage=35040,StaticReadUsage=35045,DynamicReadUsage=35049,StreamReadUsage=35041,StaticCopyUsage=35046,DynamicCopyUsage=35050,StreamCopyUsage=35042,GLSL1="100",GLSL3="300 es",WebGLCoordinateSystem=2e3,WebGPUCoordinateSystem=2001;class EventDispatcher{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}}const _lut=["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 _seed=1234567;const DEG2RAD=Math.PI/180,RAD2DEG=180/Math.PI;function generateUUID$1(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(_lut[255&t]+_lut[t>>8&255]+_lut[t>>16&255]+_lut[t>>24&255]+"-"+_lut[255&e]+_lut[e>>8&255]+"-"+_lut[e>>16&15|64]+_lut[e>>24&255]+"-"+_lut[63&n|128]+_lut[n>>8&255]+"-"+_lut[n>>16&255]+_lut[n>>24&255]+_lut[255&i]+_lut[i>>8&255]+_lut[i>>16&255]+_lut[i>>24&255]).toLowerCase()}function clamp(t,e,n){return Math.max(e,Math.min(n,t))}function euclideanModulo(t,e){return(t%e+e)%e}function mapLinear(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)}function inverseLerp(t,e,n){return t!==e?(n-t)/(e-t):0}function lerp(t,e,n){return(1-n)*t+n*e}function damp(t,e,n,i){return lerp(t,e,1-Math.exp(-n*i))}function pingpong(t,e=1){return e-Math.abs(euclideanModulo(t,2*e)-e)}function smoothstep(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)}function smootherstep(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)}function randInt(t,e){return t+Math.floor(Math.random()*(e-t+1))}function randFloat(t,e){return t+Math.random()*(e-t)}function randFloatSpread(t){return t*(.5-Math.random())}function seededRandom(t){void 0!==t&&(_seed=t);let e=_seed+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}function degToRad(t){return t*DEG2RAD}function radToDeg(t){return t*RAD2DEG}function isPowerOfTwo(t){return!(t&t-1)&&0!==t}function ceilPowerOfTwo(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function floorPowerOfTwo(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function setQuaternionFromProperEuler(t,e,n,i,r){const o=Math.cos,s=Math.sin,a=o(n/2),l=s(n/2),c=o((e+i)/2),u=s((e+i)/2),h=o((e-i)/2),d=s((e-i)/2),p=o((i-e)/2),f=s((i-e)/2);switch(r){case"XYX":t.set(a*u,l*h,l*d,a*c);break;case"YZY":t.set(l*d,a*u,l*h,a*c);break;case"ZXZ":t.set(l*h,l*d,a*u,a*c);break;case"XZX":t.set(a*u,l*f,l*p,a*c);break;case"YXY":t.set(l*p,a*u,l*f,a*c);break;case"ZYZ":t.set(l*f,l*p,a*u,a*c)}}function denormalize(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function normalize(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const MathUtils={DEG2RAD:DEG2RAD,RAD2DEG:RAD2DEG,generateUUID:generateUUID$1,clamp:clamp,euclideanModulo:euclideanModulo,mapLinear:mapLinear,inverseLerp:inverseLerp,lerp:lerp,damp:damp,pingpong:pingpong,smoothstep:smoothstep,smootherstep:smootherstep,randInt:randInt,randFloat:randFloat,randFloatSpread:randFloatSpread,seededRandom:seededRandom,degToRad:degToRad,radToDeg:radToDeg,isPowerOfTwo:isPowerOfTwo,ceilPowerOfTwo:ceilPowerOfTwo,floorPowerOfTwo:floorPowerOfTwo,setQuaternionFromProperEuler:setQuaternionFromProperEuler,normalize:normalize,denormalize:denormalize};class Vector2{constructor(t=0,e=0){Vector2.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=clamp(this.x,t.x,e.x),this.y=clamp(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=clamp(this.x,t,e),this.y=clamp(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(clamp(n,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(clamp(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*i+t.x,this.y=r*i+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Matrix3{constructor(t,e,n,i,r,o,s,a,l){Matrix3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,o,s,a,l)}set(t,e,n,i,r,o,s,a,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=s,c[3]=e,c[4]=r,c[5]=a,c[6]=n,c[7]=o,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,o=n[0],s=n[3],a=n[6],l=n[1],c=n[4],u=n[7],h=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],_=i[1],y=i[4],v=i[7],x=i[2],b=i[5],T=i[8];return r[0]=o*f+s*_+a*x,r[3]=o*m+s*y+a*b,r[6]=o*g+s*v+a*T,r[1]=l*f+c*_+u*x,r[4]=l*m+c*y+u*b,r[7]=l*g+c*v+u*T,r[2]=h*f+d*_+p*x,r[5]=h*m+d*y+p*b,r[8]=h*g+d*v+p*T,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],s=t[5],a=t[6],l=t[7],c=t[8];return e*o*c-e*s*l-n*r*c+n*s*a+i*r*l-i*o*a}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=c*o-s*l,h=s*a-c*r,d=l*r-o*a,p=e*u+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=u*f,t[1]=(i*l-c*n)*f,t[2]=(s*n-i*o)*f,t[3]=h*f,t[4]=(c*e-i*a)*f,t[5]=(i*r-s*e)*f,t[6]=d*f,t[7]=(n*a-l*e)*f,t[8]=(o*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,o,s){const a=Math.cos(r),l=Math.sin(r);return this.set(n*a,n*l,-n*(a*o+l*s)+o+t,-i*l,i*a,-i*(-l*o+a*s)+s+e,0,0,1),this}scale(t,e){return this.premultiply(_m3.makeScale(t,e)),this}rotate(t){return this.premultiply(_m3.makeRotation(-t)),this}translate(t,e){return this.premultiply(_m3.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const _m3=new Matrix3;function arrayNeedsUint32(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const TYPED_ARRAYS={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function getTypedArray(t,e){return new TYPED_ARRAYS[t](e)}function createElementNS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function createCanvasElement(){const t=createElementNS("canvas");return t.style.display="block",t}const _cache={};function warnOnce(t){t in _cache||(_cache[t]=!0)}function probeAsync(t,e,n){return new Promise((function(i,r){setTimeout((function o(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(o,n);break;default:i()}}),n)}))}function toNormalizedProjectionMatrix(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function toReversedProjectionMatrix(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}const LINEAR_REC709_TO_XYZ=(new Matrix3).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),XYZ_TO_LINEAR_REC709=(new Matrix3).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function createColorManagement(){const t={enabled:!0,workingColorSpace:LinearSRGBColorSpace,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===SRGBTransfer&&(t.r=SRGBToLinear(t.r),t.g=SRGBToLinear(t.g),t.b=SRGBToLinear(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===SRGBTransfer&&(t.r=LinearToSRGB(t.r),t.g=LinearToSRGB(t.g),t.b=LinearToSRGB(t.b)),t):t},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===NoColorSpace?LinearTransfer:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[LinearSRGBColorSpace]:{primaries:e,whitePoint:i,transfer:LinearTransfer,toXYZ:LINEAR_REC709_TO_XYZ,fromXYZ:XYZ_TO_LINEAR_REC709,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:SRGBColorSpace},outputColorSpaceConfig:{drawingBufferColorSpace:SRGBColorSpace}},[SRGBColorSpace]:{primaries:e,whitePoint:i,transfer:SRGBTransfer,toXYZ:LINEAR_REC709_TO_XYZ,fromXYZ:XYZ_TO_LINEAR_REC709,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:SRGBColorSpace}}}),t}const ColorManagement=createColorManagement();function SRGBToLinear(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function LinearToSRGB(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let _canvas;class ImageUtils{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===_canvas&&(_canvas=createElementNS("canvas")),_canvas.width=t.width,_canvas.height=t.height;const n=_canvas.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=_canvas}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=createElementNS("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*SRGBToLinear(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e[t]=e instanceof Uint8Array||e instanceof Uint8ClampedArray?Math.floor(255*SRGBToLinear(e[t]/255)):SRGBToLinear(e[t]);return{data:e,width:t.width,height:t.height}}return t}}let _sourceId=0;class Source{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:_sourceId++}),this.uuid=generateUUID$1(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)t.push(serializeImage(i[e].isDataTexture?i[e].image:i[e]))}else t=serializeImage(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function serializeImage(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?ImageUtils.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:{}}let _textureId=0;class Texture extends EventDispatcher{constructor(t=Texture.DEFAULT_IMAGE,e=Texture.DEFAULT_MAPPING,n=ClampToEdgeWrapping,i=ClampToEdgeWrapping,r=LinearFilter,o=LinearMipmapLinearFilter,s=RGBAFormat,a=UnsignedByteType,l=Texture.DEFAULT_ANISOTROPY,c=NoColorSpace){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:_textureId++}),this.uuid=generateUUID$1(),this.name="",this.source=new Source(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new Vector2(0,0),this.repeat=new Vector2(1,1),this.center=new Vector2(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Matrix3,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==UVMapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case RepeatWrapping:t.x=t.x-Math.floor(t.x);break;case ClampToEdgeWrapping:t.x=t.x<0?0:1;break;case MirroredRepeatWrapping:t.x=1===Math.abs(Math.floor(t.x)%2)?Math.ceil(t.x)-t.x:t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case RepeatWrapping:t.y=t.y-Math.floor(t.y);break;case ClampToEdgeWrapping:t.y=t.y<0?0:1;break;case MirroredRepeatWrapping:t.y=1===Math.abs(Math.floor(t.y)%2)?Math.ceil(t.y)-t.y:t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Texture.DEFAULT_IMAGE=null,Texture.DEFAULT_MAPPING=UVMapping,Texture.DEFAULT_ANISOTROPY=1;class Vector4{constructor(t=0,e=0,n=0,i=1){Vector4.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const o=.01,s=.1,a=t.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)<o&&Math.abs(u-f)<o&&Math.abs(p-m)<o){if(Math.abs(c+h)<s&&Math.abs(u+f)<s&&Math.abs(p+m)<s&&Math.abs(l+d+g-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,a=(d+1)/2,_=(g+1)/2,y=(c+h)/4,v=(u+f)/4,x=(p+m)/4;return t>a&&t>_?t<o?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=y/n,r=v/n):a>_?a<o?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(a),n=y/i,r=x/i):_<o?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(_),n=v/r,i=x/r),this.set(n,i,r,e),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(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=clamp(this.x,t.x,e.x),this.y=clamp(this.y,t.y,e.y),this.z=clamp(this.z,t.z,e.z),this.w=clamp(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=clamp(this.x,t,e),this.y=clamp(this.y,t,e),this.z=clamp(this.z,t,e),this.w=clamp(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(clamp(n,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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 RenderTarget extends EventDispatcher{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Vector4(0,0,t,e),this.scissorTest=!1,this.viewport=new Vector4(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:LinearFilter,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new Texture(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let t=0;t<o;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==t&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++)this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const e=Object.assign({},t.texture.image);return this.texture.source=new Source(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class WebGLRenderTarget extends RenderTarget{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class DataArrayTexture extends Texture{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.wrapR=ClampToEdgeWrapping,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class WebGLArrayRenderTarget extends WebGLRenderTarget{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new DataArrayTexture(null,t,e,n),this.texture.isRenderTargetTexture=!0}}class Data3DTexture extends Texture{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.wrapR=ClampToEdgeWrapping,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class WebGL3DRenderTarget extends WebGLRenderTarget{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Data3DTexture(null,t,e,n),this.texture.isRenderTargetTexture=!0}}class Quaternion{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,o,s){let a=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3];const h=r[o+0],d=r[o+1],p=r[o+2],f=r[o+3];if(0===s)return t[e+0]=a,t[e+1]=l,t[e+2]=c,void(t[e+3]=u);if(1===s)return t[e+0]=h,t[e+1]=d,t[e+2]=p,void(t[e+3]=f);if(u!==f||a!==h||l!==d||c!==p){let t=1-s;const e=a*h+l*d+c*p+u*f,n=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),o=Math.atan2(r,e*n);t=Math.sin(t*o)/r,s=Math.sin(s*o)/r}const r=s*n;if(a=a*t+h*r,l=l*t+d*r,c=c*t+p*r,u=u*t+f*r,t===1-s){const t=1/Math.sqrt(a*a+l*l+c*c+u*u);a*=t,l*=t,c*=t,u*=t}}t[e]=a,t[e+1]=l,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,o){const s=n[i],a=n[i+1],l=n[i+2],c=n[i+3],u=r[o],h=r[o+1],d=r[o+2],p=r[o+3];return t[e]=s*p+c*u+a*d-l*h,t[e+1]=a*p+c*h+l*u-s*d,t[e+2]=l*p+c*d+s*h-a*u,t[e+3]=c*p-s*u-a*h-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,o=t._order,s=Math.cos,a=Math.sin,l=s(n/2),c=s(i/2),u=s(r/2),h=a(n/2),d=a(i/2),p=a(r/2);switch(o){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}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],o=e[1],s=e[5],a=e[9],l=e[2],c=e[6],u=e[10],h=n+s+u;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(c-a)*t,this._y=(r-l)*t,this._z=(o-i)*t}else if(n>s&&n>u){const t=2*Math.sqrt(1+n-s-u);this._w=(c-a)/t,this._x=.25*t,this._y=(i+o)/t,this._z=(r+l)/t}else if(s>u){const t=2*Math.sqrt(1+s-n-u);this._w=(r-l)/t,this._x=(i+o)/t,this._y=.25*t,this._z=(a+c)/t}else{const t=2*Math.sqrt(1+u-n-s);this._w=(o-i)/t,this._x=(r+l)/t,this._y=(a+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(clamp(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,o=t._w,s=e._x,a=e._y,l=e._z,c=e._w;return this._x=n*c+o*s+i*l-r*a,this._y=i*c+o*a+r*s-n*l,this._z=r*c+o*l+n*a-i*s,this._w=o*c-n*s-i*a-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,o=this._w;let s=o*t._w+n*t._x+i*t._y+r*t._z;if(s<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,s=-s):this.copy(t),s>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const a=1-s*s;if(a<=Number.EPSILON){const t=1-e;return this._w=t*o+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(a),c=Math.atan2(l,s),u=Math.sin((1-e)*c)/l,h=Math.sin(e*c)/l;return this._w=o*u+this._w*h,this._x=n*u+this._x*h,this._y=i*u+this._y*h,this._z=r*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Vector3{constructor(t=0,e=0,n=0){Vector3.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(_quaternion$4.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(_quaternion$4.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,o=t.y,s=t.z,a=t.w,l=2*(o*i-s*n),c=2*(s*e-r*i),u=2*(r*n-o*e);return this.x=e+a*l+o*u-s*c,this.y=n+a*c+s*l-r*u,this.z=i+a*u+r*c-o*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=clamp(this.x,t.x,e.x),this.y=clamp(this.y,t.y,e.y),this.z=clamp(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=clamp(this.x,t,e),this.y=clamp(this.y,t,e),this.z=clamp(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(clamp(n,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,o=e.x,s=e.y,a=e.z;return this.x=i*a-r*s,this.y=r*o-n*a,this.z=n*s-i*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return _vector$c.copy(this).projectOnVector(t),this.sub(_vector$c)}reflect(t){return this.sub(_vector$c.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(clamp(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const _vector$c=new Vector3,_quaternion$4=new Quaternion;class Box3{constructor(t=new Vector3(1/0,1/0,1/0),e=new Vector3(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(_vector$b.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(_vector$b.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=_vector$b.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,_vector$b):_vector$b.fromBufferAttribute(i,e),_vector$b.applyMatrix4(t.matrixWorld),this.expandByPoint(_vector$b);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),_box$4.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),_box$4.copy(n.boundingBox)),_box$4.applyMatrix4(t.matrixWorld),this.union(_box$4)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,_vector$b),_vector$b.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(_center),_extents.subVectors(this.max,_center),_v0$2.subVectors(t.a,_center),_v1$7.subVectors(t.b,_center),_v2$4.subVectors(t.c,_center),_f0.subVectors(_v1$7,_v0$2),_f1.subVectors(_v2$4,_v1$7),_f2.subVectors(_v0$2,_v2$4);let e=[0,-_f0.z,_f0.y,0,-_f1.z,_f1.y,0,-_f2.z,_f2.y,_f0.z,0,-_f0.x,_f1.z,0,-_f1.x,_f2.z,0,-_f2.x,-_f0.y,_f0.x,0,-_f1.y,_f1.x,0,-_f2.y,_f2.x,0];return!!satForAxes(e,_v0$2,_v1$7,_v2$4,_extents)&&(e=[1,0,0,0,1,0,0,0,1],!!satForAxes(e,_v0$2,_v1$7,_v2$4,_extents)&&(_triangleNormal.crossVectors(_f0,_f1),e=[_triangleNormal.x,_triangleNormal.y,_triangleNormal.z],satForAxes(e,_v0$2,_v1$7,_v2$4,_extents)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,_vector$b).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(_vector$b).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(_points[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),_points[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),_points[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),_points[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),_points[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),_points[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),_points[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),_points[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(_points)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const _points=[new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3],_vector$b=new Vector3,_box$4=new Box3,_v0$2=new Vector3,_v1$7=new Vector3,_v2$4=new Vector3,_f0=new Vector3,_f1=new Vector3,_f2=new Vector3,_center=new Vector3,_extents=new Vector3,_triangleNormal=new Vector3,_testAxis=new Vector3;function satForAxes(t,e,n,i,r){for(let o=0,s=t.length-3;o<=s;o+=3){_testAxis.fromArray(t,o);const s=r.x*Math.abs(_testAxis.x)+r.y*Math.abs(_testAxis.y)+r.z*Math.abs(_testAxis.z),a=e.dot(_testAxis),l=n.dot(_testAxis),c=i.dot(_testAxis);if(Math.max(-Math.max(a,l,c),Math.min(a,l,c))>s)return!1}return!0}const _box$3=new Box3,_v1$6=new Vector3,_v2$3=new Vector3;class Sphere{constructor(t=new Vector3,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):_box$3.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;_v1$6.subVectors(t,this.center);const e=_v1$6.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(_v1$6,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(_v2$3.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(_v1$6.copy(t.center).add(_v2$3)),this.expandByPoint(_v1$6.copy(t.center).sub(_v2$3))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const _vector$a=new Vector3,_segCenter=new Vector3,_segDir=new Vector3,_diff=new Vector3,_edge1=new Vector3,_edge2=new Vector3,_normal$1=new Vector3;class Ray{constructor(t=new Vector3,e=new Vector3(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,_vector$a)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=_vector$a.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(_vector$a.copy(this.origin).addScaledVector(this.direction,e),_vector$a.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){_segCenter.copy(t).add(e).multiplyScalar(.5),_segDir.copy(e).sub(t).normalize(),_diff.copy(this.origin).sub(_segCenter);const r=.5*t.distanceTo(e),o=-this.direction.dot(_segDir),s=_diff.dot(this.direction),a=-_diff.dot(_segDir),l=_diff.lengthSq(),c=Math.abs(1-o*o);let u,h,d,p;if(c>0)if(u=o*a-s,h=o*s-a,p=r*c,u>=0)if(h>=-p)if(h<=p){const t=1/c;u*=t,h*=t,d=u*(u+o*h+2*s)+h*(o*u+h+2*a)+l}else h=r,u=Math.max(0,-(o*h+s)),d=-u*u+h*(h+2*a)+l;else h=-r,u=Math.max(0,-(o*h+s)),d=-u*u+h*(h+2*a)+l;else h<=-p?(u=Math.max(0,-(-o*r+s)),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,-(o*r+s)),h=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+h*(h+2*a)+l);else h=o>0?-r:r,u=Math.max(0,-(o*h+s)),d=-u*u+h*(h+2*a)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(_segCenter).addScaledVector(_segDir,h),d}intersectSphere(t,e){_vector$a.subVectors(t.center,this.origin);const n=_vector$a.dot(this.direction),i=_vector$a.dot(_vector$a)-n*n,r=t.radius*t.radius;if(i>r)return null;const o=Math.sqrt(r-i),s=n-o,a=n+o;return a<0?null:this.at(s<0?a:s,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,o,s,a;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(n=(t.min.x-h.x)*l,i=(t.max.x-h.x)*l):(n=(t.max.x-h.x)*l,i=(t.min.x-h.x)*l),c>=0?(r=(t.min.y-h.y)*c,o=(t.max.y-h.y)*c):(r=(t.max.y-h.y)*c,o=(t.min.y-h.y)*c),n>o||r>i?null:((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),u>=0?(s=(t.min.z-h.z)*u,a=(t.max.z-h.z)*u):(s=(t.max.z-h.z)*u,a=(t.min.z-h.z)*u),n>a||s>i?null:((s>n||n!=n)&&(n=s),(a<i||i!=i)&&(i=a),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,_vector$a)}intersectTriangle(t,e,n,i,r){_edge1.subVectors(e,t),_edge2.subVectors(n,t),_normal$1.crossVectors(_edge1,_edge2);let o,s=this.direction.dot(_normal$1);if(s>0){if(i)return null;o=1}else{if(!(s<0))return null;o=-1,s=-s}_diff.subVectors(this.origin,t);const a=o*this.direction.dot(_edge2.crossVectors(_diff,_edge2));if(a<0)return null;const l=o*this.direction.dot(_edge1.cross(_diff));if(l<0)return null;if(a+l>s)return null;const c=-o*_diff.dot(_normal$1);return c<0?null:this.at(c/s,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Matrix4{constructor(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m){Matrix4.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m)}set(t,e,n,i,r,o,s,a,l,c,u,h,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=o,g[9]=s,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 Matrix4).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/_v1$5.setFromMatrixColumn(t,0).length(),r=1/_v1$5.setFromMatrixColumn(t,1).length(),o=1/_v1$5.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,o=Math.cos(n),s=Math.sin(n),a=Math.cos(i),l=Math.sin(i),c=Math.cos(r),u=Math.sin(r);if("XYZ"===t.order){const t=o*c,n=o*u,i=s*c,r=s*u;e[0]=a*c,e[4]=-a*u,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-s*a,e[2]=r-t*l,e[6]=i+n*l,e[10]=o*a}else if("YXZ"===t.order){const t=a*c,n=a*u,i=l*c,r=l*u;e[0]=t+r*s,e[4]=i*s-n,e[8]=o*l,e[1]=o*u,e[5]=o*c,e[9]=-s,e[2]=n*s-i,e[6]=r+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*c,n=a*u,i=l*c,r=l*u;e[0]=t-r*s,e[4]=-o*u,e[8]=i+n*s,e[1]=n+i*s,e[5]=o*c,e[9]=r-t*s,e[2]=-o*l,e[6]=s,e[10]=o*a}else if("ZYX"===t.order){const t=o*c,n=o*u,i=s*c,r=s*u;e[0]=a*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=a*u,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,n=o*l,i=s*a,r=s*l;e[0]=a*c,e[4]=r-t*u,e[8]=i*u+n,e[1]=u,e[5]=o*c,e[9]=-s*c,e[2]=-l*c,e[6]=n*u+i,e[10]=t-r*u}else if("XZY"===t.order){const t=o*a,n=o*l,i=s*a,r=s*l;e[0]=a*c,e[4]=-u,e[8]=l*c,e[1]=t*u+r,e[5]=o*c,e[9]=n*u-i,e[2]=i*u-n,e[6]=s*c,e[10]=r*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(_zero,t,_one)}lookAt(t,e,n){const i=this.elements;return _z.subVectors(t,e),0===_z.lengthSq()&&(_z.z=1),_z.normalize(),_x.crossVectors(n,_z),0===_x.lengthSq()&&(1===Math.abs(n.z)?_z.x+=1e-4:_z.z+=1e-4,_z.normalize(),_x.crossVectors(n,_z)),_x.normalize(),_y.crossVectors(_z,_x),i[0]=_x.x,i[4]=_y.x,i[8]=_z.x,i[1]=_x.y,i[5]=_y.y,i[9]=_z.y,i[2]=_x.z,i[6]=_y.z,i[10]=_z.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,o=n[0],s=n[4],a=n[8],l=n[12],c=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],_=n[3],y=n[7],v=n[11],x=n[15],b=i[0],T=i[4],E=i[8],S=i[12],w=i[1],A=i[5],M=i[9],C=i[13],I=i[2],P=i[6],L=i[10],R=i[14],O=i[3],D=i[7],B=i[11],N=i[15];return r[0]=o*b+s*w+a*I+l*O,r[4]=o*T+s*A+a*P+l*D,r[8]=o*E+s*M+a*L+l*B,r[12]=o*S+s*C+a*R+l*N,r[1]=c*b+u*w+h*I+d*O,r[5]=c*T+u*A+h*P+d*D,r[9]=c*E+u*M+h*L+d*B,r[13]=c*S+u*C+h*R+d*N,r[2]=p*b+f*w+m*I+g*O,r[6]=p*T+f*A+m*P+g*D,r[10]=p*E+f*M+m*L+g*B,r[14]=p*S+f*C+m*R+g*N,r[3]=_*b+y*w+v*I+x*O,r[7]=_*T+y*A+v*P+x*D,r[11]=_*E+y*M+v*L+x*B,r[15]=_*S+y*C+v*R+x*N,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],o=t[1],s=t[5],a=t[9],l=t[13],c=t[2],u=t[6],h=t[10],d=t[14];return t[3]*(+r*a*u-i*l*u-r*s*h+n*l*h+i*s*d-n*a*d)+t[7]*(+e*a*d-e*l*h+r*o*h-i*o*d+i*l*c-r*a*c)+t[11]*(+e*l*u-e*s*d-r*o*u+n*o*d+r*s*c-n*l*c)+t[15]*(-i*s*c-e*a*u+e*s*h+i*o*u-n*o*h+n*a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],_=u*m*l-f*h*l+f*a*d-s*m*d-u*a*g+s*h*g,y=p*h*l-c*m*l-p*a*d+o*m*d+c*a*g-o*h*g,v=c*f*l-p*u*l+p*s*d-o*f*d-c*s*g+o*u*g,x=p*u*a-c*f*a-p*s*h+o*f*h+c*s*m-o*u*m,b=e*_+n*y+i*v+r*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/b;return t[0]=_*T,t[1]=(f*h*r-u*m*r-f*i*d+n*m*d+u*i*g-n*h*g)*T,t[2]=(s*m*r-f*a*r+f*i*l-n*m*l-s*i*g+n*a*g)*T,t[3]=(u*a*r-s*h*r-u*i*l+n*h*l+s*i*d-n*a*d)*T,t[4]=y*T,t[5]=(c*m*r-p*h*r+p*i*d-e*m*d-c*i*g+e*h*g)*T,t[6]=(p*a*r-o*m*r-p*i*l+e*m*l+o*i*g-e*a*g)*T,t[7]=(o*h*r-c*a*r+c*i*l-e*h*l-o*i*d+e*a*d)*T,t[8]=v*T,t[9]=(p*u*r-c*f*r-p*n*d+e*f*d+c*n*g-e*u*g)*T,t[10]=(o*f*r-p*s*r+p*n*l-e*f*l-o*n*g+e*s*g)*T,t[11]=(c*s*r-o*u*r-c*n*l+e*u*l+o*n*d-e*s*d)*T,t[12]=x*T,t[13]=(c*f*i-p*u*i+p*n*h-e*f*h-c*n*m+e*u*m)*T,t[14]=(p*s*i-o*f*i-p*n*a+e*f*a+o*n*m-e*s*m)*T,t[15]=(o*u*i-c*s*i+c*n*a-e*u*a-o*n*h+e*s*h)*T,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements;return Math.sqrt(Math.max(t[0]*t[0]+t[1]*t[1]+t[2]*t[2],t[4]*t[4]+t[5]*t[5]+t[6]*t[6],t[8]*t[8]+t[9]*t[9]+t[10]*t[10]))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,o=t.x,s=t.y,a=t.z,l=r*o,c=r*s;return this.set(l*o+n,l*s-i*a,l*a+i*s,0,l*s+i*a,c*s+n,c*a-i*o,0,l*a-i*s,c*a+i*o,r*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,o){return this.set(1,n,r,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,o=e._y,s=e._z,a=e._w,l=r+r,c=o+o,u=s+s,h=r*l,d=r*c,p=r*u,f=o*c,m=o*u,g=s*u,_=a*l,y=a*c,v=a*u,x=n.x,b=n.y,T=n.z;return i[0]=(1-(f+g))*x,i[1]=(d+v)*x,i[2]=(p-y)*x,i[3]=0,i[4]=(d-v)*b,i[5]=(1-(h+g))*b,i[6]=(m+_)*b,i[7]=0,i[8]=(p+y)*T,i[9]=(m-_)*T,i[10]=(1-(h+f))*T,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=_v1$5.set(i[0],i[1],i[2]).length();const o=_v1$5.set(i[4],i[5],i[6]).length(),s=_v1$5.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],_m1$2.copy(this);const a=1/r,l=1/o,c=1/s;return _m1$2.elements[0]*=a,_m1$2.elements[1]*=a,_m1$2.elements[2]*=a,_m1$2.elements[4]*=l,_m1$2.elements[5]*=l,_m1$2.elements[6]*=l,_m1$2.elements[8]*=c,_m1$2.elements[9]*=c,_m1$2.elements[10]*=c,e.setFromRotationMatrix(_m1$2),n.x=r,n.y=o,n.z=s,this}makePerspective(t,e,n,i,r,o,s=WebGLCoordinateSystem){const a=this.elements,l=2*r/(e-t),c=2*r/(n-i),u=(e+t)/(e-t),h=(n+i)/(n-i);let d,p;if(s===WebGLCoordinateSystem)d=-(o+r)/(o-r),p=-2*o*r/(o-r);else{if(s!==WebGPUCoordinateSystem)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);d=-o/(o-r),p=-o*r/(o-r)}return a[0]=l,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,n,i,r,o,s=WebGLCoordinateSystem){const a=this.elements,l=1/(e-t),c=1/(n-i),u=1/(o-r),h=(e+t)*l,d=(n+i)*c;let p,f;if(s===WebGLCoordinateSystem)p=(o+r)*u,f=-2*u;else{if(s!==WebGPUCoordinateSystem)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=r*u,f=-1*u}return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=f,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const _v1$5=new Vector3,_m1$2=new Matrix4,_zero=new Vector3(0,0,0),_one=new Vector3(1,1,1),_x=new Vector3,_y=new Vector3,_z=new Vector3,_matrix$2=new Matrix4,_quaternion$3=new Quaternion;class Euler{constructor(t=0,e=0,n=0,i=Euler.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],o=i[4],s=i[8],a=i[1],l=i[5],c=i[9],u=i[2],h=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(clamp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-clamp(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(-o,l));break;case"YZX":this._z=Math.asin(clamp(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(s,d));break;case"XZY":this._z=Math.asin(-clamp(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,d),this._y=0)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return _matrix$2.makeRotationFromQuaternion(t),this.setFromRotationMatrix(_matrix$2,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return _quaternion$3.setFromEuler(this),this.setFromQuaternion(_quaternion$3,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Euler.DEFAULT_ORDER="XYZ";class Layers{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return!!(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let _object3DId=0;const _v1$4=new Vector3,_q1=new Quaternion,_m1$1$1=new Matrix4,_target=new Vector3,_position$3=new Vector3,_scale$2=new Vector3,_quaternion$2=new Quaternion,_xAxis=new Vector3(1,0,0),_yAxis=new Vector3(0,1,0),_zAxis=new Vector3(0,0,1),_addedEvent={type:"added"},_removedEvent={type:"removed"},_childaddedEvent={type:"childadded",child:null},_childremovedEvent={type:"childremoved",child:null};class Object3D extends EventDispatcher{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_object3DId++}),this.uuid=generateUUID$1(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Object3D.DEFAULT_UP.clone();const t=new Vector3,e=new Euler,n=new Quaternion,i=new Vector3(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Matrix4},normalMatrix:{value:new Matrix3}}),this.matrix=new Matrix4,this.matrixWorld=new Matrix4,this.matrixAutoUpdate=Object3D.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return _q1.setFromAxisAngle(t,e),this.quaternion.multiply(_q1),this}rotateOnWorldAxis(t,e){return _q1.setFromAxisAngle(t,e),this.quaternion.premultiply(_q1),this}rotateX(t){return this.rotateOnAxis(_xAxis,t)}rotateY(t){return this.rotateOnAxis(_yAxis,t)}rotateZ(t){return this.rotateOnAxis(_zAxis,t)}translateOnAxis(t,e){return _v1$4.copy(t).applyQuaternion(this.quaternion),this.position.add(_v1$4.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(_xAxis,t)}translateY(t){return this.translateOnAxis(_yAxis,t)}translateZ(t){return this.translateOnAxis(_zAxis,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(_m1$1$1.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?_target.copy(t):_target.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),_position$3.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_m1$1$1.lookAt(_position$3,_target,this.up):_m1$1$1.lookAt(_target,_position$3,this.up),this.quaternion.setFromRotationMatrix(_m1$1$1),i&&(_m1$1$1.extractRotation(i.matrixWorld),_q1.setFromRotationMatrix(_m1$1$1),this.quaternion.premultiply(_q1.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this||t&&t.isObject3D&&(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(_addedEvent),_childaddedEvent.child=t,this.dispatchEvent(_childaddedEvent),_childaddedEvent.child=null),this}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(_removedEvent),_childremovedEvent.child=t,this.dispatchEvent(_childremovedEvent),_childremovedEvent.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),_m1$1$1.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),_m1$1$1.multiply(t.parent.matrixWorld)),t.applyMatrix4(_m1$1$1),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(_addedEvent),_childaddedEvent.child=t,this.dispatchEvent(_childaddedEvent),_childaddedEvent.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$3,t,_scale$2),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$3,_quaternion$2,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){e[n].updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.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===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){t[e].updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){r(t.shapes,n[e])}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){i.animations.push(r(t.animations,this.animations[e]))}}if(e){const e=o(t.geometries),i=o(t.materials),r=o(t.textures),s=o(t.images),a=o(t.shapes),l=o(t.skeletons),c=o(t.animations),u=o(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),a.length>0&&(n.shapes=a),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=i,n;function o(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){this.add(t.children[e].clone())}return this}}Object3D.DEFAULT_UP=new Vector3(0,1,0),Object3D.DEFAULT_MATRIX_AUTO_UPDATE=!0,Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const _v0$1=new Vector3,_v1$3=new Vector3,_v2$2=new Vector3,_v3$2=new Vector3,_vab=new Vector3,_vac=new Vector3,_vbc=new Vector3,_vap=new Vector3,_vbp=new Vector3,_vcp=new Vector3,_v40=new Vector4,_v41=new Vector4,_v42=new Vector4;class Triangle{constructor(t=new Vector3,e=new Vector3,n=new Vector3){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),_v0$1.subVectors(t,e),i.cross(_v0$1);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){_v0$1.subVectors(i,e),_v1$3.subVectors(n,e),_v2$2.subVectors(t,e);const o=_v0$1.dot(_v0$1),s=_v0$1.dot(_v1$3),a=_v0$1.dot(_v2$2),l=_v1$3.dot(_v1$3),c=_v1$3.dot(_v2$2),u=o*l-s*s;if(0===u)return r.set(0,0,0),null;const h=1/u,d=(l*a-s*c)*h,p=(o*c-s*a)*h;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,_v3$2)&&(_v3$2.x>=0&&_v3$2.y>=0&&_v3$2.x+_v3$2.y<=1)}static getInterpolation(t,e,n,i,r,o,s,a){return null===this.getBarycoord(t,e,n,i,_v3$2)?(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,_v3$2.x),a.addScaledVector(o,_v3$2.y),a.addScaledVector(s,_v3$2.z),a)}static getInterpolatedAttribute(t,e,n,i,r,o){return _v40.setScalar(0),_v41.setScalar(0),_v42.setScalar(0),_v40.fromBufferAttribute(t,e),_v41.fromBufferAttribute(t,n),_v42.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(_v40,r.x),o.addScaledVector(_v41,r.y),o.addScaledVector(_v42,r.z),o}static isFrontFacing(t,e,n,i){return _v0$1.subVectors(n,e),_v1$3.subVectors(t,e),_v0$1.cross(_v1$3).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return _v0$1.subVectors(this.c,this.b),_v1$3.subVectors(this.a,this.b),.5*_v0$1.cross(_v1$3).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Triangle.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Triangle.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Triangle.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Triangle.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Triangle.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let o,s;_vab.subVectors(i,n),_vac.subVectors(r,n),_vap.subVectors(t,n);const a=_vab.dot(_vap),l=_vac.dot(_vap);if(a<=0&&l<=0)return e.copy(n);_vbp.subVectors(t,i);const c=_vab.dot(_vbp),u=_vac.dot(_vbp);if(c>=0&&u<=c)return e.copy(i);const h=a*u-c*l;if(h<=0&&a>=0&&c<=0)return o=a/(a-c),e.copy(n).addScaledVector(_vab,o);_vcp.subVectors(t,r);const d=_vab.dot(_vcp),p=_vac.dot(_vcp);if(p>=0&&d<=p)return e.copy(r);const f=d*l-a*p;if(f<=0&&l>=0&&p<=0)return s=l/(l-p),e.copy(n).addScaledVector(_vac,s);const m=c*p-d*u;if(m<=0&&u-c>=0&&d-p>=0)return _vbc.subVectors(r,i),s=(u-c)/(u-c+(d-p)),e.copy(i).addScaledVector(_vbc,s);const g=1/(m+f+h);return o=f*g,s=h*g,e.copy(n).addScaledVector(_vab,o).addScaledVector(_vac,s)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const _colorKeywords={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},_hslA={h:0,s:0,l:0},_hslB={h:0,s:0,l:0};function hue2rgb(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Color{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=SRGBColorSpace){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,ColorManagement.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=ColorManagement.workingColorSpace){return this.r=t,this.g=e,this.b=n,ColorManagement.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=ColorManagement.workingColorSpace){if(t=euclideanModulo(t,1),e=clamp(e,0,1),n=clamp(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=hue2rgb(r,i,t+1/3),this.g=hue2rgb(r,i,t),this.b=hue2rgb(r,i,t-1/3)}return ColorManagement.toWorkingColorSpace(this,i),this}setStyle(t,e=SRGBColorSpace){let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let t;const i=n[2];switch(n[1]){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.setRGB(Math.min(255,parseInt(t[1],10))/255,Math.min(255,parseInt(t[2],10))/255,Math.min(255,parseInt(t[3],10))/255,e);if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.setRGB(Math.min(100,parseInt(t[1],10))/100,Math.min(100,parseInt(t[2],10))/100,Math.min(100,parseInt(t[3],10))/100,e);break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.setHSL(parseFloat(t[1])/360,parseFloat(t[2])/100,parseFloat(t[3])/100,e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],i=t.length;if(3===i)return this.setRGB(parseInt(t.charAt(0),16)/15,parseInt(t.charAt(1),16)/15,parseInt(t.charAt(2),16)/15,e);if(6===i)return this.setHex(parseInt(t,16),e)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=SRGBColorSpace){const n=_colorKeywords[t.toLowerCase()];return void 0!==n&&this.setHex(n,e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=SRGBToLinear(t.r),this.g=SRGBToLinear(t.g),this.b=SRGBToLinear(t.b),this}copyLinearToSRGB(t){return this.r=LinearToSRGB(t.r),this.g=LinearToSRGB(t.g),this.b=LinearToSRGB(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=SRGBColorSpace){return ColorManagement.fromWorkingColorSpace(_color.copy(this),t),65536*Math.round(clamp(255*_color.r,0,255))+256*Math.round(clamp(255*_color.g,0,255))+Math.round(clamp(255*_color.b,0,255))}getHexString(t=SRGBColorSpace){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ColorManagement.workingColorSpace){ColorManagement.fromWorkingColorSpace(_color.copy(this),e);const n=_color.r,i=_color.g,r=_color.b,o=Math.max(n,i,r),s=Math.min(n,i,r);let a,l;const c=(s+o)/2;if(s===o)a=0,l=0;else{const t=o-s;switch(l=c<=.5?t/(o+s):t/(2-o-s),o){case n:a=(i-r)/t+(i<r?6:0);break;case i:a=(r-n)/t+2;break;case r:a=(n-i)/t+4}a/=6}return t.h=a,t.s=l,t.l=c,t}getRGB(t,e=ColorManagement.workingColorSpace){return ColorManagement.fromWorkingColorSpace(_color.copy(this),e),t.r=_color.r,t.g=_color.g,t.b=_color.b,t}getStyle(t=SRGBColorSpace){ColorManagement.fromWorkingColorSpace(_color.copy(this),t);const e=_color.r,n=_color.g,i=_color.b;return t!==SRGBColorSpace?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(_hslA),this.setHSL(_hslA.h+t,_hslA.s+e,_hslA.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(_hslA),t.getHSL(_hslB);const n=lerp(_hslA.h,_hslB.h,e),i=lerp(_hslA.s,_hslB.s,e),r=lerp(_hslA.l,_hslB.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const _color=new Color;Color.NAMES=_colorKeywords;let _materialId=0;class Material extends EventDispatcher{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:_materialId++}),this.uuid=generateUUID$1(),this.name="",this.type="Material",this.blending=NormalBlending,this.side=FrontSide,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=SrcAlphaFactor,this.blendDst=OneMinusSrcAlphaFactor,this.blendEquation=AddEquation,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Color(0,0,0),this.blendAlpha=0,this.depthFunc=LessEqualDepth,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AlwaysStencilFunc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=KeepStencilOp,this.stencilZFail=KeepStencilOp,this.stencilZPass=KeepStencilOp,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n)continue;const i=this[e];void 0!==i&&(i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==NormalBlending&&(n.blending=this.blending),this.side!==FrontSide&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==SrcAlphaFactor&&(n.blendSrc=this.blendSrc),this.blendDst!==OneMinusSrcAlphaFactor&&(n.blendDst=this.blendDst),this.blendEquation!==AddEquation&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==LessEqualDepth&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==AlwaysStencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==KeepStencilOp&&(n.stencilFail=this.stencilFail),this.stencilZFail!==KeepStencilOp&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==KeepStencilOp&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}onBuild(){}}class MeshBasicMaterial extends Material{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Color(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 Euler,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const _tables=_generateTables();function _generateTables(){const t=new ArrayBuffer(4),e=new Float32Array(t),n=new Uint32Array(t),i=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,r[t]=24,r[256|t]=24):(i[t]=31744,i[256|t]=64512,r[t]=13,r[256|t]=13)}const o=new Uint32Array(2048),s=new Uint32Array(64),a=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,n=0;for(;!(8388608&e);)e<<=1,n-=8388608;e&=-8388609,n+=947912704,o[t]=e|n}for(let t=1024;t<2048;++t)o[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)s[t]=t<<23;s[31]=1199570944,s[32]=2147483648;for(let t=33;t<63;++t)s[t]=2147483648+(t-32<<23);s[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(a[t]=1024);return{floatView:e,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:o,exponentTable:s,offsetTable:a}}function toHalfFloat(t){t=clamp(t,-65504,65504),_tables.floatView[0]=t;const e=_tables.uint32View[0],n=e>>23&511;return _tables.baseTable[n]+((8388607&e)>>_tables.shiftTable[n])}function fromHalfFloat(t){const e=t>>10;return _tables.uint32View[0]=_tables.mantissaTable[_tables.offsetTable[e]+(1023&t)]+_tables.exponentTable[e],_tables.floatView[0]}const DataUtils={toHalfFloat:toHalfFloat,fromHalfFloat:fromHalfFloat},_vector$9=new Vector3,_vector2$1=new Vector2;class BufferAttribute{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=StaticDrawUsage,this.updateRanges=[],this.gpuType=FloatType,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)_vector2$1.fromBufferAttribute(this,e),_vector2$1.applyMatrix3(t),this.setXY(e,_vector2$1.x,_vector2$1.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)_vector$9.fromBufferAttribute(this,e),_vector$9.applyMatrix3(t),this.setXYZ(e,_vector$9.x,_vector$9.y,_vector$9.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)_vector$9.fromBufferAttribute(this,e),_vector$9.applyMatrix4(t),this.setXYZ(e,_vector$9.x,_vector$9.y,_vector$9.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)_vector$9.fromBufferAttribute(this,e),_vector$9.applyNormalMatrix(t),this.setXYZ(e,_vector$9.x,_vector$9.y,_vector$9.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)_vector$9.fromBufferAttribute(this,e),_vector$9.transformDirection(t),this.setXYZ(e,_vector$9.x,_vector$9.y,_vector$9.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=denormalize(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=normalize(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=denormalize(e,this.array)),e}setX(t,e){return this.normalized&&(e=normalize(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=denormalize(e,this.array)),e}setY(t,e){return this.normalized&&(e=normalize(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=denormalize(e,this.array)),e}setZ(t,e){return this.normalized&&(e=normalize(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=denormalize(e,this.array)),e}setW(t,e){return this.normalized&&(e=normalize(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array),i=normalize(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array),i=normalize(i,this.array),r=normalize(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==StaticDrawUsage&&(t.usage=this.usage),t}}class Int8BufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Int8Array(t),e,n)}}class Uint8BufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Uint8Array(t),e,n)}}class Uint8ClampedBufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}}class Int16BufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Int16Array(t),e,n)}}class Uint16BufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Int32BufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Int32Array(t),e,n)}}class Uint32BufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Float16BufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=fromHalfFloat(this.array[t*this.itemSize]);return this.normalized&&(e=denormalize(e,this.array)),e}setX(t,e){return this.normalized&&(e=normalize(e,this.array)),this.array[t*this.itemSize]=toHalfFloat(e),this}getY(t){let e=fromHalfFloat(this.array[t*this.itemSize+1]);return this.normalized&&(e=denormalize(e,this.array)),e}setY(t,e){return this.normalized&&(e=normalize(e,this.array)),this.array[t*this.itemSize+1]=toHalfFloat(e),this}getZ(t){let e=fromHalfFloat(this.array[t*this.itemSize+2]);return this.normalized&&(e=denormalize(e,this.array)),e}setZ(t,e){return this.normalized&&(e=normalize(e,this.array)),this.array[t*this.itemSize+2]=toHalfFloat(e),this}getW(t){let e=fromHalfFloat(this.array[t*this.itemSize+3]);return this.normalized&&(e=denormalize(e,this.array)),e}setW(t,e){return this.normalized&&(e=normalize(e,this.array)),this.array[t*this.itemSize+3]=toHalfFloat(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array)),this.array[t+0]=toHalfFloat(e),this.array[t+1]=toHalfFloat(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array),i=normalize(i,this.array)),this.array[t+0]=toHalfFloat(e),this.array[t+1]=toHalfFloat(n),this.array[t+2]=toHalfFloat(i),this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array),i=normalize(i,this.array),r=normalize(r,this.array)),this.array[t+0]=toHalfFloat(e),this.array[t+1]=toHalfFloat(n),this.array[t+2]=toHalfFloat(i),this.array[t+3]=toHalfFloat(r),this}}class Float32BufferAttribute extends BufferAttribute{constructor(t,e,n){super(new Float32Array(t),e,n)}}let _id$1=0;const _m1$3=new Matrix4,_obj=new Object3D,_offset=new Vector3,_box$2=new Box3,_boxMorphTargets=new Box3,_vector$8=new Vector3;class BufferGeometry extends EventDispatcher{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_id$1++}),this.uuid=generateUUID$1(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,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(t){return this.index=Array.isArray(t)?new(arrayNeedsUint32(t)?Uint32BufferAttribute:Uint16BufferAttribute)(t,1):t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new Matrix3).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return _m1$3.makeRotationFromQuaternion(t),this.applyMatrix4(_m1$3),this}rotateX(t){return _m1$3.makeRotationX(t),this.applyMatrix4(_m1$3),this}rotateY(t){return _m1$3.makeRotationY(t),this.applyMatrix4(_m1$3),this}rotateZ(t){return _m1$3.makeRotationZ(t),this.applyMatrix4(_m1$3),this}translate(t,e,n){return _m1$3.makeTranslation(t,e,n),this.applyMatrix4(_m1$3),this}scale(t,e,n){return _m1$3.makeScale(t,e,n),this.applyMatrix4(_m1$3),this}lookAt(t){return _obj.lookAt(t),_obj.updateMatrix(),this.applyMatrix4(_obj.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_offset).negate(),this.translate(_offset.x,_offset.y,_offset.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new Float32BufferAttribute(e,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Box3);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingBox.set(new Vector3(-1/0,-1/0,-1/0),new Vector3(1/0,1/0,1/0));else{if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){_box$2.setFromBufferAttribute(e[t]),this.morphTargetsRelative?(_vector$8.addVectors(this.boundingBox.min,_box$2.min),this.boundingBox.expandByPoint(_vector$8),_vector$8.addVectors(this.boundingBox.max,_box$2.max),this.boundingBox.expandByPoint(_vector$8)):(this.boundingBox.expandByPoint(_box$2.min),this.boundingBox.expandByPoint(_box$2.max))}}else this.boundingBox.makeEmpty();isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sphere);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)this.boundingSphere.set(new Vector3,1/0);else if(t){const n=this.boundingSphere.center;if(_box$2.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){_boxMorphTargets.setFromBufferAttribute(e[t]),this.morphTargetsRelative?(_vector$8.addVectors(_box$2.min,_boxMorphTargets.min),_box$2.expandByPoint(_vector$8),_vector$8.addVectors(_box$2.max,_boxMorphTargets.max),_box$2.expandByPoint(_vector$8)):(_box$2.expandByPoint(_boxMorphTargets.min),_box$2.expandByPoint(_boxMorphTargets.max))}_box$2.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)_vector$8.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(_vector$8));if(e)for(let r=0,o=e.length;r<o;r++){const o=e[r],s=this.morphTargetsRelative;for(let e=0,r=o.count;e<r;e++)_vector$8.fromBufferAttribute(o,e),s&&(_offset.fromBufferAttribute(t,e),_vector$8.add(_offset)),i=Math.max(i,n.distanceToSquared(_vector$8))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return;const n=e.position,i=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new BufferAttribute(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),s=[],a=[];for(let t=0;t<n.count;t++)s[t]=new Vector3,a[t]=new Vector3;const l=new Vector3,c=new Vector3,u=new Vector3,h=new Vector2,d=new Vector2,p=new Vector2,f=new Vector3,m=new Vector3;function g(t,e,i){l.fromBufferAttribute(n,t),c.fromBufferAttribute(n,e),u.fromBufferAttribute(n,i),h.fromBufferAttribute(r,t),d.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),c.sub(l),u.sub(l),d.sub(h),p.sub(h);const o=1/(d.x*p.y-p.x*d.y);isFinite(o)&&(f.copy(c).multiplyScalar(p.y).addScaledVector(u,-d.y).multiplyScalar(o),m.copy(u).multiplyScalar(d.x).addScaledVector(c,-p.x).multiplyScalar(o),s[t].add(f),s[e].add(f),s[i].add(f),a[t].add(m),a[e].add(m),a[i].add(m))}let _=this.groups;0===_.length&&(_=[{start:0,count:t.count}]);for(let e=0,n=_.length;e<n;++e){const n=_[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const y=new Vector3,v=new Vector3,x=new Vector3,b=new Vector3;function T(t){x.fromBufferAttribute(i,t),b.copy(x);const e=s[t];y.copy(e),y.sub(x.multiplyScalar(x.dot(e))).normalize(),v.crossVectors(b,e);const n=v.dot(a[t]);o.setXYZW(t,y.x,y.y,y.z,n<0?-1:1)}for(let e=0,n=_.length;e<n;++e){const n=_[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)T(t.getX(e+0)),T(t.getX(e+1)),T(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new BufferAttribute(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new Vector3,r=new Vector3,o=new Vector3,s=new Vector3,a=new Vector3,l=new Vector3,c=new Vector3,u=new Vector3;if(t)for(let h=0,d=t.count;h<d;h+=3){const d=t.getX(h+0),p=t.getX(h+1),f=t.getX(h+2);i.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),o.fromBufferAttribute(e,f),c.subVectors(o,r),u.subVectors(i,r),c.cross(u),s.fromBufferAttribute(n,d),a.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),s.add(c),a.add(c),l.add(c),n.setXYZ(d,s.x,s.y,s.z),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let t=0,s=e.count;t<s;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),o.fromBufferAttribute(e,t+2),c.subVectors(o,r),u.subVectors(i,r),c.cross(u),n.setXYZ(t+0,c.x,c.y,c.z),n.setXYZ(t+1,c.x,c.y,c.z),n.setXYZ(t+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)_vector$8.fromBufferAttribute(t,e),_vector$8.normalize(),t.setXYZ(e,_vector$8.x,_vector$8.y,_vector$8.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,o=new n.constructor(e.length*i);let s=0,a=0;for(let r=0,l=e.length;r<l;r++){s=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)o[a++]=n[s++]}return new BufferAttribute(o,i,r)}if(null===this.index)return this;const e=new BufferGeometry,n=this.index.array,i=this.attributes;for(const r in i){const o=t(i[r],n);e.setAttribute(r,o)}const r=this.morphAttributes;for(const i in r){const o=[],s=r[i];for(let e=0,i=s.length;e<i;e++){const i=t(s[e],n);o.push(i)}e.morphAttributes[i]=o}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let t=0,n=o.length;t<n;t++){const n=o[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){t.data.attributes[e]=n[e].toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],o=[];for(let e=0,i=n.length;e<i;e++){o.push(n[e].toJSON(t.data))}o.length>0&&(i[e]=o,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const s=this.boundingSphere;return null!==s&&(t.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){this.setAttribute(t,i[t].clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let t=0,e=o.length;t<e;t++){const e=o[t];this.addGroup(e.start,e.count,e.materialIndex)}const s=t.boundingBox;null!==s&&(this.boundingBox=s.clone());const a=t.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const _inverseMatrix$3=new Matrix4,_ray$3=new Ray,_sphere$6=new Sphere,_sphereHitAt=new Vector3,_vA$1=new Vector3,_vB$1=new Vector3,_vC$1=new Vector3,_tempA=new Vector3,_morphA=new Vector3,_intersectionPoint=new Vector3,_intersectionPointWorld=new Vector3;class Mesh extends Object3D{constructor(t=new BufferGeometry,e=new MeshBasicMaterial){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.morphAttributes.position,r=n.morphTargetsRelative;e.fromBufferAttribute(n.attributes.position,t);const o=this.morphTargetInfluences;if(i&&o){_morphA.set(0,0,0);for(let n=0,s=i.length;n<s;n++){const s=o[n];0!==s&&(_tempA.fromBufferAttribute(i[n],t),_morphA.addScaledVector(r?_tempA:_tempA.sub(e),s))}e.add(_morphA)}return e}raycast(t,e){const n=this.geometry,i=this.matrixWorld;if(void 0!==this.material){if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere$6.copy(n.boundingSphere),_sphere$6.applyMatrix4(i),_ray$3.copy(t.ray).recast(t.near),!1===_sphere$6.containsPoint(_ray$3.origin)){if(null===_ray$3.intersectSphere(_sphere$6,_sphereHitAt))return;if(_ray$3.origin.distanceToSquared(_sphereHitAt)>(t.far-t.near)**2)return}_inverseMatrix$3.copy(i).invert(),_ray$3.copy(t.ray).applyMatrix4(_inverseMatrix$3),null!==n.boundingBox&&!1===_ray$3.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,_ray$3)}}_computeIntersections(t,e,n){let i;const r=this.geometry,o=this.material,s=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!==s)if(Array.isArray(o))for(let r=0,a=h.length;r<a;r++){const a=h[r],p=o[a.materialIndex];for(let r=Math.max(a.start,d.start),o=Math.min(s.count,Math.min(a.start+a.count,d.start+d.count));r<o;r+=3){i=checkGeometryIntersection(this,p,t,n,l,c,u,s.getX(r),s.getX(r+1),s.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),a=Math.min(s.count,d.start+d.count);r<a;r+=3){i=checkGeometryIntersection(this,o,t,n,l,c,u,s.getX(r),s.getX(r+1),s.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==a)if(Array.isArray(o))for(let r=0,s=h.length;r<s;r++){const s=h[r],p=o[s.materialIndex];for(let r=Math.max(s.start,d.start),o=Math.min(a.count,Math.min(s.start+s.count,d.start+d.count));r<o;r+=3){i=checkGeometryIntersection(this,p,t,n,l,c,u,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=s.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),s=Math.min(a.count,d.start+d.count);r<s;r+=3){i=checkGeometryIntersection(this,o,t,n,l,c,u,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function checkIntersection$1(t,e,n,i,r,o,s,a){let l;if(l=e.side===BackSide?i.intersectTriangle(s,o,r,!0,a):i.intersectTriangle(r,o,s,e.side===FrontSide,a),null===l)return null;_intersectionPointWorld.copy(a),_intersectionPointWorld.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(_intersectionPointWorld);return c<n.near||c>n.far?null:{distance:c,point:_intersectionPointWorld.clone(),object:t}}function checkGeometryIntersection(t,e,n,i,r,o,s,a,l,c){t.getVertexPosition(a,_vA$1),t.getVertexPosition(l,_vB$1),t.getVertexPosition(c,_vC$1);const u=checkIntersection$1(t,e,n,i,_vA$1,_vB$1,_vC$1,_intersectionPoint);if(u){const t=new Vector3;Triangle.getBarycoord(_intersectionPoint,_vA$1,_vB$1,_vC$1,t),r&&(u.uv=Triangle.getInterpolatedAttribute(r,a,l,c,t,new Vector2)),o&&(u.uv1=Triangle.getInterpolatedAttribute(o,a,l,c,t,new Vector2)),s&&(u.normal=Triangle.getInterpolatedAttribute(s,a,l,c,t,new Vector3),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const e={a:a,b:l,c:c,normal:new Vector3,materialIndex:0};Triangle.getNormal(_vA$1,_vB$1,_vC$1,e.normal),u.face=e,u.barycoord=t}return u}class BoxGeometry extends BufferGeometry{constructor(t=1,e=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const s=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const a=[],l=[],c=[],u=[];let h=0,d=0;function p(t,e,n,i,r,o,p,f,m,g,_){const y=o/m,v=p/g,x=o/2,b=p/2,T=f/2,E=m+1,S=g+1;let w=0,A=0;const M=new Vector3;for(let o=0;o<S;o++){const s=o*v-b;for(let a=0;a<E;a++){M[t]=(a*y-x)*i,M[e]=s*r,M[n]=T,l.push(M.x,M.y,M.z),M[t]=0,M[e]=0,M[n]=f>0?1:-1,c.push(M.x,M.y,M.z),u.push(a/m),u.push(1-o/g),w+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const n=h+e+E*(t+1),i=h+(e+1)+E*(t+1),r=h+(e+1)+E*t;a.push(h+e+E*t,n,r),a.push(n,i,r),A+=6}s.addGroup(d,A,_),d+=A,h+=w}p("z","y","x",-1,-1,n,e,t,o,r,0),p("z","y","x",1,-1,n,e,-t,o,r,1),p("x","z","y",1,1,t,n,e,i,o,2),p("x","z","y",1,-1,t,n,-e,i,o,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new Float32BufferAttribute(l,3)),this.setAttribute("normal",new Float32BufferAttribute(c,3)),this.setAttribute("uv",new Float32BufferAttribute(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new BoxGeometry(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function cloneUniforms(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];e[n][i]=r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?null:r.clone():Array.isArray(r)?r.slice():r}}return e}function mergeUniforms(t){const e={};for(let n=0;n<t.length;n++){const i=cloneUniforms(t[n]);for(const t in i)e[t]=i[t]}return e}function cloneUniformsGroups(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function getUnlitUniformColorSpace(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:ColorManagement.workingColorSpace}const UniformsUtils={clone:cloneUniforms,merge:mergeUniforms};var default_vertex="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",default_fragment="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";class ShaderMaterial extends Material{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=default_vertex,this.fragmentShader=default_fragment,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!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=cloneUniforms(t.uniforms),this.uniformsGroups=cloneUniformsGroups(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;e.uniforms[n]=i&&i.isTexture?{type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?{type:"c",value:i.getHex()}:i&&i.isVector2?{type:"v2",value:i.toArray()}:i&&i.isVector3?{type:"v3",value:i.toArray()}:i&&i.isVector4?{type:"v4",value:i.toArray()}:i&&i.isMatrix3?{type:"m3",value:i.toArray()}:i&&i.isMatrix4?{type:"m4",value:i.toArray()}:{value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class Camera extends Object3D{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Matrix4,this.projectionMatrix=new Matrix4,this.projectionMatrixInverse=new Matrix4,this.coordinateSystem=WebGLCoordinateSystem}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const _v3$1=new Vector3,_minTarget=new Vector2,_maxTarget=new Vector2;class PerspectiveCamera extends Camera{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*RAD2DEG*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*DEG2RAD*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*RAD2DEG*Math.atan(Math.tan(.5*DEG2RAD*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){_v3$1.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(_v3$1.x,_v3$1.y).multiplyScalar(-t/_v3$1.z),_v3$1.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(_v3$1.x,_v3$1.y).multiplyScalar(-t/_v3$1.z)}getViewSize(t,e){return this.getViewBounds(t,_minTarget,_maxTarget),e.subVectors(_maxTarget,_minTarget)}setViewOffset(t,e,n,i,r,o){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*DEG2RAD*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const o=this.view;if(null!==this.view&&this.view.enabled){const t=o.fullWidth,s=o.fullHeight;r+=o.offsetX*i/t,e-=o.offsetY*n/s,i*=o.width/t,n*=o.height/s}const s=this.filmOffset;0!==s&&(r+=t*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const fov=-90,aspect=1;class CubeCamera extends Object3D{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new PerspectiveCamera(fov,aspect,t,e);i.layers=this.layers,this.add(i);const r=new PerspectiveCamera(fov,aspect,t,e);r.layers=this.layers,this.add(r);const o=new PerspectiveCamera(fov,aspect,t,e);o.layers=this.layers,this.add(o);const s=new PerspectiveCamera(fov,aspect,t,e);s.layers=this.layers,this.add(s);const a=new PerspectiveCamera(fov,aspect,t,e);a.layers=this.layers,this.add(a);const l=new PerspectiveCamera(fov,aspect,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,o,s,a]=e;for(const t of e)this.remove(t);if(t===WebGLCoordinateSystem)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else{if(t!==WebGPUCoordinateSystem)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,o,s,a,l,c]=this.children,u=t.getRenderTarget(),h=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,o),t.setRenderTarget(n,2,i),t.render(e,s),t.setRenderTarget(n,3,i),t.render(e,a),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=f,t.setRenderTarget(n,5,i),t.render(e,c),t.setRenderTarget(u,h,d),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class CubeTexture extends Texture{constructor(t,e,n,i,r,o,s,a,l,c){super(t=void 0!==t?t:[],e=void 0!==e?e:CubeReflectionMapping,n,i,r,o,s,a,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class WebGLCubeRenderTarget extends WebGLRenderTarget{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1};this.texture=new CubeTexture([n,n,n,n,n,n],e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:LinearFilter}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={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"},i=new BoxGeometry(5,5,5),r=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:BackSide,blending:NoBlending});r.uniforms.tEquirect.value=e;const o=new Mesh(i,r),s=e.minFilter;e.minFilter===LinearMipmapLinearFilter&&(e.minFilter=LinearFilter);return new CubeCamera(1,10,this).update(t,o),e.minFilter=s,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}class FogExp2{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new Color(t),this.density=e}clone(){return new FogExp2(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Fog{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Color(t),this.near=e,this.far=n}clone(){return new Fog(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Scene extends Object3D{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 Euler,this.environmentIntensity=1,this.environmentRotation=new Euler,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class InterleavedBuffer{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=StaticDrawUsage,this.updateRanges=[],this.version=0,this.uuid=generateUUID$1()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID$1()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID$1()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.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 _vector$7=new Vector3;class InterleavedBufferAttribute{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)_vector$7.fromBufferAttribute(this,e),_vector$7.applyMatrix4(t),this.setXYZ(e,_vector$7.x,_vector$7.y,_vector$7.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)_vector$7.fromBufferAttribute(this,e),_vector$7.applyNormalMatrix(t),this.setXYZ(e,_vector$7.x,_vector$7.y,_vector$7.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)_vector$7.fromBufferAttribute(this,e),_vector$7.transformDirection(t),this.setXYZ(e,_vector$7.x,_vector$7.y,_vector$7.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=denormalize(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=normalize(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=normalize(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=normalize(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=normalize(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=normalize(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=denormalize(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=denormalize(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=denormalize(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=denormalize(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array),i=normalize(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=normalize(e,this.array),n=normalize(n,this.array),i=normalize(i,this.array),r=normalize(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new BufferAttribute(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new InterleavedBufferAttribute(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class SpriteMaterial extends Material{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let _geometry;const _intersectPoint=new Vector3,_worldScale=new Vector3,_mvPosition=new Vector3,_alignedPosition=new Vector2,_rotatedPosition=new Vector2,_viewWorldMatrix=new Matrix4,_vA=new Vector3,_vB=new Vector3,_vC=new Vector3,_uvA=new Vector2,_uvB=new Vector2,_uvC=new Vector2;class Sprite extends Object3D{constructor(t=new SpriteMaterial){if(super(),this.isSprite=!0,this.type="Sprite",void 0===_geometry){_geometry=new BufferGeometry;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new InterleavedBuffer(t,5);_geometry.setIndex([0,1,2,0,2,3]),_geometry.setAttribute("position",new InterleavedBufferAttribute(e,3,0,!1)),_geometry.setAttribute("uv",new InterleavedBufferAttribute(e,2,3,!1))}this.geometry=_geometry,this.material=t,this.center=new Vector2(.5,.5)}raycast(t,e){_worldScale.setFromMatrixScale(this.matrixWorld),_viewWorldMatrix.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),_mvPosition.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&_worldScale.multiplyScalar(-_mvPosition.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const o=this.center;transformVertex(_vA.set(-.5,-.5,0),_mvPosition,o,_worldScale,i,r),transformVertex(_vB.set(.5,-.5,0),_mvPosition,o,_worldScale,i,r),transformVertex(_vC.set(.5,.5,0),_mvPosition,o,_worldScale,i,r),_uvA.set(0,0),_uvB.set(1,0),_uvC.set(1,1);let s=t.ray.intersectTriangle(_vA,_vB,_vC,!1,_intersectPoint);if(null===s&&(transformVertex(_vB.set(-.5,.5,0),_mvPosition,o,_worldScale,i,r),_uvB.set(0,1),s=t.ray.intersectTriangle(_vA,_vC,_vB,!1,_intersectPoint),null===s))return;const a=t.ray.origin.distanceTo(_intersectPoint);a<t.near||a>t.far||e.push({distance:a,point:_intersectPoint.clone(),uv:Triangle.getInterpolation(_intersectPoint,_vA,_vB,_vC,_uvA,_uvB,_uvC,new Vector2),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function transformVertex(t,e,n,i,r,o){_alignedPosition.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(_rotatedPosition.x=o*_alignedPosition.x-r*_alignedPosition.y,_rotatedPosition.y=r*_alignedPosition.x+o*_alignedPosition.y):_rotatedPosition.copy(_alignedPosition),t.copy(e),t.x+=_rotatedPosition.x,t.y+=_rotatedPosition.y,t.applyMatrix4(_viewWorldMatrix)}const _v1$2=new Vector3,_v2$1=new Vector3;class LOD extends Object3D{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let r;for(r=0;r<i.length&&!(e<i[r].distance);r++);return i.splice(r,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){const t=e.splice(n,1);return this.remove(t[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let i=e[n].distance;if(e[n].object.visible&&(i-=i*e[n].hysteresis),t<i)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){_v1$2.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(_v1$2);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){_v1$2.setFromMatrixPosition(t.matrixWorld),_v2$1.setFromMatrixPosition(this.matrixWorld);const n=_v1$2.distanceTo(_v2$1)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i<r;i++){let t=e[i].distance;if(e[i].object.visible&&(t-=t*e[i].hysteresis),!(n>=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i<r;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let t=0,i=n.length;t<i;t++){const i=n[t];e.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return e}}const _basePosition=new Vector3,_skinIndex=new Vector4,_skinWeight=new Vector4,_vector3=new Vector3,_matrix4=new Matrix4,_vertex=new Vector3,_sphere$5=new Sphere,_inverseMatrix$2=new Matrix4,_ray$2=new Ray;class SkinnedMesh extends Mesh{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=AttachedBindMode,this.bindMatrix=new Matrix4,this.bindMatrixInverse=new Matrix4,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Box3),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,_vertex),this.boundingBox.expandByPoint(_vertex)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Sphere),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,_vertex),this.boundingSphere.expandByPoint(_vertex)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.matrixWorld;void 0!==this.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),_sphere$5.copy(this.boundingSphere),_sphere$5.applyMatrix4(n),!1!==t.ray.intersectsSphere(_sphere$5)&&(_inverseMatrix$2.copy(n).invert(),_ray$2.copy(t.ray).applyMatrix4(_inverseMatrix$2),null!==this.boundingBox&&!1===_ray$2.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,_ray$2)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Vector4,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===AttachedBindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===DetachedBindMode&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;_skinIndex.fromBufferAttribute(i.attributes.skinIndex,t),_skinWeight.fromBufferAttribute(i.attributes.skinWeight,t),_basePosition.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=_skinWeight.getComponent(t);if(0!==i){const r=_skinIndex.getComponent(t);_matrix4.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(_vector3.copy(_basePosition).applyMatrix4(_matrix4),i)}}return e.applyMatrix4(this.bindMatrixInverse)}}class Bone extends Object3D{constructor(){super(),this.isBone=!0,this.type="Bone"}}class DataTexture extends Texture{constructor(t=null,e=1,n=1,i,r,o,s,a,l=NearestFilter,c=NearestFilter,u,h){super(null,o,s,a,l,c,i,r,u,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const _offsetMatrix=new Matrix4,_identityMatrix$1=new Matrix4;class Skeleton{constructor(t=[],e=[]){this.uuid=generateUUID$1(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new Matrix4)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new Matrix4;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=t.length;i<r;i++){_offsetMatrix.multiplyMatrices(t[i]?t[i].matrixWorld:_identityMatrix$1,e[i]),_offsetMatrix.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new Skeleton(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new DataTexture(e,t,t,RGBAFormat,FloatType);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){let i=e[t.bones[n]];void 0===i&&(i=new Bone),this.bones.push(i),this.boneInverses.push((new Matrix4).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){t.bones.push(e[i].uuid);t.boneInverses.push(n[i].toArray())}return t}}class InstancedBufferAttribute extends BufferAttribute{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const _instanceLocalMatrix=new Matrix4,_instanceWorldMatrix=new Matrix4,_instanceIntersects=[],_box3=new Box3,_identity=new Matrix4,_mesh$1=new Mesh,_sphere$4=new Sphere;class InstancedMesh extends Mesh{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new InstancedBufferAttribute(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<n;t++)this.setMatrixAt(t,_identity)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Box3),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,_instanceLocalMatrix),_box3.copy(t.boundingBox).applyMatrix4(_instanceLocalMatrix),this.boundingBox.union(_box3)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new Sphere),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,_instanceLocalMatrix),_sphere$4.copy(t.boundingSphere).applyMatrix4(_instanceLocalMatrix),this.boundingSphere.union(_sphere$4)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=t*(n.length+1)+1;for(let t=0;t<n.length;t++)n[t]=i[r+t]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(_mesh$1.geometry=this.geometry,_mesh$1.material=this.material,void 0!==_mesh$1.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),_sphere$4.copy(this.boundingSphere),_sphere$4.applyMatrix4(n),!1!==t.ray.intersectsSphere(_sphere$4)))for(let r=0;r<i;r++){this.getMatrixAt(r,_instanceLocalMatrix),_instanceWorldMatrix.multiplyMatrices(n,_instanceLocalMatrix),_mesh$1.matrixWorld=_instanceWorldMatrix,_mesh$1.raycast(t,_instanceIntersects);for(let t=0,n=_instanceIntersects.length;t<n;t++){const n=_instanceIntersects[t];n.instanceId=r,n.object=this,e.push(n)}_instanceIntersects.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new InstancedBufferAttribute(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new DataTexture(new Float32Array(i*this.count),i,this.count,RedFormat,FloatType));const r=this.morphTexture.source.data.data;let o=0;for(let t=0;t<n.length;t++)o+=n[t];const s=i*t;r[s]=this.geometry.morphTargetsRelative?1:1-o,r.set(n,s+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null),this}}const _vector1=new Vector3,_vector2=new Vector3,_normalMatrix=new Matrix3;let Plane$1=class{constructor(t=new Vector3(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=_vector1.subVectors(n,e).cross(_vector2.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(_vector1),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||_normalMatrix.getNormalMatrix(t),i=this.coplanarPoint(_vector1).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}};const _sphere$3=new Sphere,_vector$6=new Vector3;class Frustum{constructor(t=new Plane$1,e=new Plane$1,n=new Plane$1,i=new Plane$1,r=new Plane$1,o=new Plane$1){this.planes=[t,e,n,i,r,o]}set(t,e,n,i,r,o){const s=this.planes;return s[0].copy(t),s[1].copy(e),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=WebGLCoordinateSystem){const n=this.planes,i=t.elements,r=i[0],o=i[1],s=i[2],a=i[3],l=i[4],c=i[5],u=i[6],h=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],_=i[13],y=i[14],v=i[15];if(n[0].setComponents(a-r,h-l,m-d,v-g).normalize(),n[1].setComponents(a+r,h+l,m+d,v+g).normalize(),n[2].setComponents(a+o,h+c,m+p,v+_).normalize(),n[3].setComponents(a-o,h-c,m-p,v-_).normalize(),n[4].setComponents(a-s,h-u,m-f,v-y).normalize(),e===WebGLCoordinateSystem)n[5].setComponents(a+s,h+u,m+f,v+y).normalize();else{if(e!==WebGPUCoordinateSystem)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(s,u,f,y).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),_sphere$3.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),_sphere$3.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(_sphere$3)}intersectsSprite(t){return _sphere$3.center.set(0,0,0),_sphere$3.radius=.7071067811865476,_sphere$3.applyMatrix4(t.matrixWorld),this.intersectsSphere(_sphere$3)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(_vector$6.x=i.normal.x>0?t.max.x:t.min.x,_vector$6.y=i.normal.y>0?t.max.y:t.min.y,_vector$6.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(_vector$6)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function ascIdSort(t,e){return t-e}function sortOpaque(t,e){return t.z-e.z}function sortTransparent(t,e){return e.z-t.z}class MultiDrawRenderList{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){const r=this.pool,o=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const s=r[this.index];o.push(s),this.index++,s.start=t,s.count=e,s.z=n,s.index=i}reset(){this.list.length=0,this.index=0}}const _matrix$1=new Matrix4,_whiteColor=new Color(1,1,1),_frustum=new Frustum,_box$1=new Box3,_sphere$2=new Sphere,_vector$5=new Vector3,_forward=new Vector3,_temp=new Vector3,_renderList=new MultiDrawRenderList,_mesh=new Mesh,_batchIntersects=[];function copyAttributeData(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let o=0;o<r;o++)for(let r=0;r<i;r++)e.setComponent(o+n,r,t.getComponent(o,r))}else e.array.set(t.array,n*i);e.needsUpdate=!0}function copyArrayContents(t,e){if(t.constructor!==e.constructor){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++)e[i]=t[i]}else{const n=Math.min(t.length,e.length);e.set(new t.constructor(t.buffer,0,n))}}class BatchedMesh extends Mesh{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}constructor(t,e,n=2*e,i){super(new BufferGeometry,i),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=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let t=Math.sqrt(4*this._maxInstanceCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new DataTexture(e,t,t,RGBAFormat,FloatType);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),n=new DataTexture(e,t,t,RedIntegerFormat,UnsignedIntType);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),n=new DataTexture(e,t,t,RGBAFormat,FloatType);n.colorSpace=ColorManagement.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(const i in t.attributes){const r=t.getAttribute(i),{array:o,itemSize:s,normalized:a}=r,l=new o.constructor(n*s),c=new BufferAttribute(l,s,a);e.setAttribute(i,c)}if(null!==t.getIndex()){const t=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new BufferAttribute(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Box3);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,_matrix$1),this.getBoundingBoxAt(i,_box$1).applyMatrix4(_matrix$1),t.union(_box$1)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sphere);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,_matrix$1),this.getBoundingSphereAt(i,_sphere$2).applyMatrix4(_matrix$1),t.union(_sphere$2)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ascIdSort),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=e):(n=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;_matrix$1.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(_whiteColor.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={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;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const o=t.getIndex();if(null!==o&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?o.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let s;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ascIdSort),s=this._availableGeometryIds.shift(),r[s]=i):(s=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(s,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,s}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),o=e.getIndex(),s=this._geometryInfo[t];if(i&&o.count>s.reservedIndexCount||e.attributes.position.count>s.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const a=s.vertexStart,l=s.reservedVertexCount;s.vertexCount=e.getAttribute("position").count;for(const t in n.attributes){const i=e.getAttribute(t),r=n.getAttribute(t);copyAttributeData(i,r,a);const o=i.itemSize;for(let t=i.count,e=l;t<e;t++){const e=a+t;for(let t=0;t<o;t++)r.setComponent(e,t,0)}r.needsUpdate=!0,r.addUpdateRange(a*o,l*o)}if(i){const t=s.indexStart,n=s.reservedIndexCount;s.indexCount=e.getIndex().count;for(let e=0;e<o.count;e++)r.setX(t+e,a+o.getX(e));for(let e=o.count,i=n;e<i;e++)r.setX(t+e,a);r.needsUpdate=!0,r.addUpdateRange(t,s.reservedIndexCount)}return s.start=i?s.indexStart:s.vertexStart,s.count=i?s.indexCount:s.vertexCount,s.boundingBox=null,null!==e.boundingBox&&(s.boundingBox=e.boundingBox.clone()),s.boundingSphere=null,null!==e.boundingSphere&&(s.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||!1===e[t].active)return this;const n=this._instanceInfo;for(let e=0,i=n.length;e<i;e++)n[e].geometryIndex===t&&this.deleteInstance(e);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map(((t,e)=>e)).sort(((t,e)=>n[t].vertexStart-n[e].vertexStart)),r=this.geometry;for(let o=0,s=n.length;o<s;o++){const s=n[i[o]];if(!1!==s.active){if(null!==r.index){if(s.indexStart!==e){const{indexStart:n,vertexStart:i,reservedIndexCount:o}=s,a=r.index,l=a.array,c=t-i;for(let t=n;t<n+o;t++)l[t]=l[t]+c;a.array.copyWithin(e,n,n+o),a.addUpdateRange(e,o),s.indexStart=e}e+=s.reservedIndexCount}if(s.vertexStart!==t){const{vertexStart:e,reservedVertexCount:n}=s,i=r.attributes;for(const r in i){const o=i[r],{array:s,itemSize:a}=o;s.copyWithin(t*a,e*a,(e+n)*a),o.addUpdateRange(t*a,n*a)}s.vertexStart=t}t+=s.reservedVertexCount,s.start=r.index?s.indexStart:s.vertexStart,this._nextIndexStart=r.index?s.indexStart+s.reservedIndexCount:0,this._nextVertexStart=s.vertexStart+s.reservedVertexCount}}return this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Box3,e=n.index,r=n.attributes.position;for(let n=i.start,o=i.start+i.count;n<o;n++){let i=n;e&&(i=e.getX(i)),t.expandByPoint(_vector$5.fromBufferAttribute(r,i))}i.boundingBox=t}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new Sphere;this.getBoundingBoxAt(t,_box$1),_box$1.getCenter(e.center);const r=n.index,o=n.attributes.position;let s=0;for(let t=i.start,n=i.start+i.count;t<n;t++){let n=t;r&&(n=r.getX(n)),_vector$5.fromBufferAttribute(o,n),s=Math.max(s,e.center.distanceToSquared(_vector$5))}e.radius=Math.sqrt(s),i.boundingSphere=e}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const n=this._matricesTexture;return e.toArray(this._matricesTexture.image.data,16*t),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,16*t)}setColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,4*t),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,4*t)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e||(this._instanceInfo[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(ascIdSort);e[e.length-1]===n.length;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const i=new Int32Array(t),r=new Int32Array(t);copyArrayContents(this._multiDrawCounts,i),copyArrayContents(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=t;const o=this._indirectTexture,s=this._matricesTexture,a=this._colorsTexture;o.dispose(),this._initIndirectTexture(),copyArrayContents(o.image.data,this._indirectTexture.image.data),s.dispose(),this._initMatricesTexture(),copyArrayContents(s.image.data,this._matricesTexture.image.data),a&&(a.dispose(),this._initColorsTexture(),copyArrayContents(a.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const n=[...this._geometryInfo].filter((t=>t.active));if(Math.max(...n.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index){if(Math.max(...n.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`)}const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new BufferGeometry,this._initializeGeometry(i));const r=this.geometry;i.index&&copyArrayContents(i.index.array,r.index.array);for(const t in i.attributes)copyArrayContents(i.attributes[t].array,r.attributes[t].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,o=this.geometry;_mesh.material=this.material,_mesh.geometry.index=o.index,_mesh.geometry.attributes=o.attributes,null===_mesh.geometry.boundingBox&&(_mesh.geometry.boundingBox=new Box3),null===_mesh.geometry.boundingSphere&&(_mesh.geometry.boundingSphere=new Sphere);for(let o=0,s=n.length;o<s;o++){if(!n[o].visible||!n[o].active)continue;const s=n[o].geometryIndex,a=i[s];_mesh.geometry.setDrawRange(a.start,a.count),this.getMatrixAt(o,_mesh.matrixWorld).premultiply(r),this.getBoundingBoxAt(s,_mesh.geometry.boundingBox),this.getBoundingSphereAt(s,_mesh.geometry.boundingSphere),_mesh.raycast(t,_batchIntersects);for(let t=0,n=_batchIntersects.length;t<n;t++){const n=_batchIntersects[t];n.object=this,n.batchId=o,e.push(n)}_batchIntersects.length=0}_mesh.material=null,_mesh.geometry.index=null,_mesh.geometry.attributes={},_mesh.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map((t=>({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),s=null===o?1:o.array.BYTES_PER_ELEMENT,a=this._instanceInfo,l=this._multiDrawStarts,c=this._multiDrawCounts,u=this._geometryInfo,h=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;h&&(_matrix$1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),_frustum.setFromProjectionMatrix(_matrix$1,t.coordinateSystem));let f=0;if(this.sortObjects){_matrix$1.copy(this.matrixWorld).invert(),_vector$5.setFromMatrixPosition(n.matrixWorld).applyMatrix4(_matrix$1),_forward.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(_matrix$1);for(let t=0,e=a.length;t<e;t++)if(a[t].visible&&a[t].active){const e=a[t].geometryIndex;this.getMatrixAt(t,_matrix$1),this.getBoundingSphereAt(e,_sphere$2).applyMatrix4(_matrix$1);let n=!1;if(h&&(n=!_frustum.intersectsSphere(_sphere$2)),!n){const n=u[e],i=_temp.subVectors(_sphere$2.center,_vector$5).dot(_forward);_renderList.push(n.start,n.count,i,t)}}const t=_renderList.list,e=this.customSort;null===e?t.sort(r.transparent?sortTransparent:sortOpaque):e.call(this,t,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];l[f]=n.start*s,c[f]=n.count,p[f]=n.index,f++}_renderList.reset()}else for(let t=0,e=a.length;t<e;t++)if(a[t].visible&&a[t].active){const e=a[t].geometryIndex;let n=!1;if(h&&(this.getMatrixAt(t,_matrix$1),this.getBoundingSphereAt(e,_sphere$2).applyMatrix4(_matrix$1),n=!_frustum.intersectsSphere(_sphere$2)),!n){const n=u[e];l[f]=n.start*s,c[f]=n.count,p[f]=t,f++}}d.needsUpdate=!0,this._multiDrawCount=f,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,o){this.onBeforeRender(t,null,i,r,o)}}class LineBasicMaterial extends Material{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Color(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const _vStart=new Vector3,_vEnd=new Vector3,_inverseMatrix$1=new Matrix4,_ray$1=new Ray,_sphere$1=new Sphere,_intersectPointOnRay=new Vector3,_intersectPointOnSegment=new Vector3;class Line extends Object3D{constructor(t=new BufferGeometry,e=new LineBasicMaterial){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)_vStart.fromBufferAttribute(e,t-1),_vEnd.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=_vStart.distanceTo(_vEnd);t.setAttribute("lineDistance",new Float32BufferAttribute(n,1))}return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere$1.copy(n.boundingSphere),_sphere$1.applyMatrix4(i),_sphere$1.radius+=r,!1===t.ray.intersectsSphere(_sphere$1))return;_inverseMatrix$1.copy(i).invert(),_ray$1.copy(t.ray).applyMatrix4(_inverseMatrix$1);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s,l=this.isLineSegments?2:1,c=n.index,u=n.attributes.position;if(null!==c){const n=Math.max(0,o.start),i=Math.min(c.count,o.start+o.count);for(let r=n,o=i-1;r<o;r+=l){const n=c.getX(r),i=c.getX(r+1),o=checkIntersection(this,t,_ray$1,a,n,i);o&&e.push(o)}if(this.isLineLoop){const r=c.getX(i-1),o=c.getX(n),s=checkIntersection(this,t,_ray$1,a,r,o);s&&e.push(s)}}else{const n=Math.max(0,o.start),i=Math.min(u.count,o.start+o.count);for(let r=n,o=i-1;r<o;r+=l){const n=checkIntersection(this,t,_ray$1,a,r,r+1);n&&e.push(n)}if(this.isLineLoop){const r=checkIntersection(this,t,_ray$1,a,i-1,n);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function checkIntersection(t,e,n,i,r,o){const s=t.geometry.attributes.position;_vStart.fromBufferAttribute(s,r),_vEnd.fromBufferAttribute(s,o);if(n.distanceSqToSegment(_vStart,_vEnd,_intersectPointOnRay,_intersectPointOnSegment)>i)return;_intersectPointOnRay.applyMatrix4(t.matrixWorld);const a=e.ray.origin.distanceTo(_intersectPointOnRay);return a<e.near||a>e.far?void 0:{distance:a,point:_intersectPointOnSegment.clone().applyMatrix4(t.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:t}}const _start=new Vector3,_end=new Vector3;class LineSegments extends Line{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)_start.fromBufferAttribute(e,t),_end.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+_start.distanceTo(_end);t.setAttribute("lineDistance",new Float32BufferAttribute(n,1))}return this}}class LineLoop extends Line{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class PointsMaterial extends Material{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const _inverseMatrix=new Matrix4,_ray=new Ray,_sphere=new Sphere,_position$2=new Vector3;class Points extends Object3D{constructor(t=new BufferGeometry,e=new PointsMaterial){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere.copy(n.boundingSphere),_sphere.applyMatrix4(i),_sphere.radius+=r,!1===t.ray.intersectsSphere(_sphere))return;_inverseMatrix.copy(i).invert(),_ray.copy(t.ray).applyMatrix4(_inverseMatrix);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,o.start),r=Math.min(l.count,o.start+o.count);n<r;n++){const r=l.getX(n);_position$2.fromBufferAttribute(c,r),testPoint(_position$2,r,a,i,t,e,this)}}else{for(let n=Math.max(0,o.start),r=Math.min(c.count,o.start+o.count);n<r;n++)_position$2.fromBufferAttribute(c,n),testPoint(_position$2,n,a,i,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function testPoint(t,e,n,i,r,o,s){const a=_ray.distanceSqToPoint(t);if(a<n){const n=new Vector3;_ray.closestPointToPoint(t,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;o.push({distance:l,distanceToRay:Math.sqrt(a),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:s})}}class Group extends Object3D{constructor(){super(),this.isGroup=!0,this.type="Group"}}class VideoTexture extends Texture{constructor(t,e,n,i,r,o,s,a,l){super(t,e,n,i,r,o,s,a,l),this.isVideoTexture=!0,this.minFilter=void 0!==o?o:LinearFilter,this.magFilter=void 0!==r?r:LinearFilter,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class FramebufferTexture extends Texture{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.generateMipmaps=!1,this.needsUpdate=!0}}class CompressedTexture extends Texture{constructor(t,e,n,i,r,o,s,a,l,c,u,h){super(null,o,s,a,l,c,i,r,u,h),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class CompressedArrayTexture extends CompressedTexture{constructor(t,e,n,i,r,o){super(t,e,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=ClampToEdgeWrapping,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class CompressedCubeTexture extends CompressedTexture{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,CubeReflectionMapping),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class CanvasTexture extends Texture{constructor(t,e,n,i,r,o,s,a,l){super(t,e,n,i,r,o,s,a,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class DepthTexture extends Texture{constructor(t,e,n,i,r,o,s,a,l,c=DepthFormat){if(c!==DepthFormat&&c!==DepthStencilFormat)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===DepthFormat&&(n=UnsignedIntType),void 0===n&&c===DepthStencilFormat&&(n=UnsignedInt248Type),super(null,i,r,o,s,a,c,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==s?s:NearestFilter,this.minFilter=void 0!==a?a:NearestFilter,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class Curve{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const r=n.length;let o;o=e||t*n[r-1];let s,a=0,l=r-1;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),s=n[i]-o,s<0)a=i+1;else{if(!(s>0)){l=i;break}l=i-1}if(i=l,n[i]===o)return i/(r-1);const c=n[i];return(i+(o-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),s=this.getPoint(r),a=e||(o.isVector2?new Vector2:new Vector3);return a.copy(s).sub(o).normalize(),a}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new Vector3,i=[],r=[],o=[],s=new Vector3,a=new Matrix4;for(let e=0;e<=t;e++){i[e]=this.getTangentAt(e/t,new Vector3)}r[0]=new Vector3,o[0]=new Vector3;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),h<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),o[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),o[e]=o[e-1].clone(),s.crossVectors(i[e-1],i[e]),s.length()>Number.EPSILON){s.normalize();const t=Math.acos(clamp(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(a.makeRotationAxis(s,t))}o[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(clamp(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(s.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(a.makeRotationAxis(i[n],e*n)),o[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class EllipseCurve extends Curve{constructor(t=0,e=0,n=1,i=1,r=0,o=2*Math.PI,s=!1,a=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=s,this.aRotation=a}getPoint(t,e=new Vector2){const n=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=o?0:i),!0!==this.aClockwise||o||(r===i?r=-i:r-=i);const s=this.aStartAngle+t*r;let a=this.aX+this.xRadius*Math.cos(s),l=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=a-this.aX,i=l-this.aY;a=n*t-i*e+this.aX,l=n*e+i*t+this.aY}return n.set(a,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class ArcCurve extends EllipseCurve{constructor(t,e,n,i,r,o){super(t,e,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function CubicPoly(){let t=0,e=0,n=0,i=0;function r(r,o,s,a){t=r,e=s,n=-3*r+3*o-2*s-a,i=2*r-2*o+s+a}return{initCatmullRom:function(t,e,n,i,o){r(e,n,o*(n-t),o*(i-e))},initNonuniformCatmullRom:function(t,e,n,i,o,s,a){let l=(e-t)/o-(n-t)/(o+s)+(n-e)/s,c=(n-e)/s-(i-e)/(s+a)+(i-n)/a;l*=s,c*=s,r(e,n,l,c)},calc:function(r){const o=r*r;return t+e*r+n*o+i*(o*r)}}}const tmp=new Vector3,px=new CubicPoly,py=new CubicPoly,pz=new CubicPoly;class CatmullRomCurve3 extends Curve{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new Vector3){const n=e,i=this.points,r=i.length,o=(r-(this.closed?0:1))*t;let s,a,l=Math.floor(o),c=o-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?s=i[(l-1)%r]:(tmp.subVectors(i[0],i[1]).add(i[0]),s=tmp);const u=i[l%r],h=i[(l+1)%r];if(this.closed||l+2<r?a=i[(l+2)%r]:(tmp.subVectors(i[r-1],i[r-2]).add(i[r-1]),a=tmp),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(s.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(h),t),i=Math.pow(h.distanceToSquared(a),t);n<1e-4&&(n=1),e<1e-4&&(e=n),i<1e-4&&(i=n),px.initNonuniformCatmullRom(s.x,u.x,h.x,a.x,e,n,i),py.initNonuniformCatmullRom(s.y,u.y,h.y,a.y,e,n,i),pz.initNonuniformCatmullRom(s.z,u.z,h.z,a.z,e,n,i)}else"catmullrom"===this.curveType&&(px.initCatmullRom(s.x,u.x,h.x,a.x,this.tension),py.initCatmullRom(s.y,u.y,h.y,a.y,this.tension),pz.initCatmullRom(s.z,u.z,h.z,a.z,this.tension));return n.set(px.calc(c),py.calc(c),pz.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){this.points.push(t.points[e].clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){t.points.push(this.points[e].toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Vector3).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function CatmullRom(t,e,n,i,r){const o=.5*(i-e),s=.5*(r-n),a=t*t;return(2*n-2*i+o+s)*(t*a)+(-3*n+3*i-2*o-s)*a+o*t+n}function QuadraticBezierP0(t,e){const n=1-t;return n*n*e}function QuadraticBezierP1(t,e){return 2*(1-t)*t*e}function QuadraticBezierP2(t,e){return t*t*e}function QuadraticBezier(t,e,n,i){return QuadraticBezierP0(t,e)+QuadraticBezierP1(t,n)+QuadraticBezierP2(t,i)}function CubicBezierP0(t,e){const n=1-t;return n*n*n*e}function CubicBezierP1(t,e){const n=1-t;return 3*n*n*t*e}function CubicBezierP2(t,e){return 3*(1-t)*t*t*e}function CubicBezierP3(t,e){return t*t*t*e}function CubicBezier(t,e,n,i,r){return CubicBezierP0(t,e)+CubicBezierP1(t,n)+CubicBezierP2(t,i)+CubicBezierP3(t,r)}class CubicBezierCurve extends Curve{constructor(t=new Vector2,e=new Vector2,n=new Vector2,i=new Vector2){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Vector2){const n=e,i=this.v0,r=this.v1,o=this.v2,s=this.v3;return n.set(CubicBezier(t,i.x,r.x,o.x,s.x),CubicBezier(t,i.y,r.y,o.y,s.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class CubicBezierCurve3 extends Curve{constructor(t=new Vector3,e=new Vector3,n=new Vector3,i=new Vector3){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Vector3){const n=e,i=this.v0,r=this.v1,o=this.v2,s=this.v3;return n.set(CubicBezier(t,i.x,r.x,o.x,s.x),CubicBezier(t,i.y,r.y,o.y,s.y),CubicBezier(t,i.z,r.z,o.z,s.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class LineCurve extends Curve{constructor(t=new Vector2,e=new Vector2){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Vector2){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Vector2){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class LineCurve3 extends Curve{constructor(t=new Vector3,e=new Vector3){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Vector3){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Vector3){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class QuadraticBezierCurve extends Curve{constructor(t=new Vector2,e=new Vector2,n=new Vector2){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Vector2){const n=e,i=this.v0,r=this.v1,o=this.v2;return n.set(QuadraticBezier(t,i.x,r.x,o.x),QuadraticBezier(t,i.y,r.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class QuadraticBezierCurve3 extends Curve{constructor(t=new Vector3,e=new Vector3,n=new Vector3){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Vector3){const n=e,i=this.v0,r=this.v1,o=this.v2;return n.set(QuadraticBezier(t,i.x,r.x,o.x),QuadraticBezier(t,i.y,r.y,o.y),QuadraticBezier(t,i.z,r.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class SplineCurve extends Curve{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new Vector2){const n=e,i=this.points,r=(i.length-1)*t,o=Math.floor(r),s=r-o,a=i[0===o?o:o-1],l=i[o],c=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(CatmullRom(s,a.x,l.x,c.x,u.x),CatmullRom(s,a.y,l.y,c.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){this.points.push(t.points[e].clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){t.points.push(this.points[e].toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new Vector2).fromArray(n))}return this}}var Curves=Object.freeze({__proto__:null,ArcCurve:ArcCurve,CatmullRomCurve3:CatmullRomCurve3,CubicBezierCurve:CubicBezierCurve,CubicBezierCurve3:CubicBezierCurve3,EllipseCurve:EllipseCurve,LineCurve:LineCurve,LineCurve3:LineCurve3,QuadraticBezierCurve:QuadraticBezierCurve,QuadraticBezierCurve3:QuadraticBezierCurve3,SplineCurve:SplineCurve});class CurvePath extends Curve{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){this.curves.push(new Curves[!0===t.isVector2?"LineCurve":"LineCurve3"](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const t=i[r]-n,o=this.curves[r],s=o.getLength();return o.getPointAt(0===s?0:1-t/s,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.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 t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const o=r[i],s=o.getPoints(o.isEllipseCurve?2*t:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t);for(let t=0;t<s.length;t++){const i=s[t];n&&n.equals(i)||(e.push(i),n=i)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){this.curves.push(t.curves[e].clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){t.curves.push(this.curves[e].toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new Curves[n.type]).fromJSON(n))}return this}}class Path extends CurvePath{constructor(t){super(),this.type="Path",this.currentPoint=new Vector2,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new LineCurve(this.currentPoint.clone(),new Vector2(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const r=new QuadraticBezierCurve(this.currentPoint.clone(),new Vector2(t,e),new Vector2(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,o){const s=new CubicBezierCurve(this.currentPoint.clone(),new Vector2(t,e),new Vector2(n,i),new Vector2(r,o));return this.curves.push(s),this.currentPoint.set(r,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new SplineCurve(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,o){return this.absarc(t+this.currentPoint.x,e+this.currentPoint.y,n,i,r,o),this}absarc(t,e,n,i,r,o){return this.absellipse(t,e,n,n,i,r,o),this}ellipse(t,e,n,i,r,o,s,a){return this.absellipse(t+this.currentPoint.x,e+this.currentPoint.y,n,i,r,o,s,a),this}absellipse(t,e,n,i,r,o,s,a){const l=new EllipseCurve(t,e,n,i,r,o,s,a);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class LatheGeometry extends BufferGeometry{constructor(t=[new Vector2(0,-.5),new Vector2(.5,0),new Vector2(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=clamp(i,0,2*Math.PI);const r=[],o=[],s=[],a=[],l=[],c=1/e,u=new Vector3,h=new Vector2,d=new Vector3,p=new Vector3,f=new Vector3;let m=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].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 t.length-1:a.push(f.x,f.y,f.z);break;default:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].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<=e;r++){const d=n+r*c*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=t.length-1;n++){u.x=t[n].x*p,u.y=t[n].y,u.z=t[n].x*f,o.push(u.x,u.y,u.z),h.x=r/e,h.y=n/(t.length-1),s.push(h.x,h.y);l.push(a[3*n+0]*p,a[3*n+1],a[3*n+0]*f)}}for(let n=0;n<e;n++)for(let e=0;e<t.length-1;e++){const i=e+n*t.length,o=i+t.length,s=i+t.length+1,a=i+1;r.push(i,o,a),r.push(s,a,o)}this.setIndex(r),this.setAttribute("position",new Float32BufferAttribute(o,3)),this.setAttribute("uv",new Float32BufferAttribute(s,2)),this.setAttribute("normal",new Float32BufferAttribute(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new LatheGeometry(t.points,t.segments,t.phiStart,t.phiLength)}}class CapsuleGeometry extends LatheGeometry{constructor(t=1,e=1,n=4,i=8){const r=new Path;r.absarc(0,-e/2,t,1.5*Math.PI,0),r.absarc(0,e/2,t,0,.5*Math.PI),super(r.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:n,radialSegments:i}}static fromJSON(t){return new CapsuleGeometry(t.radius,t.length,t.capSegments,t.radialSegments)}}class CircleGeometry extends BufferGeometry{constructor(t=1,e=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],o=[],s=[],a=[],l=new Vector3,c=new Vector2;o.push(0,0,0),s.push(0,0,1),a.push(.5,.5);for(let r=0,u=3;r<=e;r++,u+=3){const h=n+r/e*i;l.x=t*Math.cos(h),l.y=t*Math.sin(h),o.push(l.x,l.y,l.z),s.push(0,0,1),c.x=(o[u]/t+1)/2,c.y=(o[u+1]/t+1)/2,a.push(c.x,c.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new Float32BufferAttribute(o,3)),this.setAttribute("normal",new Float32BufferAttribute(s,3)),this.setAttribute("uv",new Float32BufferAttribute(a,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new CircleGeometry(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class CylinderGeometry extends BufferGeometry{constructor(t=1,e=1,n=1,i=32,r=1,o=!1,s=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:s,thetaLength:a};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],u=[],h=[],d=[];let p=0;const f=[],m=n/2;let g=0;function _(n){const r=p,o=new Vector2,f=new Vector3;let _=0;const y=!0===n?t:e,v=!0===n?1:-1;for(let t=1;t<=i;t++)u.push(0,m*v,0),h.push(0,v,0),d.push(.5,.5),p++;const x=p;for(let t=0;t<=i;t++){const e=t/i*a+s,n=Math.cos(e),r=Math.sin(e);f.x=y*r,f.y=m*v,f.z=y*n,u.push(f.x,f.y,f.z),h.push(0,v,0),o.x=.5*n+.5,o.y=.5*r*v+.5,d.push(o.x,o.y),p++}for(let t=0;t<i;t++){const e=r+t,i=x+t;!0===n?c.push(i,i+1,e):c.push(i+1,i,e),_+=3}l.addGroup(g,_,!0===n?1:2),g+=_}!function(){const o=new Vector3,_=new Vector3;let y=0;const v=(e-t)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,y=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*a+s,l=Math.sin(r),f=Math.cos(r);_.x=y*l,_.y=-g*n+m,_.z=y*f,u.push(_.x,_.y,_.z),o.set(l,v,f).normalize(),h.push(o.x,o.y,o.z),d.push(e,1-g),c.push(p++)}f.push(c)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const o=f[i+1][n],s=f[i+1][n+1],a=f[i][n+1];(t>0||0!==i)&&(c.push(f[i][n],o,a),y+=3),(e>0||i!==r-1)&&(c.push(o,s,a),y+=3)}l.addGroup(g,y,0),g+=y}(),!1===o&&(t>0&&_(!0),e>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new Float32BufferAttribute(u,3)),this.setAttribute("normal",new Float32BufferAttribute(h,3)),this.setAttribute("uv",new Float32BufferAttribute(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new CylinderGeometry(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ConeGeometry extends CylinderGeometry{constructor(t=1,e=1,n=32,i=1,r=!1,o=0,s=2*Math.PI){super(0,t,e,n,i,r,o,s),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:s}}static fromJSON(t){return new ConeGeometry(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class PolyhedronGeometry extends BufferGeometry{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],o=[];function s(t,e,n,i){const r=i+1,o=[];for(let i=0;i<=r;i++){o[i]=[];const s=t.clone().lerp(n,i/r),a=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)o[i][t]=0===t&&i===r?s:s.clone().lerp(a,t/l)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const n=Math.floor(e/2);e%2==0?(a(o[t][n+1]),a(o[t+1][n]),a(o[t][n])):(a(o[t][n+1]),a(o[t+1][n+1]),a(o[t+1][n]))}}function a(t){r.push(t.x,t.y,t.z)}function l(e,n){const i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function c(t,e,n,i){i<0&&1===t.x&&(o[e]=t.x-1),0===n.x&&0===n.z&&(o[e]=i/2/Math.PI+.5)}function u(t){return Math.atan2(t.z,-t.x)}!function(t){const n=new Vector3,i=new Vector3,r=new Vector3;for(let o=0;o<e.length;o+=3)l(e[o+0],n),l(e[o+1],i),l(e[o+2],r),s(n,i,r,t)}(i),function(t){const e=new Vector3;for(let n=0;n<r.length;n+=3)e.x=r[n+0],e.y=r[n+1],e.z=r[n+2],e.normalize().multiplyScalar(t),r[n+0]=e.x,r[n+1]=e.y,r[n+2]=e.z}(n),function(){const t=new Vector3;for(let n=0;n<r.length;n+=3){t.x=r[n+0],t.y=r[n+1],t.z=r[n+2];const i=u(t)/2/Math.PI+.5,s=(e=t,Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5);o.push(i,1-s)}var e;(function(){const t=new Vector3,e=new Vector3,n=new Vector3,i=new Vector3,s=new Vector2,a=new Vector2,l=new Vector2;for(let h=0,d=0;h<r.length;h+=9,d+=6){t.set(r[h+0],r[h+1],r[h+2]),e.set(r[h+3],r[h+4],r[h+5]),n.set(r[h+6],r[h+7],r[h+8]),s.set(o[d+0],o[d+1]),a.set(o[d+2],o[d+3]),l.set(o[d+4],o[d+5]),i.copy(t).add(e).add(n).divideScalar(3);const p=u(i);c(s,d+0,t,p),c(a,d+2,e,p),c(l,d+4,n,p)}})(),function(){for(let t=0;t<o.length;t+=6){const e=o[t+0],n=o[t+2],i=o[t+4],r=Math.max(e,n,i),s=Math.min(e,n,i);r>.9&&s<.1&&(e<.2&&(o[t+0]+=1),n<.2&&(o[t+2]+=1),i<.2&&(o[t+4]+=1))}}()}(),this.setAttribute("position",new Float32BufferAttribute(r,3)),this.setAttribute("normal",new Float32BufferAttribute(r.slice(),3)),this.setAttribute("uv",new Float32BufferAttribute(o,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new PolyhedronGeometry(t.vertices,t.indices,t.radius,t.details)}}class DodecahedronGeometry extends PolyhedronGeometry{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[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],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new DodecahedronGeometry(t.radius,t.detail)}}const _v0$3=new Vector3,_v1$1=new Vector3,_normal=new Vector3,_triangle=new Triangle;class EdgesGeometry extends BufferGeometry{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=Math.pow(10,4),i=Math.cos(DEG2RAD*e),r=t.getIndex(),o=t.getAttribute("position"),s=r?r.count:o.count,a=[0,0,0],l=["a","b","c"],c=new Array(3),u={},h=[];for(let t=0;t<s;t+=3){r?(a[0]=r.getX(t),a[1]=r.getX(t+1),a[2]=r.getX(t+2)):(a[0]=t,a[1]=t+1,a[2]=t+2);const{a:e,b:s,c:d}=_triangle;if(e.fromBufferAttribute(o,a[0]),s.fromBufferAttribute(o,a[1]),d.fromBufferAttribute(o,a[2]),_triangle.getNormal(_normal),c[0]=`${Math.round(e.x*n)},${Math.round(e.y*n)},${Math.round(e.z*n)}`,c[1]=`${Math.round(s.x*n)},${Math.round(s.y*n)},${Math.round(s.z*n)}`,c[2]=`${Math.round(d.x*n)},${Math.round(d.y*n)},${Math.round(d.z*n)}`,c[0]!==c[1]&&c[1]!==c[2]&&c[2]!==c[0])for(let t=0;t<3;t++){const e=(t+1)%3,n=c[t],r=c[e],o=_triangle[l[t]],s=_triangle[l[e]],d=`${n}_${r}`,p=`${r}_${n}`;p in u&&u[p]?(_normal.dot(u[p].normal)<=i&&(h.push(o.x,o.y,o.z),h.push(s.x,s.y,s.z)),u[p]=null):d in u||(u[d]={index0:a[t],index1:a[e],normal:_normal.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:n}=u[t];_v0$3.fromBufferAttribute(o,e),_v1$1.fromBufferAttribute(o,n),h.push(_v0$3.x,_v0$3.y,_v0$3.z),h.push(_v1$1.x,_v1$1.y,_v1$1.z)}this.setAttribute("position",new Float32BufferAttribute(h,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class Shape extends Path{constructor(t){super(t),this.uuid=generateUUID$1(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){this.holes.push(t.holes[e].clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){t.holes.push(this.holes[e].toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new Path).fromJSON(n))}return this}}const Earcut={triangulate:function(t,e,n=2){const i=e&&e.length,r=i?e[0]*n:t.length;let o=linkedList(t,0,r,n,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c,u,h,d,p;if(i&&(o=eliminateHoles(t,e,o,n)),t.length>80*n){a=c=t[0],l=u=t[1];for(let e=n;e<r;e+=n)h=t[e],d=t[e+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-a,u-l),p=0!==p?32767/p:0}return earcutLinked(o,s,n,a,l,p,0),s}};function linkedList(t,e,n,i,r){let o,s;if(r===signedArea(t,e,n,i)>0)for(o=e;o<n;o+=i)s=insertNode(o,t[o],t[o+1],s);else for(o=n-i;o>=e;o-=i)s=insertNode(o,t[o],t[o+1],s);return s&&equals(s,s.next)&&(removeNode(s),s=s.next),s}function filterPoints(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!equals(i,i.next)&&0!==area(i.prev,i,i.next))i=i.next;else{if(removeNode(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function earcutLinked(t,e,n,i,r,o,s){if(!t)return;!s&&o&&indexCurve(t,i,r,o);let a,l,c=t;for(;t.prev!==t.next;)if(a=t.prev,l=t.next,o?isEarHashed(t,i,r,o):isEar(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),removeNode(t),t=l.next,c=l.next;else if((t=l)===c){s?1===s?earcutLinked(t=cureLocalIntersections(filterPoints(t),e,n),e,n,i,r,o,2):2===s&&splitEarcut(t,e,n,i,r,o):earcutLinked(filterPoints(t),e,n,i,r,o,1);break}}function isEar(t){const e=t.prev,n=t,i=t.next;if(area(e,n,i)>=0)return!1;const r=e.x,o=n.x,s=i.x,a=e.y,l=n.y,c=i.y,u=r<o?r<s?r:s:o<s?o:s,h=a<l?a<c?a:c:l<c?l:c,d=r>o?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=i.next;for(;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&pointInTriangle(r,a,o,l,s,c,f.x,f.y)&&area(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function isEarHashed(t,e,n,i){const r=t.prev,o=t,s=t.next;if(area(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=a<l?a<c?a:c:l<c?l:c,f=u<h?u<d?u:d:h<d?h:d,m=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,_=zOrder(p,f,e,n,i),y=zOrder(m,g,e,n,i);let v=t.prevZ,x=t.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!==s&&pointInTriangle(a,u,l,h,c,d,v.x,v.y)&&area(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!==s&&pointInTriangle(a,u,l,h,c,d,x.x,x.y)&&area(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!==s&&pointInTriangle(a,u,l,h,c,d,v.x,v.y)&&area(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!==s&&pointInTriangle(a,u,l,h,c,d,x.x,x.y)&&area(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function cureLocalIntersections(t,e,n){let i=t;do{const r=i.prev,o=i.next.next;!equals(r,o)&&intersects$2(r,i,i.next,o)&&locallyInside(r,o)&&locallyInside(o,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),removeNode(i),removeNode(i.next),i=t=o),i=i.next}while(i!==t);return filterPoints(i)}function splitEarcut(t,e,n,i,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&isValidDiagonal(s,t)){let a=splitPolygon(s,t);return s=filterPoints(s,s.next),a=filterPoints(a,a.next),earcutLinked(s,e,n,i,r,o,0),void earcutLinked(a,e,n,i,r,o,0)}t=t.next}s=s.next}while(s!==t)}function eliminateHoles(t,e,n,i){const r=[];let o,s,a,l,c;for(o=0,s=e.length;o<s;o++)a=e[o]*i,l=o<s-1?e[o+1]*i:t.length,c=linkedList(t,a,l,i,!1),c===c.next&&(c.steiner=!0),r.push(getLeftmost(c));for(r.sort(compareX),o=0;o<r.length;o++)n=eliminateHole(r[o],n);return n}function compareX(t,e){return t.x-e.x}function eliminateHole(t,e){const n=findHoleBridge(t,e);if(!n)return e;const i=splitPolygon(n,t);return filterPoints(i,i.next),filterPoints(n,n.next)}function findHoleBridge(t,e){let n,i=e,r=-1/0;const o=t.x,s=t.y;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){const t=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=o&&t>r&&(r=t,n=i.x<i.next.x?i:i.next,t===o))return n}i=i.next}while(i!==e);if(!n)return null;const a=n,l=n.x,c=n.y;let u,h=1/0;i=n;do{o>=i.x&&i.x>=l&&o!==i.x&&pointInTriangle(s<c?o:r,s,l,c,s<c?r:o,s,i.x,i.y)&&(u=Math.abs(s-i.y)/(o-i.x),locallyInside(i,t)&&(u<h||u===h&&(i.x>n.x||i.x===n.x&&sectorContainsSector(n,i)))&&(n=i,h=u)),i=i.next}while(i!==a);return n}function sectorContainsSector(t,e){return area(t.prev,t,e.prev)<0&&area(e.next,t,t.next)<0}function indexCurve(t,e,n,i){let r=t;do{0===r.z&&(r.z=zOrder(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(t){let e,n,i,r,o,s,a,l,c=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ,i);e++);for(l=c;a>0||l>0&&i;)0!==a&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(s>1);return t}function zOrder(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function getLeftmost(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function pointInTriangle(t,e,n,i,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(i-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function isValidDiagonal(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!intersectsPolygon(t,e)&&(locallyInside(t,e)&&locallyInside(e,t)&&middleInside(t,e)&&(area(t.prev,t,e.prev)||area(t,e.prev,e))||equals(t,e)&&area(t.prev,t,t.next)>0&&area(e.prev,e,e.next)>0)}function area(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function equals(t,e){return t.x===e.x&&t.y===e.y}function intersects$2(t,e,n,i){const r=sign(area(t,e,n)),o=sign(area(t,e,i)),s=sign(area(n,i,t)),a=sign(area(n,i,e));return r!==o&&s!==a||(!(0!==r||!onSegment(t,n,e))||(!(0!==o||!onSegment(t,i,e))||(!(0!==s||!onSegment(n,t,i))||!(0!==a||!onSegment(n,e,i)))))}function onSegment(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function sign(t){return t>0?1:t<0?-1:0}function intersectsPolygon(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&intersects$2(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function locallyInside(t,e){return area(t.prev,t,t.next)<0?area(t,e,t.next)>=0&&area(t,t.prev,e)>=0:area(t,e,t.prev)<0||area(t,t.next,e)<0}function middleInside(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}function splitPolygon(t,e){const n=new Node(t.i,t.x,t.y),i=new Node(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function insertNode(t,e,n,i){const r=new Node(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function removeNode(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Node(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(t,e,n,i){let r=0;for(let o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}class ShapeUtils{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*n}static isClockWise(t){return ShapeUtils.area(t)<0}static triangulateShape(t,e){const n=[],i=[],r=[];removeDupEndPts(t),addContour(n,t);let o=t.length;e.forEach(removeDupEndPts);for(let t=0;t<e.length;t++)i.push(o),o+=e[t].length,addContour(n,e[t]);const s=Earcut.triangulate(n,i);for(let t=0;t<s.length;t+=3)r.push(s.slice(t,t+3));return r}}function removeDupEndPts(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function addContour(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class ExtrudeGeometry extends BufferGeometry{constructor(t=new Shape([new Vector2(.5,.5),new Vector2(-.5,.5),new Vector2(-.5,-.5),new Vector2(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],r=[];for(let e=0,n=t.length;e<n;e++){o(t[e])}function o(t){const o=[],s=void 0!==e.curveSegments?e.curveSegments:12,a=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let c=void 0===e.bevelEnabled||e.bevelEnabled,u=void 0!==e.bevelThickness?e.bevelThickness:.2,h=void 0!==e.bevelSize?e.bevelSize:u-.1,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const f=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:WorldUVGenerator;let g,_,y,v,x,b=!1;f&&(g=f.getSpacedPoints(a),b=!0,c=!1,_=f.computeFrenetFrames(a,!1),y=new Vector3,v=new Vector3,x=new Vector3),c||(p=0,u=0,h=0,d=0);const T=t.extractPoints(s);let E=T.shape;const S=T.holes;if(!ShapeUtils.isClockWise(E)){E=E.reverse();for(let t=0,e=S.length;t<e;t++){const e=S[t];ShapeUtils.isClockWise(e)&&(S[t]=e.reverse())}}const w=ShapeUtils.triangulateShape(E,S),A=E;for(let t=0,e=S.length;t<e;t++){E=E.concat(S[t])}function M(t,e,n){return t.clone().addScaledVector(e,n)}const C=E.length,I=w.length;function P(t,e,n){let i,r,o;const s=t.x-e.x,a=t.y-e.y,l=n.x-t.x,c=n.y-t.y,u=s*s+a*a;if(Math.abs(s*c-a*l)>Number.EPSILON){const h=Math.sqrt(u),d=Math.sqrt(l*l+c*c),p=e.x-a/h,f=e.y+s/h,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(s*c-a*l);i=p+s*m-t.x,r=f+a*m-t.y;const g=i*i+r*r;if(g<=2)return new Vector2(i,r);o=Math.sqrt(g/2)}else{let t=!1;s>Number.EPSILON?l>Number.EPSILON&&(t=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(a)===Math.sign(c)&&(t=!0),t?(i=-a,r=s,o=Math.sqrt(u)):(i=s,r=a,o=Math.sqrt(u/2))}return new Vector2(i/o,r/o)}const L=[];for(let t=0,e=A.length,n=e-1,i=t+1;t<e;t++,n++,i++)n===e&&(n=0),i===e&&(i=0),L[t]=P(A[t],A[n],A[i]);const R=[];let O,D=L.concat();for(let t=0,e=S.length;t<e;t++){const e=S[t];O=[];for(let t=0,n=e.length,i=n-1,r=t+1;t<n;t++,i++,r++)i===n&&(i=0),r===n&&(r=0),O[t]=P(e[t],e[i],e[r]);R.push(O),D=D.concat(O)}for(let t=0;t<p;t++){const e=t/p,n=u*Math.cos(e*Math.PI/2),i=h*Math.sin(e*Math.PI/2)+d;for(let t=0,e=A.length;t<e;t++){const e=M(A[t],L[t],i);F(e.x,e.y,-n)}for(let t=0,e=S.length;t<e;t++){const e=S[t];O=R[t];for(let t=0,r=e.length;t<r;t++){const r=M(e[t],O[t],i);F(r.x,r.y,-n)}}}const B=h+d;for(let t=0;t<C;t++){const e=c?M(E[t],D[t],B):E[t];b?(v.copy(_.normals[0]).multiplyScalar(e.x),y.copy(_.binormals[0]).multiplyScalar(e.y),x.copy(g[0]).add(v).add(y),F(x.x,x.y,x.z)):F(e.x,e.y,0)}for(let t=1;t<=a;t++)for(let e=0;e<C;e++){const n=c?M(E[e],D[e],B):E[e];b?(v.copy(_.normals[t]).multiplyScalar(n.x),y.copy(_.binormals[t]).multiplyScalar(n.y),x.copy(g[t]).add(v).add(y),F(x.x,x.y,x.z)):F(n.x,n.y,l/a*t)}for(let t=p-1;t>=0;t--){const e=t/p,n=u*Math.cos(e*Math.PI/2),i=h*Math.sin(e*Math.PI/2)+d;for(let t=0,e=A.length;t<e;t++){const e=M(A[t],L[t],i);F(e.x,e.y,l+n)}for(let t=0,e=S.length;t<e;t++){const e=S[t];O=R[t];for(let t=0,r=e.length;t<r;t++){const r=M(e[t],O[t],i);b?F(r.x,r.y+g[a-1].y,g[a-1].x+n):F(r.x,r.y,l+n)}}}function N(t,e){let n=t.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=a+2*p;t<n;t++){const n=C*t,o=C*(t+1);k(e+i+n,e+r+n,e+r+o,e+i+o)}}}function F(t,e,n){o.push(t),o.push(e),o.push(n)}function U(t,e,r){z(t),z(e),z(r);const o=i.length/3,s=m.generateTopUV(n,i,o-3,o-2,o-1);G(s[0]),G(s[1]),G(s[2])}function k(t,e,r,o){z(t),z(e),z(o),z(e),z(r),z(o);const s=i.length/3,a=m.generateSideWallUV(n,i,s-6,s-3,s-2,s-1);G(a[0]),G(a[1]),G(a[3]),G(a[1]),G(a[2]),G(a[3])}function z(t){i.push(o[3*t+0]),i.push(o[3*t+1]),i.push(o[3*t+2])}function G(t){r.push(t.x),r.push(t.y)}!function(){const t=i.length/3;if(c){let t=0,e=C*t;for(let t=0;t<I;t++){const n=w[t];U(n[2]+e,n[1]+e,n[0]+e)}t=a+2*p,e=C*t;for(let t=0;t<I;t++){const n=w[t];U(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<I;t++){const e=w[t];U(e[2],e[1],e[0])}for(let t=0;t<I;t++){const e=w[t];U(e[0]+C*a,e[1]+C*a,e[2]+C*a)}}n.addGroup(t,i.length/3-t,0)}(),function(){const t=i.length/3;let e=0;N(A,e),e+=A.length;for(let t=0,n=S.length;t<n;t++){const n=S[t];N(n,e),e+=n.length}n.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new Float32BufferAttribute(i,3)),this.setAttribute("uv",new Float32BufferAttribute(r,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return toJSON$1(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){n.push(e[t.shapes[i]])}const i=t.options.extrudePath;return void 0!==i&&(t.options.extrudePath=(new Curves[i.type]).fromJSON(i)),new ExtrudeGeometry(n,t.options)}}const WorldUVGenerator={generateTopUV:function(t,e,n,i,r){const o=e[3*i],s=e[3*i+1],a=e[3*r],l=e[3*r+1];return[new Vector2(e[3*n],e[3*n+1]),new Vector2(o,s),new Vector2(a,l)]},generateSideWallUV:function(t,e,n,i,r,o){const s=e[3*n],a=e[3*n+1],l=e[3*n+2],c=e[3*i],u=e[3*i+1],h=e[3*i+2],d=e[3*r],p=e[3*r+1],f=e[3*r+2],m=e[3*o],g=e[3*o+1],_=e[3*o+2];return Math.abs(a-u)<Math.abs(s-c)?[new Vector2(s,1-l),new Vector2(c,1-h),new Vector2(d,1-f),new Vector2(m,1-_)]:[new Vector2(a,1-l),new Vector2(u,1-h),new Vector2(p,1-f),new Vector2(g,1-_)]}};function toJSON$1(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){n.shapes.push(t[e].uuid)}else n.shapes.push(t.uuid);return n.options=Object.assign({},e),void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON()),n}class IcosahedronGeometry extends PolyhedronGeometry{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,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],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new IcosahedronGeometry(t.radius,t.detail)}}class OctahedronGeometry extends PolyhedronGeometry{constructor(t=1,e=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],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new OctahedronGeometry(t.radius,t.detail)}}class PlaneGeometry extends BufferGeometry{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,o=e/2,s=Math.floor(n),a=Math.floor(i),l=s+1,c=a+1,u=t/s,h=e/a,d=[],p=[],f=[],m=[];for(let t=0;t<c;t++){const e=t*h-o;for(let n=0;n<l;n++){p.push(n*u-r,-e,0),f.push(0,0,1),m.push(n/s),m.push(1-t/a)}}for(let t=0;t<a;t++)for(let e=0;e<s;e++){const n=e+l*(t+1),i=e+1+l*(t+1),r=e+1+l*t;d.push(e+l*t,n,r),d.push(n,i,r)}this.setIndex(d),this.setAttribute("position",new Float32BufferAttribute(p,3)),this.setAttribute("normal",new Float32BufferAttribute(f,3)),this.setAttribute("uv",new Float32BufferAttribute(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new PlaneGeometry(t.width,t.height,t.widthSegments,t.heightSegments)}}class RingGeometry extends BufferGeometry{constructor(t=.5,e=1,n=32,i=1,r=0,o=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n);const s=[],a=[],l=[],c=[];let u=t;const h=(e-t)/(i=Math.max(1,i)),d=new Vector3,p=new Vector2;for(let t=0;t<=i;t++){for(let t=0;t<=n;t++){const i=r+t/n*o;d.x=u*Math.cos(i),d.y=u*Math.sin(i),a.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,c.push(p.x,p.y)}u+=h}for(let t=0;t<i;t++){const e=t*(n+1);for(let t=0;t<n;t++){const i=t+e,r=i+n+1,o=i+n+2,a=i+1;s.push(i,r,a),s.push(r,o,a)}}this.setIndex(s),this.setAttribute("position",new Float32BufferAttribute(a,3)),this.setAttribute("normal",new Float32BufferAttribute(l,3)),this.setAttribute("uv",new Float32BufferAttribute(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new RingGeometry(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class ShapeGeometry extends BufferGeometry{constructor(t=new Shape([new Vector2(0,.5),new Vector2(-.5,-.5),new Vector2(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],r=[],o=[];let s=0,a=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(s,a,e),s+=a,a=0;function l(t){const s=i.length/3,l=t.extractPoints(e);let c=l.shape;const u=l.holes;!1===ShapeUtils.isClockWise(c)&&(c=c.reverse());for(let t=0,e=u.length;t<e;t++){const e=u[t];!0===ShapeUtils.isClockWise(e)&&(u[t]=e.reverse())}const h=ShapeUtils.triangulateShape(c,u);for(let t=0,e=u.length;t<e;t++){c=c.concat(u[t])}for(let t=0,e=c.length;t<e;t++){const e=c[t];i.push(e.x,e.y,0),r.push(0,0,1),o.push(e.x,e.y)}for(let t=0,e=h.length;t<e;t++){const e=h[t];n.push(e[0]+s,e[1]+s,e[2]+s),a+=3}}this.setIndex(n),this.setAttribute("position",new Float32BufferAttribute(i,3)),this.setAttribute("normal",new Float32BufferAttribute(r,3)),this.setAttribute("uv",new Float32BufferAttribute(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return toJSON(this.parameters.shapes,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){n.push(e[t.shapes[i]])}return new ShapeGeometry(n,t.curveSegments)}}function toJSON(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,i=t.length;n<i;n++){e.shapes.push(t[n].uuid)}else e.shapes.push(t.uuid);return e}class SphereGeometry extends BufferGeometry{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,o=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:s},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const a=Math.min(o+s,Math.PI);let l=0;const c=[],u=new Vector3,h=new Vector3,d=[],p=[],f=[],m=[];for(let d=0;d<=n;d++){const g=[],_=d/n;let y=0;0===d&&0===o?y=.5/e:d===n&&a===Math.PI&&(y=-.5/e);for(let n=0;n<=e;n++){const a=n/e;u.x=-t*Math.cos(i+a*r)*Math.sin(o+_*s),u.y=t*Math.cos(o+_*s),u.z=t*Math.sin(i+a*r)*Math.sin(o+_*s),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 t=0;t<n;t++)for(let i=0;i<e;i++){const e=c[t][i],r=c[t+1][i],s=c[t+1][i+1];(0!==t||o>0)&&d.push(c[t][i+1],e,s),(t!==n-1||a<Math.PI)&&d.push(e,r,s)}this.setIndex(d),this.setAttribute("position",new Float32BufferAttribute(p,3)),this.setAttribute("normal",new Float32BufferAttribute(f,3)),this.setAttribute("uv",new Float32BufferAttribute(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new SphereGeometry(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class TetrahedronGeometry extends PolyhedronGeometry{constructor(t=1,e=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],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new TetrahedronGeometry(t.radius,t.detail)}}class TorusGeometry extends BufferGeometry{constructor(t=1,e=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const o=[],s=[],a=[],l=[],c=new Vector3,u=new Vector3,h=new Vector3;for(let o=0;o<=n;o++)for(let d=0;d<=i;d++){const p=d/i*r,f=o/n*Math.PI*2;u.x=(t+e*Math.cos(f))*Math.cos(p),u.y=(t+e*Math.cos(f))*Math.sin(p),u.z=e*Math.sin(f),s.push(u.x,u.y,u.z),c.x=t*Math.cos(p),c.y=t*Math.sin(p),h.subVectors(u,c).normalize(),a.push(h.x,h.y,h.z),l.push(d/i),l.push(o/n)}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+e-1,r=(i+1)*(t-1)+e,s=(i+1)*t+e;o.push((i+1)*t+e-1,n,s),o.push(n,r,s)}this.setIndex(o),this.setAttribute("position",new Float32BufferAttribute(s,3)),this.setAttribute("normal",new Float32BufferAttribute(a,3)),this.setAttribute("uv",new Float32BufferAttribute(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new TorusGeometry(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class TorusKnotGeometry extends BufferGeometry{constructor(t=1,e=.4,n=64,i=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:o},n=Math.floor(n),i=Math.floor(i);const s=[],a=[],l=[],c=[],u=new Vector3,h=new Vector3,d=new Vector3,p=new Vector3,f=new Vector3,m=new Vector3,g=new Vector3;for(let s=0;s<=n;++s){const y=s/n*r*Math.PI*2;_(y,r,o,t,d),_(y+.01,r,o,t,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let t=0;t<=i;++t){const r=t/i*Math.PI*2,o=-e*Math.cos(r),p=e*Math.sin(r);u.x=d.x+(o*g.x+p*f.x),u.y=d.y+(o*g.y+p*f.y),u.z=d.z+(o*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(s/n),c.push(t/i)}}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+(e-1),r=(i+1)*t+e,o=(i+1)*(t-1)+e;s.push((i+1)*(t-1)+(e-1),n,o),s.push(n,r,o)}function _(t,e,n,i,r){const o=Math.cos(t),s=Math.sin(t),a=n/e*t,l=Math.cos(a);r.x=i*(2+l)*.5*o,r.y=i*(2+l)*s*.5,r.z=i*Math.sin(a)*.5}this.setIndex(s),this.setAttribute("position",new Float32BufferAttribute(a,3)),this.setAttribute("normal",new Float32BufferAttribute(l,3)),this.setAttribute("uv",new Float32BufferAttribute(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new TorusKnotGeometry(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class TubeGeometry extends BufferGeometry{constructor(t=new QuadraticBezierCurve3(new Vector3(-1,-1,0),new Vector3(-1,1,0),new Vector3(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};const o=t.computeFrenetFrames(e,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const s=new Vector3,a=new Vector3,l=new Vector2;let c=new Vector3;const u=[],h=[],d=[],p=[];function f(r){c=t.getPointAt(r/e,c);const l=o.normals[r],d=o.binormals[r];for(let t=0;t<=i;t++){const e=t/i*Math.PI*2,r=Math.sin(e),o=-Math.cos(e);a.x=o*l.x+r*d.x,a.y=o*l.y+r*d.y,a.z=o*l.z+r*d.z,a.normalize(),h.push(a.x,a.y,a.z),s.x=c.x+n*a.x,s.y=c.y+n*a.y,s.z=c.z+n*a.z,u.push(s.x,s.y,s.z)}}!function(){for(let t=0;t<e;t++)f(t);f(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let n=0;n<=i;n++)l.x=t/e,l.y=n/i,d.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+(e-1),r=(i+1)*t+e,o=(i+1)*(t-1)+e;p.push((i+1)*(t-1)+(e-1),n,o),p.push(n,r,o)}}()}(),this.setIndex(p),this.setAttribute("position",new Float32BufferAttribute(u,3)),this.setAttribute("normal",new Float32BufferAttribute(h,3)),this.setAttribute("uv",new Float32BufferAttribute(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new TubeGeometry((new Curves[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class WireframeGeometry extends BufferGeometry{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],n=new Set,i=new Vector3,r=new Vector3;if(null!==t.index){const o=t.attributes.position,s=t.index;let a=t.groups;0===a.length&&(a=[{start:0,count:s.count,materialIndex:0}]);for(let t=0,l=a.length;t<l;++t){const l=a[t],c=l.start;for(let t=c,a=c+l.count;t<a;t+=3)for(let a=0;a<3;a++){const l=s.getX(t+a),c=s.getX(t+(a+1)%3);i.fromBufferAttribute(o,l),r.fromBufferAttribute(o,c),!0===isUniqueEdge(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}}else{const o=t.attributes.position;for(let t=0,s=o.count/3;t<s;t++)for(let s=0;s<3;s++){const a=3*t+(s+1)%3;i.fromBufferAttribute(o,3*t+s),r.fromBufferAttribute(o,a),!0===isUniqueEdge(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new Float32BufferAttribute(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function isUniqueEdge(t,e,n){const i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var Geometries=Object.freeze({__proto__:null,BoxGeometry:BoxGeometry,CapsuleGeometry:CapsuleGeometry,CircleGeometry:CircleGeometry,ConeGeometry:ConeGeometry,CylinderGeometry:CylinderGeometry,DodecahedronGeometry:DodecahedronGeometry,EdgesGeometry:EdgesGeometry,ExtrudeGeometry:ExtrudeGeometry,IcosahedronGeometry:IcosahedronGeometry,LatheGeometry:LatheGeometry,OctahedronGeometry:OctahedronGeometry,PlaneGeometry:PlaneGeometry,PolyhedronGeometry:PolyhedronGeometry,RingGeometry:RingGeometry,ShapeGeometry:ShapeGeometry,SphereGeometry:SphereGeometry,TetrahedronGeometry:TetrahedronGeometry,TorusGeometry:TorusGeometry,TorusKnotGeometry:TorusKnotGeometry,TubeGeometry:TubeGeometry,WireframeGeometry:WireframeGeometry});class ShadowMaterial extends Material{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Color(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class RawShaderMaterial extends ShaderMaterial{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class MeshStandardMaterial extends Material{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Color(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 Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(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 Euler,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class MeshPhysicalMaterial extends MeshStandardMaterial{constructor(t){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 Vector2(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return clamp(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Color(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 Color(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Color(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(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class MeshPhongMaterial extends Material{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Color(16777215),this.specular=new Color(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Euler,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class MeshToonMaterial extends Material{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Color(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class MeshNormalMaterial extends Material{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class MeshLambertMaterial extends Material{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Euler,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class MeshDepthMaterial extends Material{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=BasicDepthPacking,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class MeshDistanceMaterial extends Material{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class MeshMatcapMaterial extends Material{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Color(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class LineDashedMaterial extends LineBasicMaterial{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function convertArray(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function getKeyframeOrder(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function sortedArray(t,e,n){const i=t.length,r=new t.constructor(i);for(let o=0,s=0;s!==i;++o){const i=n[o]*e;for(let n=0;n!==e;++n)r[s++]=t[i+n]}return r}function flattenJSON(t,e,n,i){let r=1,o=t[0];for(;void 0!==o&&void 0===o[i];)o=t[r++];if(void 0===o)return;let s=o[i];if(void 0!==s)if(Array.isArray(s))do{s=o[i],void 0!==s&&(e.push(o.time),n.push.apply(n,s)),o=t[r++]}while(void 0!==o);else if(void 0!==s.toArray)do{s=o[i],void 0!==s&&(e.push(o.time),s.toArray(n,n.length)),o=t[r++]}while(void 0!==o);else do{s=o[i],void 0!==s&&(e.push(o.time),n.push(s)),o=t[r++]}while(void 0!==o)}function subclip(t,e,n,i,r=30){const o=t.clone();o.name=e;const s=[];for(let t=0;t<o.tracks.length;++t){const e=o.tracks[t],a=e.getValueSize(),l=[],c=[];for(let t=0;t<e.times.length;++t){const o=e.times[t]*r;if(!(o<n||o>=i)){l.push(e.times[t]);for(let n=0;n<a;++n)c.push(e.values[t*a+n])}}0!==l.length&&(e.times=convertArray(l,e.times.constructor),e.values=convertArray(c,e.values.constructor),s.push(e))}o.tracks=s;let a=1/0;for(let t=0;t<o.tracks.length;++t)a>o.tracks[t].times[0]&&(a=o.tracks[t].times[0]);for(let t=0;t<o.tracks.length;++t)o.tracks[t].shift(-1*a);return o.resetDuration(),o}function makeClipAdditive(t,e=0,n=t,i=30){i<=0&&(i=30);const r=n.tracks.length,o=e/i;for(let e=0;e<r;++e){const i=n.tracks[e],r=i.ValueTypeName;if("bool"===r||"string"===r)continue;const s=t.tracks.find((function(t){return t.name===i.name&&t.ValueTypeName===r}));if(void 0===s)continue;let a=0;const l=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(a=l/3);let c=0;const u=s.getValueSize();s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const h=i.times.length-1;let d;if(o<=i.times[0]){d=i.values.slice(a,l-a)}else if(o>=i.times[h]){const t=h*l+a;d=i.values.slice(t,t+l-a)}else{const t=i.createInterpolant(),e=a,n=l-a;t.evaluate(o),d=t.resultBuffer.slice(e,n)}if("quaternion"===r){(new Quaternion).fromArray(d).normalize().conjugate().toArray(d)}const p=s.times.length;for(let t=0;t<p;++t){const e=t*u+c;if("quaternion"===r)Quaternion.multiplyQuaternionsFlat(s.values,e,d,0,s.values,e);else{const t=u-2*c;for(let n=0;n<t;++n)s.values[e+n]-=d[n]}}}return t.blendMode=AdditiveAnimationBlendMode,t}const AnimationUtils={convertArray:convertArray,isTypedArray:isTypedArray,getKeyframeOrder:getKeyframeOrder,sortedArray:sortedArray,flattenJSON:flattenJSON,subclip:subclip,makeClipAdditive:makeClipAdditive};class Interpolant{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let o;n:{i:if(!(t<i)){for(let o=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=e[++n],t<i)break e}o=e.length;break n}if(t>=r)break t;{const s=e[1];t<s&&(n=2,r=s);for(let o=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=r,r=e[--n-1],t>=r)break e}o=n,n=0}}for(;n<o;){const i=n+o>>>1;t<e[i]?o=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=n[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class CubicInterpolant extends Interpolant{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ZeroCurvatureEnding,endingEnd:ZeroCurvatureEnding}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,o=t+1,s=i[r],a=i[o];if(void 0===s)switch(this.getSettings_().endingStart){case ZeroSlopeEnding:r=t,s=2*e-n;break;case WrapAroundEnding:r=i.length-2,s=e+i[r]-i[r+1];break;default:r=t,s=n}if(void 0===a)switch(this.getSettings_().endingEnd){case ZeroSlopeEnding:o=t,a=2*n-e;break;case WrapAroundEnding:o=1,a=n+i[1]-i[0];break;default:o=t-1,a=e}const l=.5*(n-e),c=this.valueSize;this._weightPrev=l/(e-s),this._weightNext=l/(a-n),this._offsetPrev=r*c,this._offsetNext=o*c}interpolate_(t,e,n,i){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=t*s,l=a-s,c=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-e)/(i-e),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 t=0;t!==s;++t)r[t]=g*o[c+t]+_*o[l+t]+y*o[a+t]+v*o[u+t];return r}}class LinearInterpolant extends Interpolant{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=t*s,l=a-s,c=(n-e)/(i-e),u=1-c;for(let t=0;t!==s;++t)r[t]=o[l+t]*u+o[a+t]*c;return r}}class DiscreteInterpolant extends Interpolant{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class KeyframeTrack{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=convertArray(e,this.TimeBufferType),this.values=convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:convertArray(t.times,Array),values:convertArray(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new DiscreteInterpolant(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new LinearInterpolant(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new CubicInterpolant(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case InterpolateDiscrete:e=this.InterpolantFactoryMethodDiscrete;break;case InterpolateLinear:e=this.InterpolantFactoryMethodLinear;break;case InterpolateSmooth:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error("unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name);this.setInterpolation(this.DefaultInterpolation)}return this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return InterpolateDiscrete;case this.InterpolantFactoryMethodLinear:return InterpolateLinear;case this.InterpolantFactoryMethodSmooth:return InterpolateSmooth}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==o&&n[o]>e;)--o;if(++o,0!==r||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const t=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*t,o*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(t=!1);let o=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){t=!1;break}if(null!==o&&o>i){t=!1;break}o=i}if(void 0!==i&&isTypedArray(i))for(let e=0,n=i.length;e!==n;++e){if(isNaN(i[e])){t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===InterpolateSmooth,r=t.length-1;let o=1;for(let s=1;s<r;++s){let r=!1;const a=t[s];if(a!==t[s+1]&&(1!==s||a!==t[0]))if(i)r=!0;else{const t=s*n,i=t-n,o=t+n;for(let s=0;s!==n;++s){const n=e[t+s];if(n!==e[i+s]||n!==e[o+s]){r=!0;break}}}if(r){if(s!==o){t[o]=t[s];const i=s*n,r=o*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++o}}if(r>0){t[o]=t[r];for(let t=r*n,i=o*n,s=0;s!==n;++s)e[i+s]=e[t+s];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}KeyframeTrack.prototype.TimeBufferType=Float32Array,KeyframeTrack.prototype.ValueBufferType=Float32Array,KeyframeTrack.prototype.DefaultInterpolation=InterpolateLinear;class BooleanKeyframeTrack extends KeyframeTrack{constructor(t,e,n){super(t,e,n)}}BooleanKeyframeTrack.prototype.ValueTypeName="bool",BooleanKeyframeTrack.prototype.ValueBufferType=Array,BooleanKeyframeTrack.prototype.DefaultInterpolation=InterpolateDiscrete,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class ColorKeyframeTrack extends KeyframeTrack{}ColorKeyframeTrack.prototype.ValueTypeName="color";class NumberKeyframeTrack extends KeyframeTrack{}NumberKeyframeTrack.prototype.ValueTypeName="number";class QuaternionLinearInterpolant extends Interpolant{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(n-e)/(i-e);let l=t*s;for(let t=l+s;l!==t;l+=4)Quaternion.slerpFlat(r,0,o,l-s,o,l,a);return r}}class QuaternionKeyframeTrack extends KeyframeTrack{InterpolantFactoryMethodLinear(t){return new QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),t)}}QuaternionKeyframeTrack.prototype.ValueTypeName="quaternion",QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class StringKeyframeTrack extends KeyframeTrack{constructor(t,e,n){super(t,e,n)}}StringKeyframeTrack.prototype.ValueTypeName="string",StringKeyframeTrack.prototype.ValueBufferType=Array,StringKeyframeTrack.prototype.DefaultInterpolation=InterpolateDiscrete,StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class VectorKeyframeTrack extends KeyframeTrack{}VectorKeyframeTrack.prototype.ValueTypeName="vector";class AnimationClip{constructor(t="",e=-1,n=[],i=NormalAnimationBlendMode){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=generateUUID$1(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(parseKeyframeTrack(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(KeyframeTrack.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,o=[];for(let t=0;t<r;t++){let s=[],a=[];s.push((t+r-1)%r,t,(t+1)%r),a.push(0,1,0);const l=getKeyframeOrder(s);s=sortedArray(s,1,l),a=sortedArray(a,1,l),i||0!==s[0]||(s.push(r),a.push(a[0])),o.push(new NumberKeyframeTrack(".morphTargetInfluences["+e[t].name+"]",s,a).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){n=t.geometry&&t.geometry.animations||t.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],o=n.name.match(r);if(o&&o.length>1){const t=o[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const o=[];for(const t in i)o.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return o}static parseAnimation(t,e){if(!t)return null;const n=function(t,e,n,i,r){if(0!==n.length){const o=[],s=[];flattenJSON(n,o,s,i),0!==o.length&&r.push(new t(e,o,s))}},i=[],r=t.name||"default",o=t.fps||30,s=t.blendMode;let a=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const r=l[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let n=0;n<r[e].morphTargets.length;n++)t[r[e].morphTargets[n]]=-1;for(const n in t){const t=[],o=[];for(let i=0;i!==r[e].morphTargets.length;++i){const i=r[e];t.push(i.time),o.push(i.morphTarget===n?1:0)}i.push(new NumberKeyframeTrack(".morphTargetInfluence["+n+"]",t,o))}a=t.length*o}else{const o=".bones["+e[t].name+"]";n(VectorKeyframeTrack,o+".position",r,"pos",i),n(QuaternionKeyframeTrack,o+".quaternion",r,"rot",i),n(VectorKeyframeTrack,o+".scale",r,"scl",i)}}if(0===i.length)return null;return new this(r,a,i,s)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function getTrackTypeForValueTypeName(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return VectorKeyframeTrack;case"color":return ColorKeyframeTrack;case"quaternion":return QuaternionKeyframeTrack;case"bool":case"boolean":return BooleanKeyframeTrack;case"string":return StringKeyframeTrack}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}function parseKeyframeTrack(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=getTrackTypeForValueTypeName(t.type);if(void 0===t.times){const e=[],n=[];flattenJSON(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const Cache={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class LoadingManager{constructor(t,e,n){const i=this;let r,o=!1,s=0,a=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){a++,!1===o&&void 0!==i.onStart&&i.onStart(t,s,a),o=!0},this.itemEnd=function(t){s++,void 0!==i.onProgress&&i.onProgress(t,s,a),s===a&&(o=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null}}}const DefaultLoadingManager=new LoadingManager;class Loader{constructor(t){this.manager=void 0!==t?t:DefaultLoadingManager,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Loader.DEFAULT_MATERIAL_NAME="__DEFAULT";const loading={};class HttpError extends Error{constructor(t,e){super(t),this.response=e}}class FileLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=Cache.get(t);if(void 0!==r)return this.manager.itemStart(t),setTimeout((()=>{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==loading[t])return void loading[t].push({onLoad:e,onProgress:n,onError:i});loading[t]=[],loading[t].push({onLoad:e,onProgress:n,onError:i});const o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,a=this.responseType;fetch(o).then((e=>{if(200===e.status||0===e.status){if("undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=loading[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),o=r?parseInt(r):0,s=0!==o;let a=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{a+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:s,loaded:a,total:o});for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onProgress&&e.onProgress(i)}t.enqueue(r),e()}}),(e=>{t.error(e)}))}()}});return new Response(l)}throw new HttpError(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(a){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,s)));case"json":return t.json();default:if(void 0===s)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(s),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{Cache.add(t,e);const n=loading[t];delete loading[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onLoad&&i.onLoad(e)}})).catch((e=>{const n=loading[t];if(void 0===n)throw this.manager.itemError(t),e;delete loading[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}this.manager.itemError(t)})).finally((()=>{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class AnimationLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){const r=this,o=new FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i&&i(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=[];for(let n=0;n<t.length;n++){const i=AnimationClip.parse(t[n]);e.push(i)}return e}}class CompressedTextureLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){const r=this,o=[],s=new CompressedTexture,a=new FileLoader(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(t[c],(function(t){const n=r.parse(t,!0);o[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(s.minFilter=LinearFilter),s.image=o,s.format=n.format,s.needsUpdate=!0,e&&e(s))}),n,i)}if(Array.isArray(t))for(let e=0,n=t.length;e<n;++e)c(e);else a.load(t,(function(t){const n=r.parse(t,!0);if(n.isCubemap){const t=n.mipmaps.length/n.mipmapCount;for(let e=0;e<t;e++){o[e]={mipmaps:[]};for(let t=0;t<n.mipmapCount;t++)o[e].mipmaps.push(n.mipmaps[e*n.mipmapCount+t]),o[e].format=n.format,o[e].width=n.width,o[e].height=n.height}s.image=o}else s.image.width=n.width,s.image.height=n.height,s.mipmaps=n.mipmaps;1===n.mipmapCount&&(s.minFilter=LinearFilter),s.format=n.format,s.needsUpdate=!0,e&&e(s)}),n,i);return s}}class ImageLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,o=Cache.get(t);if(void 0!==o)return r.manager.itemStart(t),setTimeout((function(){e&&e(o),r.manager.itemEnd(t)}),0),o;const s=createElementNS("img");function a(){c(),Cache.add(t,this),e&&e(this),r.manager.itemEnd(t)}function l(e){c(),i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)}function c(){s.removeEventListener("load",a,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",a,!1),s.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(t),s.src=t,s}}class CubeTextureLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){const r=new CubeTexture;r.colorSpace=SRGBColorSpace;const o=new ImageLoader(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let s=0;function a(n){o.load(t[n],(function(t){r.images[n]=t,s++,6===s&&(r.needsUpdate=!0,e&&e(r))}),void 0,i)}for(let e=0;e<t.length;++e)a(e);return r}}class DataTextureLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){const r=this,o=new DataTexture,s=new FileLoader(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(t,(function(t){let n;try{n=r.parse(t)}catch(t){if(void 0===i)return;i(t)}void 0!==n.image?o.image=n.image:void 0!==n.data&&(o.image.width=n.width,o.image.height=n.height,o.image.data=n.data),o.wrapS=void 0!==n.wrapS?n.wrapS:ClampToEdgeWrapping,o.wrapT=void 0!==n.wrapT?n.wrapT:ClampToEdgeWrapping,o.magFilter=void 0!==n.magFilter?n.magFilter:LinearFilter,o.minFilter=void 0!==n.minFilter?n.minFilter:LinearFilter,o.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace&&(o.colorSpace=n.colorSpace),void 0!==n.flipY&&(o.flipY=n.flipY),void 0!==n.format&&(o.format=n.format),void 0!==n.type&&(o.type=n.type),void 0!==n.mipmaps&&(o.mipmaps=n.mipmaps,o.minFilter=LinearMipmapLinearFilter),1===n.mipmapCount&&(o.minFilter=LinearFilter),void 0!==n.generateMipmaps&&(o.generateMipmaps=n.generateMipmaps),o.needsUpdate=!0,e&&e(o,n)}),n,i),o}}class TextureLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){const r=new Texture,o=new ImageLoader(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,(function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)}),n,i),r}}class Light extends Object3D{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Color(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(e.object.target=this.target.uuid),e}}class HemisphereLight extends Light{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Color(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const _projScreenMatrix$1=new Matrix4,_lightPositionWorld$1=new Vector3,_lookTarget$1=new Vector3;class LightShadow{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vector2(512,512),this.map=null,this.mapPass=null,this.matrix=new Matrix4,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Frustum,this._frameExtents=new Vector2(1,1),this._viewportCount=1,this._viewports=[new Vector4(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;_lightPositionWorld$1.setFromMatrixPosition(t.matrixWorld),e.position.copy(_lightPositionWorld$1),_lookTarget$1.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(_lookTarget$1),e.updateMatrixWorld(),_projScreenMatrix$1.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_projScreenMatrix$1),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(_projScreenMatrix$1)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class SpotLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,n=2*RAD2DEG*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class SpotLight extends Light{constructor(t,e,n=0,i=Math.PI/3,r=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new SpotLightShadow}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const _projScreenMatrix=new Matrix4,_lightPositionWorld=new Vector3,_lookTarget=new Vector3;class PointLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Vector2(4,2),this._viewportCount=6,this._viewports=[new Vector4(2,1,1,1),new Vector4(0,1,1,1),new Vector4(3,1,1,1),new Vector4(1,1,1,1),new Vector4(3,0,1,1),new Vector4(1,0,1,1)],this._cubeDirections=[new Vector3(1,0,0),new Vector3(-1,0,0),new Vector3(0,0,1),new Vector3(0,0,-1),new Vector3(0,1,0),new Vector3(0,-1,0)],this._cubeUps=[new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,0,1),new Vector3(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),_lightPositionWorld.setFromMatrixPosition(t.matrixWorld),n.position.copy(_lightPositionWorld),_lookTarget.copy(n.position),_lookTarget.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(_lookTarget),n.updateMatrixWorld(),i.makeTranslation(-_lightPositionWorld.x,-_lightPositionWorld.y,-_lightPositionWorld.z),_projScreenMatrix.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_projScreenMatrix)}}class PointLight extends Light{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new PointLightShadow}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class OrthographicCamera extends Camera{constructor(t=-1,e=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,o){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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,o=n+t,s=i+e,a=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,o=r+t*this.view.width,s-=e*this.view.offsetY,a=s-e*this.view.height}this.projectionMatrix.makeOrthographic(r,o,s,a,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}class DirectionalLightShadow extends LightShadow{constructor(){super(new OrthographicCamera(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class DirectionalLight extends Light{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.shadow=new DirectionalLightShadow}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class AmbientLight extends Light{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class RectAreaLight extends Light{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class SphericalHarmonics3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Vector3)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,r=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*i),e.addScaledVector(o[2],.488603*r),e.addScaledVector(o[3],.488603*n),e.addScaledVector(o[4],n*i*1.092548),e.addScaledVector(o[5],i*r*1.092548),e.addScaledVector(o[6],.315392*(3*r*r-1)),e.addScaledVector(o[7],n*r*1.092548),e.addScaledVector(o[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,r=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],1.023328*i),e.addScaledVector(o[2],1.023328*r),e.addScaledVector(o[3],1.023328*n),e.addScaledVector(o[4],.858086*n*i),e.addScaledVector(o[5],.858086*i*r),e.addScaledVector(o[6],.743125*r*r-.247708),e.addScaledVector(o[7],.858086*n*r),e.addScaledVector(o[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+3*i);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+3*i);return t}static getBasisAt(t,e){const n=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*n*r,e[8]=.546274*(n*n-i*i)}}class LightProbe extends Light{constructor(t=new SphericalHarmonics3,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class MaterialLoader extends Loader{constructor(t){super(t),this.textures={}}load(t,e,n,i){const r=this,o=new FileLoader(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i&&i(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=this.textures;function n(t){return e[t]}const i=this.createMaterialFromType(t.type);if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new Color).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(i.dispersion=t.dispersion),void 0!==t.iridescence&&(i.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(i.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(i.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(i.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(i.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(i.depthFunc=t.depthFunc),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(i.blendSrc=t.blendSrc),void 0!==t.blendDst&&(i.blendDst=t.blendDst),void 0!==t.blendEquation&&(i.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(i.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(i.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(i.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(i.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),void 0!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(i.forceSinglePass=t.forceSinglePass),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&(i.vertexColors="number"==typeof t.vertexColors?t.vertexColors>0:t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=n(r.value);break;case"c":i.uniforms[e].value=(new Color).setHex(r.value);break;case"v2":i.uniforms[e].value=(new Vector2).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new Vector3).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new Vector4).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new Matrix3).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new Matrix4).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new Vector2).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Vector2).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return MaterialLoader.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:ShadowMaterial,SpriteMaterial:SpriteMaterial,RawShaderMaterial:RawShaderMaterial,ShaderMaterial:ShaderMaterial,PointsMaterial:PointsMaterial,MeshPhysicalMaterial:MeshPhysicalMaterial,MeshStandardMaterial:MeshStandardMaterial,MeshPhongMaterial:MeshPhongMaterial,MeshToonMaterial:MeshToonMaterial,MeshNormalMaterial:MeshNormalMaterial,MeshLambertMaterial:MeshLambertMaterial,MeshDepthMaterial:MeshDepthMaterial,MeshDistanceMaterial:MeshDistanceMaterial,MeshBasicMaterial:MeshBasicMaterial,MeshMatcapMaterial:MeshMatcapMaterial,LineDashedMaterial:LineDashedMaterial,LineBasicMaterial:LineBasicMaterial,Material:Material}[t]}}class LoaderUtils{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(t){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class InstancedBufferGeometry extends BufferGeometry{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class BufferGeometryLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){const r=this,o=new FileLoader(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i&&i(e),r.manager.itemError(t)}}),n,i)}parse(t){const e={},n={};function i(t,i){if(void 0!==e[i])return e[i];const r=t.interleavedBuffers[i],o=function(t,e){if(void 0!==n[e])return n[e];const i=t.arrayBuffers,r=i[e],o=new Uint32Array(r).buffer;return n[e]=o,o}(t,r.buffer),s=getTypedArray(r.type,o),a=new InterleavedBuffer(s,r.stride);return a.uuid=r.uuid,e[i]=a,a}const r=t.isInstancedBufferGeometry?new InstancedBufferGeometry:new BufferGeometry,o=t.data.index;if(void 0!==o){const t=getTypedArray(o.type,o.array);r.setIndex(new BufferAttribute(t,1))}const s=t.data.attributes;for(const e in s){const n=s[e];let o;if(n.isInterleavedBufferAttribute){const e=i(t.data,n.data);o=new InterleavedBufferAttribute(e,n.itemSize,n.offset,n.normalized)}else{const t=getTypedArray(n.type,n.array);o=new(n.isInstancedBufferAttribute?InstancedBufferAttribute:BufferAttribute)(t,n.itemSize,n.normalized)}void 0!==n.name&&(o.name=n.name),void 0!==n.usage&&o.setUsage(n.usage),r.setAttribute(e,o)}const a=t.data.morphAttributes;if(a)for(const e in a){const n=a[e],o=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];let s;if(r.isInterleavedBufferAttribute){const e=i(t.data,r.data);s=new InterleavedBufferAttribute(e,r.itemSize,r.offset,r.normalized)}else{const t=getTypedArray(r.type,r.array);s=new BufferAttribute(t,r.itemSize,r.normalized)}void 0!==r.name&&(s.name=r.name),o.push(s)}r.morphAttributes[e]=o}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let t=0,e=l.length;t!==e;++t){const e=l[t];r.addGroup(e.start,e.count,e.materialIndex)}const c=t.data.boundingSphere;if(void 0!==c){const t=new Vector3;void 0!==c.center&&t.fromArray(c.center),r.boundingSphere=new Sphere(t,c.radius)}return t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}class ObjectLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){const r=this,o=""===this.path?LoaderUtils.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||o;const s=new FileLoader(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){let o=null;try{o=JSON.parse(n)}catch(t){return void(void 0!==i&&i(t))}const s=o.metadata;void 0!==s&&void 0!==s.type&&"geometry"!==s.type.toLowerCase()?r.parse(o,e):void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+t))}),n,i)}async loadAsync(t,e){const n=""===this.path?LoaderUtils.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||n;const i=new FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const r=await i.loadAsync(t,e),o=JSON.parse(r),s=o.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(o)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),o=this.parseImages(t.images,(function(){void 0!==e&&e(l)})),s=this.parseTextures(t.textures,o),a=this.parseMaterials(t.materials,s),l=this.parseObject(t.object,r,a,s,n),c=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,c),this.bindLightTargets(l),void 0!==e){let t=!1;for(const e in o)if(o[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),r=await this.parseImagesAsync(t.images),o=this.parseTextures(t.textures,r),s=this.parseMaterials(t.materials,o),a=this.parseObject(t.object,i,s,o,e),l=this.parseSkeletons(t.skeletons,a);return this.bindSkeletons(a,l),this.bindLightTargets(a),a}parseShapes(t){const e={};if(void 0!==t)for(let n=0,i=t.length;n<i;n++){const i=(new Shape).fromJSON(t[n]);e[i.uuid]=i}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse((function(t){t.isBone&&(i[t.uuid]=t)})),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new Skeleton).fromJSON(t[e],i);n[r.uuid]=r}return n}parseGeometries(t,e){const n={};if(void 0!==t){const i=new BufferGeometryLoader;for(let r=0,o=t.length;r<o;r++){let o;const s=t[r];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":o=i.parse(s);break;default:s.type in Geometries&&(o=Geometries[s.type].fromJSON(s,e))}o.uuid=s.uuid,void 0!==s.name&&(o.name=s.name),void 0!==s.userData&&(o.userData=s.userData),n[s.uuid]=o}}return n}parseMaterials(t,e){const n={},i={};if(void 0!==t){const r=new MaterialLoader;r.setTextures(e);for(let e=0,o=t.length;e<o;e++){const o=t[e];void 0===n[o.uuid]&&(n[o.uuid]=r.parse(o)),i[o.uuid]=n[o.uuid]}}return i}parseAnimations(t){const e={};if(void 0!==t)for(let n=0;n<t.length;n++){const i=AnimationClip.parse(t[n]);e[i.uuid]=i}return e}parseImages(t,e){const n=this,i={};let r;function o(t){if("string"==typeof t){const e=t;return function(t){return n.manager.itemStart(t),r.load(t,(function(){n.manager.itemEnd(t)}),void 0,(function(){n.manager.itemError(t),n.manager.itemEnd(t)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:n.resourcePath+e)}return t.data?{data:getTypedArray(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const n=new LoadingManager(e);r=new ImageLoader(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,n=r.length;e<n;e++){const n=o(r[e]);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new DataTexture(n.data,n.width,n.height)))}i[n.uuid]=new Source(t)}else{const t=o(n.url);i[n.uuid]=new Source(t)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function r(t){if("string"==typeof t){const n=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:e.resourcePath+n;return await i.loadAsync(r)}return t.data?{data:getTypedArray(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){i=new ImageLoader(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],o=i.url;if(Array.isArray(o)){const t=[];for(let e=0,n=o.length;e<n;e++){const n=o[e],i=await r(n);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new DataTexture(i.data,i.width,i.height)))}n[i.uuid]=new Source(t)}else{const t=await r(i.url);n[i.uuid]=new Source(t)}}}return n}parseTextures(t,e){function n(t,e){return"number"==typeof t?t:e[t]}const i={};if(void 0!==t)for(let r=0,o=t.length;r<o;r++){const o=t[r],s=e[o.image],a=s.data;let l;Array.isArray(a)?(l=new CubeTexture,6===a.length&&(l.needsUpdate=!0)):(l=a&&a.data?new DataTexture:new Texture,a&&(l.needsUpdate=!0)),l.source=s,l.uuid=o.uuid,void 0!==o.name&&(l.name=o.name),void 0!==o.mapping&&(l.mapping=n(o.mapping,TEXTURE_MAPPING)),void 0!==o.channel&&(l.channel=o.channel),void 0!==o.offset&&l.offset.fromArray(o.offset),void 0!==o.repeat&&l.repeat.fromArray(o.repeat),void 0!==o.center&&l.center.fromArray(o.center),void 0!==o.rotation&&(l.rotation=o.rotation),void 0!==o.wrap&&(l.wrapS=n(o.wrap[0],TEXTURE_WRAPPING),l.wrapT=n(o.wrap[1],TEXTURE_WRAPPING)),void 0!==o.format&&(l.format=o.format),void 0!==o.internalFormat&&(l.internalFormat=o.internalFormat),void 0!==o.type&&(l.type=o.type),void 0!==o.colorSpace&&(l.colorSpace=o.colorSpace),void 0!==o.minFilter&&(l.minFilter=n(o.minFilter,TEXTURE_FILTER)),void 0!==o.magFilter&&(l.magFilter=n(o.magFilter,TEXTURE_FILTER)),void 0!==o.anisotropy&&(l.anisotropy=o.anisotropy),void 0!==o.flipY&&(l.flipY=o.flipY),void 0!==o.generateMipmaps&&(l.generateMipmaps=o.generateMipmaps),void 0!==o.premultiplyAlpha&&(l.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(l.unpackAlignment=o.unpackAlignment),void 0!==o.compareFunction&&(l.compareFunction=o.compareFunction),void 0!==o.userData&&(l.userData=o.userData),i[o.uuid]=l}return i}parseObject(t,e,n,i,r){let o,s,a;function l(t){return e[t]}function c(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];e.push(n[r])}return e}return n[t]}}function u(t){return i[t]}switch(t.type){case"Scene":o=new Scene,void 0!==t.background&&(o.background=Number.isInteger(t.background)?new Color(t.background):u(t.background)),void 0!==t.environment&&(o.environment=u(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?o.fog=new Fog(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(o.fog=new FogExp2(t.fog.color,t.fog.density)),""!==t.fog.name&&(o.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(o.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(o.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&o.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(o.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&o.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":o=new PerspectiveCamera(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(o.focus=t.focus),void 0!==t.zoom&&(o.zoom=t.zoom),void 0!==t.filmGauge&&(o.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(o.filmOffset=t.filmOffset),void 0!==t.view&&(o.view=Object.assign({},t.view));break;case"OrthographicCamera":o=new OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(o.zoom=t.zoom),void 0!==t.view&&(o.view=Object.assign({},t.view));break;case"AmbientLight":o=new AmbientLight(t.color,t.intensity);break;case"DirectionalLight":o=new DirectionalLight(t.color,t.intensity),o.target=t.target||"";break;case"PointLight":o=new PointLight(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":o=new RectAreaLight(t.color,t.intensity,t.width,t.height);break;case"SpotLight":o=new SpotLight(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),o.target=t.target||"";break;case"HemisphereLight":o=new HemisphereLight(t.color,t.groundColor,t.intensity);break;case"LightProbe":o=(new LightProbe).fromJSON(t);break;case"SkinnedMesh":s=l(t.geometry),a=c(t.material),o=new SkinnedMesh(s,a),void 0!==t.bindMode&&(o.bindMode=t.bindMode),void 0!==t.bindMatrix&&o.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(o.skeleton=t.skeleton);break;case"Mesh":s=l(t.geometry),a=c(t.material),o=new Mesh(s,a);break;case"InstancedMesh":s=l(t.geometry),a=c(t.material);const e=t.instanceMatrix,n=t.instanceColor;o=new InstancedMesh(s,a,t.count),o.instanceMatrix=new InstancedBufferAttribute(new Float32Array(e.array),16),void 0!==n&&(o.instanceColor=new InstancedBufferAttribute(new Float32Array(n.array),n.itemSize));break;case"BatchedMesh":s=l(t.geometry),a=c(t.material),o=new BatchedMesh(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,a),o.geometry=s,o.perObjectFrustumCulled=t.perObjectFrustumCulled,o.sortObjects=t.sortObjects,o._drawRanges=t.drawRanges,o._reservedRanges=t.reservedRanges,o._visibility=t.visibility,o._active=t.active,o._bounds=t.bounds.map((t=>{const e=new Box3;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const n=new Sphere;return n.radius=t.sphereRadius,n.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:n}})),o._maxInstanceCount=t.maxInstanceCount,o._maxVertexCount=t.maxVertexCount,o._maxIndexCount=t.maxIndexCount,o._geometryInitialized=t.geometryInitialized,o._geometryCount=t.geometryCount,o._matricesTexture=u(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(o._colorsTexture=u(t.colorsTexture.uuid));break;case"LOD":o=new LOD;break;case"Line":o=new Line(l(t.geometry),c(t.material));break;case"LineLoop":o=new LineLoop(l(t.geometry),c(t.material));break;case"LineSegments":o=new LineSegments(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":o=new Points(l(t.geometry),c(t.material));break;case"Sprite":o=new Sprite(c(t.material));break;case"Group":o=new Group;break;case"Bone":o=new Bone;break;default:o=new Object3D}if(o.uuid=t.uuid,void 0!==t.name&&(o.name=t.name),void 0!==t.matrix?(o.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(o.matrixAutoUpdate=t.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(void 0!==t.position&&o.position.fromArray(t.position),void 0!==t.rotation&&o.rotation.fromArray(t.rotation),void 0!==t.quaternion&&o.quaternion.fromArray(t.quaternion),void 0!==t.scale&&o.scale.fromArray(t.scale)),void 0!==t.up&&o.up.fromArray(t.up),void 0!==t.castShadow&&(o.castShadow=t.castShadow),void 0!==t.receiveShadow&&(o.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(o.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(o.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(o.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(o.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&o.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(o.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(o.visible=t.visible),void 0!==t.frustumCulled&&(o.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(o.renderOrder=t.renderOrder),void 0!==t.userData&&(o.userData=t.userData),void 0!==t.layers&&(o.layers.mask=t.layers),void 0!==t.children){const s=t.children;for(let t=0;t<s.length;t++)o.add(this.parseObject(s[t],e,n,i,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){o.animations.push(r[e[t]])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(o.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const n=e[t],i=o.getObjectByProperty("uuid",n.object);void 0!==i&&o.addLevel(i,n.distance,n.hysteresis)}}return o}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse((function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const n=e[t.skeleton];void 0===n||t.bind(n,t.bindMatrix)}}))}bindLightTargets(t){t.traverse((function(e){if(e.isDirectionalLight||e.isSpotLight){const n=t.getObjectByProperty("uuid",e.target);e.target=void 0!==n?n:new Object3D}}))}}const TEXTURE_MAPPING={UVMapping:UVMapping,CubeReflectionMapping:CubeReflectionMapping,CubeRefractionMapping:CubeRefractionMapping,EquirectangularReflectionMapping:EquirectangularReflectionMapping,EquirectangularRefractionMapping:EquirectangularRefractionMapping,CubeUVReflectionMapping:CubeUVReflectionMapping},TEXTURE_WRAPPING={RepeatWrapping:RepeatWrapping,ClampToEdgeWrapping:ClampToEdgeWrapping,MirroredRepeatWrapping:MirroredRepeatWrapping},TEXTURE_FILTER={NearestFilter:NearestFilter,NearestMipmapNearestFilter:NearestMipmapNearestFilter,NearestMipmapLinearFilter:NearestMipmapLinearFilter,LinearFilter:LinearFilter,LinearMipmapNearestFilter:LinearMipmapNearestFilter,LinearMipmapLinearFilter:LinearMipmapLinearFilter};class ImageBitmapLoader extends Loader{constructor(t){super(t),this.isImageBitmapLoader=!0,this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,o=Cache.get(t);if(void 0!==o)return r.manager.itemStart(t),o.then?void o.then((n=>{e&&e(n),r.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){e&&e(o),r.manager.itemEnd(t)}),0),o);const s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader;const a=fetch(t,s).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return Cache.add(t,n),e&&e(n),r.manager.itemEnd(t),n})).catch((function(e){i&&i(e),Cache.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));Cache.add(t,a),r.manager.itemStart(t)}}let _context;class AudioContext{static getContext(){return void 0===_context&&(_context=new(window.AudioContext||window.webkitAudioContext)),_context}static setContext(t){_context=t}}class AudioLoader extends Loader{constructor(t){super(t)}load(t,e,n,i){const r=this,o=new FileLoader(this.manager);function s(e){i&&i(e),r.manager.itemError(t)}o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(t){try{const n=t.slice(0);AudioContext.getContext().decodeAudioData(n,(function(t){e(t)})).catch(s)}catch(t){s(t)}}),n,i)}}const _eyeRight=new Matrix4,_eyeLeft=new Matrix4,_projectionMatrix=new Matrix4;class StereoCamera{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new PerspectiveCamera,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(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,_projectionMatrix.copy(t.projectionMatrix);const n=e.eyeSep/2,i=n*e.near/e.focus,r=e.near*Math.tan(DEG2RAD*e.fov*.5)/e.zoom;let o,s;_eyeLeft.elements[12]=-n,_eyeRight.elements[12]=n,o=-r*e.aspect+i,s=r*e.aspect+i,_projectionMatrix.elements[0]=2*e.near/(s-o),_projectionMatrix.elements[8]=(s+o)/(s-o),this.cameraL.projectionMatrix.copy(_projectionMatrix),o=-r*e.aspect-i,s=r*e.aspect-i,_projectionMatrix.elements[0]=2*e.near/(s-o),_projectionMatrix.elements[8]=(s+o)/(s-o),this.cameraR.projectionMatrix.copy(_projectionMatrix)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(_eyeLeft),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(_eyeRight)}}class ArrayCamera extends PerspectiveCamera{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Clock{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=now$1(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=now$1();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function now$1(){return performance.now()}const _position$1=new Vector3,_quaternion$1=new Quaternion,_scale$1=new Vector3,_orientation$1=new Vector3;class AudioListener extends Object3D{constructor(){super(),this.type="AudioListener",this.context=AudioContext.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Clock}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(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(_position$1,_quaternion$1,_scale$1),_orientation$1.set(0,0,-1).applyQuaternion(_quaternion$1),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(_position$1.x,t),e.positionY.linearRampToValueAtTime(_position$1.y,t),e.positionZ.linearRampToValueAtTime(_position$1.z,t),e.forwardX.linearRampToValueAtTime(_orientation$1.x,t),e.forwardY.linearRampToValueAtTime(_orientation$1.y,t),e.forwardZ.linearRampToValueAtTime(_orientation$1.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(_position$1.x,_position$1.y,_position$1.z),e.setOrientation(_orientation$1.x,_orientation$1.y,_orientation$1.z,n.x,n.y,n.z)}}class Audio extends Object3D{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.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(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return;if(!1===this.hasPlaybackControl)return;this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,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}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);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 t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);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(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,!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(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return!1!==this.hasPlaybackControl&&this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),"buffer"!==t.sourceType||(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice()),this}clone(t){return new this.constructor(this.listener).copy(this,t)}}const _position=new Vector3,_quaternion=new Quaternion,_scale=new Vector3,_orientation=new Vector3;class PositionalAudio extends Audio{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(_position,_quaternion,_scale),_orientation.set(0,0,1).applyQuaternion(_quaternion);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(_position.x,t),e.positionY.linearRampToValueAtTime(_position.y,t),e.positionZ.linearRampToValueAtTime(_position.z,t),e.orientationX.linearRampToValueAtTime(_orientation.x,t),e.orientationY.linearRampToValueAtTime(_orientation.y,t),e.orientationZ.linearRampToValueAtTime(_orientation.z,t)}else e.setPosition(_position.x,_position.y,_position.z),e.setOrientation(_orientation.x,_orientation.y,_orientation.z)}}class AudioAnalyser{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}}class PropertyMixer{constructor(t,e,n){let i,r,o;switch(this.binding=t,this.valueSize=n,e){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,r=t*i+i;let o=this.cumulativeWeight;if(0===o){for(let t=0;t!==i;++t)n[r+t]=n[t];o=e}else{o+=e;this._mixBufferRegion(n,r,0,e/o,i)}this.cumulativeWeight=o}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){this._mixBufferRegion(n,i,e*this._origIndex,1-r,e)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){s.setValue(n,i);break}}saveOriginalState(){const t=this.buffer,e=this.valueSize,n=e*this._origIndex;this.binding.getValue(t,n);for(let i=e,r=n;i!==r;++i)t[i]=t[n+i%e];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){this.binding.setValue(this.buffer,3*this.valueSize)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,r){if(i>=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){Quaternion.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const o=this._workIndex*r;Quaternion.multiplyQuaternionsFlat(t,o,t,e,t,n),Quaternion.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,n,i,r){const o=1-i;for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]*o+t[n+s]*i}}_lerpAdditive(t,e,n,i,r){for(let o=0;o!==r;++o){const r=e+o;t[r]=t[r]+t[n+o]*i}}}const _RESERVED_CHARS_RE="\\[\\]\\.:\\/",_reservedRe=new RegExp("["+_RESERVED_CHARS_RE+"]","g"),_wordChar="[^"+_RESERVED_CHARS_RE+"]",_wordCharOrDot="[^"+_RESERVED_CHARS_RE.replace("\\.","")+"]",_directoryRe=/((?:WC+[\/:])*)/.source.replace("WC",_wordChar),_nodeRe=/(WCOD+)?/.source.replace("WCOD",_wordCharOrDot),_objectRe=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",_wordChar),_propertyRe=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",_wordChar),_trackRe=new RegExp("^"+_directoryRe+_nodeRe+_objectRe+_propertyRe+"$"),_supportedObjectNames=["material","materials","bones","map"];class Composite{constructor(t,e,n){const i=n||PropertyBinding.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._bindings[this._targetGroup.nCachedObjects_];void 0!==n&&n.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class PropertyBinding{constructor(t,e,n){this.path=e,this.parsedPath=n||PropertyBinding.parseTrackName(e),this.node=PropertyBinding.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new PropertyBinding.Composite(t,e,n):new PropertyBinding(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(_reservedRe,"")}static parseTrackName(t){const e=_trackRe.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==_supportedObjectNames.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const o=n(r.children);if(o)return o}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=PropertyBinding.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return;if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return;if(!t.material.materials)return;t=t.material.materials;break;case"bones":if(!t.skeleton)return;t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return;if(!t.material.map)return;t=t.material.map;break;default:if(void 0===t[n])return;t=t[n]}if(void 0!==i){if(void 0===t[i])return;t=t[i]}}const o=t[i];if(void 0===o)return;let s=this.Versioning.None;this.targetObject=t,!0===t.isMaterial?s=this.Versioning.NeedsUpdate:!0===t.isObject3D&&(s=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return;if(!t.geometry.morphAttributes)return;void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}a=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else void 0!==o.fromArray&&void 0!==o.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(a=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}PropertyBinding.Composite=Composite,PropertyBinding.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},PropertyBinding.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},PropertyBinding.prototype.GetterByBindingType=[PropertyBinding.prototype._getValue_direct,PropertyBinding.prototype._getValue_array,PropertyBinding.prototype._getValue_arrayElement,PropertyBinding.prototype._getValue_toArray],PropertyBinding.prototype.SetterByBindingTypeAndVersioning=[[PropertyBinding.prototype._setValue_direct,PropertyBinding.prototype._setValue_direct_setNeedsUpdate,PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_array,PropertyBinding.prototype._setValue_array_setNeedsUpdate,PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_arrayElement,PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate,PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_fromArray,PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate,PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class AnimationObjectGroup{constructor(){this.isAnimationObjectGroup=!0,this.uuid=generateUUID$1(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,o=r.length;let s,a=t.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],h=u.uuid;let d=e[h];if(void 0===d){d=a++,e[h]=d,t.push(u);for(let t=0,e=o;t!==e;++t)r[t].push(new PropertyBinding(u,n[t],i[t]))}else if(d<l){s=t[d];const a=--l,c=t[a];e[c.uuid]=d,t[d]=c,e[h]=a,t[a]=u;for(let t=0,e=o;t!==e;++t){const e=r[t];let o=e[d];e[d]=e[a],void 0===o&&(o=new PropertyBinding(u,n[t],i[t])),e[a]=o}}}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let o=0,s=arguments.length;o!==s;++o){const s=arguments[o],a=s.uuid,l=e[a];if(void 0!==l&&l>=r){const o=r++,c=t[o];e[c.uuid]=l,t[l]=c,e[a]=o,t[o]=s;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[l];e[l]=e[o],e[o]=i}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,o=t.length;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s].uuid,l=e[a];if(void 0!==l)if(delete e[a],l<r){const s=--r,a=t[s],c=--o,u=t[c];e[a.uuid]=l,t[l]=a,e[u.uuid]=s,t[s]=u,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[c];e[l]=e[s],e[s]=i,e.pop()}}else{const r=--o,s=t[r];r>0&&(e[s.uuid]=l),t[l]=s,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const o=this._paths,s=this._parsedPaths,a=this._objects,l=this.nCachedObjects_,c=new Array(a.length);i=r.length,n[t]=i,o.push(t),s.push(e),r.push(c);for(let n=l,i=a.length;n!==i;++n){c[n]=new PropertyBinding(a[n],t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s];e[t[s]]=n,o[n]=a,o.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}}class AnimationAction{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,o=r.length,s=new Array(o),a={endingStart:ZeroCurvatureEnding,endingEnd:ZeroCurvatureEnding};for(let t=0;t!==o;++t){const e=r[t].createInterpolant(null);s[t]=e,e.settings=a}this._interpolantSettings=a,this._interpolants=s,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=LoopRepeat,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,i=t._clip.duration,r=n/i;t.warp(1,i/n,e),this.warp(r,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,o=this.timeScale;let s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);const a=s.parameterPositions,l=s.sampleValues;return a[0]=r,a[1]=r+n,l[0]=t/o,l[1]=e/o,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const o=this._updateTime(e),s=this._updateWeight(t);if(s>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===AdditiveAnimationBlendMode)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(o),e[n].accumulateAdditive(s);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(o),e[n].accumulate(i,s)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const o=n===LoopPingPong;if(0===t)return-1===r||!o||1&~r?i:e-i;if(n===LoopOnce){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){const e=t<0;this._setEndings(e,!e,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(o&&!(1&~r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=ZeroSlopeEnding,i.endingEnd=ZeroSlopeEnding):(i.endingStart=t?this.zeroSlopeAtStart?ZeroSlopeEnding:ZeroCurvatureEnding:WrapAroundEnding,i.endingEnd=e?this.zeroSlopeAtEnd?ZeroSlopeEnding:ZeroCurvatureEnding:WrapAroundEnding)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const s=o.parameterPositions,a=o.sampleValues;return s[0]=r,a[0]=e,s[1]=r+t,a[1]=n,this}}const _controlInterpolantsResultBuffer=new Float32Array(1);class AnimationMixer extends EventDispatcher{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,o=t._propertyBindings,s=t._interpolants,a=n.uuid,l=this._bindingsByRootAndName;let c=l[a];void 0===c&&(c={},l[a]=c);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let u=c[l];if(void 0!==u)++u.referenceCount,o[t]=u;else{if(u=o[t],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,a,l));continue}u=new PropertyMixer(PropertyBinding.create(n,l,e&&e._propertyBindings[t].binding.parsedPath),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,a,l),o[t]=u}s[t].resultBuffer=u.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,r=this._actionsByClip;let o=r[e];if(void 0===o)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=o;else{const e=o.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,o=this._actionsByClip,s=o[r],a=s.knownActions,l=a[a.length-1],c=t._byClipCacheIndex;l._byClipCacheIndex=c,a[c]=l,a.pop(),t._byClipCacheIndex=null;delete s.actionByRoot[(t._localRoot||this._root).uuid],0===a.length&&delete o[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,r=this._bindings;let o=i[e];void 0===o&&(o={},i[e]=o),o[n]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,s=o[i],a=e[e.length-1],l=t._cacheIndex;a._cacheIndex=l,e[l]=a,e.pop(),delete s[r],0===Object.keys(s).length&&delete o[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return void 0===n&&(n=new LinearInterpolant(new Float32Array(2),new Float32Array(2),1,_controlInterpolantsResultBuffer),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r}clipAction(t,e,n){const i=e||this._root,r=i.uuid;let o="string"==typeof t?AnimationClip.findByName(i,t):t;const s=null!==o?o.uuid:t,a=this._actionsByClip[s];let l=null;if(void 0===n&&(n=null!==o?o.blendMode:NormalAnimationBlendMode),void 0!==a){const t=a.actionByRoot[r];if(void 0!==t&&t.blendMode===n)return t;l=a.knownActions[0],null===o&&(o=l._clip)}if(null===o)return null;const c=new AnimationAction(this,o,e,n);return this._bindAction(c,l),this._addInactiveAction(c,s,r),c}existingAction(t,e){const n=e||this._root,i=n.uuid,r="string"==typeof t?AnimationClip.findByName(n,t):t,o=this._actionsByClip[r?r.uuid:t];return void 0!==o&&o.actionByRoot[i]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){const e=this._actions,n=this._nActiveActions,i=this.time+=t*=this.timeScale,r=Math.sign(t),o=this._accuIndex^=1;for(let s=0;s!==n;++s){e[s]._update(i,t,r,o)}const s=this._bindings,a=this._nActiveBindings;for(let t=0;t!==a;++t)s[t].apply(o);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const t=r.knownActions;for(let n=0,i=t.length;n!==i;++n){const i=t[n];this._deactivateAction(i);const r=i._cacheIndex,o=e[e.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,o._cacheIndex=r,e[r]=o,e.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const t in n){const i=n[t].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[e];if(void 0!==i)for(const t in i){const e=i[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class RenderTarget3D extends RenderTarget{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new Data3DTexture(null,t,e,n),this.texture.isRenderTargetTexture=!0}}class RenderTargetArray extends RenderTarget{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isRenderTargetArray=!0,this.depth=n,this.texture=new DataArrayTexture(null,t,e,n),this.texture.isRenderTargetTexture=!0}}class Uniform{constructor(t){this.value=t}clone(){return new Uniform(void 0===this.value.clone?this.value:this.value.clone())}}let _id$2=0;class UniformsGroup extends EventDispatcher{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:_id$2++}),this.name="",this.usage=StaticDrawUsage,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,n=e.length;t<n;t++){const n=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<n.length;t++)this.uniforms.push(n[t].clone())}return this}clone(){return(new this.constructor).copy(this)}}class InstancedInterleavedBuffer extends InterleavedBuffer{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class GLBufferAttribute{constructor(t,e,n,i,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}}const _matrix=new Matrix4;class Raycaster{constructor(t,e,n=0,i=1/0){this.ray=new Ray(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new Layers,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera&&(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e)}setFromXRController(t){return _matrix.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(_matrix),this}intersectObject(t,e=!0,n=[]){return intersect(t,this,n,e),n.sort(ascSort),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)intersect(t[i],this,n,e);return n.sort(ascSort),n}}function ascSort(t,e){return t.distance-e.distance}function intersect(t,e,n,i){let r=!0;if(t.layers.test(e.layers)){!1===t.raycast(e,n)&&(r=!1)}if(!0===r&&!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)intersect(i[t],e,n,!0)}}class Spherical{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=clamp(this.phi,t,Math.PI-t),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(clamp(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class Cylindrical{constructor(t=1,e=0,n=0){return this.radius=t,this.theta=e,this.y=n,this}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return(new this.constructor).copy(this)}}class Matrix2{constructor(t,e,n,i){Matrix2.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}const _vector$4=new Vector2;class Box2{constructor(t=new Vector2(1/0,1/0),e=new Vector2(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=_vector$4.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,_vector$4).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const _startP=new Vector3,_startEnd=new Vector3;class Line3{constructor(t=new Vector3,e=new Vector3){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){_startP.subVectors(t,this.start),_startEnd.subVectors(this.end,this.start);const n=_startEnd.dot(_startEnd);let i=_startEnd.dot(_startP)/n;return e&&(i=clamp(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const _vector$3=new Vector3;class SpotLightHelper extends Object3D{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new BufferGeometry,i=[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 t=0,e=1,n=32;t<n;t++,e++){const r=t/n*Math.PI*2,o=e/n*Math.PI*2;i.push(Math.cos(r),Math.sin(r),1,Math.cos(o),Math.sin(o),1)}n.setAttribute("position",new Float32BufferAttribute(i,3));const r=new LineBasicMaterial({fog:!1,toneMapped:!1});this.cone=new LineSegments(n,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 t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),_vector$3.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(_vector$3),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const _vector$2=new Vector3,_boneMatrix=new Matrix4,_matrixWorldInv=new Matrix4;class SkeletonHelper extends LineSegments{constructor(t){const e=getBoneList(t),n=new BufferGeometry,i=[],r=[],o=new Color(0,0,1),s=new Color(0,1,0);for(let t=0;t<e.length;t++){const n=e[t];n.parent&&n.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(o.r,o.g,o.b),r.push(s.r,s.g,s.b))}n.setAttribute("position",new Float32BufferAttribute(i,3)),n.setAttribute("color",new Float32BufferAttribute(r,3));super(n,new LineBasicMaterial({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,n=this.geometry,i=n.getAttribute("position");_matrixWorldInv.copy(this.root.matrixWorld).invert();for(let t=0,n=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(_boneMatrix.multiplyMatrices(_matrixWorldInv,r.matrixWorld),_vector$2.setFromMatrixPosition(_boneMatrix),i.setXYZ(n,_vector$2.x,_vector$2.y,_vector$2.z),_boneMatrix.multiplyMatrices(_matrixWorldInv,r.parent.matrixWorld),_vector$2.setFromMatrixPosition(_boneMatrix),i.setXYZ(n+1,_vector$2.x,_vector$2.y,_vector$2.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}}function getBoneList(t){const e=[];!0===t.isBone&&e.push(t);for(let n=0;n<t.children.length;n++)e.push.apply(e,getBoneList(t.children[n]));return e}class PointLightHelper extends Mesh{constructor(t,e,n){super(new SphereGeometry(e,4,2),new MeshBasicMaterial({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=n,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)}}const _vector$1=new Vector3,_color1=new Color,_color2=new Color;class HemisphereLightHelper extends Object3D{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new OctahedronGeometry(e);i.rotateY(.5*Math.PI),this.material=new MeshBasicMaterial({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),o=new Float32Array(3*r.count);i.setAttribute("color",new BufferAttribute(o,3)),this.add(new Mesh(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");_color1.copy(this.light.color),_color2.copy(this.light.groundColor);for(let t=0,n=e.count;t<n;t++){const i=t<n/2?_color1:_color2;e.setXYZ(t,i.r,i.g,i.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(_vector$1.setFromMatrixPosition(this.light.matrixWorld).negate())}}class GridHelper extends LineSegments{constructor(t=10,e=10,n=4473924,i=8947848){n=new Color(n),i=new Color(i);const r=e/2,o=t/e,s=t/2,a=[],l=[];for(let t=0,c=0,u=-s;t<=e;t++,u+=o){a.push(-s,0,u,s,0,u),a.push(u,0,-s,u,0,s);const e=t===r?n:i;e.toArray(l,c),c+=3,e.toArray(l,c),c+=3,e.toArray(l,c),c+=3,e.toArray(l,c),c+=3}const c=new BufferGeometry;c.setAttribute("position",new Float32BufferAttribute(a,3)),c.setAttribute("color",new Float32BufferAttribute(l,3));super(c,new LineBasicMaterial({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class PolarGridHelper extends LineSegments{constructor(t=10,e=16,n=8,i=64,r=4473924,o=8947848){r=new Color(r),o=new Color(o);const s=[],a=[];if(e>1)for(let n=0;n<e;n++){const i=n/e*(2*Math.PI),l=Math.sin(i)*t,c=Math.cos(i)*t;s.push(0,0,0),s.push(l,0,c);const u=1&n?r:o;a.push(u.r,u.g,u.b),a.push(u.r,u.g,u.b)}for(let e=0;e<n;e++){const l=1&e?r:o,c=t-t/n*e;for(let t=0;t<i;t++){let e=t/i*(2*Math.PI),n=Math.sin(e)*c,r=Math.cos(e)*c;s.push(n,0,r),a.push(l.r,l.g,l.b),e=(t+1)/i*(2*Math.PI),n=Math.sin(e)*c,r=Math.cos(e)*c,s.push(n,0,r),a.push(l.r,l.g,l.b)}}const l=new BufferGeometry;l.setAttribute("position",new Float32BufferAttribute(s,3)),l.setAttribute("color",new Float32BufferAttribute(a,3));super(l,new LineBasicMaterial({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const _v1=new Vector3,_v2=new Vector3,_v3=new Vector3;class DirectionalLightHelper extends Object3D{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===e&&(e=1);let i=new BufferGeometry;i.setAttribute("position",new Float32BufferAttribute([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new LineBasicMaterial({fog:!1,toneMapped:!1});this.lightPlane=new Line(i,r),this.add(this.lightPlane),i=new BufferGeometry,i.setAttribute("position",new Float32BufferAttribute([0,0,0,0,0,1],3)),this.targetLine=new Line(i,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),_v1.setFromMatrixPosition(this.light.matrixWorld),_v2.setFromMatrixPosition(this.light.target.matrixWorld),_v3.subVectors(_v2,_v1),this.lightPlane.lookAt(_v2),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(_v2),this.targetLine.scale.z=_v3.length()}}const _vector=new Vector3,_camera=new Camera;class CameraHelper extends LineSegments{constructor(t){const e=new BufferGeometry,n=new LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],o={};function s(t,e){a(t),a(e)}function a(t){i.push(0,0,0),r.push(0,0,0),void 0===o[t]&&(o[t]=[]),o[t].push(i.length/3-1)}s("n1","n2"),s("n2","n4"),s("n4","n3"),s("n3","n1"),s("f1","f2"),s("f2","f4"),s("f4","f3"),s("f3","f1"),s("n1","f1"),s("n2","f2"),s("n3","f3"),s("n4","f4"),s("p","n1"),s("p","n2"),s("p","n3"),s("p","n4"),s("u1","u2"),s("u2","u3"),s("u3","u1"),s("c","t"),s("p","c"),s("cn1","cn2"),s("cn3","cn4"),s("cf1","cf2"),s("cf3","cf4"),e.setAttribute("position",new Float32BufferAttribute(i,3)),e.setAttribute("color",new Float32BufferAttribute(r,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const l=new Color(16755200),c=new Color(16711680),u=new Color(43775),h=new Color(16777215),d=new Color(3355443);this.setColors(l,c,u,h,d)}setColors(t,e,n,i,r){const o=this.geometry.getAttribute("color");o.setXYZ(0,t.r,t.g,t.b),o.setXYZ(1,t.r,t.g,t.b),o.setXYZ(2,t.r,t.g,t.b),o.setXYZ(3,t.r,t.g,t.b),o.setXYZ(4,t.r,t.g,t.b),o.setXYZ(5,t.r,t.g,t.b),o.setXYZ(6,t.r,t.g,t.b),o.setXYZ(7,t.r,t.g,t.b),o.setXYZ(8,t.r,t.g,t.b),o.setXYZ(9,t.r,t.g,t.b),o.setXYZ(10,t.r,t.g,t.b),o.setXYZ(11,t.r,t.g,t.b),o.setXYZ(12,t.r,t.g,t.b),o.setXYZ(13,t.r,t.g,t.b),o.setXYZ(14,t.r,t.g,t.b),o.setXYZ(15,t.r,t.g,t.b),o.setXYZ(16,t.r,t.g,t.b),o.setXYZ(17,t.r,t.g,t.b),o.setXYZ(18,t.r,t.g,t.b),o.setXYZ(19,t.r,t.g,t.b),o.setXYZ(20,t.r,t.g,t.b),o.setXYZ(21,t.r,t.g,t.b),o.setXYZ(22,t.r,t.g,t.b),o.setXYZ(23,t.r,t.g,t.b),o.setXYZ(24,e.r,e.g,e.b),o.setXYZ(25,e.r,e.g,e.b),o.setXYZ(26,e.r,e.g,e.b),o.setXYZ(27,e.r,e.g,e.b),o.setXYZ(28,e.r,e.g,e.b),o.setXYZ(29,e.r,e.g,e.b),o.setXYZ(30,e.r,e.g,e.b),o.setXYZ(31,e.r,e.g,e.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,i.r,i.g,i.b),o.setXYZ(39,i.r,i.g,i.b),o.setXYZ(40,r.r,r.g,r.b),o.setXYZ(41,r.r,r.g,r.b),o.setXYZ(42,r.r,r.g,r.b),o.setXYZ(43,r.r,r.g,r.b),o.setXYZ(44,r.r,r.g,r.b),o.setXYZ(45,r.r,r.g,r.b),o.setXYZ(46,r.r,r.g,r.b),o.setXYZ(47,r.r,r.g,r.b),o.setXYZ(48,r.r,r.g,r.b),o.setXYZ(49,r.r,r.g,r.b),o.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;_camera.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const n=this.camera.coordinateSystem===WebGLCoordinateSystem?-1:0;setPoint("c",e,t,_camera,0,0,n),setPoint("t",e,t,_camera,0,0,1),setPoint("n1",e,t,_camera,-1,-1,n),setPoint("n2",e,t,_camera,1,-1,n),setPoint("n3",e,t,_camera,-1,1,n),setPoint("n4",e,t,_camera,1,1,n),setPoint("f1",e,t,_camera,-1,-1,1),setPoint("f2",e,t,_camera,1,-1,1),setPoint("f3",e,t,_camera,-1,1,1),setPoint("f4",e,t,_camera,1,1,1),setPoint("u1",e,t,_camera,.7,1.1,n),setPoint("u2",e,t,_camera,-.7,1.1,n),setPoint("u3",e,t,_camera,0,2,n),setPoint("cf1",e,t,_camera,-1,0,1),setPoint("cf2",e,t,_camera,1,0,1),setPoint("cf3",e,t,_camera,0,-1,1),setPoint("cf4",e,t,_camera,0,1,1),setPoint("cn1",e,t,_camera,-1,0,n),setPoint("cn2",e,t,_camera,1,0,n),setPoint("cn3",e,t,_camera,0,-1,n),setPoint("cn4",e,t,_camera,0,1,n),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function setPoint(t,e,n,i,r,o,s){_vector.set(r,o,s).unproject(i);const a=e[t];if(void 0!==a){const t=n.getAttribute("position");for(let e=0,n=a.length;e<n;e++)t.setXYZ(a[e],_vector.x,_vector.y,_vector.z)}}const _box=new Box3;class BoxHelper extends LineSegments{constructor(t,e=16776960){const n=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]),i=new Float32Array(24),r=new BufferGeometry;r.setIndex(new BufferAttribute(n,1)),r.setAttribute("position",new BufferAttribute(i,3)),super(r,new LineBasicMaterial({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==this.object&&_box.setFromObject(this.object),_box.isEmpty())return;const e=_box.min,n=_box.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=e.x,r[4]=n.y,r[5]=n.z,r[6]=e.x,r[7]=e.y,r[8]=n.z,r[9]=n.x,r[10]=e.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=e.z,r[15]=e.x,r[16]=n.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=n.x,r[22]=e.y,r[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Box3Helper extends LineSegments{constructor(t,e=16776960){const n=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]),i=new BufferGeometry;i.setIndex(new BufferAttribute(n,1)),i.setAttribute("position",new Float32BufferAttribute([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(i,new LineBasicMaterial({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class PlaneHelper extends Line{constructor(t,e=1,n=16776960){const i=n,r=new BufferGeometry;r.setAttribute("position",new Float32BufferAttribute([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 LineBasicMaterial({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const o=new BufferGeometry;o.setAttribute("position",new Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),o.computeBoundingSphere(),this.add(new Mesh(o,new MeshBasicMaterial({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){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(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const _axis=new Vector3;let _lineGeometry,_coneGeometry;class ArrowHelper extends Object3D{constructor(t=new Vector3(0,0,1),e=new Vector3(0,0,0),n=1,i=16776960,r=.2*n,o=.2*r){super(),this.type="ArrowHelper",void 0===_lineGeometry&&(_lineGeometry=new BufferGeometry,_lineGeometry.setAttribute("position",new Float32BufferAttribute([0,0,0,0,1,0],3)),_coneGeometry=new CylinderGeometry(0,.5,1,5,1),_coneGeometry.translate(0,-.5,0)),this.position.copy(e),this.line=new Line(_lineGeometry,new LineBasicMaterial({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Mesh(_coneGeometry,new MeshBasicMaterial({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,r,o)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{_axis.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(_axis,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class AxesHelper extends LineSegments{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new BufferGeometry;n.setAttribute("position",new Float32BufferAttribute(e,3)),n.setAttribute("color",new Float32BufferAttribute([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new LineBasicMaterial({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const i=new Color,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class ShapePath{constructor(){this.type="ShapePath",this.color=new Color,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,o){return this.currentPath.bezierCurveTo(t,e,n,i,r,o),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let i=!1;for(let r=n-1,o=0;o<n;r=o++){let n=e[r],s=e[o],a=s.x-n.x,l=s.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=e[o],a=-a,s=e[r],l=-l),t.y<n.y||t.y>s.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-a*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(s.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=s.x)return!0}}return i}const n=ShapeUtils.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,o,s;const a=[];if(1===i.length)return o=i[0],s=new Shape,s.curves=o.curves,a.push(s),a;let l=!n(i[0].getPoints());l=t?!l:l;const c=[],u=[];let h,d,p=[],f=0;u[f]=void 0,p[f]=[];for(let e=0,s=i.length;e<s;e++)o=i[e],h=o.getPoints(),r=n(h),r=t?!r:r,r?(!l&&u[f]&&f++,u[f]={s:new Shape,p:h},u[f].s.curves=o.curves,l&&f++,p[f]=[]):p[f].push({h:o,p:h[0]});if(!u[0])return function(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n],r=new Shape;r.curves=i.curves,e.push(r)}return e}(i);if(u.length>1){let t=!1,n=0;for(let t=0,e=u.length;t<e;t++)c[t]=[];for(let i=0,r=u.length;i<r;i++){const r=p[i];for(let o=0;o<r.length;o++){const s=r[o];let a=!0;for(let r=0;r<u.length;r++)e(s.p,u[r].p)&&(i!==r&&n++,a?(a=!1,c[r].push(s)):t=!0);a&&c[i].push(s)}}n>0&&!1===t&&(p=c)}for(let t=0,e=u.length;t<e;t++){s=u[t].s,a.push(s),d=p[t];for(let t=0,e=d.length;t<e;t++)s.holes.push(d[t].h)}return a}}class Controls extends EventDispatcher{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}function contain(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}function cover(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}function fill(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}function getByteLength(t,e,n,i){const r=getTextureTypeByteLength(i);switch(n){case AlphaFormat:case LuminanceFormat:return t*e;case LuminanceAlphaFormat:return t*e*2;case RedFormat:case RedIntegerFormat:return t*e/r.components*r.byteLength;case RGFormat:case RGIntegerFormat:return t*e*2/r.components*r.byteLength;case RGBFormat:return t*e*3/r.components*r.byteLength;case RGBAFormat:case RGBAIntegerFormat:return t*e*4/r.components*r.byteLength;case RGB_S3TC_DXT1_Format:case RGBA_S3TC_DXT1_Format:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case RGBA_S3TC_DXT3_Format:case RGBA_S3TC_DXT5_Format:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case RGB_PVRTC_2BPPV1_Format:case RGBA_PVRTC_2BPPV1_Format:return Math.max(t,16)*Math.max(e,8)/4;case RGB_PVRTC_4BPPV1_Format:case RGBA_PVRTC_4BPPV1_Format:return Math.max(t,8)*Math.max(e,8)/2;case RGB_ETC1_Format:case RGB_ETC2_Format:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case RGBA_ETC2_EAC_Format:case RGBA_ASTC_4x4_Format:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case RGBA_ASTC_5x4_Format:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case RGBA_ASTC_5x5_Format:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case RGBA_ASTC_6x5_Format:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case RGBA_ASTC_6x6_Format:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case RGBA_ASTC_8x5_Format:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case RGBA_ASTC_8x6_Format:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case RGBA_ASTC_8x8_Format:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case RGBA_ASTC_10x5_Format:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case RGBA_ASTC_10x6_Format:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case RGBA_ASTC_10x8_Format:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case RGBA_ASTC_10x10_Format:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case RGBA_ASTC_12x10_Format:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case RGBA_ASTC_12x12_Format:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case RGBA_BPTC_Format:case RGB_BPTC_SIGNED_Format:case RGB_BPTC_UNSIGNED_Format:return Math.ceil(t/4)*Math.ceil(e/4)*16;case RED_RGTC1_Format:case SIGNED_RED_RGTC1_Format:return Math.ceil(t/4)*Math.ceil(e/4)*8;case RED_GREEN_RGTC2_Format:case SIGNED_RED_GREEN_RGTC2_Format:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function getTextureTypeByteLength(t){switch(t){case UnsignedByteType:case ByteType:return{byteLength:1,components:1};case UnsignedShortType:case ShortType:case HalfFloatType:return{byteLength:2,components:1};case UnsignedShort4444Type:case UnsignedShort5551Type:return{byteLength:2,components:4};case UnsignedIntType:case IntType:case FloatType:return{byteLength:4,components:1};case UnsignedInt5999Type:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}const TextureUtils={contain:contain,cover:cover,fill:fill,getByteLength:getByteLength};
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
function WebGLAnimation(){let t=null,e=!1,n=null,i=null;function r(e,o){n(e,o),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function WebGLAttributes(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.version<n.version)&&e.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=e.get(n);if(void 0===r)e.set(n,function(e,n){const i=e.array,r=e.usage,o=i.byteLength,s=t.createBuffer();let a;if(t.bindBuffer(n,s),t.bufferData(n,i,r),e.onUploadCallback(),i instanceof Float32Array)a=t.FLOAT;else if(i instanceof Uint16Array)a=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(i instanceof Int16Array)a=t.SHORT;else if(i instanceof Uint32Array)a=t.UNSIGNED_INT;else if(i instanceof Int32Array)a=t.INT;else if(i instanceof Int8Array)a=t.BYTE;else if(i instanceof Uint8Array)a=t.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);a=t.UNSIGNED_BYTE}return{buffer:s,type:a,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,size:o}}(n,i));else if(r.version<n.version){if(r.size!==n.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(e,n,i){const r=n.array,o=n.updateRanges;if(t.bindBuffer(i,e),0===o.length)t.bufferSubData(i,0,r);else{o.sort(((t,e)=>t.start-e.start));let e=0;for(let t=1;t<o.length;t++){const n=o[e],i=o[t];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++e,o[e]=i)}o.length=e+1;for(let e=0,n=o.length;e<n;e++){const n=o[e];t.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:REVISION}})),"undefined"!=typeof window&&(window.__THREE__||(window.__THREE__=REVISION));var 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\tvec3 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 ).rgb;\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_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex="#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common$1="#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}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\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#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\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\t\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_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",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, roughness * 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",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 * ( 1.0 - 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 = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), 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.07, 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="struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\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#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 saturate(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.specularColor;\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 * transposeMat3( 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 a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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}\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.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\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\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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 );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\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 )\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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\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\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_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment="#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\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$1="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\treturn depth * ( near - far ) - near;\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\treturn ( near * far ) / ( ( far - near ) * depth - far );\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\tuniform sampler2D directionalShadowMap[ 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\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\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 sampler2D pointShadowMap[ 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\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D 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\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\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\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.diffuseColor, material.specularColor, 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";const vertex$h="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}",fragment$h="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}",vertex$g="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}",fragment$g="#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}",vertex$f="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}",fragment$f="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}",vertex$e="#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}",fragment$e="#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\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\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}",vertex$d="#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}",fragment$d="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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 <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 = packDepthToRGBA( dist );\n}",vertex$c="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",fragment$c="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}",vertex$b="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}",fragment$b="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}",vertex$a="#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}",fragment$a="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}",vertex$9="#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}",fragment$9="#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\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 <envmap_common_pars_fragment>\n#include <envmap_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}",vertex$8="#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}",fragment$8="#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}",vertex$7="#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}",fragment$7="#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 <packing>\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( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",vertex$6="#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}",fragment$6="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\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 <envmap_common_pars_fragment>\n#include <envmap_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}",vertex$5="#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}",fragment$5="#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 <packing>\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\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\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}",vertex$4="#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}",fragment$4="#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\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}",vertex$3="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}",fragment$3="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}",vertex$2="#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}",fragment$2="uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\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}",vertex$1="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}",fragment$1="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}",ShaderChunk={alphahash_fragment:alphahash_fragment,alphahash_pars_fragment:alphahash_pars_fragment,alphamap_fragment:alphamap_fragment,alphamap_pars_fragment:alphamap_pars_fragment,alphatest_fragment:alphatest_fragment,alphatest_pars_fragment:alphatest_pars_fragment,aomap_fragment:aomap_fragment,aomap_pars_fragment:aomap_pars_fragment,batching_pars_vertex:batching_pars_vertex,batching_vertex:batching_vertex,begin_vertex:begin_vertex,beginnormal_vertex:beginnormal_vertex,bsdfs:bsdfs,iridescence_fragment:iridescence_fragment,bumpmap_pars_fragment:bumpmap_pars_fragment,clipping_planes_fragment:clipping_planes_fragment,clipping_planes_pars_fragment:clipping_planes_pars_fragment,clipping_planes_pars_vertex:clipping_planes_pars_vertex,clipping_planes_vertex:clipping_planes_vertex,color_fragment:color_fragment,color_pars_fragment:color_pars_fragment,color_pars_vertex:color_pars_vertex,color_vertex:color_vertex,common:common$1,cube_uv_reflection_fragment:cube_uv_reflection_fragment,defaultnormal_vertex:defaultnormal_vertex,displacementmap_pars_vertex:displacementmap_pars_vertex,displacementmap_vertex:displacementmap_vertex,emissivemap_fragment:emissivemap_fragment,emissivemap_pars_fragment:emissivemap_pars_fragment,colorspace_fragment:colorspace_fragment,colorspace_pars_fragment:colorspace_pars_fragment,envmap_fragment:envmap_fragment,envmap_common_pars_fragment:envmap_common_pars_fragment,envmap_pars_fragment:envmap_pars_fragment,envmap_pars_vertex:envmap_pars_vertex,envmap_physical_pars_fragment:envmap_physical_pars_fragment,envmap_vertex:envmap_vertex,fog_vertex:fog_vertex,fog_pars_vertex:fog_pars_vertex,fog_fragment:fog_fragment,fog_pars_fragment:fog_pars_fragment,gradientmap_pars_fragment:gradientmap_pars_fragment,lightmap_pars_fragment:lightmap_pars_fragment,lights_lambert_fragment:lights_lambert_fragment,lights_lambert_pars_fragment:lights_lambert_pars_fragment,lights_pars_begin:lights_pars_begin,lights_toon_fragment:lights_toon_fragment,lights_toon_pars_fragment:lights_toon_pars_fragment,lights_phong_fragment:lights_phong_fragment,lights_phong_pars_fragment:lights_phong_pars_fragment,lights_physical_fragment:lights_physical_fragment,lights_physical_pars_fragment:lights_physical_pars_fragment,lights_fragment_begin:lights_fragment_begin,lights_fragment_maps:lights_fragment_maps,lights_fragment_end:lights_fragment_end,logdepthbuf_fragment:logdepthbuf_fragment,logdepthbuf_pars_fragment:logdepthbuf_pars_fragment,logdepthbuf_pars_vertex:logdepthbuf_pars_vertex,logdepthbuf_vertex:logdepthbuf_vertex,map_fragment:map_fragment,map_pars_fragment:map_pars_fragment,map_particle_fragment:map_particle_fragment,map_particle_pars_fragment:map_particle_pars_fragment,metalnessmap_fragment:metalnessmap_fragment,metalnessmap_pars_fragment:metalnessmap_pars_fragment,morphinstance_vertex:morphinstance_vertex,morphcolor_vertex:morphcolor_vertex,morphnormal_vertex:morphnormal_vertex,morphtarget_pars_vertex:morphtarget_pars_vertex,morphtarget_vertex:morphtarget_vertex,normal_fragment_begin:normal_fragment_begin,normal_fragment_maps:normal_fragment_maps,normal_pars_fragment:normal_pars_fragment,normal_pars_vertex:normal_pars_vertex,normal_vertex:normal_vertex,normalmap_pars_fragment:normalmap_pars_fragment,clearcoat_normal_fragment_begin:clearcoat_normal_fragment_begin,clearcoat_normal_fragment_maps:clearcoat_normal_fragment_maps,clearcoat_pars_fragment:clearcoat_pars_fragment,iridescence_pars_fragment:iridescence_pars_fragment,opaque_fragment:opaque_fragment,packing:packing$1,premultiplied_alpha_fragment:premultiplied_alpha_fragment,project_vertex:project_vertex,dithering_fragment:dithering_fragment,dithering_pars_fragment:dithering_pars_fragment,roughnessmap_fragment:roughnessmap_fragment,roughnessmap_pars_fragment:roughnessmap_pars_fragment,shadowmap_pars_fragment:shadowmap_pars_fragment,shadowmap_pars_vertex:shadowmap_pars_vertex,shadowmap_vertex:shadowmap_vertex,shadowmask_pars_fragment:shadowmask_pars_fragment,skinbase_vertex:skinbase_vertex,skinning_pars_vertex:skinning_pars_vertex,skinning_vertex:skinning_vertex,skinnormal_vertex:skinnormal_vertex,specularmap_fragment:specularmap_fragment,specularmap_pars_fragment:specularmap_pars_fragment,tonemapping_fragment:tonemapping_fragment,tonemapping_pars_fragment:tonemapping_pars_fragment,transmission_fragment:transmission_fragment,transmission_pars_fragment:transmission_pars_fragment,uv_pars_fragment:uv_pars_fragment,uv_pars_vertex:uv_pars_vertex,uv_vertex:uv_vertex,worldpos_vertex:worldpos_vertex,background_vert:vertex$h,background_frag:fragment$h,backgroundCube_vert:vertex$g,backgroundCube_frag:fragment$g,cube_vert:vertex$f,cube_frag:fragment$f,depth_vert:vertex$e,depth_frag:fragment$e,distanceRGBA_vert:vertex$d,distanceRGBA_frag:fragment$d,equirect_vert:vertex$c,equirect_frag:fragment$c,linedashed_vert:vertex$b,linedashed_frag:fragment$b,meshbasic_vert:vertex$a,meshbasic_frag:fragment$a,meshlambert_vert:vertex$9,meshlambert_frag:fragment$9,meshmatcap_vert:vertex$8,meshmatcap_frag:fragment$8,meshnormal_vert:vertex$7,meshnormal_frag:fragment$7,meshphong_vert:vertex$6,meshphong_frag:fragment$6,meshphysical_vert:vertex$5,meshphysical_frag:fragment$5,meshtoon_vert:vertex$4,meshtoon_frag:fragment$4,points_vert:vertex$3,points_frag:fragment$3,shadow_vert:vertex$2,shadow_frag:fragment$2,sprite_vert:vertex$1,sprite_frag:fragment$1},UniformsLib={common:{diffuse:{value:new Color(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Matrix3}},envmap:{envMap:{value:null},envMapRotation:{value:new Matrix3},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Matrix3}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Matrix3}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Matrix3},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Matrix3},normalScale:{value:new Vector2(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Matrix3},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Matrix3}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Matrix3}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Matrix3}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Color(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},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 Color(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0},uvTransform:{value:new Matrix3}},sprite:{diffuse:{value:new Color(16777215)},opacity:{value:1},center:{value:new Vector2(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}}},ShaderLib={basic:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.fog]),vertexShader:ShaderChunk.meshbasic_vert,fragmentShader:ShaderChunk.meshbasic_frag},lambert:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)}}]),vertexShader:ShaderChunk.meshlambert_vert,fragmentShader:ShaderChunk.meshlambert_frag},phong:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)},specular:{value:new Color(1118481)},shininess:{value:30}}]),vertexShader:ShaderChunk.meshphong_vert,fragmentShader:ShaderChunk.meshphong_frag},standard:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.roughnessmap,UniformsLib.metalnessmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ShaderChunk.meshphysical_vert,fragmentShader:ShaderChunk.meshphysical_frag},toon:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.gradientmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)}}]),vertexShader:ShaderChunk.meshtoon_vert,fragmentShader:ShaderChunk.meshtoon_frag},matcap:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,{matcap:{value:null}}]),vertexShader:ShaderChunk.meshmatcap_vert,fragmentShader:ShaderChunk.meshmatcap_frag},points:{uniforms:mergeUniforms([UniformsLib.points,UniformsLib.fog]),vertexShader:ShaderChunk.points_vert,fragmentShader:ShaderChunk.points_frag},dashed:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ShaderChunk.linedashed_vert,fragmentShader:ShaderChunk.linedashed_frag},depth:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.displacementmap]),vertexShader:ShaderChunk.depth_vert,fragmentShader:ShaderChunk.depth_frag},normal:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,{opacity:{value:1}}]),vertexShader:ShaderChunk.meshnormal_vert,fragmentShader:ShaderChunk.meshnormal_frag},sprite:{uniforms:mergeUniforms([UniformsLib.sprite,UniformsLib.fog]),vertexShader:ShaderChunk.sprite_vert,fragmentShader:ShaderChunk.sprite_frag},background:{uniforms:{uvTransform:{value:new Matrix3},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ShaderChunk.background_vert,fragmentShader:ShaderChunk.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Matrix3}},vertexShader:ShaderChunk.backgroundCube_vert,fragmentShader:ShaderChunk.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ShaderChunk.cube_vert,fragmentShader:ShaderChunk.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ShaderChunk.equirect_vert,fragmentShader:ShaderChunk.equirect_frag},distanceRGBA:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.displacementmap,{referencePosition:{value:new Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ShaderChunk.distanceRGBA_vert,fragmentShader:ShaderChunk.distanceRGBA_frag},shadow:{uniforms:mergeUniforms([UniformsLib.lights,UniformsLib.fog,{color:{value:new Color(0)},opacity:{value:1}}]),vertexShader:ShaderChunk.shadow_vert,fragmentShader:ShaderChunk.shadow_frag}};ShaderLib.physical={uniforms:mergeUniforms([ShaderLib.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Matrix3},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Matrix3},clearcoatNormalScale:{value:new Vector2(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Matrix3},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Matrix3},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Matrix3},sheen:{value:0},sheenColor:{value:new Color(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Matrix3},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Matrix3},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Matrix3},transmissionSamplerSize:{value:new Vector2},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Matrix3},attenuationDistance:{value:0},attenuationColor:{value:new Color(0)},specularColor:{value:new Color(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Matrix3},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Matrix3},anisotropyVector:{value:new Vector2},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Matrix3}}]),vertexShader:ShaderChunk.meshphysical_vert,fragmentShader:ShaderChunk.meshphysical_frag};const _rgb={r:0,b:0,g:0},_e1$1=new Euler,_m1$1=new Matrix4;function WebGLBackground(t,e,n,i,r,o,s){const a=new Color(0);let l,c,u=!0===o?0:1,h=null,d=0,p=null;function f(t){let i=!0===t.isScene?t.background:null;if(i&&i.isTexture){i=(t.backgroundBlurriness>0?n:e).get(i)}return i}function m(e,n){e.getRGB(_rgb,getUnlitUniformColorSpace(t)),i.buffers.color.setClear(_rgb.r,_rgb.g,_rgb.b,n,s)}return{getClearColor:function(){return a},setClearColor:function(t,e=1){a.set(t),u=e,m(a,u)},getClearAlpha:function(){return u},setClearAlpha:function(t){u=t,m(a,u)},render:function(e){let n=!1;const r=f(e);null===r?m(a,u):r&&r.isColor&&(m(r,1),n=!0);const o=t.xr.getEnvironmentBlendMode();"additive"===o?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===o&&i.buffers.color.setClear(0,0,0,0,s),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===CubeUVReflectionMapping)?(void 0===c&&(c=new Mesh(new BoxGeometry(1,1,1),new ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:cloneUniforms(ShaderLib.backgroundCube.uniforms),vertexShader:ShaderLib.backgroundCube.vertexShader,fragmentShader:ShaderLib.backgroundCube.fragmentShader,side:BackSide,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),_e1$1.copy(n.backgroundRotation),_e1$1.x*=-1,_e1$1.y*=-1,_e1$1.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(_e1$1.y*=-1,_e1$1.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$1.makeRotationFromEuler(_e1$1)),c.material.toneMapped=ColorManagement.getTransfer(i.colorSpace)!==SRGBTransfer,h===i&&d===i.version&&p===t.toneMapping||(c.material.needsUpdate=!0,h=i,d=i.version,p=t.toneMapping),c.layers.enableAll(),e.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Mesh(new PlaneGeometry(2,2),new ShaderMaterial({name:"BackgroundMaterial",uniforms:cloneUniforms(ShaderLib.background.uniforms),vertexShader:ShaderLib.background.vertexShader,fragmentShader:ShaderLib.background.fragmentShader,side:FrontSide,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=ColorManagement.getTransfer(i.colorSpace)!==SRGBTransfer,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),h===i&&d===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,h=i,d=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==c&&(c.geometry.dispose(),c.material.dispose()),void 0!==l&&(l.geometry.dispose(),l.material.dispose())}}}function WebGLBindingStates(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=c(null);let o=r,s=!1;function a(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],r=[];for(let t=0;t<n;t++)e[t]=0,i[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:r,object:t,attributes:{},index:null}}function u(){const t=o.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function h(t){d(t,0)}function d(e,n){const i=o.enabledAttributes,r=o.attributeDivisors;o.newAttributes[e]=1,0===i[e]&&(t.enableVertexAttribArray(e),i[e]=1),r[e]!==n&&(t.vertexAttribDivisor(e,n),r[e]=n)}function p(){const e=o.newAttributes,n=o.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function f(e,n,i,r,o,s,a){!0===a?t.vertexAttribIPointer(e,n,i,o,s):t.vertexAttribPointer(e,n,i,r,o,s)}function m(){g(),s=!0,o!==r&&(o=r,a(o.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){let _=!1;const y=function(e,n,r){const o=!0===r.wireframe;let s=i[e.id];void 0===s&&(s={},i[e.id]=s);let a=s[n.id];void 0===a&&(a={},s[n.id]=a);let l=a[o];void 0===l&&(l=c(t.createVertexArray()),a[o]=l);return l}(m,l,r);o!==y&&(o=y,a(o.object)),_=function(t,e,n,i){const r=o.attributes,s=e.attributes;let a=0;const l=n.getAttributes();for(const e in l){if(l[e].location>=0){const n=r[e];let i=s[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}}return o.attributesNum!==a||o.index!==i}(n,m,l,g),_&&function(t,e,n,i){const r={},s=e.attributes;let a=0;const l=n.getAttributes();for(const e in l){if(l[e].location>=0){let n=s[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,a++}}o.attributes=r,o.attributesNum=a,o.index=i}(n,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(_||s)&&(s=!1,function(n,i,r,o){u();const s=o.attributes,a=r.getAttributes(),l=i.defaultAttributeValues;for(const i in a){const r=a[i];if(r.location>=0){let a=s[i];if(void 0===a&&("instanceMatrix"===i&&n.instanceMatrix&&(a=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(a=n.instanceColor)),void 0!==a){const i=a.normalized,s=a.itemSize,l=e.get(a);if(void 0===l)continue;const c=l.buffer,u=l.type,p=l.bytesPerElement,m=u===t.INT||u===t.UNSIGNED_INT||a.gpuType===IntType;if(a.isInterleavedBufferAttribute){const e=a.data,l=e.stride,g=a.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)d(r.location+t,e.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)h(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)f(r.location+t,s/r.locationSize,u,i,l*p,(g+s/r.locationSize*t)*p,m)}else{if(a.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)d(r.location+t,a.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let t=0;t<r.locationSize;t++)h(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<r.locationSize;t++)f(r.location+t,s/r.locationSize,u,i,s*p,s/r.locationSize*t*p,m)}}else if(void 0!==l){const e=l[i];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(n,r,l,m),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const t in i){const e=i[t];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t]}},releaseStatesOfGeometry:function(t){if(void 0===i[t.id])return;const e=i[t.id];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t.id]},releaseStatesOfProgram:function(t){for(const e in i){const n=i[e];if(void 0===n[t.id])continue;const r=n[t.id];for(const t in r)l(r[t].object),delete r[t];delete n[t.id]}},initAttributes:u,enableAttribute:h,disableUnusedAttributes:p}}function WebGLBufferRenderer(t,e,n){let i;function r(e,r,o){0!==o&&(t.drawArraysInstanced(i,e,r,o),n.update(r,i,o))}this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(t,r,o){if(0===o)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,t,0,r,0,o);let s=0;for(let t=0;t<o;t++)s+=r[t];n.update(s,i,1)},this.renderMultiDrawInstances=function(t,o,s,a){if(0===s)return;const l=e.get("WEBGL_multi_draw");if(null===l)for(let e=0;e<t.length;e++)r(t[e],o[e],a[e]);else{l.multiDrawArraysInstancedWEBGL(i,t,0,o,0,a,0,s);let e=0;for(let t=0;t<s;t++)e+=o[t]*a[t];n.update(e,i,1)}}}function WebGLCapabilities(t,e,n,i){let r;function o(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp";const a=o(s);a!==s&&(s=a);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reverseDepthBuffer&&e.has("EXT_clip_control"),u=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:o,textureFormatReadable:function(e){return e===RGBAFormat||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===HalfFloatType&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==UnsignedByteType&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==FloatType&&!r)},precision:s,logarithmicDepthBuffer:l,reverseDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:h>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function WebGLClipping(t){const e=this;let n=null,i=0,r=!1,o=!1;const s=new Plane$1,a=new Matrix3,l={value:null,needsUpdate:!1};function c(t,n,i,r){const o=null!==t?t.length:0;let c=null;if(0!==o){if(c=l.value,!0!==r||null===c){const e=i+4*o,r=n.matrixWorldInverse;a.getNormalMatrix(r),(null===c||c.length<e)&&(c=new Float32Array(e));for(let e=0,n=i;e!==o;++e,n+=4)s.copy(t[e]).applyMatrix4(r,a),s.normal.toArray(c,n),c[n+3]=s.constant}l.value=c,l.needsUpdate=!0}return e.numPlanes=o,e.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const n=0!==t.length||e||0!==i||r;return r=e,i=t.length,n},this.beginShadows=function(){o=!0,c(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(t,e){n=c(t,e,0)},this.setState=function(s,a,u){const h=s.clippingPlanes,d=s.clipIntersection,p=s.clipShadows,f=t.get(s);if(!r||null===h||0===h.length||o&&!p)o?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);e.numPlanes=i,e.numIntersection=0}();else{const t=o?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=c(h,a,e,u);for(let t=0;t!==e;++t)r[t]=n[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function WebGLCubeMaps(t){let e=new WeakMap;function n(t,e){return e===EquirectangularReflectionMapping?t.mapping=CubeReflectionMapping:e===EquirectangularRefractionMapping&&(t.mapping=CubeRefractionMapping),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const o=r.mapping;if(o===EquirectangularReflectionMapping||o===EquirectangularRefractionMapping){if(e.has(r)){return n(e.get(r).texture,r.mapping)}{const o=r.image;if(o&&o.height>0){const s=new WebGLCubeRenderTarget(o.height);return s.fromEquirectangularTexture(t,r),e.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}const LOD_MIN=4,EXTRA_LOD_SIGMA=[.125,.215,.35,.446,.526,.582],MAX_SAMPLES=20,_flatCamera=new OrthographicCamera,_clearColor=new Color;let _oldTarget=null,_oldActiveCubeFace=0,_oldActiveMipmapLevel=0,_oldXrEnabled=!1;const PHI=(1+Math.sqrt(5))/2,INV_PHI=1/PHI,_axisDirections=[new Vector3(-PHI,INV_PHI,0),new Vector3(PHI,INV_PHI,0),new Vector3(-INV_PHI,0,PHI),new Vector3(INV_PHI,0,PHI),new Vector3(0,PHI,-INV_PHI),new Vector3(0,PHI,INV_PHI),new Vector3(-1,1,-1),new Vector3(1,1,-1),new Vector3(-1,1,1),new Vector3(1,1,1)];class PMREMGenerator{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){_oldTarget=this._renderer.getRenderTarget(),_oldActiveCubeFace=this._renderer.getActiveCubeFace(),_oldActiveMipmapLevel=this._renderer.getActiveMipmapLevel(),_oldXrEnabled=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(_oldTarget,_oldActiveCubeFace,_oldActiveMipmapLevel),this._renderer.xr.enabled=_oldXrEnabled,t.scissorTest=!1,_setViewport(t,0,0,t.width,t.height)}_fromTexture(t,e){this._setSize(t.mapping===CubeReflectionMapping||t.mapping===CubeRefractionMapping?0===t.image.length?16:t.image[0].width||t.image[0].image.width:t.image.width/4),_oldTarget=this._renderer.getRenderTarget(),_oldActiveCubeFace=this._renderer.getActiveCubeFace(),_oldActiveMipmapLevel=this._renderer.getActiveMipmapLevel(),_oldXrEnabled=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:LinearFilter,minFilter:LinearFilter,generateMipmaps:!1,type:HalfFloatType,format:RGBAFormat,colorSpace:LinearSRGBColorSpace,depthBuffer:!1},i=_createRenderTarget(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=_createRenderTarget(t,e,n);const{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=_createPlanes(i)),this._blurMaterial=_getBlurShader(i,t,e)}return i}_compileMaterial(t){const e=new Mesh(this._lodPlanes[0],t);this._renderer.compile(e,_flatCamera)}_sceneToCubeUV(t,e,n,i){const r=new PerspectiveCamera(90,1,e,n),o=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],a=this._renderer,l=a.autoClear,c=a.toneMapping;a.getClearColor(_clearColor),a.toneMapping=NoToneMapping,a.autoClear=!1;const u=new MeshBasicMaterial({name:"PMREM.Background",side:BackSide,depthWrite:!1,depthTest:!1}),h=new Mesh(new BoxGeometry,u);let d=!1;const p=t.background;p?p.isColor&&(u.color.copy(p),t.background=null,d=!0):(u.color.copy(_clearColor),d=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(r.up.set(0,o[e],0),r.lookAt(s[e],0,0)):1===n?(r.up.set(0,0,o[e]),r.lookAt(0,s[e],0)):(r.up.set(0,o[e],0),r.lookAt(0,0,s[e]));const l=this._cubeSize;_setViewport(i,n*l,e>2?l:0,l,l),a.setRenderTarget(i),d&&a.render(h,r),a.render(t,r)}h.geometry.dispose(),h.material.dispose(),a.toneMapping=c,a.autoClear=l,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===CubeReflectionMapping||t.mapping===CubeRefractionMapping;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial());const r=i?this._cubemapMaterial:this._equirectMaterial,o=new Mesh(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const s=this._cubeSize;_setViewport(e,0,0,3*s,2*s),n.setRenderTarget(e),n.render(o,_flatCamera)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e<i;e++){const n=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]);this._blur(t,e-1,e,n,_axisDirections[(i-e-1)%_axisDirections.length])}e.autoClear=n}_blur(t,e,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,i,"latitudinal",r),this._halfBlur(o,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,o,s){const a=this._renderer,l=this._blurMaterial,c=new Mesh(this._lodPlanes[i],l),u=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*h):2*Math.PI/(2*MAX_SAMPLES-1),p=r/d,f=isFinite(r)?1+Math.floor(3*p):MAX_SAMPLES,m=[];let g=0;for(let t=0;t<MAX_SAMPLES;++t){const e=t/p,n=Math.exp(-e*e/2);m.push(n),0===t?g+=n:t<f&&(g+=2*n)}for(let t=0;t<m.length;t++)m[t]=m[t]/g;u.envMap.value=t.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===o,s&&(u.poleAxis.value=s);const{_lodMax:_}=this;u.dTheta.value=d,u.mipInt.value=_-n;const y=this._sizeLods[i];_setViewport(e,3*y*(i>_-LOD_MIN?i-_+LOD_MIN:0),4*(this._cubeSize-y),3*y,2*y),a.setRenderTarget(e),a.render(c,_flatCamera)}}function _createPlanes(t){const e=[],n=[],i=[];let r=t;const o=t-LOD_MIN+1+EXTRA_LOD_SIGMA.length;for(let s=0;s<o;s++){const o=Math.pow(2,r);n.push(o);let a=1/o;s>t-LOD_MIN?a=EXTRA_LOD_SIGMA[s-t+LOD_MIN-1]:0===s&&(a=0),i.push(a);const l=1/(o-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 t=0;t<d;t++){const e=t%3*2/3-1,n=t>2?0:-1;_.set([e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0],f*p*t),y.set(h,m*p*t);v.set([t,t,t,t,t,t],g*p*t)}const x=new BufferGeometry;x.setAttribute("position",new BufferAttribute(_,f)),x.setAttribute("uv",new BufferAttribute(y,m)),x.setAttribute("faceIndex",new BufferAttribute(v,g)),e.push(x),r>LOD_MIN&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}function _createRenderTarget(t,e,n){const i=new WebGLRenderTarget(t,e,n);return i.texture.mapping=CubeUVReflectionMapping,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function _setViewport(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function _getBlurShader(t,e,n){const i=new Float32Array(MAX_SAMPLES),r=new Vector3(0,1,0);return new ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:MAX_SAMPLES,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:_getCommonVertexShader(),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:NoBlending,depthTest:!1,depthWrite:!1})}function _getEquirectMaterial(){return new ShaderMaterial({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_getCommonVertexShader(),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:NoBlending,depthTest:!1,depthWrite:!1})}function _getCubemapMaterial(){return new ShaderMaterial({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_getCommonVertexShader(),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:NoBlending,depthTest:!1,depthWrite:!1})}function _getCommonVertexShader(){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"}function WebGLCubeUVMaps(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const o=r.mapping,s=o===EquirectangularReflectionMapping||o===EquirectangularRefractionMapping,a=o===CubeReflectionMapping||o===CubeRefractionMapping;if(s||a){let o=e.get(r);if(r.isRenderTargetTexture&&r.pmremVersion!==(void 0!==o?o.texture.pmremVersion:0))return null===n&&(n=new PMREMGenerator(t)),o=s?n.fromEquirectangular(r,o):n.fromCubemap(r,o),o.texture.pmremVersion=r.pmremVersion,e.set(r,o),o.texture;if(void 0!==o)return o.texture;{const l=r.image;return s&&l&&l.height>0||a&&l&&function(t){let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(l)?(null===n&&(n=new PMREMGenerator(t)),o=s?n.fromEquirectangular(r):n.fromCubemap(r),o.texture.pmremVersion=r.pmremVersion,e.set(r,o),r.addEventListener("dispose",i),o.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function WebGLExtensions(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&warnOnce("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function WebGLGeometries(t,e,n,i){const r={},o=new WeakMap;function s(t){const a=t.target;null!==a.index&&e.remove(a.index);for(const t in a.attributes)e.remove(a.attributes[t]);a.removeEventListener("dispose",s),delete r[a.id];const l=o.get(a);l&&(e.remove(l),o.delete(a)),i.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,n.memory.geometries--}function a(t){const n=[],i=t.index,r=t.attributes.position;let s=0;if(null!==i){const t=i.array;s=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],r=t[e+1],o=t[e+2];n.push(i,r,r,o,o,i)}}else{if(void 0===r)return;s=r.version;for(let t=0,e=r.array.length/3-1;t<e;t+=3){const e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}const a=new(arrayNeedsUint32(n)?Uint32BufferAttribute:Uint16BufferAttribute)(n,1);a.version=s;const l=o.get(t);l&&e.remove(l),o.set(t,a)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",s),r[e.id]=!0,n.memory.geometries++),e},update:function(n){const i=n.attributes;for(const n in i)e.update(i[n],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=o.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&a(t)}else a(t);return o.get(t)}}}function WebGLIndexedBufferRenderer(t,e,n){let i,r,o;function s(e,s,a){0!==a&&(t.drawElementsInstanced(i,s,r,e*o,a),n.update(s,i,a))}this.setMode=function(t){i=t},this.setIndex=function(t){r=t.type,o=t.bytesPerElement},this.render=function(e,s){t.drawElements(i,s,r,e*o),n.update(s,i,1)},this.renderInstances=s,this.renderMultiDraw=function(t,o,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,o,0,r,t,0,s);let a=0;for(let t=0;t<s;t++)a+=o[t];n.update(a,i,1)},this.renderMultiDrawInstances=function(t,a,l,c){if(0===l)return;const u=e.get("WEBGL_multi_draw");if(null===u)for(let e=0;e<t.length;e++)s(t[e]/o,a[e],c[e]);else{u.multiDrawElementsInstancedWEBGL(i,a,0,r,t,0,c,0,l);let e=0;for(let t=0;t<l;t++)e+=a[t]*c[t];n.update(e,i,1)}}}function WebGLInfo(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(n,i,r){switch(e.calls++,i){case t.TRIANGLES:e.triangles+=r*(n/3);break;case t.LINES:e.lines+=r*(n/2);break;case t.LINE_STRIP:e.lines+=r*(n-1);break;case t.LINE_LOOP:e.lines+=r*n;break;case t.POINTS:e.points+=r*n}}}}function WebGLMorphtargets(t,e,n){const i=new WeakMap,r=new Vector4;return{update:function(o,s,a){const l=o.morphTargetInfluences,c=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,u=void 0!==c?c.length:0;let h=i.get(s);if(void 0===h||h.count!==u){void 0!==h&&h.texture.dispose();const d=void 0!==s.morphAttributes.position,p=void 0!==s.morphAttributes.normal,f=void 0!==s.morphAttributes.color,m=s.morphAttributes.position||[],g=s.morphAttributes.normal||[],_=s.morphAttributes.color||[];let y=0;!0===d&&(y=1),!0===p&&(y=2),!0===f&&(y=3);let v=s.attributes.position.count*y,x=1;v>e.maxTextureSize&&(x=Math.ceil(v/e.maxTextureSize),v=e.maxTextureSize);const b=new Float32Array(v*x*4*u),T=new DataArrayTexture(b,v,x,u);T.type=FloatType,T.needsUpdate=!0;const E=4*y;for(let w=0;w<u;w++){const A=m[w],M=g[w],C=_[w],I=v*x*4*w;for(let P=0;P<A.count;P++){const L=P*E;!0===d&&(r.fromBufferAttribute(A,P),b[I+L+0]=r.x,b[I+L+1]=r.y,b[I+L+2]=r.z,b[I+L+3]=0),!0===p&&(r.fromBufferAttribute(M,P),b[I+L+4]=r.x,b[I+L+5]=r.y,b[I+L+6]=r.z,b[I+L+7]=0),!0===f&&(r.fromBufferAttribute(C,P),b[I+L+8]=r.x,b[I+L+9]=r.y,b[I+L+10]=r.z,b[I+L+11]=4===C.itemSize?r.w:1)}}function S(){T.dispose(),i.delete(s),s.removeEventListener("dispose",S)}h={count:u,texture:T,size:new Vector2(v,x)},i.set(s,h),s.addEventListener("dispose",S)}if(!0===o.isInstancedMesh&&null!==o.morphTexture)a.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let R=0;for(let D=0;D<l.length;D++)R+=l[D];const O=s.morphTargetsRelative?1:1-R;a.getUniforms().setValue(t,"morphTargetBaseInfluence",O),a.getUniforms().setValue(t,"morphTargetInfluences",l)}a.getUniforms().setValue(t,"morphTargetsTexture",h.texture,n),a.getUniforms().setValue(t,"morphTargetsTextureSize",h.size)}}}function WebGLObjects(t,e,n,i){let r=new WeakMap;function o(t){const e=t.target;e.removeEventListener("dispose",o),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(s){const a=i.render.frame,l=e.get(s,s.geometry);if(r.get(l)!==a&&(e.update(l),r.set(l,a)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",o)&&s.addEventListener("dispose",o),r.get(s)!==a&&(n.update(s.instanceMatrix,t.ARRAY_BUFFER),null!==s.instanceColor&&n.update(s.instanceColor,t.ARRAY_BUFFER),r.set(s,a))),s.isSkinnedMesh){const t=s.skeleton;r.get(t)!==a&&(t.update(),r.set(t,a))}return l},dispose:function(){r=new WeakMap}}}const emptyTexture=new Texture,emptyShadowTexture=new DepthTexture(1,1),emptyArrayTexture=new DataArrayTexture,empty3dTexture=new Data3DTexture,emptyCubeTexture=new CubeTexture,arrayCacheF32=[],arrayCacheI32=[],mat4array=new Float32Array(16),mat3array=new Float32Array(9),mat2array=new Float32Array(4);function flatten(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let o=arrayCacheF32[r];if(void 0===o&&(o=new Float32Array(r),arrayCacheF32[r]=o),0!==e){i.toArray(o,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(o,r)}return o}function arraysEqual(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function copyArray(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function allocTexUnits(t,e){let n=arrayCacheI32[e];void 0===n&&(n=new Int32Array(e),arrayCacheI32[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function setValueV1f(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function setValueV2f(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(arraysEqual(n,e))return;t.uniform2fv(this.addr,e),copyArray(n,e)}}function setValueV3f(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(arraysEqual(n,e))return;t.uniform3fv(this.addr,e),copyArray(n,e)}}function setValueV4f(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(arraysEqual(n,e))return;t.uniform4fv(this.addr,e),copyArray(n,e)}}function setValueM2(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(arraysEqual(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),copyArray(n,e)}else{if(arraysEqual(n,i))return;mat2array.set(i),t.uniformMatrix2fv(this.addr,!1,mat2array),copyArray(n,i)}}function setValueM3(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(arraysEqual(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),copyArray(n,e)}else{if(arraysEqual(n,i))return;mat3array.set(i),t.uniformMatrix3fv(this.addr,!1,mat3array),copyArray(n,i)}}function setValueM4(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(arraysEqual(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),copyArray(n,e)}else{if(arraysEqual(n,i))return;mat4array.set(i),t.uniformMatrix4fv(this.addr,!1,mat4array),copyArray(n,i)}}function setValueV1i(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function setValueV2i(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(arraysEqual(n,e))return;t.uniform2iv(this.addr,e),copyArray(n,e)}}function setValueV3i(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(arraysEqual(n,e))return;t.uniform3iv(this.addr,e),copyArray(n,e)}}function setValueV4i(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(arraysEqual(n,e))return;t.uniform4iv(this.addr,e),copyArray(n,e)}}function setValueV1ui(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function setValueV2ui(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(arraysEqual(n,e))return;t.uniform2uiv(this.addr,e),copyArray(n,e)}}function setValueV3ui(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(arraysEqual(n,e))return;t.uniform3uiv(this.addr,e),copyArray(n,e)}}function setValueV4ui(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(arraysEqual(n,e))return;t.uniform4uiv(this.addr,e),copyArray(n,e)}}function setValueT1(t,e,n){const i=this.cache,r=n.allocateTextureUnit();let o;i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),this.type===t.SAMPLER_2D_SHADOW?(emptyShadowTexture.compareFunction=LessEqualCompare,o=emptyShadowTexture):o=emptyTexture,n.setTexture2D(e||o,r)}function setValueT3D1(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||empty3dTexture,r)}function setValueT6(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||emptyCubeTexture,r)}function setValueT2DArray1(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||emptyArrayTexture,r)}function getSingularSetter(t){switch(t){case 5126:return setValueV1f;case 35664:return setValueV2f;case 35665:return setValueV3f;case 35666:return setValueV4f;case 35674:return setValueM2;case 35675:return setValueM3;case 35676:return setValueM4;case 5124:case 35670:return setValueV1i;case 35667:case 35671:return setValueV2i;case 35668:case 35672:return setValueV3i;case 35669:case 35673:return setValueV4i;case 5125:return setValueV1ui;case 36294:return setValueV2ui;case 36295:return setValueV3ui;case 36296:return setValueV4ui;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1;case 35679:case 36299:case 36307:return setValueT3D1;case 35680:case 36300:case 36308:case 36293:return setValueT6;case 36289:case 36303:case 36311:case 36292:return setValueT2DArray1}}function setValueV1fArray(t,e){t.uniform1fv(this.addr,e)}function setValueV2fArray(t,e){const n=flatten(e,this.size,2);t.uniform2fv(this.addr,n)}function setValueV3fArray(t,e){const n=flatten(e,this.size,3);t.uniform3fv(this.addr,n)}function setValueV4fArray(t,e){const n=flatten(e,this.size,4);t.uniform4fv(this.addr,n)}function setValueM2Array(t,e){const n=flatten(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function setValueM3Array(t,e){const n=flatten(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function setValueM4Array(t,e){const n=flatten(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function setValueV1iArray(t,e){t.uniform1iv(this.addr,e)}function setValueV2iArray(t,e){t.uniform2iv(this.addr,e)}function setValueV3iArray(t,e){t.uniform3iv(this.addr,e)}function setValueV4iArray(t,e){t.uniform4iv(this.addr,e)}function setValueV1uiArray(t,e){t.uniform1uiv(this.addr,e)}function setValueV2uiArray(t,e){t.uniform2uiv(this.addr,e)}function setValueV3uiArray(t,e){t.uniform3uiv(this.addr,e)}function setValueV4uiArray(t,e){t.uniform4uiv(this.addr,e)}function setValueT1Array(t,e,n){const i=this.cache,r=e.length,o=allocTexUnits(n,r);arraysEqual(i,o)||(t.uniform1iv(this.addr,o),copyArray(i,o));for(let t=0;t!==r;++t)n.setTexture2D(e[t]||emptyTexture,o[t])}function setValueT3DArray(t,e,n){const i=this.cache,r=e.length,o=allocTexUnits(n,r);arraysEqual(i,o)||(t.uniform1iv(this.addr,o),copyArray(i,o));for(let t=0;t!==r;++t)n.setTexture3D(e[t]||empty3dTexture,o[t])}function setValueT6Array(t,e,n){const i=this.cache,r=e.length,o=allocTexUnits(n,r);arraysEqual(i,o)||(t.uniform1iv(this.addr,o),copyArray(i,o));for(let t=0;t!==r;++t)n.setTextureCube(e[t]||emptyCubeTexture,o[t])}function setValueT2DArrayArray(t,e,n){const i=this.cache,r=e.length,o=allocTexUnits(n,r);arraysEqual(i,o)||(t.uniform1iv(this.addr,o),copyArray(i,o));for(let t=0;t!==r;++t)n.setTexture2DArray(e[t]||emptyArrayTexture,o[t])}function getPureArraySetter(t){switch(t){case 5126:return setValueV1fArray;case 35664:return setValueV2fArray;case 35665:return setValueV3fArray;case 35666:return setValueV4fArray;case 35674:return setValueM2Array;case 35675:return setValueM3Array;case 35676:return setValueM4Array;case 5124:case 35670:return setValueV1iArray;case 35667:case 35671:return setValueV2iArray;case 35668:case 35672:return setValueV3iArray;case 35669:case 35673:return setValueV4iArray;case 5125:return setValueV1uiArray;case 36294:return setValueV2uiArray;case 36295:return setValueV3uiArray;case 36296:return setValueV4uiArray;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1Array;case 35679:case 36299:case 36307:return setValueT3DArray;case 35680:case 36300:case 36308:case 36293:return setValueT6Array;case 36289:case 36303:case 36311:case 36292:return setValueT2DArrayArray}}class SingleUniform{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=getSingularSetter(e.type)}}class PureArrayUniform{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=getPureArraySetter(e.type)}}class StructuredUniform{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,o=i.length;r!==o;++r){const o=i[r];o.setValue(t,e[o.id],n)}}}const RePathPart=/(\w+)(\])?(\[|\.)?/g;function addUniform(t,e){t.seq.push(e),t.map[e.id]=e}function parseUniform(t,e,n){const i=t.name,r=i.length;for(RePathPart.lastIndex=0;;){const o=RePathPart.exec(i);let s=o[1];const a=o[3];if("]"===o[2]&&(s|=0),void 0===a||"["===a&&RePathPart.lastIndex+2===r){addUniform(n,void 0===a?new SingleUniform(s,t,e):new PureArrayUniform(s,t,e));break}{let t=n.map[s];void 0===t&&(t=new StructuredUniform(s),addUniform(n,t)),n=t}}}class WebGLUniforms{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=t.getActiveUniform(e,i);parseUniform(n,t.getUniformLocation(e,n.name),this)}}setValue(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,o=e.length;r!==o;++r){const o=e[r],s=n[o.id];!1!==s.needsUpdate&&o.setValue(t,s.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const r=t[i];r.id in e&&n.push(r)}return n}}function WebGLShader(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}const COMPLETION_STATUS_KHR=37297;let programIdCount=0;function handleSource(t,e){const n=t.split("\n"),i=[],r=Math.max(e-6,0),o=Math.min(e+6,n.length);for(let t=r;t<o;t++){const r=t+1;i.push(`${r===e?">":" "} ${r}: ${n[t]}`)}return i.join("\n")}const _m0=new Matrix3;function getEncodingComponents(t){ColorManagement._getMatrix(_m0,ColorManagement.workingColorSpace,t);const e=`mat3( ${_m0.elements.map((t=>t.toFixed(4)))} )`;switch(ColorManagement.getTransfer(t)){case LinearTransfer:return[e,"LinearTransferOETF"];case SRGBTransfer:return[e,"sRGBTransferOETF"];default:return[e,"LinearTransferOETF"]}}function getShaderErrors(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),r=t.getShaderInfoLog(e).trim();if(i&&""===r)return"";const o=/ERROR: 0:(\d+)/.exec(r);if(o){const i=parseInt(o[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+handleSource(t.getShaderSource(e),i)}return r}function getTexelEncodingFunction(t,e){const n=getEncodingComponents(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function getToneMappingFunction(t,e){let n;switch(e){case LinearToneMapping:n="Linear";break;case ReinhardToneMapping:n="Reinhard";break;case CineonToneMapping:n="Cineon";break;case ACESFilmicToneMapping:n="ACESFilmic";break;case AgXToneMapping:n="AgX";break;case NeutralToneMapping:n="Neutral";break;case CustomToneMapping:n="Custom";break;default:n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const _v0=new Vector3;function getLuminanceFunction(){ColorManagement.getLuminanceCoefficients(_v0);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${_v0.x.toFixed(4)}, ${_v0.y.toFixed(4)}, ${_v0.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function generateVertexExtensions(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(filterEmptyLine).join("\n")}function generateDefines(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}function fetchAttributeLocations(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=t.getActiveAttrib(e,r),o=i.name;let s=1;i.type===t.FLOAT_MAT2&&(s=2),i.type===t.FLOAT_MAT3&&(s=3),i.type===t.FLOAT_MAT4&&(s=4),n[o]={type:i.type,location:t.getAttribLocation(e,o),locationSize:s}}return n}function filterEmptyLine(t){return""!==t}function replaceLightNums(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function replaceClippingPlaneNums(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const includePattern=/^[ \t]*#include +<([\w\d./]+)>/gm;function resolveIncludes(t){return t.replace(includePattern,includeReplacer)}const shaderChunkMap=new Map;function includeReplacer(t,e){let n=ShaderChunk[e];if(void 0===n){const t=shaderChunkMap.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=ShaderChunk[t]}return resolveIncludes(n)}const unrollLoopPattern=/#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 unrollLoops(t){return t.replace(unrollLoopPattern,loopReplacer)}function loopReplacer(t,e,n,i){let r="";for(let t=parseInt(e);t<parseInt(n);t++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function generatePrecision(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function generateShadowMapTypeDefine(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===PCFShadowMap?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===PCFSoftShadowMap?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===VSMShadowMap&&(e="SHADOWMAP_TYPE_VSM"),e}function generateEnvMapTypeDefine(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case CubeReflectionMapping:case CubeRefractionMapping:e="ENVMAP_TYPE_CUBE";break;case CubeUVReflectionMapping:e="ENVMAP_TYPE_CUBE_UV"}return e}function generateEnvMapModeDefine(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap&&t.envMapMode===CubeRefractionMapping)e="ENVMAP_MODE_REFRACTION";return e}function generateEnvMapBlendingDefine(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case MultiplyOperation:e="ENVMAP_BLENDING_MULTIPLY";break;case MixOperation:e="ENVMAP_BLENDING_MIX";break;case AddOperation:e="ENVMAP_BLENDING_ADD"}return e}function generateCubeUVSize(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function WebGLProgram(t,e,n,i){const r=t.getContext(),o=n.defines;let s=n.vertexShader,a=n.fragmentShader;const l=generateShadowMapTypeDefine(n),c=generateEnvMapTypeDefine(n),u=generateEnvMapModeDefine(n),h=generateEnvMapBlendingDefine(n),d=generateCubeUVSize(n),p=generateVertexExtensions(n),f=generateDefines(o),m=r.createProgram();let g,_,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(filterEmptyLine).join("\n"),g.length>0&&(g+="\n"),_=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(filterEmptyLine).join("\n"),_.length>0&&(_+="\n")):(g=[generatePrecision(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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(filterEmptyLine).join("\n"),_=[generatePrecision(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.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":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==NoToneMapping?"#define TONE_MAPPING":"",n.toneMapping!==NoToneMapping?ShaderChunk.tonemapping_pars_fragment:"",n.toneMapping!==NoToneMapping?getToneMappingFunction("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ShaderChunk.colorspace_pars_fragment,getTexelEncodingFunction("linearToOutputTexel",n.outputColorSpace),getLuminanceFunction(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(filterEmptyLine).join("\n")),s=resolveIncludes(s),s=replaceLightNums(s,n),s=replaceClippingPlaneNums(s,n),a=resolveIncludes(a),a=replaceLightNums(a,n),a=replaceClippingPlaneNums(a,n),s=unrollLoops(s),a=unrollLoops(a),!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,_=["#define varying in",n.glslVersion===GLSL3?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===GLSL3?"":"#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=WebGLShader(r,r.VERTEX_SHADER,y+g+s),b=WebGLShader(r,r.FRAGMENT_SHADER,v);function T(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(x).trim(),o=r.getShaderInfoLog(b).trim();let s=!0,a=!0;!1===r.getProgramParameter(m,r.LINK_STATUS)?(s=!1,"function"==typeof t.debug.onShaderError?t.debug.onShaderError(r,m,x,b):(getShaderErrors(r,x,"vertex"),getShaderErrors(r,b,"fragment"))):""!==n||""!==i&&""!==o||(a=!1),a&&(e.diagnostics={runnable:s,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:o,prefix:_}})}r.deleteShader(x),r.deleteShader(b),E=new WebGLUniforms(r,m),S=fetchAttributeLocations(r,m)}let E,S;r.attachShader(m,x),r.attachShader(m,b),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===E&&T(this),E},this.getAttributes=function(){return void 0===S&&T(this),S};let w=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===w&&(w=r.getProgramParameter(m,COMPLETION_STATUS_KHR)),w},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=programIdCount++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=x,this.fragmentShader=b,this}let _id=0;class WebGLShaderCache{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.fragmentShader,n=this._getShaderStage(t.vertexShader),i=this._getShaderStage(e),r=this._getShaderCacheForMaterial(t);return!1===r.has(n)&&(r.add(n),n.usedTimes++),!1===r.has(i)&&(r.add(i),i.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new WebGLShaderStage(t),e.set(t,n)),n}}class WebGLShaderStage{constructor(t){this.id=_id++,this.code=t,this.usedTimes=0}}function WebGLPrograms(t,e,n,i,r,o,s){const a=new Layers,l=new WebGLShaderCache,c=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.vertexTextures;let p=r.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 m(t){return c.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(o,a,u,g,_){const y=g.fog,v=_.geometry,x=(o.isMeshStandardMaterial?n:e).get(o.envMap||(o.isMeshStandardMaterial?g.environment:null)),b=x&&x.mapping===CubeUVReflectionMapping?x.image.height:null,T=f[o.type];null!==o.precision&&(p=r.getMaxPrecision(o.precision));const E=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,S=void 0!==E?E.length:0;let w,A,M,C,I=0;if(void 0!==v.morphAttributes.position&&(I=1),void 0!==v.morphAttributes.normal&&(I=2),void 0!==v.morphAttributes.color&&(I=3),T){const t=ShaderLib[T];w=t.vertexShader,A=t.fragmentShader}else w=o.vertexShader,A=o.fragmentShader,l.update(o),M=l.getVertexShaderID(o),C=l.getFragmentShaderID(o);const P=t.getRenderTarget(),L=t.state.buffers.depth.getReversed(),R=!0===_.isInstancedMesh,O=!0===_.isBatchedMesh,D=!!o.map,B=!!x,N=!!o.aoMap,F=!!o.lightMap,U=!!o.bumpMap,k=!!o.normalMap,z=!!o.displacementMap,G=!!o.emissiveMap,V=!!o.metalnessMap,j=!!o.roughnessMap,$=o.anisotropy>0,H=o.clearcoat>0,W=o.iridescence>0,q=o.sheen>0,X=o.transmission>0,Y=$&&!!o.anisotropyMap,Z=H&&!!o.clearcoatMap,J=H&&!!o.clearcoatNormalMap,K=H&&!!o.clearcoatRoughnessMap,Q=W&&!!o.iridescenceMap,tt=W&&!!o.iridescenceThicknessMap,et=q&&!!o.sheenColorMap,nt=q&&!!o.sheenRoughnessMap,it=!!o.specularMap,rt=!!o.specularColorMap,ot=!!o.specularIntensityMap,st=X&&!!o.transmissionMap,at=X&&!!o.thicknessMap,lt=!!o.alphaMap,ct=!!o.extensions;let ut=NoToneMapping;o.toneMapped&&(null!==P&&!0!==P.isXRRenderTarget||(ut=t.toneMapping));const ht={shaderID:T,shaderType:o.type,shaderName:o.name,vertexShader:w,fragmentShader:A,defines:o.defines,customVertexShaderID:M,customFragmentShaderID:C,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:p,batching:O,batchingColor:O&&null!==_._colorsTexture,instancing:R,instancingColor:R&&null!==_.instanceColor,instancingMorph:R&&null!==_.morphTexture,supportsVertexTextures:d,outputColorSpace:null===P?t.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:LinearSRGBColorSpace,alphaToCoverage:!!o.alphaToCoverage,map:D,matcap:!!o.matcap,envMap:B,envMapMode:B&&x.mapping,envMapCubeUVHeight:b,aoMap:N,lightMap:F,bumpMap:U,normalMap:k,displacementMap:d&&z,emissiveMap:G,normalMapObjectSpace:k&&o.normalMapType===ObjectSpaceNormalMap,normalMapTangentSpace:k&&o.normalMapType===TangentSpaceNormalMap,metalnessMap:V,roughnessMap:j,anisotropy:$,anisotropyMap:Y,clearcoat:H,clearcoatMap:Z,clearcoatNormalMap:J,clearcoatRoughnessMap:K,dispersion:o.dispersion>0,iridescence:W,iridescenceMap:Q,iridescenceThicknessMap:tt,sheen:q,sheenColorMap:et,sheenRoughnessMap:nt,specularMap:it,specularColorMap:rt,specularIntensityMap:ot,transmission:X,transmissionMap:st,thicknessMap:at,gradientMap:!!o.gradientMap,opaque:!1===o.transparent&&o.blending===NormalBlending&&!1===o.alphaToCoverage,alphaMap:lt,alphaTest:o.alphaTest>0,alphaHash:!!o.alphaHash,combine:o.combine,mapUv:D&&m(o.map.channel),aoMapUv:N&&m(o.aoMap.channel),lightMapUv:F&&m(o.lightMap.channel),bumpMapUv:U&&m(o.bumpMap.channel),normalMapUv:k&&m(o.normalMap.channel),displacementMapUv:z&&m(o.displacementMap.channel),emissiveMapUv:G&&m(o.emissiveMap.channel),metalnessMapUv:V&&m(o.metalnessMap.channel),roughnessMapUv:j&&m(o.roughnessMap.channel),anisotropyMapUv:Y&&m(o.anisotropyMap.channel),clearcoatMapUv:Z&&m(o.clearcoatMap.channel),clearcoatNormalMapUv:J&&m(o.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:K&&m(o.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&m(o.iridescenceMap.channel),iridescenceThicknessMapUv:tt&&m(o.iridescenceThicknessMap.channel),sheenColorMapUv:et&&m(o.sheenColorMap.channel),sheenRoughnessMapUv:nt&&m(o.sheenRoughnessMap.channel),specularMapUv:it&&m(o.specularMap.channel),specularColorMapUv:rt&&m(o.specularColorMap.channel),specularIntensityMapUv:ot&&m(o.specularIntensityMap.channel),transmissionMapUv:st&&m(o.transmissionMap.channel),thicknessMapUv:at&&m(o.thicknessMap.channel),alphaMapUv:lt&&m(o.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(k||$),vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!v.attributes.color&&4===v.attributes.color.itemSize,pointsUvs:!0===_.isPoints&&!!v.attributes.uv&&(D||lt),fog:!!y,useFog:!0===o.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!0===o.flatShading,sizeAttenuation:!0===o.sizeAttenuation,logarithmicDepthBuffer:h,reverseDepthBuffer:L,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==v.morphAttributes.position,morphNormals:void 0!==v.morphAttributes.normal,morphColors:void 0!==v.morphAttributes.color,morphTargetsCount:S,morphTextureStride:I,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numSpotLightMaps:a.spotLightMap.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numSpotLightShadowsWithMaps:a.numSpotLightShadowsWithMaps,numLightProbes:a.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:o.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.length>0,shadowMapType:t.shadowMap.type,toneMapping:ut,decodeVideoTexture:D&&!0===o.map.isVideoTexture&&ColorManagement.getTransfer(o.map.colorSpace)===SRGBTransfer,decodeVideoTextureEmissive:G&&!0===o.emissiveMap.isVideoTexture&&ColorManagement.getTransfer(o.emissiveMap.colorSpace)===SRGBTransfer,premultipliedAlpha:o.premultipliedAlpha,doubleSided:o.side===DoubleSide,flipSided:o.side===BackSide,useDepthPacking:o.depthPacking>=0,depthPacking:o.depthPacking||0,index0AttributeName:o.index0AttributeName,extensionClipCullDistance:ct&&!0===o.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ct&&!0===o.extensions.multiDraw||O)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:o.customProgramCacheKey()};return ht.vertexUv1s=c.has(1),ht.vertexUv2s=c.has(2),ht.vertexUv3s=c.has(3),c.clear(),ht},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){a.disableAll(),e.supportsVertexTextures&&a.enable(0);e.instancing&&a.enable(1);e.instancingColor&&a.enable(2);e.instancingMorph&&a.enable(3);e.matcap&&a.enable(4);e.envMap&&a.enable(5);e.normalMapObjectSpace&&a.enable(6);e.normalMapTangentSpace&&a.enable(7);e.clearcoat&&a.enable(8);e.iridescence&&a.enable(9);e.alphaTest&&a.enable(10);e.vertexColors&&a.enable(11);e.vertexAlphas&&a.enable(12);e.vertexUv1s&&a.enable(13);e.vertexUv2s&&a.enable(14);e.vertexUv3s&&a.enable(15);e.vertexTangents&&a.enable(16);e.anisotropy&&a.enable(17);e.alphaHash&&a.enable(18);e.batching&&a.enable(19);e.dispersion&&a.enable(20);e.batchingColor&&a.enable(21);t.push(a.mask),a.disableAll(),e.fog&&a.enable(0);e.useFog&&a.enable(1);e.flatShading&&a.enable(2);e.logarithmicDepthBuffer&&a.enable(3);e.reverseDepthBuffer&&a.enable(4);e.skinning&&a.enable(5);e.morphTargets&&a.enable(6);e.morphNormals&&a.enable(7);e.morphColors&&a.enable(8);e.premultipliedAlpha&&a.enable(9);e.shadowMapEnabled&&a.enable(10);e.doubleSided&&a.enable(11);e.flipSided&&a.enable(12);e.useDepthPacking&&a.enable(13);e.dithering&&a.enable(14);e.transmission&&a.enable(15);e.sheen&&a.enable(16);e.opaque&&a.enable(17);e.pointsUvs&&a.enable(18);e.decodeVideoTexture&&a.enable(19);e.decodeVideoTextureEmissive&&a.enable(20);e.alphaToCoverage&&a.enable(21);t.push(a.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){n=UniformsUtils.clone(ShaderLib[e].uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=u.length;t<e;t++){const e=u[t];if(e.cacheKey===n){i=e,++i.usedTimes;break}}return void 0===i&&(i=new WebGLProgram(t,n,e,o),u.push(i)),i},releaseProgram:function(t){if(0==--t.usedTimes){const e=u.indexOf(t);u[e]=u[u.length-1],u.pop(),t.destroy()}},releaseShaderCache:function(t){l.remove(t)},programs:u,dispose:function(){l.dispose()}}}function WebGLProperties(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function painterSortStable(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function reversePainterSortStable(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function WebGLRenderList(){const t=[];let e=0;const n=[],i=[],r=[];function o(n,i,r,o,s,a){let l=t[e];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:o,renderOrder:n.renderOrder,z:s,group:a},t[e]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=o,l.renderOrder=n.renderOrder,l.z=s,l.group=a),e++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){e=0,n.length=0,i.length=0,r.length=0},push:function(t,e,s,a,l,c){const u=o(t,e,s,a,l,c);s.transmission>0?i.push(u):!0===s.transparent?r.push(u):n.push(u)},unshift:function(t,e,s,a,l,c){const u=o(t,e,s,a,l,c);s.transmission>0?i.unshift(u):!0===s.transparent?r.unshift(u):n.unshift(u)},finish:function(){for(let n=e,i=t.length;n<i;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||painterSortStable),i.length>1&&i.sort(e||reversePainterSortStable),r.length>1&&r.sort(e||reversePainterSortStable)}}}function WebGLRenderLists(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new WebGLRenderList,t.set(e,[r])):n>=i.length?(r=new WebGLRenderList,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function UniformsCache(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Vector3,color:new Color};break;case"SpotLight":n={position:new Vector3,direction:new Vector3,color:new Color,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Vector3,color:new Color,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Vector3,skyColor:new Color,groundColor:new Color};break;case"RectAreaLight":n={color:new Color,position:new Vector3,halfWidth:new Vector3,halfHeight:new Vector3}}return t[e.id]=n,n}}}function ShadowUniformsCache(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}let nextVersion=0;function shadowCastingAndTexturingLightsFirst(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function WebGLLights(t){const e=new UniformsCache,n=ShadowUniformsCache(),i={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 t=0;t<9;t++)i.probe.push(new Vector3);const r=new Vector3,o=new Matrix4,s=new Matrix4;return{setup:function(r){let o=0,s=0,a=0;for(let t=0;t<9;t++)i.probe[t].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(shadowCastingAndTexturingLightsFirst);for(let t=0,v=r.length;t<v;t++){const v=r[t],x=v.color,b=v.intensity,T=v.distance,E=v.shadow&&v.shadow.map?v.shadow.map.texture:null;if(v.isAmbientLight)o+=x.r*b,s+=x.g*b,a+=x.b*b;else if(v.isLightProbe){for(let t=0;t<9;t++)i.probe[t].addScaledVector(v.sh.coefficients[t],b);y++}else if(v.isDirectionalLight){const t=e.get(v);if(t.color.copy(v.color).multiplyScalar(v.intensity),v.castShadow){const t=v.shadow,e=n.get(v);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,i.directionalShadow[l]=e,i.directionalShadowMap[l]=E,i.directionalShadowMatrix[l]=v.shadow.matrix,p++}i.directional[l]=t,l++}else if(v.isSpotLight){const t=e.get(v);t.position.setFromMatrixPosition(v.matrixWorld),t.color.copy(x).multiplyScalar(b),t.distance=T,t.coneCos=Math.cos(v.angle),t.penumbraCos=Math.cos(v.angle*(1-v.penumbra)),t.decay=v.decay,i.spot[u]=t;const r=v.shadow;if(v.map&&(i.spotLightMap[g]=v.map,g++,r.updateMatrices(v),v.castShadow&&_++),i.spotLightMatrix[u]=r.matrix,v.castShadow){const t=n.get(v);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,i.spotShadow[u]=t,i.spotShadowMap[u]=E,m++}u++}else if(v.isRectAreaLight){const t=e.get(v);t.color.copy(x).multiplyScalar(b),t.halfWidth.set(.5*v.width,0,0),t.halfHeight.set(0,.5*v.height,0),i.rectArea[h]=t,h++}else if(v.isPointLight){const t=e.get(v);if(t.color.copy(v.color).multiplyScalar(v.intensity),t.distance=v.distance,t.decay=v.decay,v.castShadow){const t=v.shadow,e=n.get(v);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,i.pointShadow[c]=e,i.pointShadowMap[c]=E,i.pointShadowMatrix[c]=v.shadow.matrix,f++}i.point[c]=t,c++}else if(v.isHemisphereLight){const t=e.get(v);t.skyColor.copy(v.color).multiplyScalar(b),t.groundColor.copy(v.groundColor).multiplyScalar(b),i.hemi[d]=t,d++}}h>0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=UniformsLib.LTC_FLOAT_1,i.rectAreaLTC2=UniformsLib.LTC_FLOAT_2):(i.rectAreaLTC1=UniformsLib.LTC_HALF_1,i.rectAreaLTC2=UniformsLib.LTC_HALF_2)),i.ambient[0]=o,i.ambient[1]=s,i.ambient[2]=a;const v=i.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||(i.directional.length=l,i.spot.length=u,i.rectArea.length=h,i.point.length=c,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-_,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=_,i.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,i.version=nextVersion++)},setupView:function(t,e){let n=0,a=0,l=0,c=0,u=0;const h=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=i.directional[n];t.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(h),n++}else if(d.isSpotLight){const t=i.spot[l];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(h),t.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(h),l++}else if(d.isRectAreaLight){const t=i.rectArea[c];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(h),s.identity(),o.copy(d.matrixWorld),o.premultiply(h),s.extractRotation(o),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(s),t.halfHeight.applyMatrix4(s),c++}else if(d.isPointLight){const t=i.point[a];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(h),a++}else if(d.isHemisphereLight){const t=i.hemi[u];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(h),u++}}},state:i}}function WebGLRenderState(t){const e=new WebGLLights(t),n=[],i=[];const r={lightsArray:n,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){r.camera=t,n.length=0,i.length=0},state:r,setupLights:function(){e.setup(n)},setupLightsView:function(t){e.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){i.push(t)}}}function WebGLRenderStates(t){let e=new WeakMap;return{get:function(n,i=0){const r=e.get(n);let o;return void 0===r?(o=new WebGLRenderState(t),e.set(n,[o])):i>=r.length?(o=new WebGLRenderState(t),r.push(o)):o=r[i],o},dispose:function(){e=new WeakMap}}}const vertex="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragment="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\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 = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\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( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";function WebGLShadowMap(t,e,n){let i=new Frustum;const r=new Vector2,o=new Vector2,s=new Vector4,a=new MeshDepthMaterial({depthPacking:RGBADepthPacking}),l=new MeshDistanceMaterial,c={},u=n.maxTextureSize,h={[FrontSide]:BackSide,[BackSide]:FrontSide,[DoubleSide]:DoubleSide},d=new ShaderMaterial({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Vector2},radius:{value:4}},vertexShader:vertex,fragmentShader:fragment}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new BufferGeometry;f.setAttribute("position",new BufferAttribute(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Mesh(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=PCFShadowMap;let _=this.type;function y(n,i){const o=e.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new WebGLRenderTarget(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,o,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,o,p,m,null)}function v(e,n,i,r){let o=null;const s=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==s)o=s;else if(o=!0===i.isPointLight?l:a,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=o.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let r=i[e];void 0===r&&(r=o.clone(),i[e]=r,n.addEventListener("dispose",b)),o=r}if(o.visible=n.visible,o.wireframe=n.wireframe,o.side=r===VSMShadowMap?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],o.alphaMap=n.alphaMap,o.alphaTest=n.alphaTest,o.map=n.map,o.clipShadows=n.clipShadows,o.clippingPlanes=n.clippingPlanes,o.clipIntersection=n.clipIntersection,o.displacementMap=n.displacementMap,o.displacementScale=n.displacementScale,o.displacementBias=n.displacementBias,o.wireframeLinewidth=n.wireframeLinewidth,o.linewidth=n.linewidth,!0===i.isPointLight&&!0===o.isMeshDistanceMaterial){t.properties.get(o).light=i}return o}function x(n,r,o,s,a){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&a===VSMShadowMap)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,u=e.length;c<u;c++){const u=e[c],h=l[u.materialIndex];if(h&&h.visible){const e=v(n,h,s,a);n.onBeforeShadow(t,n,r,o,i,e,u),t.renderBufferDirect(o,null,i,e,n,u),n.onAfterShadow(t,n,r,o,i,e,u)}}}else if(l.visible){const e=v(n,l,s,a);n.onBeforeShadow(t,n,r,o,i,e,null),t.renderBufferDirect(o,null,i,e,n,null),n.onAfterShadow(t,n,r,o,i,e,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)x(l[t],r,o,s,a)}function b(t){t.target.removeEventListener("dispose",b);for(const e in c){const n=c[e],i=t.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(e,n,a){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),c=t.getActiveCubeFace(),h=t.getActiveMipmapLevel(),d=t.state;d.setBlending(NoBlending),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=_!==VSMShadowMap&&this.type===VSMShadowMap,f=_===VSMShadowMap&&this.type!==VSMShadowMap;for(let l=0,c=e.length;l<c;l++){const c=e[l],h=c.shadow;if(void 0===h)continue;if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;r.copy(h.mapSize);const m=h.getFrameExtents();if(r.multiply(m),o.copy(h.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(o.x=Math.floor(u/m.x),r.x=o.x*m.x,h.mapSize.x=o.x),r.y>u&&(o.y=Math.floor(u/m.y),r.y=o.y*m.y,h.mapSize.y=o.y)),null===h.map||!0===p||!0===f){const t=this.type!==VSMShadowMap?{minFilter:NearestFilter,magFilter:NearestFilter}:{};null!==h.map&&h.map.dispose(),h.map=new WebGLRenderTarget(r.x,r.y,t),h.map.texture.name=c.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const g=h.getViewportCount();for(let t=0;t<g;t++){const e=h.getViewport(t);s.set(o.x*e.x,o.y*e.y,o.x*e.z,o.y*e.w),d.viewport(s),h.updateMatrices(c,t),i=h.getFrustum(),x(n,a,h.camera,c,this.type)}!0!==h.isPointLightShadow&&this.type===VSMShadowMap&&y(h,a),h.needsUpdate=!1}_=this.type,g.needsUpdate=!1,t.setRenderTarget(l,c,h)}}const reversedFuncs={[NeverDepth]:AlwaysDepth,[LessDepth]:GreaterDepth,[EqualDepth]:NotEqualDepth,[LessEqualDepth]:GreaterEqualDepth,[AlwaysDepth]:NeverDepth,[GreaterDepth]:LessDepth,[NotEqualDepth]:EqualDepth,[GreaterEqualDepth]:LessEqualDepth};function WebGLState(t,e){const n=new function(){let e=!1;const n=new Vector4;let i=null;const r=new Vector4(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,o,s,a){!0===a&&(e*=s,i*=s,o*=s),n.set(e,i,o,s),!1===r.equals(n)&&(t.clearColor(e,i,o,s),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,o=null,s=null;return{setReversed:function(t){if(i!==t){const t=e.get("EXT_clip_control");t.clipControlEXT(t.LOWER_LEFT_EXT,i?t.ZERO_TO_ONE_EXT:t.NEGATIVE_ONE_TO_ONE_EXT);const n=s;s=null,this.setClear(n)}i=t},getReversed:function(){return i},setTest:function(e){e?z(t.DEPTH_TEST):G(t.DEPTH_TEST)},setMask:function(e){r===e||n||(t.depthMask(e),r=e)},setFunc:function(e){if(i&&(e=reversedFuncs[e]),o!==e){switch(e){case NeverDepth:t.depthFunc(t.NEVER);break;case AlwaysDepth:t.depthFunc(t.ALWAYS);break;case LessDepth:t.depthFunc(t.LESS);break;case LessEqualDepth:t.depthFunc(t.LEQUAL);break;case EqualDepth:t.depthFunc(t.EQUAL);break;case GreaterEqualDepth:t.depthFunc(t.GEQUAL);break;case GreaterDepth:t.depthFunc(t.GREATER);break;case NotEqualDepth:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}o=e}},setLocked:function(t){n=t},setClear:function(e){s!==e&&(i&&(e=1-e),t.clearDepth(e),s=e)},reset:function(){n=!1,r=null,o=null,s=null,i=!1}}},r=new function(){let e=!1,n=null,i=null,r=null,o=null,s=null,a=null,l=null,c=null;return{setTest:function(n){e||(n?z(t.STENCIL_TEST):G(t.STENCIL_TEST))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,s){i===e&&r===n&&o===s||(t.stencilFunc(e,n,s),i=e,r=n,o=s)},setOp:function(e,n,i){s===e&&a===n&&l===i||(t.stencilOp(e,n,i),s=e,a=n,l=i)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,n=null,i=null,r=null,o=null,s=null,a=null,l=null,c=null}}},o=new WeakMap,s=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 Color(0,0,0),b=0,T=!1,E=null,S=null,w=null,A=null,M=null;const C=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let I=!1,P=0;const L=t.getParameter(t.VERSION);-1!==L.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(L)[1]),I=P>=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),I=P>=2);let R=null,O={};const D=t.getParameter(t.SCISSOR_BOX),B=t.getParameter(t.VIEWPORT),N=(new Vector4).fromArray(D),F=(new Vector4).fromArray(B);function U(e,n,i,r){const o=new Uint8Array(4),s=t.createTexture();t.bindTexture(e,s),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let s=0;s<i;s++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(n,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,o):t.texImage2D(n+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,o);return s}const k={};function z(e){!0!==a[e]&&(t.enable(e),a[e]=!0)}function G(e){!1!==a[e]&&(t.disable(e),a[e]=!1)}k[t.TEXTURE_2D]=U(t.TEXTURE_2D,t.TEXTURE_2D,1),k[t.TEXTURE_CUBE_MAP]=U(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),k[t.TEXTURE_2D_ARRAY]=U(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),k[t.TEXTURE_3D]=U(t.TEXTURE_3D,t.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),z(t.DEPTH_TEST),i.setFunc(LessEqualDepth),H(!1),W(CullFaceBack),z(t.CULL_FACE),$(NoBlending);const V={[AddEquation]:t.FUNC_ADD,[SubtractEquation]:t.FUNC_SUBTRACT,[ReverseSubtractEquation]:t.FUNC_REVERSE_SUBTRACT};V[MinEquation]=t.MIN,V[MaxEquation]=t.MAX;const j={[ZeroFactor]:t.ZERO,[OneFactor]:t.ONE,[SrcColorFactor]:t.SRC_COLOR,[SrcAlphaFactor]:t.SRC_ALPHA,[SrcAlphaSaturateFactor]:t.SRC_ALPHA_SATURATE,[DstColorFactor]:t.DST_COLOR,[DstAlphaFactor]:t.DST_ALPHA,[OneMinusSrcColorFactor]:t.ONE_MINUS_SRC_COLOR,[OneMinusSrcAlphaFactor]:t.ONE_MINUS_SRC_ALPHA,[OneMinusDstColorFactor]:t.ONE_MINUS_DST_COLOR,[OneMinusDstAlphaFactor]:t.ONE_MINUS_DST_ALPHA,[ConstantColorFactor]:t.CONSTANT_COLOR,[OneMinusConstantColorFactor]:t.ONE_MINUS_CONSTANT_COLOR,[ConstantAlphaFactor]:t.CONSTANT_ALPHA,[OneMinusConstantAlphaFactor]:t.ONE_MINUS_CONSTANT_ALPHA};function $(e,n,i,r,o,s,a,l,c,u){if(e!==NoBlending){if(!1===d&&(z(t.BLEND),d=!0),e===CustomBlending)o=o||n,s=s||i,a=a||r,n===f&&o===_||(t.blendEquationSeparate(V[n],V[o]),f=n,_=o),i===m&&r===g&&s===y&&a===v||(t.blendFuncSeparate(j[i],j[r],j[s],j[a]),m=i,g=r,y=s,v=a),!1!==l.equals(x)&&c===b||(t.blendColor(l.r,l.g,l.b,c),x.copy(l),b=c),p=e,T=!1;else if(e!==p||u!==T){if(f===AddEquation&&_===AddEquation||(t.blendEquation(t.FUNC_ADD),f=AddEquation,_=AddEquation),u)switch(e){case NormalBlending:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case AdditiveBlending:t.blendFunc(t.ONE,t.ONE);break;case SubtractiveBlending:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case MultiplyBlending:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA)}else switch(e){case NormalBlending:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case AdditiveBlending:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case SubtractiveBlending:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case MultiplyBlending:t.blendFunc(t.ZERO,t.SRC_COLOR)}m=null,g=null,y=null,v=null,x.set(0,0,0),b=0,p=e,T=u}}else!0===d&&(G(t.BLEND),d=!1)}function H(e){E!==e&&(t.frontFace(e?t.CW:t.CCW),E=e)}function W(e){e!==CullFaceNone?(z(t.CULL_FACE),e!==S&&t.cullFace(e===CullFaceBack?t.BACK:e===CullFaceFront?t.FRONT:t.FRONT_AND_BACK)):G(t.CULL_FACE),S=e}function q(e,n,i){e?(z(t.POLYGON_OFFSET_FILL),A===n&&M===i||(t.polygonOffset(n,i),A=n,M=i)):G(t.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:z,disable:G,bindFramebuffer:function(e,n){return l[e]!==n&&(t.bindFramebuffer(e,n),l[e]=n,e===t.DRAW_FRAMEBUFFER&&(l[t.FRAMEBUFFER]=n),e===t.FRAMEBUFFER&&(l[t.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(e,n){let i=u,r=!1;if(e){i=c.get(n),void 0===i&&(i=[],c.set(n,i));const o=e.textures;if(i.length!==o.length||i[0]!==t.COLOR_ATTACHMENT0){for(let e=0,n=o.length;e<n;e++)i[e]=t.COLOR_ATTACHMENT0+e;i.length=o.length,r=!0}}else i[0]!==t.BACK&&(i[0]=t.BACK,r=!0);r&&t.drawBuffers(i)},useProgram:function(e){return h!==e&&(t.useProgram(e),h=e,!0)},setBlending:$,setMaterial:function(e,o){e.side===DoubleSide?G(t.CULL_FACE):z(t.CULL_FACE);let s=e.side===BackSide;o&&(s=!s),H(s),e.blending===NormalBlending&&!1===e.transparent?$(NoBlending):$(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),i.setFunc(e.depthFunc),i.setTest(e.depthTest),i.setMask(e.depthWrite),n.setMask(e.colorWrite);const a=e.stencilWrite;r.setTest(a),a&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),q(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?z(t.SAMPLE_ALPHA_TO_COVERAGE):G(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:H,setCullFace:W,setLineWidth:function(e){e!==w&&(I&&t.lineWidth(e),w=e)},setPolygonOffset:q,setScissorTest:function(e){e?z(t.SCISSOR_TEST):G(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+C-1),R!==e&&(t.activeTexture(e),R=e)},bindTexture:function(e,n,i){void 0===i&&(i=null===R?t.TEXTURE0+C-1:R);let r=O[i];void 0===r&&(r={type:void 0,texture:void 0},O[i]=r),r.type===e&&r.texture===n||(R!==i&&(t.activeTexture(i),R=i),t.bindTexture(e,n||k[e]),r.type=e,r.texture=n)},unbindTexture:function(){const e=O[R];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){}},updateUBOMapping:function(e,n){let i=s.get(n);void 0===i&&(i=new WeakMap,s.set(n,i));let r=i.get(e);void 0===r&&(r=t.getUniformBlockIndex(n,e.name),i.set(e,r))},uniformBlockBinding:function(e,n){const i=s.get(n).get(e);o.get(n)!==i&&(t.uniformBlockBinding(n,i,e.__bindingPointIndex),o.set(n,i))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){}},scissor:function(e){!1===N.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),N.copy(e))},viewport:function(e){!1===F.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),F.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),i.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.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 Color(0,0,0),b=0,T=!1,E=null,S=null,w=null,A=null,M=null,N.set(0,0,t.canvas.width,t.canvas.height),F.set(0,0,t.canvas.width,t.canvas.height),n.reset(),i.reset(),r.reset()}}}function WebGLTextures(t,e,n,i,r,o,s){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new Vector2,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(t){}function f(t,e){return p?new OffscreenCanvas(t,e):createElementNS("canvas")}function m(t,e,n){let i=1;const r=G(t);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*r.width),o=Math.floor(i*r.height);void 0===h&&(h=f(n,o));const s=e?f(n,o):h;s.width=n,s.height=o;return s.getContext("2d").drawImage(t,0,0,n,o),s}return t}return t}function g(t){return t.generateMipmaps}function _(e){t.generateMipmap(e)}function y(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function v(n,i,r,o,s=!1){if(null!==n&&void 0!==t[n])return t[n];let a=i;if(i===t.RED&&(r===t.FLOAT&&(a=t.R32F),r===t.HALF_FLOAT&&(a=t.R16F),r===t.UNSIGNED_BYTE&&(a=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(a=t.R8UI),r===t.UNSIGNED_SHORT&&(a=t.R16UI),r===t.UNSIGNED_INT&&(a=t.R32UI),r===t.BYTE&&(a=t.R8I),r===t.SHORT&&(a=t.R16I),r===t.INT&&(a=t.R32I)),i===t.RG&&(r===t.FLOAT&&(a=t.RG32F),r===t.HALF_FLOAT&&(a=t.RG16F),r===t.UNSIGNED_BYTE&&(a=t.RG8)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(a=t.RG8UI),r===t.UNSIGNED_SHORT&&(a=t.RG16UI),r===t.UNSIGNED_INT&&(a=t.RG32UI),r===t.BYTE&&(a=t.RG8I),r===t.SHORT&&(a=t.RG16I),r===t.INT&&(a=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(a=t.RGB8UI),r===t.UNSIGNED_SHORT&&(a=t.RGB16UI),r===t.UNSIGNED_INT&&(a=t.RGB32UI),r===t.BYTE&&(a=t.RGB8I),r===t.SHORT&&(a=t.RGB16I),r===t.INT&&(a=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(a=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(a=t.RGBA16UI),r===t.UNSIGNED_INT&&(a=t.RGBA32UI),r===t.BYTE&&(a=t.RGBA8I),r===t.SHORT&&(a=t.RGBA16I),r===t.INT&&(a=t.RGBA32I)),i===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(a=t.RGB9_E5),i===t.RGBA){const e=s?LinearTransfer:ColorManagement.getTransfer(o);r===t.FLOAT&&(a=t.RGBA32F),r===t.HALF_FLOAT&&(a=t.RGBA16F),r===t.UNSIGNED_BYTE&&(a=e===SRGBTransfer?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(a=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(a=t.RGB5_A1)}return a!==t.R16F&&a!==t.R32F&&a!==t.RG16F&&a!==t.RG32F&&a!==t.RGBA16F&&a!==t.RGBA32F||e.get("EXT_color_buffer_float"),a}function x(e,n){let i;return e?null===n||n===UnsignedIntType||n===UnsignedInt248Type?i=t.DEPTH24_STENCIL8:n===FloatType?i=t.DEPTH32F_STENCIL8:n===UnsignedShortType&&(i=t.DEPTH24_STENCIL8):null===n||n===UnsignedIntType||n===UnsignedInt248Type?i=t.DEPTH_COMPONENT24:n===FloatType?i=t.DEPTH_COMPONENT32F:n===UnsignedShortType&&(i=t.DEPTH_COMPONENT16),i}function b(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==NearestFilter&&t.minFilter!==LinearFilter?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function T(t){const e=t.target;e.removeEventListener("dispose",T),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=d.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&S(t),0===Object.keys(r).length&&d.delete(n)}i.remove(t)}(e),e.isVideoTexture&&u.delete(e)}function E(e){const n=e.target;n.removeEventListener("dispose",E),function(e){const n=i.get(e);e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i<n.__webglFramebuffer[e].length;i++)t.deleteFramebuffer(n.__webglFramebuffer[e][i]);else t.deleteFramebuffer(n.__webglFramebuffer[e]);n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[e])}else{if(Array.isArray(n.__webglFramebuffer))for(let e=0;e<n.__webglFramebuffer.length;e++)t.deleteFramebuffer(n.__webglFramebuffer[e]);else t.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&t.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let e=0;e<n.__webglColorRenderbuffer.length;e++)n.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(n.__webglColorRenderbuffer[e]);n.__webglDepthRenderbuffer&&t.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,n=r.length;e<n;e++){const n=i.get(r[e]);n.__webglTexture&&(t.deleteTexture(n.__webglTexture),s.memory.textures--),i.remove(r[e])}i.remove(e)}(n)}function S(e){const n=i.get(e);t.deleteTexture(n.__webglTexture);delete d.get(e.source)[n.__cacheKey],s.memory.textures--}let w=0;function A(e,r){const o=i.get(e);if(e.isVideoTexture&&function(t){const e=s.render.frame;u.get(t)!==e&&(u.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&o.__version!==e.version){const t=e.image;if(null===t);else if(!1!==t.complete)return void R(o,e,r)}n.bindTexture(t.TEXTURE_2D,o.__webglTexture,t.TEXTURE0+r)}const M={[RepeatWrapping]:t.REPEAT,[ClampToEdgeWrapping]:t.CLAMP_TO_EDGE,[MirroredRepeatWrapping]:t.MIRRORED_REPEAT},C={[NearestFilter]:t.NEAREST,[NearestMipmapNearestFilter]:t.NEAREST_MIPMAP_NEAREST,[NearestMipmapLinearFilter]:t.NEAREST_MIPMAP_LINEAR,[LinearFilter]:t.LINEAR,[LinearMipmapNearestFilter]:t.LINEAR_MIPMAP_NEAREST,[LinearMipmapLinearFilter]:t.LINEAR_MIPMAP_LINEAR},I={[NeverCompare]:t.NEVER,[AlwaysCompare]:t.ALWAYS,[LessCompare]:t.LESS,[LessEqualCompare]:t.LEQUAL,[EqualCompare]:t.EQUAL,[GreaterEqualCompare]:t.GEQUAL,[GreaterCompare]:t.GREATER,[NotEqualCompare]:t.NOTEQUAL};function P(n,o){if(o.type===FloatType&&e.has("OES_texture_float_linear"),t.texParameteri(n,t.TEXTURE_WRAP_S,M[o.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,M[o.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,M[o.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,C[o.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,C[o.minFilter]),o.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,I[o.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(o.magFilter===NearestFilter)return;if(o.minFilter!==NearestMipmapLinearFilter&&o.minFilter!==LinearMipmapLinearFilter)return;if(o.type===FloatType&&!1===e.has("OES_texture_float_linear"))return;if(o.anisotropy>1||i.get(o).__currentAnisotropy){const s=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy}}}function L(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",T));const r=n.source;let o=d.get(r);void 0===o&&(o={},d.set(r,o));const a=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(a!==e.__cacheKey){void 0===o[a]&&(o[a]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,i=!0),o[a].usedTimes++;const r=o[e.__cacheKey];void 0!==r&&(o[e.__cacheKey].usedTimes--,0===r.usedTimes&&S(n)),e.__cacheKey=a,e.__webglTexture=o[a].texture}return i}function R(e,s,a){let l=t.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=t.TEXTURE_3D);const c=L(e,s),u=s.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+a);const h=i.get(u);if(u.version!==h.__version||!0===c){n.activeTexture(t.TEXTURE0+a);const e=ColorManagement.getPrimaries(ColorManagement.workingColorSpace),i=s.colorSpace===NoColorSpace?null:ColorManagement.getPrimaries(s.colorSpace),d=s.colorSpace===NoColorSpace||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,s.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=m(s.image,!1,r.maxTextureSize);p=z(s,p);const f=o.convert(s.format,s.colorSpace),y=o.convert(s.type);let T,E=v(s.internalFormat,f,y,s.colorSpace,s.isVideoTexture);P(l,s);const S=s.mipmaps,w=!0!==s.isVideoTexture,A=void 0===h.__version||!0===c,M=u.dataReady,C=b(s,p);if(s.isDepthTexture)E=x(s.format===DepthStencilFormat,s.type),A&&(w?n.texStorage2D(t.TEXTURE_2D,1,E,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,E,p.width,p.height,0,f,y,null));else if(s.isDataTexture)if(S.length>0){w&&A&&n.texStorage2D(t.TEXTURE_2D,C,E,S[0].width,S[0].height);for(let e=0,i=S.length;e<i;e++)T=S[e],w?M&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,T.width,T.height,f,y,T.data):n.texImage2D(t.TEXTURE_2D,e,E,T.width,T.height,0,f,y,T.data);s.generateMipmaps=!1}else w?(A&&n.texStorage2D(t.TEXTURE_2D,C,E,p.width,p.height),M&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,p.width,p.height,f,y,p.data)):n.texImage2D(t.TEXTURE_2D,0,E,p.width,p.height,0,f,y,p.data);else if(s.isCompressedTexture)if(s.isCompressedArrayTexture){w&&A&&n.texStorage3D(t.TEXTURE_2D_ARRAY,C,E,S[0].width,S[0].height,p.depth);for(let e=0,i=S.length;e<i;e++)if(T=S[e],s.format!==RGBAFormat){if(null!==f)if(w){if(M)if(s.layerUpdates.size>0){const i=getByteLength(T.width,T.height,s.format,s.type);for(const r of s.layerUpdates){const o=T.data.subarray(r*i/T.data.BYTES_PER_ELEMENT,(r+1)*i/T.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,T.width,T.height,1,f,o)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,T.width,T.height,p.depth,f,T.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,E,T.width,T.height,p.depth,0,T.data,0,0)}else w?M&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,T.width,T.height,p.depth,f,y,T.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,E,T.width,T.height,p.depth,0,f,y,T.data)}else{w&&A&&n.texStorage2D(t.TEXTURE_2D,C,E,S[0].width,S[0].height);for(let e=0,i=S.length;e<i;e++)T=S[e],s.format!==RGBAFormat?null!==f&&(w?M&&n.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,T.width,T.height,f,T.data):n.compressedTexImage2D(t.TEXTURE_2D,e,E,T.width,T.height,0,T.data)):w?M&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,T.width,T.height,f,y,T.data):n.texImage2D(t.TEXTURE_2D,e,E,T.width,T.height,0,f,y,T.data)}else if(s.isDataArrayTexture)if(w){if(A&&n.texStorage3D(t.TEXTURE_2D_ARRAY,C,E,p.width,p.height,p.depth),M)if(s.layerUpdates.size>0){const e=getByteLength(p.width,p.height,s.format,s.type);for(const i of s.layerUpdates){const r=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,y,r)}s.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,y,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,E,p.width,p.height,p.depth,0,f,y,p.data);else if(s.isData3DTexture)w?(A&&n.texStorage3D(t.TEXTURE_3D,C,E,p.width,p.height,p.depth),M&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,y,p.data)):n.texImage3D(t.TEXTURE_3D,0,E,p.width,p.height,p.depth,0,f,y,p.data);else if(s.isFramebufferTexture){if(A)if(w)n.texStorage2D(t.TEXTURE_2D,C,E,p.width,p.height);else{let e=p.width,i=p.height;for(let r=0;r<C;r++)n.texImage2D(t.TEXTURE_2D,r,E,e,i,0,f,y,null),e>>=1,i>>=1}}else if(S.length>0){if(w&&A){const e=G(S[0]);n.texStorage2D(t.TEXTURE_2D,C,E,e.width,e.height)}for(let e=0,i=S.length;e<i;e++)T=S[e],w?M&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,f,y,T):n.texImage2D(t.TEXTURE_2D,e,E,f,y,T);s.generateMipmaps=!1}else if(w){if(A){const e=G(p);n.texStorage2D(t.TEXTURE_2D,C,E,e.width,e.height)}M&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,f,y,p)}else n.texImage2D(t.TEXTURE_2D,0,E,f,y,p);g(s)&&_(l),h.__version=u.version,s.onUpdate&&s.onUpdate(s)}e.__version=s.version}function O(e,r,s,l,c,u){const h=o.convert(s.format,s.colorSpace),d=o.convert(s.type),p=v(s.internalFormat,h,d,s.colorSpace),f=i.get(r),m=i.get(s);if(m.__renderTarget=r,!f.__hasExternalTextures){const e=Math.max(1,r.width>>u),i=Math.max(1,r.height>>u);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,u,p,e,i,r.depth,0,h,d,null):n.texImage2D(c,u,p,e,i,0,h,d,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),k(r)?a.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,m.__webglTexture,0,U(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,m.__webglTexture,u),n.bindFramebuffer(t.FRAMEBUFFER,null)}function D(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,o=x(n.stencilBuffer,r&&r.isDepthTexture?r.type:null),s=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,l=U(n);k(n)?a.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,l,o,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,l,o,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,o,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,s,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r<e.length;r++){const s=e[r],l=o.convert(s.format,s.colorSpace),c=o.convert(s.type),u=v(s.internalFormat,l,c,s.colorSpace),h=U(n);i&&!1===k(n)?t.renderbufferStorageMultisample(t.RENDERBUFFER,h,u,n.width,n.height):k(n)?a.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,h,u,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,u,n.width,n.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function B(e){const r=i.get(e),o=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(o)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const o=i.get(r.depthTexture);o.__renderTarget=r,o.__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),A(r.depthTexture,0);const s=o.__webglTexture,l=U(r);if(r.depthTexture.format===DepthFormat)k(r)?a.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,s,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,s,0);else{if(r.depthTexture.format!==DepthStencilFormat)throw new Error("Unknown depthTexture format");k(r)?a.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,s,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,s,0)}}(r.__webglFramebuffer,e)}else if(o){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),D(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,o=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,o),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,o)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),D(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}n.bindFramebuffer(t.FRAMEBUFFER,null)}const N=[],F=[];function U(t){return Math.min(r.maxSamples,t.samples)}function k(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function z(t,e){const n=t.colorSpace;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==LinearSRGBColorSpace&&n!==NoColorSpace&&ColorManagement.getTransfer(n),e}function G(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=w;return w+=1,t},this.resetTextureUnits=function(){w=0},this.setTexture2D=A,this.setTexture2DArray=function(e,r){const o=i.get(e);e.version>0&&o.__version!==e.version?R(o,e,r):n.bindTexture(t.TEXTURE_2D_ARRAY,o.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const o=i.get(e);e.version>0&&o.__version!==e.version?R(o,e,r):n.bindTexture(t.TEXTURE_3D,o.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,s){const a=i.get(e);e.version>0&&a.__version!==e.version?function(e,s,a){if(6!==s.image.length)return;const l=L(e,s),c=s.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+a);const u=i.get(c);if(c.version!==u.__version||!0===l){n.activeTexture(t.TEXTURE0+a);const e=ColorManagement.getPrimaries(ColorManagement.workingColorSpace),i=s.colorSpace===NoColorSpace?null:ColorManagement.getPrimaries(s.colorSpace),h=s.colorSpace===NoColorSpace||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,s.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);const d=s.isCompressedTexture||s.image[0].isCompressedTexture,p=s.image[0]&&s.image[0].isDataTexture,f=[];for(let t=0;t<6;t++)f[t]=d||p?p?s.image[t].image:s.image[t]:m(s.image[t],!0,r.maxCubemapSize),f[t]=z(s,f[t]);const y=f[0],x=o.convert(s.format,s.colorSpace),T=o.convert(s.type),E=v(s.internalFormat,x,T,s.colorSpace),S=!0!==s.isVideoTexture,w=void 0===u.__version||!0===l,A=c.dataReady;let M,C=b(s,y);if(P(t.TEXTURE_CUBE_MAP,s),d){S&&w&&n.texStorage2D(t.TEXTURE_CUBE_MAP,C,E,y.width,y.height);for(let e=0;e<6;e++){M=f[e].mipmaps;for(let i=0;i<M.length;i++){const r=M[i];s.format!==RGBAFormat?null!==x&&(S?A&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,x,r.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,E,r.width,r.height,0,r.data)):S?A&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,x,T,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,E,r.width,r.height,0,x,T,r.data)}}}else{if(M=s.mipmaps,S&&w){M.length>0&&C++;const e=G(f[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,C,E,e.width,e.height)}for(let e=0;e<6;e++)if(p){S?A&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,x,T,f[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,E,f[e].width,f[e].height,0,x,T,f[e].data);for(let i=0;i<M.length;i++){const r=M[i].image[e].image;S?A&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,r.width,r.height,x,T,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,E,r.width,r.height,0,x,T,r.data)}}else{S?A&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,T,f[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,E,x,T,f[e]);for(let i=0;i<M.length;i++){const r=M[i];S?A&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,x,T,r.image[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,E,x,T,r.image[e])}}}g(s)&&_(t.TEXTURE_CUBE_MAP),u.__version=c.version,s.onUpdate&&s.onUpdate(s)}e.__version=s.version}(a,e,s):n.bindTexture(t.TEXTURE_CUBE_MAP,a.__webglTexture,t.TEXTURE0+s)},this.rebindTextures=function(e,n,r){const o=i.get(e);void 0!==n&&O(o.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&B(e)},this.setupRenderTarget=function(e){const r=e.texture,a=i.get(e),l=i.get(r);e.addEventListener("dispose",E);const c=e.textures,u=!0===e.isWebGLCubeRenderTarget,h=c.length>1;if(h||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,s.memory.textures++),u){a.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){a.__webglFramebuffer[e]=[];for(let n=0;n<r.mipmaps.length;n++)a.__webglFramebuffer[e][n]=t.createFramebuffer()}else a.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){a.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)a.__webglFramebuffer[e]=t.createFramebuffer()}else a.__webglFramebuffer=t.createFramebuffer();if(h)for(let e=0,n=c.length;e<n;e++){const n=i.get(c[e]);void 0===n.__webglTexture&&(n.__webglTexture=t.createTexture(),s.memory.textures++)}if(e.samples>0&&!1===k(e)){a.__webglMultisampledFramebuffer=t.createFramebuffer(),a.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,a.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];a.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,a.__webglColorRenderbuffer[n]);const r=o.convert(i.format,i.colorSpace),s=o.convert(i.type),l=v(i.internalFormat,r,s,i.colorSpace,!0===e.isXRRenderTarget),u=U(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,u,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,a.__webglColorRenderbuffer[n])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(a.__webglDepthRenderbuffer=t.createRenderbuffer(),D(a.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(u){n.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)O(a.__webglFramebuffer[n][i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else O(a.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(r)&&_(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(h){for(let r=0,o=c.length;r<o;r++){const o=c[r],s=i.get(o);n.bindTexture(t.TEXTURE_2D,s.__webglTexture),P(t.TEXTURE_2D,o),O(a.__webglFramebuffer,e,o,t.COLOR_ATTACHMENT0+r,t.TEXTURE_2D,0),g(o)&&_(t.TEXTURE_2D)}n.unbindTexture()}else{let i=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(i=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),P(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)O(a.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,i,n);else O(a.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,i,0);g(r)&&_(i),n.unbindTexture()}e.depthBuffer&&B(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,o=e.length;r<o;r++){const o=e[r];if(g(o)){const e=y(t),r=i.get(o).__webglTexture;n.bindTexture(e,r),_(e),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===k(e)){const r=e.textures,o=e.width,s=e.height;let a=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,u=i.get(e),h=r.length>1;if(h)for(let e=0;e<r.length;e++)n.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<r.length;n++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT)),h){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,u.__webglColorRenderbuffer[n]);const e=i.get(r[n]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,o,s,0,0,o,s,a,t.NEAREST),!0===l&&(N.length=0,F.length=0,N.push(t.COLOR_ATTACHMENT0+n),e.depthBuffer&&!1===e.resolveDepthBuffer&&(N.push(c),F.push(c),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,F)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,N))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),h)for(let e=0;e<r.length;e++){n.bindFramebuffer(t.FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,u.__webglColorRenderbuffer[e]);const o=i.get(r[e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,u.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,o,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT])}},this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=O,this.useMultisampledRTT=k}function WebGLUtils(t,e){return{convert:function(n,i=NoColorSpace){let r;const o=ColorManagement.getTransfer(i);if(n===UnsignedByteType)return t.UNSIGNED_BYTE;if(n===UnsignedShort4444Type)return t.UNSIGNED_SHORT_4_4_4_4;if(n===UnsignedShort5551Type)return t.UNSIGNED_SHORT_5_5_5_1;if(n===UnsignedInt5999Type)return t.UNSIGNED_INT_5_9_9_9_REV;if(n===ByteType)return t.BYTE;if(n===ShortType)return t.SHORT;if(n===UnsignedShortType)return t.UNSIGNED_SHORT;if(n===IntType)return t.INT;if(n===UnsignedIntType)return t.UNSIGNED_INT;if(n===FloatType)return t.FLOAT;if(n===HalfFloatType)return t.HALF_FLOAT;if(n===AlphaFormat)return t.ALPHA;if(n===RGBFormat)return t.RGB;if(n===RGBAFormat)return t.RGBA;if(n===LuminanceFormat)return t.LUMINANCE;if(n===LuminanceAlphaFormat)return t.LUMINANCE_ALPHA;if(n===DepthFormat)return t.DEPTH_COMPONENT;if(n===DepthStencilFormat)return t.DEPTH_STENCIL;if(n===RedFormat)return t.RED;if(n===RedIntegerFormat)return t.RED_INTEGER;if(n===RGFormat)return t.RG;if(n===RGIntegerFormat)return t.RG_INTEGER;if(n===RGBAIntegerFormat)return t.RGBA_INTEGER;if(n===RGB_S3TC_DXT1_Format||n===RGBA_S3TC_DXT1_Format||n===RGBA_S3TC_DXT3_Format||n===RGBA_S3TC_DXT5_Format)if(o===SRGBTransfer){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===RGB_S3TC_DXT1_Format)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===RGBA_S3TC_DXT1_Format)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===RGBA_S3TC_DXT3_Format)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===RGBA_S3TC_DXT5_Format)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===RGB_S3TC_DXT1_Format)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===RGBA_S3TC_DXT1_Format)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===RGBA_S3TC_DXT3_Format)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===RGBA_S3TC_DXT5_Format)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===RGB_PVRTC_4BPPV1_Format||n===RGB_PVRTC_2BPPV1_Format||n===RGBA_PVRTC_4BPPV1_Format||n===RGBA_PVRTC_2BPPV1_Format){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===RGB_PVRTC_4BPPV1_Format)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===RGB_PVRTC_2BPPV1_Format)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===RGBA_PVRTC_4BPPV1_Format)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===RGBA_PVRTC_2BPPV1_Format)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===RGB_ETC1_Format||n===RGB_ETC2_Format||n===RGBA_ETC2_EAC_Format){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===RGB_ETC1_Format||n===RGB_ETC2_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===RGBA_ETC2_EAC_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(n===RGBA_ASTC_4x4_Format||n===RGBA_ASTC_5x4_Format||n===RGBA_ASTC_5x5_Format||n===RGBA_ASTC_6x5_Format||n===RGBA_ASTC_6x6_Format||n===RGBA_ASTC_8x5_Format||n===RGBA_ASTC_8x6_Format||n===RGBA_ASTC_8x8_Format||n===RGBA_ASTC_10x5_Format||n===RGBA_ASTC_10x6_Format||n===RGBA_ASTC_10x8_Format||n===RGBA_ASTC_10x10_Format||n===RGBA_ASTC_12x10_Format||n===RGBA_ASTC_12x12_Format){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===RGBA_ASTC_4x4_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===RGBA_ASTC_5x4_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===RGBA_ASTC_5x5_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===RGBA_ASTC_6x5_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===RGBA_ASTC_6x6_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===RGBA_ASTC_8x5_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===RGBA_ASTC_8x6_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===RGBA_ASTC_8x8_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===RGBA_ASTC_10x5_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===RGBA_ASTC_10x6_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===RGBA_ASTC_10x8_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===RGBA_ASTC_10x10_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===RGBA_ASTC_12x10_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===RGBA_ASTC_12x12_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===RGBA_BPTC_Format||n===RGB_BPTC_SIGNED_Format||n===RGB_BPTC_UNSIGNED_Format){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(n===RGBA_BPTC_Format)return o===SRGBTransfer?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===RGB_BPTC_SIGNED_Format)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===RGB_BPTC_UNSIGNED_Format)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===RED_RGTC1_Format||n===SIGNED_RED_RGTC1_Format||n===RED_GREEN_RGTC2_Format||n===SIGNED_RED_GREEN_RGTC2_Format){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===RGBA_BPTC_Format)return r.COMPRESSED_RED_RGTC1_EXT;if(n===SIGNED_RED_RGTC1_Format)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===RED_GREEN_RGTC2_Format)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===SIGNED_RED_GREEN_RGTC2_Format)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===UnsignedInt248Type?t.UNSIGNED_INT_24_8:void 0!==t[n]?t[n]:null}}}const _moveEvent={type:"move"};class WebXRController{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Group,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 Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Vector3,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Vector3),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Vector3,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Vector3),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,o=null;const s=this._targetRay,a=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){o=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n),r=this._getHandJoint(l,i);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const i=l.joints["index-finger-tip"].position.distanceTo(l.joints["thumb-tip"].position),r=.02,s=.005;l.inputState.pinching&&i>r+s?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&i<=r-s&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==a&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),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!==s&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(_moveEvent)))}return null!==s&&(s.visible=null!==i),null!==a&&(a.visible=null!==r),null!==l&&(l.visible=null!==o),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new Group;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const _occlusion_vertex="\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",_occlusion_fragment="\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}";class WebXRDepthSensing{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(null===this.texture){const i=new Texture;t.properties.get(i).__webglTexture=e.texture,e.depthNear===n.depthNear&&e.depthFar===n.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new ShaderMaterial({vertexShader:_occlusion_vertex,fragmentShader:_occlusion_fragment,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Mesh(new PlaneGeometry(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class WebXRManager extends EventDispatcher{constructor(t,e){super();const n=this;let i=null,r=1,o=null,s="local-floor",a=1,l=null,c=null,u=null,h=null,d=null,p=null;const f=new WebXRDepthSensing,m=e.getContextAttributes();let g=null,_=null;const y=[],v=[],x=new Vector2;let b=null;const T=new PerspectiveCamera;T.viewport=new Vector4;const E=new PerspectiveCamera;E.viewport=new Vector4;const S=[T,E],w=new ArrayCamera;let A=null,M=null;function C(t){const e=v.indexOf(t.inputSource);if(-1===e)return;const n=y[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||o),n.dispatchEvent({type:t.type,data:t.inputSource}))}function I(){i.removeEventListener("select",C),i.removeEventListener("selectstart",C),i.removeEventListener("selectend",C),i.removeEventListener("squeeze",C),i.removeEventListener("squeezestart",C),i.removeEventListener("squeezeend",C),i.removeEventListener("end",I),i.removeEventListener("inputsourceschange",P);for(let t=0;t<y.length;t++){const e=v[t];null!==e&&(v[t]=null,y[t].disconnect(e))}A=null,M=null,f.reset(),t.setRenderTarget(g),d=null,h=null,u=null,i=null,_=null,B.stop(),n.isPresenting=!1,t.setPixelRatio(b),t.setSize(x.width,x.height,!1),n.dispatchEvent({type:"sessionend"})}function P(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=v.indexOf(n);i>=0&&(v[i]=null,y[i].disconnect(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let i=v.indexOf(n);if(-1===i){for(let t=0;t<y.length;t++){if(t>=v.length){v.push(n),i=t;break}if(null===v[t]){v[t]=n,i=t;break}}if(-1===i)break}const r=y[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=y[t];return void 0===e&&(e=new WebXRController,y[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=y[t];return void 0===e&&(e=new WebXRController,y[t]=e),e.getGripSpace()},this.getHand=function(t){let e=y[t];return void 0===e&&(e=new WebXRController,y[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t},this.setReferenceSpaceType=function(t){s=t},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==h?h:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){g=t.getRenderTarget(),i.addEventListener("select",C),i.addEventListener("selectstart",C),i.addEventListener("selectend",C),i.addEventListener("squeeze",C),i.addEventListener("squeezestart",C),i.addEventListener("squeezeend",C),i.addEventListener("end",I),i.addEventListener("inputsourceschange",P),!0!==m.xrCompatible&&await e.makeXRCompatible(),b=t.getPixelRatio(),t.getSize(x);if(void 0!==i.enabledFeatures&&i.enabledFeatures.includes("layers")){let n=null,o=null,s=null;m.depth&&(s=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=m.stencil?DepthStencilFormat:DepthFormat,o=m.stencil?UnsignedInt248Type:UnsignedIntType);const a={colorFormat:e.RGBA8,depthFormat:s,scaleFactor:r};u=new XRWebGLBinding(i,e),h=u.createProjectionLayer(a),i.updateRenderState({layers:[h]}),t.setPixelRatio(1),t.setSize(h.textureWidth,h.textureHeight,!1),_=new WebGLRenderTarget(h.textureWidth,h.textureHeight,{format:RGBAFormat,type:UnsignedByteType,depthTexture:new DepthTexture(h.textureWidth,h.textureHeight,o,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===h.ignoreDepthValues})}else{d=new XRWebGLLayer(i,e,{antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r}),i.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),_=new WebGLRenderTarget(d.framebufferWidth,d.framebufferHeight,{format:RGBAFormat,type:UnsignedByteType,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}_.isXRRenderTarget=!0,this.setFoveation(a),l=null,o=await i.requestReferenceSpace(s),B.setContext(i),B.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const L=new Vector3,R=new Vector3;function O(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),w.near=E.near=T.near=e,w.far=E.far=T.far=n,A===w.near&&M===w.far||(i.updateRenderState({depthNear:w.near,depthFar:w.far}),A=w.near,M=w.far),T.layers.mask=2|t.layers.mask,E.layers.mask=4|t.layers.mask,w.layers.mask=T.layers.mask|E.layers.mask;const r=t.parent,o=w.cameras;O(w,r);for(let t=0;t<o.length;t++)O(o[t],r);2===o.length?function(t,e,n){L.setFromMatrixPosition(e.matrixWorld),R.setFromMatrixPosition(n.matrixWorld);const i=L.distanceTo(R),r=e.projectionMatrix.elements,o=n.projectionMatrix.elements,s=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=(o[8]+1)/o[0],d=s*u,p=s*h,f=i/(-u+h),m=f*-u;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=s+f,n=a+f;t.projectionMatrix.makePerspective(d-m,p+(i-m),l*a/n*e,c*a/n*e,e,n),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(w,T,E):w.projectionMatrix.copy(T.projectionMatrix),function(t,e,n){null===n?t.matrix.copy(e.matrixWorld):(t.matrix.copy(n.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*RAD2DEG*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,w,r)},this.getCamera=function(){return w},this.getFoveation=function(){if(null!==h||null!==d)return a},this.setFoveation=function(t){a=t,null!==h&&(h.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(w)};let D=null;const B=new WebGLAnimation;B.setAnimationLoop((function(e,r){if(c=r.getViewerPose(l||o),p=r,null!==c){const e=c.views;null!==d&&(t.setRenderTargetFramebuffer(_,d.framebuffer),t.setRenderTarget(_));let n=!1;e.length!==w.cameras.length&&(w.cameras.length=0,n=!0);for(let i=0;i<e.length;i++){const r=e[i];let o=null;if(null!==d)o=d.getViewport(r);else{const e=u.getViewSubImage(h,r);o=e.viewport,0===i&&(t.setRenderTargetTextures(_,e.colorTexture,h.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(_))}let s=S[i];void 0===s&&(s=new PerspectiveCamera,s.layers.enable(i),s.viewport=new Vector4,S[i]=s),s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(r.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(o.x,o.y,o.width,o.height),0===i&&(w.matrix.copy(s.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),!0===n&&w.cameras.push(s)}const r=i.enabledFeatures;if(r&&r.includes("depth-sensing")){const n=u.getDepthInformation(e[0]);n&&n.isValid&&n.texture&&f.init(t,n,i.renderState)}}for(let t=0;t<y.length;t++){const e=v[t],n=y[t];null!==e&&void 0!==n&&n.update(e,r,l||o)}D&&D(e,r),r.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:r}),p=null})),this.setAnimationLoop=function(t){D=t},this.dispose=function(){}}}const _e1=new Euler,_m1=new Matrix4;function WebGLMaterials(t,e){function n(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function i(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map,n(i.map,t.mapTransform)),i.alphaMap&&(t.alphaMap.value=i.alphaMap,n(i.alphaMap,t.alphaMapTransform)),i.bumpMap&&(t.bumpMap.value=i.bumpMap,n(i.bumpMap,t.bumpMapTransform),t.bumpScale.value=i.bumpScale,i.side===BackSide&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,n(i.normalMap,t.normalMapTransform),t.normalScale.value.copy(i.normalScale),i.side===BackSide&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,n(i.displacementMap,t.displacementMapTransform),t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,t.emissiveMapTransform)),i.specularMap&&(t.specularMap.value=i.specularMap,n(i.specularMap,t.specularMapTransform)),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),o=r.envMap,s=r.envMapRotation;o&&(t.envMap.value=o,_e1.copy(s),_e1.x*=-1,_e1.y*=-1,_e1.z*=-1,o.isCubeTexture&&!1===o.isRenderTargetTexture&&(_e1.y*=-1,_e1.z*=-1),t.envMapRotation.value.setFromMatrix4(_m1.makeRotationFromEuler(_e1)),t.flipEnvMap.value=o.isCubeTexture&&!1===o.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,getUnlitUniformColorSpace(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,o,s,a){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===BackSide&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,a)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,o,s):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function WebGLUniformsGroups(t,e,n,i){let r={},o={},s=[];const a=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,o=e+"_"+n;if(void 0===i[o])return i[o]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[o];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[o]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4&&(e.boundary=64,e.storage=64),e}function u(e){const n=e.target;n.removeEventListener("dispose",u);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete o[n.id]}return{bind:function(t,e){i.uniformBlockBinding(t,e.program)},update:function(n,h){let d=r[n.id];void 0===d&&(!function(t){const e=t.uniforms;let n=0;const i=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],o=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=o.length;t<r;t++){const r=c(o[t]),s=n%i,a=s%r.boundary,l=s+a;n+=a,0!==l&&i-l<r.storage&&(n+=i-l),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);t.__size=n,t.__cache={}}(n),d=function(e){const n=function(){for(let t=0;t<a;t++)if(-1===s.indexOf(t))return s.push(t),t;return 0}();e.__bindingPointIndex=n;const i=t.createBuffer(),r=e.__size,o=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,r,o),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=d,n.addEventListener("dispose",u)),i.updateUBOMapping(n,h.program);const p=e.render.frame;o[n.id]!==p&&(!function(e){const n=r[e.id],i=e.uniforms,o=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,n);for(let e=0,n=i.length;e<n;e++){const n=Array.isArray(i[e])?i[e]:[i[e]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,e,i,o)){const e=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let o=0;o<n.length;o++){const s=n[o],a=c(s);"number"==typeof s||"boolean"==typeof s?(r.__data[0]=s,t.bufferSubData(t.UNIFORM_BUFFER,e+i,r.__data)):s.isMatrix3?(r.__data[0]=s.elements[0],r.__data[1]=s.elements[1],r.__data[2]=s.elements[2],r.__data[3]=0,r.__data[4]=s.elements[3],r.__data[5]=s.elements[4],r.__data[6]=s.elements[5],r.__data[7]=0,r.__data[8]=s.elements[6],r.__data[9]=s.elements[7],r.__data[10]=s.elements[8],r.__data[11]=0):(s.toArray(r.__data,i),i+=a.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(n),o[n.id]=p)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);s=[],r={},o={}}}}class WebGLRenderer{constructor(t={}){const{canvas:e=createCanvasElement(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:s=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:h=!1}=t;let d;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=o;const p=new Uint32Array(4),f=new Int32Array(4);let m=null,g=null;const _=[],y=[];this.domElement=e,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._outputColorSpace=SRGBColorSpace,this.toneMapping=NoToneMapping,this.toneMappingExposure=1;const v=this;let x=!1,b=0,T=0,E=null,S=-1,w=null;const A=new Vector4,M=new Vector4;let C=null;const I=new Color(0);let P=0,L=e.width,R=e.height,O=1,D=null,B=null;const N=new Vector4(0,0,L,R),F=new Vector4(0,0,L,R);let U=!1;const k=new Frustum;let z=!1,G=!1;this.transmissionResolutionScale=1;const V=new Matrix4,j=new Matrix4,$=new Vector3,H=new Vector4,W={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let q=!1;function X(){return null===E?O:1}let Y,Z,J,K,Q,tt,et,nt,it,rt,ot,st,at,lt,ct,ut,ht,dt,pt,ft,mt,gt,_t,yt,vt=n;function xt(t,n){return e.getContext(t,n)}try{const t={alpha:!0,depth:i,stencil:r,antialias:s,premultipliedAlpha:a,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${REVISION}`),e.addEventListener("webglcontextlost",Et,!1),e.addEventListener("webglcontextrestored",St,!1),e.addEventListener("webglcontextcreationerror",wt,!1),null===vt){const e="webgl2";if(vt=xt(e,t),null===vt)throw xt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw t}function bt(){Y=new WebGLExtensions(vt),Y.init(),gt=new WebGLUtils(vt,Y),Z=new WebGLCapabilities(vt,Y,t,gt),J=new WebGLState(vt,Y),Z.reverseDepthBuffer&&h&&J.buffers.depth.setReversed(!0),K=new WebGLInfo(vt),Q=new WebGLProperties,tt=new WebGLTextures(vt,Y,J,Q,Z,gt,K),et=new WebGLCubeMaps(v),nt=new WebGLCubeUVMaps(v),it=new WebGLAttributes(vt),_t=new WebGLBindingStates(vt,it),rt=new WebGLGeometries(vt,it,K,_t),ot=new WebGLObjects(vt,rt,it,K),pt=new WebGLMorphtargets(vt,Z,tt),ut=new WebGLClipping(Q),st=new WebGLPrograms(v,et,nt,Y,Z,_t,ut),at=new WebGLMaterials(v,Q),lt=new WebGLRenderLists,ct=new WebGLRenderStates(Y),dt=new WebGLBackground(v,et,nt,J,ot,d,a),ht=new WebGLShadowMap(v,ot,Z),yt=new WebGLUniformsGroups(vt,K,Z,J),ft=new WebGLBufferRenderer(vt,Y,K),mt=new WebGLIndexedBufferRenderer(vt,Y,K),K.programs=st.programs,v.capabilities=Z,v.extensions=Y,v.properties=Q,v.renderLists=lt,v.shadowMap=ht,v.state=J,v.info=K}bt();const Tt=new WebXRManager(v,vt);function Et(t){t.preventDefault(),x=!0}function St(){x=!1;const t=K.autoReset,e=ht.enabled,n=ht.autoUpdate,i=ht.needsUpdate,r=ht.type;bt(),K.autoReset=t,ht.enabled=e,ht.autoUpdate=n,ht.needsUpdate=i,ht.type=r}function wt(t){}function At(t){const e=t.target;e.removeEventListener("dispose",At),function(t){(function(t){const e=Q.get(t).programs;void 0!==e&&(e.forEach((function(t){st.releaseProgram(t)})),t.isShaderMaterial&&st.releaseShaderCache(t))})(t),Q.remove(t)}(e)}function Mt(t,e,n){!0===t.transparent&&t.side===DoubleSide&&!1===t.forceSinglePass?(t.side=BackSide,t.needsUpdate=!0,Ft(t,e,n),t.side=FrontSide,t.needsUpdate=!0,Ft(t,e,n),t.side=DoubleSide):Ft(t,e,n)}this.xr=Tt,this.getContext=function(){return vt},this.getContextAttributes=function(){return vt.getContextAttributes()},this.forceContextLoss=function(){const t=Y.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Y.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(t){void 0!==t&&(O=t,this.setSize(L,R,!1))},this.getSize=function(t){return t.set(L,R)},this.setSize=function(t,n,i=!0){Tt.isPresenting||(L=t,R=n,e.width=Math.floor(t*O),e.height=Math.floor(n*O),!0===i&&(e.style.width=t+"px",e.style.height=n+"px"),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return t.set(L*O,R*O).floor()},this.setDrawingBufferSize=function(t,n,i){L=t,R=n,O=i,e.width=Math.floor(t*i),e.height=Math.floor(n*i),this.setViewport(0,0,t,n)},this.getCurrentViewport=function(t){return t.copy(A)},this.getViewport=function(t){return t.copy(N)},this.setViewport=function(t,e,n,i){t.isVector4?N.set(t.x,t.y,t.z,t.w):N.set(t,e,n,i),J.viewport(A.copy(N).multiplyScalar(O).round())},this.getScissor=function(t){return t.copy(F)},this.setScissor=function(t,e,n,i){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,n,i),J.scissor(M.copy(F).multiplyScalar(O).round())},this.getScissorTest=function(){return U},this.setScissorTest=function(t){J.setScissorTest(U=t)},this.setOpaqueSort=function(t){D=t},this.setTransparentSort=function(t){B=t},this.getClearColor=function(t){return t.copy(dt.getClearColor())},this.setClearColor=function(){dt.setClearColor.apply(dt,arguments)},this.getClearAlpha=function(){return dt.getClearAlpha()},this.setClearAlpha=function(){dt.setClearAlpha.apply(dt,arguments)},this.clear=function(t=!0,e=!0,n=!0){let i=0;if(t){let t=!1;if(null!==E){const e=E.texture.format;t=e===RGBAIntegerFormat||e===RGIntegerFormat||e===RedIntegerFormat}if(t){const t=E.texture.type,e=t===UnsignedByteType||t===UnsignedIntType||t===UnsignedShortType||t===UnsignedInt248Type||t===UnsignedShort4444Type||t===UnsignedShort5551Type,n=dt.getClearColor(),i=dt.getClearAlpha(),r=n.r,o=n.g,s=n.b;e?(p[0]=r,p[1]=o,p[2]=s,p[3]=i,vt.clearBufferuiv(vt.COLOR,0,p)):(f[0]=r,f[1]=o,f[2]=s,f[3]=i,vt.clearBufferiv(vt.COLOR,0,f))}else i|=vt.COLOR_BUFFER_BIT}e&&(i|=vt.DEPTH_BUFFER_BIT),n&&(i|=vt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),vt.clear(i)},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(){e.removeEventListener("webglcontextlost",Et,!1),e.removeEventListener("webglcontextrestored",St,!1),e.removeEventListener("webglcontextcreationerror",wt,!1),dt.dispose(),lt.dispose(),ct.dispose(),Q.dispose(),et.dispose(),nt.dispose(),ot.dispose(),_t.dispose(),yt.dispose(),st.dispose(),Tt.dispose(),Tt.removeEventListener("sessionstart",It),Tt.removeEventListener("sessionend",Pt),Lt.stop()},this.renderBufferDirect=function(t,e,n,i,r,o){null===e&&(e=W);const s=r.isMesh&&r.matrixWorld.determinant()<0,a=function(t,e,n,i,r){!0!==e.isScene&&(e=W);tt.resetTextureUnits();const o=e.fog,s=i.isMeshStandardMaterial?e.environment:null,a=null===E?v.outputColorSpace:!0===E.isXRRenderTarget?E.texture.colorSpace:LinearSRGBColorSpace,l=(i.isMeshStandardMaterial?nt:et).get(i.envMap||s),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),h=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=NoToneMapping;i.toneMapped&&(null!==E&&!0!==E.isXRRenderTarget||(f=v.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=void 0!==m?m.length:0,y=Q.get(i),x=g.state.lights;if(!0===z&&(!0===G||t!==w)){ut.setState(i,t,t===w&&i.id===S)}let b=!1;i.version===y.__version?y.needsLights&&y.lightsStateVersion!==x.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!==l||!0===i.fog&&y.fog!==o?b=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===ut.numPlanes&&y.numIntersection===ut.numIntersection?(y.vertexAlphas!==c||y.vertexTangents!==u||y.morphTargets!==h||y.morphNormals!==d||y.morphColors!==p||y.toneMapping!==f||y.morphTargetsCount!==_)&&(b=!0):b=!0:b=!0:b=!0:b=!0:(b=!0,y.__version=i.version);let T=y.currentProgram;!0===b&&(T=Ft(i,e,r));let A=!1,M=!1,C=!1;const I=T.getUniforms(),P=y.uniforms;J.useProgram(T.program)&&(A=!0,M=!0,C=!0);i.id!==S&&(S=i.id,M=!0);if(A||w!==t){J.buffers.depth.getReversed()?(V.copy(t.projectionMatrix),toNormalizedProjectionMatrix(V),toReversedProjectionMatrix(V),I.setValue(vt,"projectionMatrix",V)):I.setValue(vt,"projectionMatrix",t.projectionMatrix),I.setValue(vt,"viewMatrix",t.matrixWorldInverse);const e=I.map.cameraPosition;void 0!==e&&e.setValue(vt,$.setFromMatrixPosition(t.matrixWorld)),Z.logarithmicDepthBuffer&&I.setValue(vt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&I.setValue(vt,"isOrthographic",!0===t.isOrthographicCamera),w!==t&&(w=t,M=!0,C=!0)}if(r.isSkinnedMesh){I.setOptional(vt,r,"bindMatrix"),I.setOptional(vt,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),I.setValue(vt,"boneTexture",t.boneTexture,tt))}r.isBatchedMesh&&(I.setOptional(vt,r,"batchingTexture"),I.setValue(vt,"batchingTexture",r._matricesTexture,tt),I.setOptional(vt,r,"batchingIdTexture"),I.setValue(vt,"batchingIdTexture",r._indirectTexture,tt),I.setOptional(vt,r,"batchingColorTexture"),null!==r._colorsTexture&&I.setValue(vt,"batchingColorTexture",r._colorsTexture,tt));const L=n.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||pt.update(r,n,T);(M||y.receiveShadow!==r.receiveShadow)&&(y.receiveShadow=r.receiveShadow,I.setValue(vt,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(P.envMapIntensity.value=e.environmentIntensity);M&&(I.setValue(vt,"toneMappingExposure",v.toneMappingExposure),y.needsLights&&((D=P).ambientLightColor.needsUpdate=B=C,D.lightProbe.needsUpdate=B,D.directionalLights.needsUpdate=B,D.directionalLightShadows.needsUpdate=B,D.pointLights.needsUpdate=B,D.pointLightShadows.needsUpdate=B,D.spotLights.needsUpdate=B,D.spotLightShadows.needsUpdate=B,D.rectAreaLights.needsUpdate=B,D.hemisphereLights.needsUpdate=B),o&&!0===i.fog&&at.refreshFogUniforms(P,o),at.refreshMaterialUniforms(P,i,O,R,g.state.transmissionRenderTarget[t.id]),WebGLUniforms.upload(vt,Ut(y),P,tt));var D,B;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(WebGLUniforms.upload(vt,Ut(y),P,tt),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&I.setValue(vt,"center",r.center);if(I.setValue(vt,"modelViewMatrix",r.modelViewMatrix),I.setValue(vt,"normalMatrix",r.normalMatrix),I.setValue(vt,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e<n;e++){const n=t[e];yt.update(n,T),yt.bind(n,T)}}return T}(t,e,n,i,r);J.setMaterial(i,s);let l=n.index,c=1;if(!0===i.wireframe){if(l=rt.getWireframeAttribute(n),void 0===l)return;c=2}const u=n.drawRange,h=n.attributes.position;let d=u.start*c,p=(u.start+u.count)*c;null!==o&&(d=Math.max(d,o.start*c),p=Math.min(p,(o.start+o.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;_t.setup(r,i,a,n,l);let _=ft;if(null!==l&&(m=it.get(l),_=mt,_.setIndex(m)),r.isMesh)!0===i.wireframe?(J.setLineWidth(i.wireframeLinewidth*X()),_.setMode(vt.LINES)):_.setMode(vt.TRIANGLES);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),J.setLineWidth(t*X()),_.setMode(r.isLineSegments?vt.LINES:r.isLineLoop?vt.LINE_LOOP:vt.LINE_STRIP)}else r.isPoints?_.setMode(vt.POINTS):r.isSprite&&_.setMode(vt.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)_.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Y.get("WEBGL_multi_draw"))_.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,n=r._multiDrawCount,o=l?it.get(l).bytesPerElement:1,s=Q.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)s.setValue(vt,"_gl_DrawID",i),_.render(t[i]/o,e[i])}else if(r.isInstancedMesh)_.renderInstances(d,f,r.count);else if(n.isInstancedBufferGeometry){const t=Math.min(n.instanceCount,void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0);_.renderInstances(d,f,t)}else _.render(d,f)},this.compile=function(t,e,n=null){null===n&&(n=t),g=ct.get(n),g.init(e),y.push(g),n.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),t!==n&&t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),g.setupLights();const i=new Set;return t.traverse((function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const o=e[r];Mt(o,n,t),i.add(o)}else Mt(e,n,t),i.add(e)})),y.pop(),g=null,i},this.compileAsync=function(t,e,n=null){const i=this.compile(t,e,n);return new Promise((e=>{function n(){i.forEach((function(t){Q.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==Y.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Ct=null;function It(){Lt.stop()}function Pt(){Lt.start()}const Lt=new WebGLAnimation;function Rt(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)g.pushLight(t),t.castShadow&&g.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||k.intersectsSprite(t)){i&&H.setFromMatrixPosition(t.matrixWorld).applyMatrix4(j);const e=ot.update(t),r=t.material;r.visible&&m.push(t,e,r,n,H.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||k.intersectsObject(t))){const e=ot.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),H.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),H.copy(e.boundingSphere.center)),H.applyMatrix4(t.matrixWorld).applyMatrix4(j)),Array.isArray(r)){const i=e.groups;for(let o=0,s=i.length;o<s;o++){const s=i[o],a=r[s.materialIndex];a&&a.visible&&m.push(t,e,a,n,H.z,s)}}else r.visible&&m.push(t,e,r,n,H.z,null)}const r=t.children;for(let t=0,o=r.length;t<o;t++)Rt(r[t],e,n,i)}function Ot(t,e,n,i){const r=t.opaque,o=t.transmissive,s=t.transparent;g.setupLightsView(n),!0===z&&ut.setGlobalState(v.clippingPlanes,n),i&&J.viewport(A.copy(i)),r.length>0&&Bt(r,e,n),o.length>0&&Bt(o,e,n),s.length>0&&Bt(s,e,n),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Dt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===g.state.transmissionRenderTarget[i.id]&&(g.state.transmissionRenderTarget[i.id]=new WebGLRenderTarget(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")||Y.has("EXT_color_buffer_float")?HalfFloatType:UnsignedByteType,minFilter:LinearMipmapLinearFilter,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ColorManagement.workingColorSpace}));const o=g.state.transmissionRenderTarget[i.id],s=i.viewport||A;o.setSize(s.z*v.transmissionResolutionScale,s.w*v.transmissionResolutionScale);const a=v.getRenderTarget();v.setRenderTarget(o),v.getClearColor(I),P=v.getClearAlpha(),P<1&&v.setClearColor(16777215,.5),v.clear(),q&&dt.render(n);const l=v.toneMapping;v.toneMapping=NoToneMapping;const c=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),g.setupLightsView(i),!0===z&&ut.setGlobalState(v.clippingPlanes,i),Bt(t,n,i),tt.updateMultisampleRenderTarget(o),tt.updateRenderTargetMipmap(o),!1===Y.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,o=e.length;r<o;r++){const o=e[r],s=o.object,a=o.geometry,l=o.material,c=o.group;if(l.side===DoubleSide&&s.layers.test(i.layers)){const e=l.side;l.side=BackSide,l.needsUpdate=!0,Nt(s,n,i,a,l,c),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(tt.updateMultisampleRenderTarget(o),tt.updateRenderTargetMipmap(o))}v.setRenderTarget(a),v.setClearColor(I,P),void 0!==c&&(i.viewport=c),v.toneMapping=l}function Bt(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let r=0,o=t.length;r<o;r++){const o=t[r],s=o.object,a=o.geometry,l=null===i?o.material:i,c=o.group;s.layers.test(n.layers)&&Nt(s,e,n,a,l,c)}}function Nt(t,e,n,i,r,o){t.onBeforeRender(v,e,n,i,r,o),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(v,e,n,i,t,o),!0===r.transparent&&r.side===DoubleSide&&!1===r.forceSinglePass?(r.side=BackSide,r.needsUpdate=!0,v.renderBufferDirect(n,e,i,r,t,o),r.side=FrontSide,r.needsUpdate=!0,v.renderBufferDirect(n,e,i,r,t,o),r.side=DoubleSide):v.renderBufferDirect(n,e,i,r,t,o),t.onAfterRender(v,e,n,i,r,o)}function Ft(t,e,n){!0!==e.isScene&&(e=W);const i=Q.get(t),r=g.state.lights,o=r.state.version,s=st.getParameters(t,r.state,g.state.shadowsArray,e,n),a=st.getProgramCacheKey(s);let l=i.programs;i.environment=t.isMeshStandardMaterial?e.environment:null,i.fog=e.fog,i.envMap=(t.isMeshStandardMaterial?nt:et).get(t.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===l&&(t.addEventListener("dispose",At),l=new Map,i.programs=l);let c=l.get(a);if(void 0!==c){if(i.currentProgram===c&&i.lightsStateVersion===o)return kt(t,s),c}else s.uniforms=st.getUniforms(t),t.onBeforeCompile(s,v),c=st.acquireProgram(s,a),l.set(a,c),i.uniforms=s.uniforms;const u=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=ut.uniform),kt(t,s),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=o,i.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.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=c,i.uniformsList=null,c}function Ut(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=WebGLUniforms.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function kt(t,e){const n=Q.get(t);n.outputColorSpace=e.outputColorSpace,n.batching=e.batching,n.batchingColor=e.batchingColor,n.instancing=e.instancing,n.instancingColor=e.instancingColor,n.instancingMorph=e.instancingMorph,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}Lt.setAnimationLoop((function(t){Ct&&Ct(t)})),"undefined"!=typeof self&&Lt.setContext(self),this.setAnimationLoop=function(t){Ct=t,Tt.setAnimationLoop(t),null===t?Lt.stop():Lt.start()},Tt.addEventListener("sessionstart",It),Tt.addEventListener("sessionend",Pt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return;if(!0===x)return;if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Tt.enabled&&!0===Tt.isPresenting&&(!0===Tt.cameraAutoUpdate&&Tt.updateCamera(e),e=Tt.getCamera()),!0===t.isScene&&t.onBeforeRender(v,t,e,E),g=ct.get(t,y.length),g.init(e),y.push(g),j.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),k.setFromProjectionMatrix(j),G=this.localClippingEnabled,z=ut.init(this.clippingPlanes,G),m=lt.get(t,_.length),m.init(),_.push(m),!0===Tt.enabled&&!0===Tt.isPresenting){const t=v.xr.getDepthSensingMesh();null!==t&&Rt(t,e,-1/0,v.sortObjects)}Rt(t,e,0,v.sortObjects),m.finish(),!0===v.sortObjects&&m.sort(D,B),q=!1===Tt.enabled||!1===Tt.isPresenting||!1===Tt.hasDepthSensing(),q&&dt.addToRenderList(m,t),this.info.render.frame++,!0===z&&ut.beginShadows();ht.render(g.state.shadowsArray,t,e),!0===z&&ut.endShadows(),!0===this.info.autoReset&&this.info.reset();const n=m.opaque,i=m.transmissive;if(g.setupLights(),e.isArrayCamera){const r=e.cameras;if(i.length>0)for(let e=0,o=r.length;e<o;e++){Dt(n,i,t,r[e])}q&&dt.render(t);for(let e=0,n=r.length;e<n;e++){const n=r[e];Ot(m,t,n,n.viewport)}}else i.length>0&&Dt(n,i,t,e),q&&dt.render(t),Ot(m,t,e);null!==E&&0===T&&(tt.updateMultisampleRenderTarget(E),tt.updateRenderTargetMipmap(E)),!0===t.isScene&&t.onAfterRender(v,t,e),_t.resetDefaultState(),S=-1,w=null,y.pop(),y.length>0?(g=y[y.length-1],!0===z&&ut.setGlobalState(v.clippingPlanes,g.state.camera)):g=null,_.pop(),m=_.length>0?_[_.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(t,e,n){Q.get(t.texture).__webglTexture=e,Q.get(t.depthTexture).__webglTexture=n;const i=Q.get(t);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===Y.has("WEBGL_multisampled_render_to_texture")&&(i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const n=Q.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e};const zt=vt.createFramebuffer();this.setRenderTarget=function(t,e=0,n=0){E=t,b=e,T=n;let i=!0,r=null,o=!1,s=!1;if(t){const a=Q.get(t);if(void 0!==a.__useDefaultFramebuffer)J.bindFramebuffer(vt.FRAMEBUFFER,null),i=!1;else if(void 0===a.__webglFramebuffer)tt.setupRenderTarget(t);else if(a.__hasExternalTextures)tt.rebindTextures(t,Q.get(t.texture).__webglTexture,Q.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(a.__boundDepthTexture!==e){if(null!==e&&Q.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");tt.setupDepthRenderbuffer(t)}}const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);const c=Q.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(c[e])?c[e][n]:c[e],o=!0):r=t.samples>0&&!1===tt.useMultisampledRTT(t)?Q.get(t).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,A.copy(t.viewport),M.copy(t.scissor),C=t.scissorTest}else A.copy(N).multiplyScalar(O).floor(),M.copy(F).multiplyScalar(O).floor(),C=U;0!==n&&(r=zt);if(J.bindFramebuffer(vt.FRAMEBUFFER,r)&&i&&J.drawBuffers(t,r),J.viewport(A),J.scissor(M),J.setScissorTest(C),o){const i=Q.get(t.texture);vt.framebufferTexture2D(vt.FRAMEBUFFER,vt.COLOR_ATTACHMENT0,vt.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(s){const i=Q.get(t.texture);vt.framebufferTextureLayer(vt.FRAMEBUFFER,vt.COLOR_ATTACHMENT0,i.__webglTexture,n,e)}else if(null!==t&&0!==n){const e=Q.get(t.texture);vt.framebufferTexture2D(vt.FRAMEBUFFER,vt.COLOR_ATTACHMENT0,vt.TEXTURE_2D,e.__webglTexture,n)}S=-1},this.readRenderTargetPixels=function(t,e,n,i,r,o,s){if(!t||!t.isWebGLRenderTarget)return;let a=Q.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==s&&(a=a[s]),a){J.bindFramebuffer(vt.FRAMEBUFFER,a);try{const s=t.texture,a=s.format,l=s.type;if(!Z.textureFormatReadable(a))return;if(!Z.textureTypeReadable(l))return;e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&vt.readPixels(e,n,i,r,gt.convert(a),gt.convert(l),o)}finally{const t=null!==E?Q.get(E).__webglFramebuffer:null;J.bindFramebuffer(vt.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,o,s){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=Q.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==s&&(a=a[s]),a){const s=t.texture,l=s.format,c=s.type;if(!Z.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){J.bindFramebuffer(vt.FRAMEBUFFER,a);const t=vt.createBuffer();vt.bindBuffer(vt.PIXEL_PACK_BUFFER,t),vt.bufferData(vt.PIXEL_PACK_BUFFER,o.byteLength,vt.STREAM_READ),vt.readPixels(e,n,i,r,gt.convert(l),gt.convert(c),0);const s=null!==E?Q.get(E).__webglFramebuffer:null;J.bindFramebuffer(vt.FRAMEBUFFER,s);const u=vt.fenceSync(vt.SYNC_GPU_COMMANDS_COMPLETE,0);return vt.flush(),await probeAsync(vt,u,4),vt.bindBuffer(vt.PIXEL_PACK_BUFFER,t),vt.getBufferSubData(vt.PIXEL_PACK_BUFFER,0,o),vt.deleteBuffer(t),vt.deleteSync(u),o}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){!0!==t.isTexture&&(warnOnce("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),o=Math.floor(t.image.height*i),s=null!==e?e.x:0,a=null!==e?e.y:0;tt.setTexture2D(t,0),vt.copyTexSubImage2D(vt.TEXTURE_2D,n,0,0,s,a,r,o),J.unbindTexture()};const Gt=vt.createFramebuffer(),Vt=vt.createFramebuffer();this.copyTextureToTexture=function(t,e,n=null,i=null,r=0,o=null){let s,a,l,c,u,h,d,p,f;!0!==t.isTexture&&(warnOnce("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,t=arguments[1],e=arguments[2],o=arguments[3]||0,n=null),null===o&&(0!==r?(warnOnce("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),o=r,r=0):o=0);const m=t.isCompressedTexture?t.mipmaps[o]:t.image;if(null!==n)s=n.max.x-n.min.x,a=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,u=n.min.y,h=n.isBox3?n.min.z:0;else{const e=Math.pow(2,-r);s=Math.floor(m.width*e),a=Math.floor(m.height*e),l=t.isDataArrayTexture?m.depth:t.isData3DTexture?Math.floor(m.depth*e):1,c=0,u=0,h=0}null!==i?(d=i.x,p=i.y,f=i.z):(d=0,p=0,f=0);const g=gt.convert(e.format),_=gt.convert(e.type);let y;e.isData3DTexture?(tt.setTexture3D(e,0),y=vt.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(tt.setTexture2DArray(e,0),y=vt.TEXTURE_2D_ARRAY):(tt.setTexture2D(e,0),y=vt.TEXTURE_2D),vt.pixelStorei(vt.UNPACK_FLIP_Y_WEBGL,e.flipY),vt.pixelStorei(vt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),vt.pixelStorei(vt.UNPACK_ALIGNMENT,e.unpackAlignment);const v=vt.getParameter(vt.UNPACK_ROW_LENGTH),x=vt.getParameter(vt.UNPACK_IMAGE_HEIGHT),b=vt.getParameter(vt.UNPACK_SKIP_PIXELS),T=vt.getParameter(vt.UNPACK_SKIP_ROWS),E=vt.getParameter(vt.UNPACK_SKIP_IMAGES);vt.pixelStorei(vt.UNPACK_ROW_LENGTH,m.width),vt.pixelStorei(vt.UNPACK_IMAGE_HEIGHT,m.height),vt.pixelStorei(vt.UNPACK_SKIP_PIXELS,c),vt.pixelStorei(vt.UNPACK_SKIP_ROWS,u),vt.pixelStorei(vt.UNPACK_SKIP_IMAGES,h);const S=t.isDataArrayTexture||t.isData3DTexture,w=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const n=Q.get(t),i=Q.get(e),m=Q.get(n.__renderTarget),g=Q.get(i.__renderTarget);J.bindFramebuffer(vt.READ_FRAMEBUFFER,m.__webglFramebuffer),J.bindFramebuffer(vt.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<l;n++)S&&(vt.framebufferTextureLayer(vt.READ_FRAMEBUFFER,vt.COLOR_ATTACHMENT0,Q.get(t).__webglTexture,r,h+n),vt.framebufferTextureLayer(vt.DRAW_FRAMEBUFFER,vt.COLOR_ATTACHMENT0,Q.get(e).__webglTexture,o,f+n)),vt.blitFramebuffer(c,u,s,a,d,p,s,a,vt.DEPTH_BUFFER_BIT,vt.NEAREST);J.bindFramebuffer(vt.READ_FRAMEBUFFER,null),J.bindFramebuffer(vt.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||Q.has(t)){const n=Q.get(t),i=Q.get(e);J.bindFramebuffer(vt.READ_FRAMEBUFFER,Gt),J.bindFramebuffer(vt.DRAW_FRAMEBUFFER,Vt);for(let t=0;t<l;t++)S?vt.framebufferTextureLayer(vt.READ_FRAMEBUFFER,vt.COLOR_ATTACHMENT0,n.__webglTexture,r,h+t):vt.framebufferTexture2D(vt.READ_FRAMEBUFFER,vt.COLOR_ATTACHMENT0,vt.TEXTURE_2D,n.__webglTexture,r),w?vt.framebufferTextureLayer(vt.DRAW_FRAMEBUFFER,vt.COLOR_ATTACHMENT0,i.__webglTexture,o,f+t):vt.framebufferTexture2D(vt.DRAW_FRAMEBUFFER,vt.COLOR_ATTACHMENT0,vt.TEXTURE_2D,i.__webglTexture,o),0!==r?vt.blitFramebuffer(c,u,s,a,d,p,s,a,vt.COLOR_BUFFER_BIT,vt.NEAREST):w?vt.copyTexSubImage3D(y,o,d,p,f+t,c,u,s,a):vt.copyTexSubImage2D(y,o,d,p,c,u,s,a);J.bindFramebuffer(vt.READ_FRAMEBUFFER,null),J.bindFramebuffer(vt.DRAW_FRAMEBUFFER,null)}else w?t.isDataTexture||t.isData3DTexture?vt.texSubImage3D(y,o,d,p,f,s,a,l,g,_,m.data):e.isCompressedArrayTexture?vt.compressedTexSubImage3D(y,o,d,p,f,s,a,l,g,m.data):vt.texSubImage3D(y,o,d,p,f,s,a,l,g,_,m):t.isDataTexture?vt.texSubImage2D(vt.TEXTURE_2D,o,d,p,s,a,g,_,m.data):t.isCompressedTexture?vt.compressedTexSubImage2D(vt.TEXTURE_2D,o,d,p,m.width,m.height,g,m.data):vt.texSubImage2D(vt.TEXTURE_2D,o,d,p,s,a,g,_,m);vt.pixelStorei(vt.UNPACK_ROW_LENGTH,v),vt.pixelStorei(vt.UNPACK_IMAGE_HEIGHT,x),vt.pixelStorei(vt.UNPACK_SKIP_PIXELS,b),vt.pixelStorei(vt.UNPACK_SKIP_ROWS,T),vt.pixelStorei(vt.UNPACK_SKIP_IMAGES,E),0===o&&e.generateMipmaps&&vt.generateMipmap(y),J.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n=null,i=null,r=0){return!0!==t.isTexture&&(warnOnce("WebGLRenderer: copyTextureToTexture3D function signature has changed."),n=arguments[0]||null,i=arguments[1]||null,t=arguments[2],e=arguments[3],r=arguments[4]||0),warnOnce('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(t,e,n,i,r)},this.initRenderTarget=function(t){void 0===Q.get(t).__webglFramebuffer&&tt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?tt.setTextureCube(t,0):t.isData3DTexture?tt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?tt.setTexture2DArray(t,0):tt.setTexture2D(t,0),J.unbindTexture()},this.resetState=function(){b=0,T=0,E=null,J.reset(),_t.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return WebGLCoordinateSystem}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=ColorManagement._getDrawingBufferColorSpace(t),e.unpackColorSpace=ColorManagement._getUnpackColorSpace()}}var three=Object.freeze({__proto__:null,ACESFilmicToneMapping:ACESFilmicToneMapping,AddEquation:AddEquation,AddOperation:AddOperation,AdditiveAnimationBlendMode:AdditiveAnimationBlendMode,AdditiveBlending:AdditiveBlending,AgXToneMapping:AgXToneMapping,AlphaFormat:AlphaFormat,AlwaysCompare:AlwaysCompare,AlwaysDepth:AlwaysDepth,AlwaysStencilFunc:AlwaysStencilFunc,AmbientLight:AmbientLight,AnimationAction:AnimationAction,AnimationClip:AnimationClip,AnimationLoader:AnimationLoader,AnimationMixer:AnimationMixer,AnimationObjectGroup:AnimationObjectGroup,AnimationUtils:AnimationUtils,ArcCurve:ArcCurve,ArrayCamera:ArrayCamera,ArrowHelper:ArrowHelper,AttachedBindMode:AttachedBindMode,Audio:Audio,AudioAnalyser:AudioAnalyser,AudioContext:AudioContext,AudioListener:AudioListener,AudioLoader:AudioLoader,AxesHelper:AxesHelper,BackSide:BackSide,BasicDepthPacking:BasicDepthPacking,BasicShadowMap:BasicShadowMap,BatchedMesh:BatchedMesh,Bone:Bone,BooleanKeyframeTrack:BooleanKeyframeTrack,Box2:Box2,Box3:Box3,Box3Helper:Box3Helper,BoxGeometry:BoxGeometry,BoxHelper:BoxHelper,BufferAttribute:BufferAttribute,BufferGeometry:BufferGeometry,BufferGeometryLoader:BufferGeometryLoader,ByteType:ByteType,Cache:Cache,Camera:Camera,CameraHelper:CameraHelper,CanvasTexture:CanvasTexture,CapsuleGeometry:CapsuleGeometry,CatmullRomCurve3:CatmullRomCurve3,CineonToneMapping:CineonToneMapping,CircleGeometry:CircleGeometry,ClampToEdgeWrapping:ClampToEdgeWrapping,Clock:Clock,Color:Color,ColorKeyframeTrack:ColorKeyframeTrack,ColorManagement:ColorManagement,CompressedArrayTexture:CompressedArrayTexture,CompressedCubeTexture:CompressedCubeTexture,CompressedTexture:CompressedTexture,CompressedTextureLoader:CompressedTextureLoader,ConeGeometry:ConeGeometry,ConstantAlphaFactor:ConstantAlphaFactor,ConstantColorFactor:ConstantColorFactor,Controls:Controls,CubeCamera:CubeCamera,CubeReflectionMapping:CubeReflectionMapping,CubeRefractionMapping:CubeRefractionMapping,CubeTexture:CubeTexture,CubeTextureLoader:CubeTextureLoader,CubeUVReflectionMapping:CubeUVReflectionMapping,CubicBezierCurve:CubicBezierCurve,CubicBezierCurve3:CubicBezierCurve3,CubicInterpolant:CubicInterpolant,CullFaceBack:CullFaceBack,CullFaceFront:CullFaceFront,CullFaceFrontBack:CullFaceFrontBack,CullFaceNone:CullFaceNone,Curve:Curve,CurvePath:CurvePath,CustomBlending:CustomBlending,CustomToneMapping:CustomToneMapping,CylinderGeometry:CylinderGeometry,Cylindrical:Cylindrical,Data3DTexture:Data3DTexture,DataArrayTexture:DataArrayTexture,DataTexture:DataTexture,DataTextureLoader:DataTextureLoader,DataUtils:DataUtils,DecrementStencilOp:DecrementStencilOp,DecrementWrapStencilOp:DecrementWrapStencilOp,DefaultLoadingManager:DefaultLoadingManager,DepthFormat:DepthFormat,DepthStencilFormat:DepthStencilFormat,DepthTexture:DepthTexture,DetachedBindMode:DetachedBindMode,DirectionalLight:DirectionalLight,DirectionalLightHelper:DirectionalLightHelper,DiscreteInterpolant:DiscreteInterpolant,DodecahedronGeometry:DodecahedronGeometry,DoubleSide:DoubleSide,DstAlphaFactor:DstAlphaFactor,DstColorFactor:DstColorFactor,DynamicCopyUsage:DynamicCopyUsage,DynamicDrawUsage:DynamicDrawUsage,DynamicReadUsage:DynamicReadUsage,EdgesGeometry:EdgesGeometry,EllipseCurve:EllipseCurve,EqualCompare:EqualCompare,EqualDepth:EqualDepth,EqualStencilFunc:EqualStencilFunc,EquirectangularReflectionMapping:EquirectangularReflectionMapping,EquirectangularRefractionMapping:EquirectangularRefractionMapping,Euler:Euler,EventDispatcher:EventDispatcher,ExtrudeGeometry:ExtrudeGeometry,FileLoader:FileLoader,Float16BufferAttribute:Float16BufferAttribute,Float32BufferAttribute:Float32BufferAttribute,FloatType:FloatType,Fog:Fog,FogExp2:FogExp2,FramebufferTexture:FramebufferTexture,FrontSide:FrontSide,Frustum:Frustum,GLBufferAttribute:GLBufferAttribute,GLSL1:GLSL1,GLSL3:GLSL3,GreaterCompare:GreaterCompare,GreaterDepth:GreaterDepth,GreaterEqualCompare:GreaterEqualCompare,GreaterEqualDepth:GreaterEqualDepth,GreaterEqualStencilFunc:GreaterEqualStencilFunc,GreaterStencilFunc:GreaterStencilFunc,GridHelper:GridHelper,Group:Group,HalfFloatType:HalfFloatType,HemisphereLight:HemisphereLight,HemisphereLightHelper:HemisphereLightHelper,IcosahedronGeometry:IcosahedronGeometry,ImageBitmapLoader:ImageBitmapLoader,ImageLoader:ImageLoader,ImageUtils:ImageUtils,IncrementStencilOp:IncrementStencilOp,IncrementWrapStencilOp:IncrementWrapStencilOp,InstancedBufferAttribute:InstancedBufferAttribute,InstancedBufferGeometry:InstancedBufferGeometry,InstancedInterleavedBuffer:InstancedInterleavedBuffer,InstancedMesh:InstancedMesh,Int16BufferAttribute:Int16BufferAttribute,Int32BufferAttribute:Int32BufferAttribute,Int8BufferAttribute:Int8BufferAttribute,IntType:IntType,InterleavedBuffer:InterleavedBuffer,InterleavedBufferAttribute:InterleavedBufferAttribute,Interpolant:Interpolant,InterpolateDiscrete:InterpolateDiscrete,InterpolateLinear:InterpolateLinear,InterpolateSmooth:InterpolateSmooth,InvertStencilOp:InvertStencilOp,KeepStencilOp:KeepStencilOp,KeyframeTrack:KeyframeTrack,LOD:LOD,LatheGeometry:LatheGeometry,Layers:Layers,LessCompare:LessCompare,LessDepth:LessDepth,LessEqualCompare:LessEqualCompare,LessEqualDepth:LessEqualDepth,LessEqualStencilFunc:LessEqualStencilFunc,LessStencilFunc:LessStencilFunc,Light:Light,LightProbe:LightProbe,Line:Line,Line3:Line3,LineBasicMaterial:LineBasicMaterial,LineCurve:LineCurve,LineCurve3:LineCurve3,LineDashedMaterial:LineDashedMaterial,LineLoop:LineLoop,LineSegments:LineSegments,LinearFilter:LinearFilter,LinearInterpolant:LinearInterpolant,LinearMipMapLinearFilter:LinearMipMapLinearFilter,LinearMipMapNearestFilter:LinearMipMapNearestFilter,LinearMipmapLinearFilter:LinearMipmapLinearFilter,LinearMipmapNearestFilter:LinearMipmapNearestFilter,LinearSRGBColorSpace:LinearSRGBColorSpace,LinearToneMapping:LinearToneMapping,LinearTransfer:LinearTransfer,Loader:Loader,LoaderUtils:LoaderUtils,LoadingManager:LoadingManager,LoopOnce:LoopOnce,LoopPingPong:LoopPingPong,LoopRepeat:LoopRepeat,LuminanceAlphaFormat:LuminanceAlphaFormat,LuminanceFormat:LuminanceFormat,MOUSE:MOUSE,Material:Material,MaterialLoader:MaterialLoader,MathUtils:MathUtils,Matrix2:Matrix2,Matrix3:Matrix3,Matrix4:Matrix4,MaxEquation:MaxEquation,Mesh:Mesh,MeshBasicMaterial:MeshBasicMaterial,MeshDepthMaterial:MeshDepthMaterial,MeshDistanceMaterial:MeshDistanceMaterial,MeshLambertMaterial:MeshLambertMaterial,MeshMatcapMaterial:MeshMatcapMaterial,MeshNormalMaterial:MeshNormalMaterial,MeshPhongMaterial:MeshPhongMaterial,MeshPhysicalMaterial:MeshPhysicalMaterial,MeshStandardMaterial:MeshStandardMaterial,MeshToonMaterial:MeshToonMaterial,MinEquation:MinEquation,MirroredRepeatWrapping:MirroredRepeatWrapping,MixOperation:MixOperation,MultiplyBlending:MultiplyBlending,MultiplyOperation:MultiplyOperation,NearestFilter:NearestFilter,NearestMipMapLinearFilter:NearestMipMapLinearFilter,NearestMipMapNearestFilter:NearestMipMapNearestFilter,NearestMipmapLinearFilter:NearestMipmapLinearFilter,NearestMipmapNearestFilter:NearestMipmapNearestFilter,NeutralToneMapping:NeutralToneMapping,NeverCompare:NeverCompare,NeverDepth:NeverDepth,NeverStencilFunc:NeverStencilFunc,NoBlending:NoBlending,NoColorSpace:NoColorSpace,NoToneMapping:NoToneMapping,NormalAnimationBlendMode:NormalAnimationBlendMode,NormalBlending:NormalBlending,NotEqualCompare:NotEqualCompare,NotEqualDepth:NotEqualDepth,NotEqualStencilFunc:NotEqualStencilFunc,NumberKeyframeTrack:NumberKeyframeTrack,Object3D:Object3D,ObjectLoader:ObjectLoader,ObjectSpaceNormalMap:ObjectSpaceNormalMap,OctahedronGeometry:OctahedronGeometry,OneFactor:OneFactor,OneMinusConstantAlphaFactor:OneMinusConstantAlphaFactor,OneMinusConstantColorFactor:OneMinusConstantColorFactor,OneMinusDstAlphaFactor:OneMinusDstAlphaFactor,OneMinusDstColorFactor:OneMinusDstColorFactor,OneMinusSrcAlphaFactor:OneMinusSrcAlphaFactor,OneMinusSrcColorFactor:OneMinusSrcColorFactor,OrthographicCamera:OrthographicCamera,PCFShadowMap:PCFShadowMap,PCFSoftShadowMap:PCFSoftShadowMap,PMREMGenerator:PMREMGenerator,Path:Path,PerspectiveCamera:PerspectiveCamera,Plane:Plane$1,PlaneGeometry:PlaneGeometry,PlaneHelper:PlaneHelper,PointLight:PointLight,PointLightHelper:PointLightHelper,Points:Points,PointsMaterial:PointsMaterial,PolarGridHelper:PolarGridHelper,PolyhedronGeometry:PolyhedronGeometry,PositionalAudio:PositionalAudio,PropertyBinding:PropertyBinding,PropertyMixer:PropertyMixer,QuadraticBezierCurve:QuadraticBezierCurve,QuadraticBezierCurve3:QuadraticBezierCurve3,Quaternion:Quaternion,QuaternionKeyframeTrack:QuaternionKeyframeTrack,QuaternionLinearInterpolant:QuaternionLinearInterpolant,RED_GREEN_RGTC2_Format:RED_GREEN_RGTC2_Format,RED_RGTC1_Format:RED_RGTC1_Format,REVISION:REVISION,RGBADepthPacking:RGBADepthPacking,RGBAFormat:RGBAFormat,RGBAIntegerFormat:RGBAIntegerFormat,RGBA_ASTC_10x10_Format:RGBA_ASTC_10x10_Format,RGBA_ASTC_10x5_Format:RGBA_ASTC_10x5_Format,RGBA_ASTC_10x6_Format:RGBA_ASTC_10x6_Format,RGBA_ASTC_10x8_Format:RGBA_ASTC_10x8_Format,RGBA_ASTC_12x10_Format:RGBA_ASTC_12x10_Format,RGBA_ASTC_12x12_Format:RGBA_ASTC_12x12_Format,RGBA_ASTC_4x4_Format:RGBA_ASTC_4x4_Format,RGBA_ASTC_5x4_Format:RGBA_ASTC_5x4_Format,RGBA_ASTC_5x5_Format:RGBA_ASTC_5x5_Format,RGBA_ASTC_6x5_Format:RGBA_ASTC_6x5_Format,RGBA_ASTC_6x6_Format:RGBA_ASTC_6x6_Format,RGBA_ASTC_8x5_Format:RGBA_ASTC_8x5_Format,RGBA_ASTC_8x6_Format:RGBA_ASTC_8x6_Format,RGBA_ASTC_8x8_Format:RGBA_ASTC_8x8_Format,RGBA_BPTC_Format:RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:RGBA_ETC2_EAC_Format,RGBA_PVRTC_2BPPV1_Format:RGBA_PVRTC_2BPPV1_Format,RGBA_PVRTC_4BPPV1_Format:RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:RGBA_S3TC_DXT1_Format,RGBA_S3TC_DXT3_Format:RGBA_S3TC_DXT3_Format,RGBA_S3TC_DXT5_Format:RGBA_S3TC_DXT5_Format,RGBDepthPacking:RGBDepthPacking,RGBFormat:RGBFormat,RGBIntegerFormat:RGBIntegerFormat,RGB_BPTC_SIGNED_Format:RGB_BPTC_SIGNED_Format,RGB_BPTC_UNSIGNED_Format:RGB_BPTC_UNSIGNED_Format,RGB_ETC1_Format:RGB_ETC1_Format,RGB_ETC2_Format:RGB_ETC2_Format,RGB_PVRTC_2BPPV1_Format:RGB_PVRTC_2BPPV1_Format,RGB_PVRTC_4BPPV1_Format:RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:RGB_S3TC_DXT1_Format,RGDepthPacking:RGDepthPacking,RGFormat:RGFormat,RGIntegerFormat:RGIntegerFormat,RawShaderMaterial:RawShaderMaterial,Ray:Ray,Raycaster:Raycaster,RectAreaLight:RectAreaLight,RedFormat:RedFormat,RedIntegerFormat:RedIntegerFormat,ReinhardToneMapping:ReinhardToneMapping,RenderTarget:RenderTarget,RenderTarget3D:RenderTarget3D,RenderTargetArray:RenderTargetArray,RepeatWrapping:RepeatWrapping,ReplaceStencilOp:ReplaceStencilOp,ReverseSubtractEquation:ReverseSubtractEquation,RingGeometry:RingGeometry,SIGNED_RED_GREEN_RGTC2_Format:SIGNED_RED_GREEN_RGTC2_Format,SIGNED_RED_RGTC1_Format:SIGNED_RED_RGTC1_Format,SRGBColorSpace:SRGBColorSpace,SRGBTransfer:SRGBTransfer,Scene:Scene,ShaderChunk:ShaderChunk,ShaderLib:ShaderLib,ShaderMaterial:ShaderMaterial,ShadowMaterial:ShadowMaterial,Shape:Shape,ShapeGeometry:ShapeGeometry,ShapePath:ShapePath,ShapeUtils:ShapeUtils,ShortType:ShortType,Skeleton:Skeleton,SkeletonHelper:SkeletonHelper,SkinnedMesh:SkinnedMesh,Source:Source,Sphere:Sphere,SphereGeometry:SphereGeometry,Spherical:Spherical,SphericalHarmonics3:SphericalHarmonics3,SplineCurve:SplineCurve,SpotLight:SpotLight,SpotLightHelper:SpotLightHelper,Sprite:Sprite,SpriteMaterial:SpriteMaterial,SrcAlphaFactor:SrcAlphaFactor,SrcAlphaSaturateFactor:SrcAlphaSaturateFactor,SrcColorFactor:SrcColorFactor,StaticCopyUsage:StaticCopyUsage,StaticDrawUsage:StaticDrawUsage,StaticReadUsage:StaticReadUsage,StereoCamera:StereoCamera,StreamCopyUsage:StreamCopyUsage,StreamDrawUsage:StreamDrawUsage,StreamReadUsage:StreamReadUsage,StringKeyframeTrack:StringKeyframeTrack,SubtractEquation:SubtractEquation,SubtractiveBlending:SubtractiveBlending,TOUCH:TOUCH,TangentSpaceNormalMap:TangentSpaceNormalMap,TetrahedronGeometry:TetrahedronGeometry,Texture:Texture,TextureLoader:TextureLoader,TextureUtils:TextureUtils,TorusGeometry:TorusGeometry,TorusKnotGeometry:TorusKnotGeometry,Triangle:Triangle,TriangleFanDrawMode:TriangleFanDrawMode,TriangleStripDrawMode:TriangleStripDrawMode,TrianglesDrawMode:TrianglesDrawMode,TubeGeometry:TubeGeometry,UVMapping:UVMapping,Uint16BufferAttribute:Uint16BufferAttribute,Uint32BufferAttribute:Uint32BufferAttribute,Uint8BufferAttribute:Uint8BufferAttribute,Uint8ClampedBufferAttribute:Uint8ClampedBufferAttribute,Uniform:Uniform,UniformsGroup:UniformsGroup,UniformsLib:UniformsLib,UniformsUtils:UniformsUtils,UnsignedByteType:UnsignedByteType,UnsignedInt248Type:UnsignedInt248Type,UnsignedInt5999Type:UnsignedInt5999Type,UnsignedIntType:UnsignedIntType,UnsignedShort4444Type:UnsignedShort4444Type,UnsignedShort5551Type:UnsignedShort5551Type,UnsignedShortType:UnsignedShortType,VSMShadowMap:VSMShadowMap,Vector2:Vector2,Vector3:Vector3,Vector4:Vector4,VectorKeyframeTrack:VectorKeyframeTrack,VideoTexture:VideoTexture,WebGL3DRenderTarget:WebGL3DRenderTarget,WebGLArrayRenderTarget:WebGLArrayRenderTarget,WebGLCoordinateSystem:WebGLCoordinateSystem,WebGLCubeRenderTarget:WebGLCubeRenderTarget,WebGLRenderTarget:WebGLRenderTarget,WebGLRenderer:WebGLRenderer,WebGLUtils:WebGLUtils,WebGPUCoordinateSystem:WebGPUCoordinateSystem,WireframeGeometry:WireframeGeometry,WrapAroundEnding:WrapAroundEnding,ZeroCurvatureEnding:ZeroCurvatureEnding,ZeroFactor:ZeroFactor,ZeroSlopeEnding:ZeroSlopeEnding,ZeroStencilOp:ZeroStencilOp,createCanvasElement:createCanvasElement});const SQRT3=Math.sqrt(3);class ThreeLayer{constructor(t){const e=this;e.implementation=t,e._tick=e._tick.bind(e),e._onResize=e._onResize.bind(e)}onAdd(t,e){const n=this,i=n.implementation,r=i.id,o=t.map;n.map=t,n.modelOrigin=t.getModelOrigin(),o.addLayer({id:r,type:"custom",renderingMode:"3d",onAdd:(e,r)=>{n._onAdd(e,r),i.onAdd&&i.onAdd(t,{renderer:n.renderer,scene:n.scene,camera:n.camera})},onRemove:(e,r)=>{n._onRemove(e,r),i.onRemove&&i.onRemove(t,{renderer:n.renderer,scene:n.scene,camera:n.camera})},render:n._render.bind(n)},e||"poi"),o.setLayerZoomRange(r,i.minzoom,i.maxzoom)}_onAdd(t,e){const n=this,{_fov:i,width:r,height:o}=t.transform,s=n.renderer=new WebGLRenderer({canvas:t.getCanvas(),context:e}),a=n.scene=new Scene,l=valueOrDefault(n.implementation.lightColor,(new Color).copy(n.map.getLightColor())),c=n.light=new DirectionalLight(l,.8*Math.PI),u=n.ambientLight=new AmbientLight(l,.4*Math.PI);s.outputColorSpace=LinearSRGBColorSpace,s.autoClear=!1,a.add(c),a.add(u),a.add(new Mesh),n.mbox=t,n.camera=new PerspectiveCamera(MathUtils.radToDeg(i),r/o),t.on("resize",n._onResize),void 0===n.implementation.lightColor&&n._tick()}_tick(){const t=this,e=t.map,n=e.clock.getTime();if(Math.floor(n/6e4)!==Math.floor(t.lastRefresh/6e4)){const i=e.getLightColor();t.light.color.copy(i),t.ambientLight.color.copy(i),t.lastRefresh=n}t.mbox&&requestAnimationFrame(t._tick)}_onRemove(t){t.off("resize",this._onResize),delete this.mbox}_render(t,e){const{modelOrigin:n,mbox:i,renderer:r,camera:o,light:s,scene:a}=this,{_fov:l,_camera:c,_horizonShift:u,pixelsPerMeter:h,worldSize:d,_pitch:p,width:f,height:m}=i.transform,g=l/2,_=c.position[2]*d/Math.cos(p),y=_/u,v=1e3*h/Math.cos(p),x=o.far=Math.max(y,_+v),b=o.near=m/50,T=Math.tan(g)*b,E=T*f/m,S=(new Matrix4).fromArray(e),w=(new Matrix4).makeTranslation(n.x,n.y,0).scale(new Vector3(1,-1,1));o.projectionMatrix.makePerspective(-E,E,T,-T,b,x).clone().invert().multiply(S).multiply(w).invert().decompose(o.position,o.quaternion,o.scale);const A=MathUtils.degToRad(i.getBearing()+30);s.position.set(-Math.sin(A),-Math.cos(A),SQRT3).normalize(),r.resetState(),r.render(a,o)}_onResize(t){const e=this.camera,n=t.target.transform;e.aspect=n.width/n.height,e.updateProjectionMatrix()}}const INTERSECTION={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};new Vector3$1,new Vector3$1;const scratchVector$6=new Vector3$1,scratchVector2$2=new Vector3$1;class BoundingSphere{constructor(t=[0,0,0],e=0){_defineProperty(this,"center",void 0),_defineProperty(this,"radius",void 0),this.radius=-0,this.center=new Vector3$1,this.fromCenterRadius(t,e)}fromCenterRadius(t,e){return this.center.from(t),this.radius=e,this}fromCornerPoints(t,e){return e=scratchVector$6.from(e),this.center=(new Vector3$1).from(t).add(e).scale(.5),this.radius=this.center.distance(e),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new BoundingSphere(this.center,this.radius)}union(t){const e=this.center,n=this.radius,i=t.radius,r=scratchVector$6.copy(t.center).subtract(e),o=r.magnitude();if(n>=o+i)return this.clone();if(i>=o+n)return t.clone();const s=.5*(n+o+i);return scratchVector2$2.copy(r).scale((-n+s)/o).add(e),this.center.copy(scratchVector2$2),this.radius=s,this}expand(t){const e=scratchVector$6.from(t).subtract(this.center).magnitude();return e>this.radius&&(this.radius=e),this}transform(t){this.center.transform(t);const e=getScaling(scratchVector$6,t);return this.radius=Math.max(e[0],Math.max(e[1],e[2]))*this.radius,this}distanceSquaredTo(t){const e=this.distanceTo(t);return e*e}distanceTo(t){const e=scratchVector$6.from(t).subtract(this.center);return Math.max(0,e.len()-this.radius)}intersectPlane(t){const e=this.radius,n=t.normal.dot(this.center)+t.distance;return n<-e?INTERSECTION.OUTSIDE:n<e?INTERSECTION.INTERSECTING:INTERSECTION.INSIDE}}const scratchVector3$2=new Vector3$1,scratchOffset=new Vector3$1,scratchVectorU=new Vector3$1,scratchVectorV=new Vector3$1,scratchVectorW=new Vector3$1,scratchCorner=new Vector3$1,scratchToCenter=new Vector3$1,MATRIX3={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8};class OrientedBoundingBox{constructor(t=[0,0,0],e=[0,0,0,0,0,0,0,0,0]){_defineProperty(this,"center",void 0),_defineProperty(this,"halfAxes",void 0),this.center=(new Vector3$1).from(t),this.halfAxes=new Matrix3$1(e)}get halfSize(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new Vector3$1(t).len(),new Vector3$1(e).len(),new Vector3$1(n).len()]}get quaternion(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),i=new Vector3$1(t).normalize(),r=new Vector3$1(e).normalize(),o=new Vector3$1(n).normalize();return(new Quaternion$1).fromMatrix3(new Matrix3$1([...i,...r,...o]))}fromCenterHalfSizeQuaternion(t,e,n){const i=new Quaternion$1(n),r=(new Matrix3$1).fromQuaternion(i);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],this.center=(new Vector3$1).from(t),this.halfAxes=r,this}clone(){return new OrientedBoundingBox(this.center,this.halfAxes)}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new BoundingSphere){const e=this.halfAxes,n=e.getColumn(0,scratchVectorU),i=e.getColumn(1,scratchVectorV),r=e.getColumn(2,scratchVectorW),o=scratchVector3$2.copy(n).add(i).add(r);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){const e=this.center,n=t.normal,i=this.halfAxes,r=n.x,o=n.y,s=n.z,a=Math.abs(r*i[MATRIX3.COLUMN0ROW0]+o*i[MATRIX3.COLUMN0ROW1]+s*i[MATRIX3.COLUMN0ROW2])+Math.abs(r*i[MATRIX3.COLUMN1ROW0]+o*i[MATRIX3.COLUMN1ROW1]+s*i[MATRIX3.COLUMN1ROW2])+Math.abs(r*i[MATRIX3.COLUMN2ROW0]+o*i[MATRIX3.COLUMN2ROW1]+s*i[MATRIX3.COLUMN2ROW2]),l=n.dot(e)+t.distance;return l<=-a?INTERSECTION.OUTSIDE:l>=a?INTERSECTION.INSIDE:INTERSECTION.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){const e=scratchOffset.from(t).subtract(this.center),n=this.halfAxes,i=n.getColumn(0,scratchVectorU),r=n.getColumn(1,scratchVectorV),o=n.getColumn(2,scratchVectorW),s=i.magnitude(),a=r.magnitude(),l=o.magnitude();i.normalize(),r.normalize(),o.normalize();let c,u=0;return c=Math.abs(e.dot(i))-s,c>0&&(u+=c*c),c=Math.abs(e.dot(r))-a,c>0&&(u+=c*c),c=Math.abs(e.dot(o))-l,c>0&&(u+=c*c),u}computePlaneDistances(t,e,n=[-0,-0]){let i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const o=this.center,s=this.halfAxes,a=s.getColumn(0,scratchVectorU),l=s.getColumn(1,scratchVectorV),c=s.getColumn(2,scratchVectorW),u=scratchCorner.copy(a).add(l).add(c).add(o),h=scratchToCenter.copy(u).subtract(t);let d=e.dot(h);return i=Math.min(d,i),r=Math.max(d,r),u.copy(o).add(a).add(l).subtract(c),h.copy(u).subtract(t),d=e.dot(h),i=Math.min(d,i),r=Math.max(d,r),u.copy(o).add(a).subtract(l).add(c),h.copy(u).subtract(t),d=e.dot(h),i=Math.min(d,i),r=Math.max(d,r),u.copy(o).add(a).subtract(l).subtract(c),h.copy(u).subtract(t),d=e.dot(h),i=Math.min(d,i),r=Math.max(d,r),o.copy(u).subtract(a).add(l).add(c),h.copy(u).subtract(t),d=e.dot(h),i=Math.min(d,i),r=Math.max(d,r),o.copy(u).subtract(a).add(l).subtract(c),h.copy(u).subtract(t),d=e.dot(h),i=Math.min(d,i),r=Math.max(d,r),o.copy(u).subtract(a).subtract(l).add(c),h.copy(u).subtract(t),d=e.dot(h),i=Math.min(d,i),r=Math.max(d,r),o.copy(u).subtract(a).subtract(l).subtract(c),h.copy(u).subtract(t),d=e.dot(h),i=Math.min(d,i),r=Math.max(d,r),n[0]=i,n[1]=r,n}transform(t){this.center.transformAsPoint(t);const e=this.halfAxes.getColumn(0,scratchVectorU);e.transformAsPoint(t);const n=this.halfAxes.getColumn(1,scratchVectorV);n.transformAsPoint(t);const i=this.halfAxes.getColumn(2,scratchVectorW);return i.transformAsPoint(t),this.halfAxes=new Matrix3$1([...e,...n,...i]),this}getTransform(){throw new Error("not implemented")}}const scratchPosition$2=new Vector3$1,scratchNormal$2=new Vector3$1;class Plane{constructor(t=[0,0,1],e=0){_defineProperty(this,"normal",void 0),_defineProperty(this,"distance",void 0),this.normal=new Vector3$1,this.distance=-0,this.fromNormalDistance(t,e)}fromNormalDistance(t,e){return assert$6(Number.isFinite(e)),this.normal.from(t).normalize(),this.distance=e,this}fromPointNormal(t,e){t=scratchPosition$2.from(t),this.normal.from(e).normalize();const n=-this.normal.dot(t);return this.distance=n,this}fromCoefficients(t,e,n,i){return this.normal.set(t,e,n),assert$6(equals$1(this.normal.len(),1)),this.distance=i,this}clone(){return new Plane(this.normal,this.distance)}equals(t){return equals$1(this.distance,t.distance)&&equals$1(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){const e=scratchNormal$2.copy(this.normal).transformAsVector(t).normalize(),n=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(n,e)}projectPointOntoPlane(t,e=[0,0,0]){t=scratchPosition$2.from(t);const n=this.getPointDistance(t),i=scratchNormal$2.copy(this.normal).scale(n);return t.subtract(i).to(e)}}const faces=[new Vector3$1([1,0,0]),new Vector3$1([0,1,0]),new Vector3$1([0,0,1])],scratchPlaneCenter=new Vector3$1,scratchPlaneNormal=new Vector3$1;new Plane(new Vector3$1(1,0,0),0);class CullingVolume{constructor(t=[]){_defineProperty(this,"planes",void 0),this.planes=t}fromBoundingSphere(t){this.planes.length=2*faces.length;const e=t.center,n=t.radius;let i=0;for(const t of faces){let r=this.planes[i],o=this.planes[i+1];r||(r=this.planes[i]=new Plane),o||(o=this.planes[i+1]=new Plane);const s=scratchPlaneCenter.copy(t).scale(-n).add(e);t.dot(s),r.fromPointNormal(s,t);const a=scratchPlaneCenter.copy(t).scale(n).add(e),l=scratchPlaneNormal.copy(t).negate();l.dot(a),o.fromPointNormal(a,l),i+=2}return this}computeVisibility(t){let e=INTERSECTION.INSIDE;for(const n of this.planes){switch(t.intersectPlane(n)){case INTERSECTION.OUTSIDE:return INTERSECTION.OUTSIDE;case INTERSECTION.INTERSECTING:e=INTERSECTION.INTERSECTING}}return e}computeVisibilityWithPlaneMask(t,e){if(assert$6(Number.isFinite(e),"parentPlaneMask is required."),e===CullingVolume.MASK_OUTSIDE||e===CullingVolume.MASK_INSIDE)return e;let n=CullingVolume.MASK_INSIDE;const i=this.planes;for(let r=0;r<this.planes.length;++r){const o=r<31?1<<r:0;if(r<31&&!(e&o))continue;const s=t.intersectPlane(i[r]);if(s===INTERSECTION.OUTSIDE)return CullingVolume.MASK_OUTSIDE;s===INTERSECTION.INTERSECTING&&(n|=o)}return n}}_defineProperty(CullingVolume,"MASK_OUTSIDE",4294967295),_defineProperty(CullingVolume,"MASK_INSIDE",0),_defineProperty(CullingVolume,"MASK_INDETERMINATE",2147483647),new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1,new Vector3$1;const scratchMatrix=new Matrix3$1,scratchUnitary=new Matrix3$1,scratchDiagonal=new Matrix3$1,jMatrix=new Matrix3$1,jMatrixTranspose=new Matrix3$1;function computeEigenDecomposition(t,e={}){const n=_MathUtils.EPSILON20;let i=0,r=0;const o=scratchUnitary,s=scratchDiagonal;o.identity(),s.copy(t);const a=n*computeFrobeniusNorm(s);for(;r<10&&offDiagonalFrobeniusNorm(s)>a;)shurDecomposition(s,jMatrix),jMatrixTranspose.copy(jMatrix).transpose(),s.multiplyRight(jMatrix),s.multiplyLeft(jMatrixTranspose),o.multiplyRight(jMatrix),++i>2&&(++r,i=0);return e.unitary=o.toTarget(e.unitary),e.diagonal=s.toTarget(e.diagonal),e}function computeFrobeniusNorm(t){let e=0;for(let n=0;n<9;++n){const i=t[n];e+=i*i}return Math.sqrt(e)}const rowVal=[1,0,0],colVal=[2,2,1];function offDiagonalFrobeniusNorm(t){let e=0;for(let n=0;n<3;++n){const i=t[scratchMatrix.getElementIndex(colVal[n],rowVal[n])];e+=2*i*i}return Math.sqrt(e)}function shurDecomposition(t,e){const n=_MathUtils.EPSILON15;let i=0,r=1;for(let e=0;e<3;++e){const n=Math.abs(t[scratchMatrix.getElementIndex(colVal[e],rowVal[e])]);n>i&&(r=e,i=n)}const o=rowVal[r],s=colVal[r];let a=1,l=0;if(Math.abs(t[scratchMatrix.getElementIndex(s,o)])>n){const e=(t[scratchMatrix.getElementIndex(s,s)]-t[scratchMatrix.getElementIndex(o,o)])/2/t[scratchMatrix.getElementIndex(s,o)];let n;n=e<0?-1/(-e+Math.sqrt(1+e*e)):1/(e+Math.sqrt(1+e*e)),a=1/Math.sqrt(1+n*n),l=n*a}return Matrix3$1.IDENTITY.to(e),e[scratchMatrix.getElementIndex(o,o)]=e[scratchMatrix.getElementIndex(s,s)]=a,e[scratchMatrix.getElementIndex(s,o)]=l,e[scratchMatrix.getElementIndex(o,s)]=-l,e}const scratchVector2$1=new Vector3$1,scratchVector3$1=new Vector3$1,scratchVector4=new Vector3$1,scratchVector5=new Vector3$1,scratchVector6=new Vector3$1,scratchCovarianceResult=new Matrix3$1,scratchEigenResult={diagonal:new Matrix3$1,unitary:new Matrix3$1};function makeOrientedBoundingBoxFromPoints(t,e=new OrientedBoundingBox){if(!t||0===t.length)return e.halfAxes=new Matrix3$1([0,0,0,0,0,0,0,0,0]),e.center=new Vector3$1,e;const n=t.length,i=new Vector3$1(0,0,0);for(const e of t)i.add(e);const r=1/n;i.multiplyByScalar(r);let o=0,s=0,a=0,l=0,c=0,u=0;for(const e of t){const t=scratchVector2$1.copy(e).subtract(i);o+=t.x*t.x,s+=t.x*t.y,a+=t.x*t.z,l+=t.y*t.y,c+=t.y*t.z,u+=t.z*t.z}o*=r,s*=r,a*=r,l*=r,c*=r,u*=r;const h=scratchCovarianceResult;h[0]=o,h[1]=s,h[2]=a,h[3]=s,h[4]=l,h[5]=c,h[6]=a,h[7]=c,h[8]=u;const{unitary:d}=computeEigenDecomposition(h,scratchEigenResult),p=e.halfAxes.copy(d);let f=p.getColumn(0,scratchVector4),m=p.getColumn(1,scratchVector5),g=p.getColumn(2,scratchVector6),_=-Number.MAX_VALUE,y=-Number.MAX_VALUE,v=-Number.MAX_VALUE,x=Number.MAX_VALUE,b=Number.MAX_VALUE,T=Number.MAX_VALUE;for(const e of t)scratchVector2$1.copy(e),_=Math.max(scratchVector2$1.dot(f),_),y=Math.max(scratchVector2$1.dot(m),y),v=Math.max(scratchVector2$1.dot(g),v),x=Math.min(scratchVector2$1.dot(f),x),b=Math.min(scratchVector2$1.dot(m),b),T=Math.min(scratchVector2$1.dot(g),T);f=f.multiplyByScalar(.5*(x+_)),m=m.multiplyByScalar(.5*(b+y)),g=g.multiplyByScalar(.5*(T+v)),e.center.copy(f).add(m).add(g);const E=scratchVector3$1.set(_-x,y-b,v-T).multiplyByScalar(.5),S=new Matrix3$1([E[0],0,0,0,E[1],0,0,0,E[2]]);return e.halfAxes.multiplyRight(S),e}const RADIAN_PER_DEGREE=Math.PI/180,modelMatrix=new Float32Array(16),valueArray=new Float32Array(12);function calculateTransformMatrix(t,e,n){const i=e[0]*RADIAN_PER_DEGREE,r=e[1]*RADIAN_PER_DEGREE,o=e[2]*RADIAN_PER_DEGREE,s=Math.sin(o),a=Math.sin(i),l=Math.sin(r),c=Math.cos(o),u=Math.cos(i),h=Math.cos(r),d=n[0],p=n[1],f=n[2];t[0]=d*h*u,t[1]=d*l*u,t[2]=d*-a,t[3]=p*(-l*c+h*a*s),t[4]=p*(h*c+l*a*s),t[5]=p*u*s,t[6]=f*(l*s+h*a*c),t[7]=f*(-h*s+l*a*c),t[8]=f*u*c}function getExtendedMat3FromMat4(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}const MATRIX_ATTRIBUTES={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(t,{startRow:e,endRow:n}){const{data:i,getOrientation:r,getScale:o,getTranslation:s,getTransformMatrix:a}=this.props,l=Array.isArray(a),c=l&&16===a.length,u=Array.isArray(o),h=Array.isArray(r),d=Array.isArray(s),p=c||!l&&Boolean(a(i[0]));t.constant=p?c:h&&u&&d;const f=t.value;if(t.constant){let e;if(p)modelMatrix.set(a),e=getExtendedMat3FromMat4(modelMatrix);else{e=valueArray;calculateTransformMatrix(e,r,o),e.set(s,9)}t.value=new Float32Array(e)}else{let l=e*t.size;const{iterable:m,objectInfo:g}=createIterable(i,e,n);for(const t of m){let e;if(g.index++,p)modelMatrix.set(c?a:a(t,g)),e=getExtendedMat3FromMat4(modelMatrix);else{e=valueArray;calculateTransformMatrix(e,h?r:r(t,g),u?o:o(t,g)),e.set(d?s:s(t,g),9)}f[l++]=e[0],f[l++]=e[1],f[l++]=e[2],f[l++]=e[3],f[l++]=e[4],f[l++]=e[5],f[l++]=e[6],f[l++]=e[7],f[l++]=e[8],f[l++]=e[9],f[l++]=e[10],f[l++]=e[11]}}}};function shouldComposeModelMatrix(t,e){return e===COORDINATE_SYSTEM.CARTESIAN||e===COORDINATE_SYSTEM.METER_OFFSETS||e===COORDINATE_SYSTEM.DEFAULT&&!t.isGeospatial}var vs$3="#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$3="#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";function getMeshBoundingBox(t){let e=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,s=-1/0;const a=t.POSITION?t.POSITION.value:[],l=a&&a.length;for(let t=0;t<l;t+=3){const l=a[t],c=a[t+1],u=a[t+2];e=l<e?l:e,n=c<n?c:n,i=u<i?u:i,r=l>r?l:r,o=c>o?c:o,s=u>s?u:s}return[[e,n,i],[r,o,s]]}function assert$3(t,e){if(!t)throw new Error("loader assertion failed.")}class Schema{constructor(t,e){_defineProperty(this,"fields",void 0),_defineProperty(this,"metadata",void 0),assert$3(Array.isArray(t)),checkNames(t),this.fields=t,this.metadata=e||new Map}compareTo(t){if(this.metadata!==t.metadata)return!1;if(this.fields.length!==t.fields.length)return!1;for(let e=0;e<this.fields.length;++e)if(!this.fields[e].compareTo(t.fields[e]))return!1;return!0}select(){const t=Object.create(null);for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];for(const e of n)t[e]=!0;const r=this.fields.filter((e=>t[e.name]));return new Schema(r,this.metadata)}selectAt(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];const i=e.map((t=>this.fields[t])).filter(Boolean);return new Schema(i,this.metadata)}assign(t){let e,n=this.metadata;if(t instanceof Schema){const i=t;e=i.fields,n=mergeMaps(mergeMaps(new Map,this.metadata),i.metadata)}else e=t;const i=Object.create(null);for(const t of this.fields)i[t.name]=t;for(const t of e)i[t.name]=t;const r=Object.values(i);return new Schema(r,n)}}function checkNames(t){const e={};for(const n of t)e[n.name]=!0}function mergeMaps(t,e){return new Map([...t||new Map,...e||new Map])}class Field{constructor(t,e){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Map;_defineProperty(this,"name",void 0),_defineProperty(this,"type",void 0),_defineProperty(this,"nullable",void 0),_defineProperty(this,"metadata",void 0),this.name=t,this.type=e,this.nullable=n,this.metadata=i}get typeId(){return this.type&&this.type.typeId}clone(){return new Field(this.name,this.type,this.nullable,this.metadata)}compareTo(t){return this.name===t.name&&this.type===t.type&&this.nullable===t.nullable&&this.metadata===t.metadata}toString(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}let Type=function(t){return t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t}({}),_Symbol$toStringTag,_Symbol$toStringTag2,_Symbol$toStringTag7;class DataType{static isNull(t){return t&&t.typeId===Type.Null}static isInt(t){return t&&t.typeId===Type.Int}static isFloat(t){return t&&t.typeId===Type.Float}static isBinary(t){return t&&t.typeId===Type.Binary}static isUtf8(t){return t&&t.typeId===Type.Utf8}static isBool(t){return t&&t.typeId===Type.Bool}static isDecimal(t){return t&&t.typeId===Type.Decimal}static isDate(t){return t&&t.typeId===Type.Date}static isTime(t){return t&&t.typeId===Type.Time}static isTimestamp(t){return t&&t.typeId===Type.Timestamp}static isInterval(t){return t&&t.typeId===Type.Interval}static isList(t){return t&&t.typeId===Type.List}static isStruct(t){return t&&t.typeId===Type.Struct}static isUnion(t){return t&&t.typeId===Type.Union}static isFixedSizeBinary(t){return t&&t.typeId===Type.FixedSizeBinary}static isFixedSizeList(t){return t&&t.typeId===Type.FixedSizeList}static isMap(t){return t&&t.typeId===Type.Map}static isDictionary(t){return t&&t.typeId===Type.Dictionary}get typeId(){return Type.NONE}compareTo(t){return this===t}}_Symbol$toStringTag=Symbol.toStringTag;class Int extends DataType{constructor(t,e){super(),_defineProperty(this,"isSigned",void 0),_defineProperty(this,"bitWidth",void 0),this.isSigned=t,this.bitWidth=e}get typeId(){return Type.Int}get[_Symbol$toStringTag](){return"Int"}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}class Int8 extends Int{constructor(){super(!0,8)}}class Int16 extends Int{constructor(){super(!0,16)}}class Int32 extends Int{constructor(){super(!0,32)}}class Uint8 extends Int{constructor(){super(!1,8)}}class Uint16 extends Int{constructor(){super(!1,16)}}class Uint32 extends Int{constructor(){super(!1,32)}}const Precision={HALF:16,SINGLE:32,DOUBLE:64};_Symbol$toStringTag2=Symbol.toStringTag;class Float extends DataType{constructor(t){super(),_defineProperty(this,"precision",void 0),this.precision=t}get typeId(){return Type.Float}get[_Symbol$toStringTag2](){return"Float"}toString(){return"Float".concat(this.precision)}}class Float32 extends Float{constructor(){super(Precision.SINGLE)}}class Float64 extends Float{constructor(){super(Precision.DOUBLE)}}_Symbol$toStringTag7=Symbol.toStringTag;class FixedSizeList extends DataType{constructor(t,e){super(),_defineProperty(this,"listSize",void 0),_defineProperty(this,"children",void 0),this.listSize=t,this.children=[e]}get typeId(){return Type.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[_Symbol$toStringTag7](){return"FixedSizeList"}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}function getArrowTypeFromTypedArray(t){switch(t.constructor){case Int8Array:return new Int8;case Uint8Array:return new Uint8;case Int16Array:return new Int16;case Uint16Array:return new Uint16;case Int32Array:return new Int32;case Uint32Array:return new Uint32;case Float32Array:return new Float32;case Float64Array:return new Float64;default:throw new Error("array type not supported")}}function deduceMeshField(t,e,n){const i=getArrowTypeFromTypedArray(e.value),r=n||makeMeshAttributeMetadata(e);return new Field(t,new FixedSizeList(e.size,new Field("value",i)),!1,r)}function makeMeshAttributeMetadata(t){const e=new Map;return"byteOffset"in t&&e.set("byteOffset",t.byteOffset.toString(10)),"byteStride"in t&&e.set("byteStride",t.byteStride.toString(10)),"normalized"in t&&e.set("normalized",t.normalized.toString()),e}function validateGeometryAttributes$1(t,e){(t.COLOR_0||t.colors)&&e||(t.colors={constant:!0,value:new Float32Array([1,1,1])}),log$2.assert(t.positions||t.POSITION,'no "postions" or "POSITION" attribute in mesh')}function getGeometry(t,e){if(t.attributes)return validateGeometryAttributes$1(t.attributes,e),t instanceof Geometry?t:new Geometry(t);if(t.positions||t.POSITION)return validateGeometryAttributes$1(t,e),new Geometry({attributes:t});throw Error("Invalid mesh")}const DEFAULT_COLOR$1=[0,0,0,255],defaultProps$3={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:t=>t.position},getColor:{type:"accessor",value:DEFAULT_COLOR$1},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 SimpleMeshLayer extends Layer{constructor(...t){super(...t),_defineProperty(this,"state",void 0)}getShaders(){const t=!isWebGL2$1(this.context.gl),e={};return hasFeature(this.context.gl,FEATURES$1.GLSL_DERIVATIVES)&&(e.DERIVATIVES_AVAILABLE=1),super.getShaders({vs:vs$3,fs:fs$3,modules:[project32,phongLighting,picking],transpileToGLSL100:t,defines:e})}getBounds(){var t;if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;const{mesh:n}=this.props;if(!n)return null;if(e=null===(t=n.header)||void 0===t?void 0:t.boundingBox,!e){const{attributes:t}=getGeometry(n,this.props._useMeshColors);t.POSITION=t.POSITION||t.positions,e=getMeshBoundingBox(t)}return this.state.positionBounds=e,e}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:MATRIX_ATTRIBUTES}),this.setState({emptyTexture:new Texture2D(this.context.gl,{data:new Uint8Array(4),width:1,height:1})})}updateState(t){super.updateState(t);const{props:e,oldProps:n,changeFlags:i}=t;if(e.mesh!==n.mesh||i.extensionsChanged){var r;if(this.state.positionBounds=null,null===(r=this.state.model)||void 0===r||r.delete(),e.mesh){this.state.model=this.getModel(e.mesh);const t=e.mesh.attributes||e.mesh;this.setState({hasNormals:Boolean(t.NORMAL||t.normals)})}this.getAttributeManager().invalidateAll()}e.texture!==n.texture&&this.setTexture(e.texture),this.state.model&&this.state.model.setDrawMode(this.props.wireframe?3:4)}finalizeState(t){super.finalizeState(t),this.state.emptyTexture.delete()}draw({uniforms:t}){if(!this.state.model)return;const{viewport:e}=this.context,{sizeScale:n,coordinateSystem:i,_instanced:r}=this.props;this.state.model.setUniforms(t).setUniforms({sizeScale:n,composeModelMatrix:!r||shouldComposeModelMatrix(e,i),flatShading:!this.state.hasNormals}).draw()}get isLoaded(){var t;return(null===(t=this.state)||void 0===t?void 0:t.model)&&super.isLoaded}getModel(t){const e=new Model(this.context.gl,{...this.getShaders(),id:this.props.id,geometry:getGeometry(t,this.props._useMeshColors),isInstanced:!0}),{texture:n}=this.props,{emptyTexture:i}=this.state;return e.setUniforms({sampler:n||i,hasTexture:Boolean(n)}),e}setTexture(t){const{emptyTexture:e,model:n}=this.state;n&&n.setUniforms({sampler:t||e,hasTexture:Boolean(t)})}}_defineProperty(SimpleMeshLayer,"defaultProps",defaultProps$3),_defineProperty(SimpleMeshLayer,"layerName","SimpleMeshLayer");class ScenegraphNode{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:e}=t;this.id=e||uid(this.constructor.name),this.display=!0,this.position=new Vector3$1,this.rotation=new Vector3$1,this.scale=new Vector3$1(1,1,1),this.matrix=new Matrix4$1,this.userData={},this.props={},this._setScenegraphNodeProps(t)}delete(){}setProps(t){return this._setScenegraphNodeProps(t),this}toString(){return"{type: ScenegraphNode, id: ".concat(this.id,")}")}getBounds(){return null}setPosition(t){return assert$8(3===t.length,"setPosition requires vector argument"),this.position=t,this}setRotation(t){return assert$8(3===t.length,"setRotation requires vector argument"),this.rotation=t,this}setScale(t){return assert$8(3===t.length,"setScale requires vector argument"),this.scale=t,this}setMatrix(t){!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?this.matrix.copy(t):this.matrix=t}setMatrixComponents(t){let{position:e,rotation:n,scale:i,update:r=!0}=t;return e&&this.setPosition(e),n&&this.setRotation(n),i&&this.setScale(i),r&&this.updateMatrix(),this}updateMatrix(){const t=this.position,e=this.rotation,n=this.scale;return this.matrix.identity(),this.matrix.translate(t),this.matrix.rotateXYZ(e),this.matrix.scale(n),this}update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{position:e,rotation:n,scale:i}=t;return e&&this.setPosition(e),n&&this.setRotation(n),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(t,e){assert$8(t),e=e||this.matrix;const n=new Matrix4$1(t).multiplyRight(e),i=n.invert(),r=i.transpose();return{viewMatrix:t,modelMatrix:e,objectMatrix:e,worldMatrix:n,worldInverseMatrix:i,worldInverseTransposeMatrix:r}}_setScenegraphNodeProps(t){"display"in t&&(this.display=t.display),"position"in t&&this.setPosition(t.position),"rotation"in t&&this.setRotation(t.rotation),"scale"in t&&this.setScale(t.scale),"matrix"in t&&this.setMatrix(t.matrix),Object.assign(this.props,t)}}class GroupNode extends ScenegraphNode{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=Array.isArray(t)?{children:t}:t;const{children:e=[]}=t;log$1.assert(e.every((t=>t instanceof ScenegraphNode)),"every child must an instance of ScenegraphNode"),super(t),this.children=e}add(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];for(const t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(t){const e=this.children,n=e.indexOf(t);return n>-1&&e.splice(n,1),this}removeAll(){return this.children=[],this}delete(){this.children.forEach((t=>t.delete())),this.removeAll(),super.delete()}getBounds(){const t=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse(((e,n)=>{let{worldMatrix:i}=n;const r=e.getBounds();if(!r)return;const[o,s]=r,a=new Vector3$1(o).add(s).divide([2,2,2]);i.transformAsPoint(a,a);const l=new Vector3$1(s).subtract(o).divide([2,2,2]);i.transformAsVector(l,l);for(let e=0;e<8;e++){const n=new Vector3$1(1&e?-1:1,2&e?-1:1,4&e?-1:1).multiply(l).add(a);for(let e=0;e<3;e++)t[0][e]=Math.min(t[0][e],n[e]),t[1][e]=Math.max(t[1][e],n[e])}})),Number.isFinite(t[0][0])?t:null}traverse(t){let{worldMatrix:e=new Matrix4$1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new Matrix4$1(e).multiplyRight(this.matrix);for(const e of this.children)e instanceof GroupNode?e.traverse(t,{worldMatrix:n}):t(e,{worldMatrix:n})}}const ATTRIBUTE_TYPE_TO_COMPONENTS$2={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY$1={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function accessorToJsArray(t){if(!t._animation){const e=ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY$1[t.componentType],n=ATTRIBUTE_TYPE_TO_COMPONENTS$2[t.type],i=n*t.count,{buffer:r,byteOffset:o}=t.bufferView.data,s=new e(r,o+(t.byteOffset||0),i);if(1===n)t._animation=Array.from(s);else{const e=[];for(let t=0;t<s.length;t+=n)e.push(Array.from(s.slice(t,t+n)));t._animation=e}}return t._animation}const helperMatrix=new Matrix4$1;function applyTranslationRotationScale(t,e){if(e.matrix.identity(),t.translation&&e.matrix.translate(t.translation),t.rotation){const n=helperMatrix.fromQuaternion(t.rotation);e.matrix.multiplyRight(n)}t.scale&&e.matrix.scale(t.scale)}const quaternion=new Quaternion$1;function linearInterpolate(t,e,n,i,r){if("rotation"===e){quaternion.slerp({start:n,target:i,ratio:r});for(let n=0;n<quaternion.length;n++)t[e][n]=quaternion[n]}else for(let o=0;o<n.length;o++)t[e][o]=r*i[o]+(1-r)*n[o]}function cubicsplineInterpolate(t,e,n){let{p0:i,outTangent0:r,inTangent1:o,p1:s,tDiff:a,ratio:l}=n;for(let n=0;n<t[e].length;n++){const c=r[n]*a,u=o[n]*a;t[e][n]=(2*Math.pow(l,3)-3*Math.pow(l,2)+1)*i[n]+(Math.pow(l,3)-2*Math.pow(l,2)+l)*c+(-2*Math.pow(l,3)+3*Math.pow(l,2))*s[n]+(Math.pow(l,3)-Math.pow(l,2))*u}}function stepInterpolate(t,e,n){for(let i=0;i<n.length;i++)t[e][i]=n[i]}function interpolate(t,e,n,i){let{input:r,interpolation:o,output:s}=e;const a=t%r[r.length-1],l=r.findIndex((t=>t>=a)),c=Math.max(0,l-1);if(!Array.isArray(n[i]))switch(i){case"translation":n[i]=[0,0,0];break;case"rotation":n[i]=[0,0,0,1];break;case"scale":n[i]=[1,1,1];break;default:log$1.warn("Bad animation path ".concat(i))()}assert$8(n[i].length===s[c].length);const u=r[c],h=r[l];switch(o){case"STEP":stepInterpolate(n,i,s[c]);break;case"LINEAR":if(h>u){linearInterpolate(n,i,s[c],s[l],(a-u)/(h-u))}break;case"CUBICSPLINE":if(h>u){cubicsplineInterpolate(n,i,{p0:s[3*c+1],outTangent0:s[3*c+2],inTangent1:s[3*l+0],p1:s[3*l+1],tDiff:h-u,ratio:(a-u)/(h-u)})}break;default:log$1.warn("Interpolation ".concat(o," not supported"))()}}class GLTFAnimation{constructor(t){this.startTime=0,this.playing=!0,this.speed=1,this.channels=[],Object.assign(this,t)}animate(t){if(!this.playing)return;const e=(t/1e3-this.startTime)*this.speed;this.channels.forEach((t=>{let{sampler:n,target:i,path:r}=t;interpolate(e,n,i,r),applyTranslationRotationScale(i,i._node)}))}}class GLTFAnimator{constructor(t){this.animations=t.animations.map(((e,n)=>{const i=e.name||"Animation-".concat(n),r=e.samplers.map((e=>{let{input:n,interpolation:i="LINEAR",output:r}=e;return{input:accessorToJsArray(t.accessors[n]),interpolation:i,output:accessorToJsArray(t.accessors[r])}})),o=e.channels.map((e=>{let{sampler:n,target:i}=e;return{sampler:r[n],target:t.nodes[i.node],path:i.path}}));return new GLTFAnimation({name:i,channels:o})}))}animate(t){this.setTime(t)}setTime(t){this.animations.forEach((e=>e.animate(t)))}getAnimations(){return this.animations}}class ModelNode extends ScenegraphNode{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),this.onBeforeRender=null,this.AfterRender=null,t instanceof Model?(this.model=t,this._setModelNodeProps(e)):this.model=new Model(t,e),this.bounds=null,this.managedResources=e.managedResources||[]}setProps(t){return super.setProps(t),this._setModelNodeProps(t),this}getBounds(){return this.bounds}delete(){this.model&&(this.model.delete(),this.model=null),this.managedResources.forEach((t=>t.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(t){this.model.setProps(t)}}class GLTFMaterialParser{constructor(t,e){let{attributes:n,material:i,pbrDebug:r,imageBasedLightingEnvironment:o,lights:s,useTangents:a}=e;this.gl=t,this.defines={MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},hasFeature(t,FEATURES$1.GLSL_TEXTURE_LOD)&&(this.defines.USE_TEX_LOD=1),this.uniforms={u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},this.parameters={},this.generatedTextures=[],o&&(this.uniforms.u_DiffuseEnvSampler=o.getDiffuseEnvSampler(),this.uniforms.u_SpecularEnvSampler=o.getSpecularEnvSampler(),this.uniforms.u_brdfLUT=o.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(n.NORMAL,"HAS_NORMALS"),this.defineIfPresent(n.TANGENT&&a,"HAS_TANGENTS"),this.defineIfPresent(n.TEXCOORD_0,"HAS_UV"),this.defineIfPresent(o,"USE_IBL"),this.defineIfPresent(s,"USE_LIGHTS"),this.defineIfPresent(r,"PBR_DEBUG"),i&&this.parseMaterial(i)}defineIfPresent(t,e){t&&(this.defines[e]=1)}parseTexture(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const i=t.texture&&t.texture.sampler&&t.texture.sampler.parameters||{},r=t.texture.source.image;let o,s={};r.compressed?(o=r,s={[this.gl.TEXTURE_MIN_FILTER]:r.data.length>1?this.gl.LINEAR_MIPMAP_NEAREST:this.gl.LINEAR}):o={data:r};const a=new Texture2D(this.gl,{id:t.name||t.id,parameters:{...i,...s},pixelStore:{[this.gl.UNPACK_FLIP_Y_WEBGL]:!1},...o});this.uniforms[e]=a,this.defineIfPresent(n,n),this.generatedTextures.push(a)}parsePbrMetallicRoughness(t){t.baseColorTexture&&this.parseTexture(t.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP"),this.uniforms.u_BaseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&this.parseTexture(t.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP");const{metallicFactor:e=1,roughnessFactor:n=1}=t;this.uniforms.u_MetallicRoughnessValues=[e,n]}parseMaterial(t){if(this.uniforms.pbr_uUnlit=Boolean(t.unlit),t.pbrMetallicRoughness&&this.parsePbrMetallicRoughness(t.pbrMetallicRoughness),t.normalTexture){this.parseTexture(t.normalTexture,"u_NormalSampler","HAS_NORMALMAP");const{scale:e=1}=t.normalTexture;this.uniforms.u_NormalScale=e}if(t.occlusionTexture){this.parseTexture(t.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP");const{strength:e=1}=t.occlusionTexture;this.uniforms.u_OcclusionStrength=e}if(t.emissiveTexture&&(this.parseTexture(t.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP"),this.uniforms.u_EmissiveFactor=t.emissiveFactor||[0,0,0]),"MASK"===t.alphaMode){const{alphaCutoff:e=.5}=t;this.defines.ALPHA_CUTOFF=1,this.uniforms.u_AlphaCutoff=e}else"BLEND"===t.alphaMode&&(log$1.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((t=>t.delete()))}}const vs$2="\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$2="\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";function addVersionToShader(t,e){return isWebGL2$1(t)?"#version 300 es\n".concat(e):e}function createGLTFModel(t,e){const{id:n,drawMode:i,vertexCount:r,attributes:o,modelOptions:s}=e,a=new GLTFMaterialParser(t,e);log$1.info(4,"createGLTFModel defines: ",a.defines)();const l=[];l.push(...a.generatedTextures),l.push(...Object.values(o).map((t=>t.buffer)));const c=new ModelNode(t,{id:n,drawMode:i,vertexCount:r,modules:[pbr],parameters:a.parameters,vs:addVersionToShader(t,vs$2),fs:addVersionToShader(t,fs$2),managedResources:l,...s,defines:{...a.defines,...s.defines}});return c.setProps({attributes:o}),c.setUniforms(a.uniforms),c}const ATTRIBUTE_TYPE_TO_COMPONENTS$1={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},DEFAULT_OPTIONS={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1};class GLTFInstantiator{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.options=Object.assign({},DEFAULT_OPTIONS,e)}instantiate(t){this.gltf=t;return(t.scenes||[]).map((t=>this.createScene(t)))}createAnimator(){return Array.isArray(this.gltf.animations)?new GLTFAnimator(this.gltf):null}createScene(t){const e=(t.nodes||[]).map((t=>this.createNode(t)));return new GroupNode({id:t.name||t.id,children:e})}createNode(t){if(!t._node){const e=(t.children||[]).map((t=>this.createNode(t)));t.mesh&&e.push(this.createMesh(t.mesh));const n=new GroupNode({id:t.name||t.id,children:e});if(t.matrix)n.setMatrix(t.matrix);else{if(n.matrix.identity(),t.translation&&n.matrix.translate(t.translation),t.rotation){const e=(new Matrix4$1).fromQuaternion(t.rotation);n.matrix.multiplyRight(e)}t.scale&&n.matrix.scale(t.scale)}t._node=n}return t._node}createMesh(t){if(!t._mesh){const e=(t.primitives||[]).map(((e,n)=>this.createPrimitive(e,n,t))),n=new GroupNode({id:t.name||t.id,children:e});t._mesh=n}return t._mesh}getVertexCount(t){log$1.warn("getVertexCount() not found")()}createPrimitive(t,e,n){const i=createGLTFModel(this.gl,Object.assign({id:t.name||"".concat(n.name||n.id,"-primitive-").concat(e),drawMode:t.mode||4,vertexCount:t.indices?t.indices.count:this.getVertexCount(t.attributes),attributes:this.createAttributes(t.attributes,t.indices),material:t.material},this.options));return i.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],i}createAttributes(t,e){const n={};return Object.keys(t).forEach((e=>{n[e]=this.createAccessor(t[e],this.createBuffer(t[e],this.gl.ARRAY_BUFFER))})),e&&(n.indices=this.createAccessor(e,this.createBuffer(e,this.gl.ELEMENT_ARRAY_BUFFER))),log$1.info(4,"glTF Attributes",{attributes:t,indices:e,generated:n})(),n}createBuffer(t,e){t.bufferView||(t.bufferView={});const{bufferView:n}=t;return n.lumaBuffers||(n.lumaBuffers={}),n.lumaBuffers[e]||(n.lumaBuffers[e]=new Buffer(this.gl,{id:"from-".concat(n.id),data:n.data||t.value,target:e})),n.lumaBuffers[e]}createAccessor(t,e){return new Accessor({buffer:e,offset:t.byteOffset||0,stride:t.bufferView.byteStride||0,type:t.componentType,size:ATTRIBUTE_TYPE_TO_COMPONENTS$1[t.type]})}createSampler(t){return t}needsPOT(){return!1}}function createGLTFObjects(t,e,n){const i=new GLTFInstantiator(t,n);return{scenes:i.instantiate(e),animator:i.createAnimator()}}const VERSION$4="3.4.15",VERSION$3="3.4.15",VERSION$2="3.4.15",BASIS_CDN_ENCODER_WASM="https://unpkg.com/@loaders.gl/textures@".concat(VERSION$2,"/dist/libs/basis_encoder.wasm"),BASIS_CDN_ENCODER_JS="https://unpkg.com/@loaders.gl/textures@".concat(VERSION$2,"/dist/libs/basis_encoder.js");let loadBasisTranscoderPromise,loadBasisEncoderPromise;async function loadBasisTrascoderModule(t){const e=t.modules||{};return e.basis?e.basis:(loadBasisTranscoderPromise=loadBasisTranscoderPromise||loadBasisTrascoder(t),await loadBasisTranscoderPromise)}async function loadBasisTrascoder(t){let e=null,n=null;return[e,n]=await Promise.all([await loadLibrary("basis_transcoder.js","textures",t),await loadLibrary("basis_transcoder.wasm","textures",t)]),e=e||globalThis.BASIS,await initializeBasisTrascoderModule(e,n)}function initializeBasisTrascoderModule(t,e){const n={};return e&&(n.wasmBinary=e),new Promise((e=>{t(n).then((t=>{const{BasisFile:n,initializeBasis:i}=t;i(),e({BasisFile:n})}))}))}async function loadBasisEncoderModule(t){const e=t.modules||{};return e.basisEncoder?e.basisEncoder:(loadBasisEncoderPromise=loadBasisEncoderPromise||loadBasisEncoder(t),await loadBasisEncoderPromise)}async function loadBasisEncoder(t){let e=null,n=null;return[e,n]=await Promise.all([await loadLibrary(BASIS_CDN_ENCODER_JS,"textures",t),await loadLibrary(BASIS_CDN_ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await initializeBasisEncoderModule(e,n)}function initializeBasisEncoderModule(t,e){const n={};return e&&(n.wasmBinary=e),new Promise((e=>{t(n).then((t=>{const{BasisFile:n,KTX2File:i,initializeBasis:r,BasisEncoder:o}=t;r(),e({BasisFile:n,KTX2File:i,BasisEncoder:o})}))}))}const GL_EXTENSIONS_CONSTANTS={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_RGBA8_ETC2_EAC:37493,COMPRESSED_SRGB8_ETC2:37494,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37495,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37496,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37497,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGB_ATC_WEBGL:35986,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:35987,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:34798,COMPRESSED_RGBA_ASTC_4X4_KHR:37808,COMPRESSED_RGBA_ASTC_5X4_KHR:37809,COMPRESSED_RGBA_ASTC_5X5_KHR:37810,COMPRESSED_RGBA_ASTC_6X5_KHR:37811,COMPRESSED_RGBA_ASTC_6X6_KHR:37812,COMPRESSED_RGBA_ASTC_8X5_KHR:37813,COMPRESSED_RGBA_ASTC_8X6_KHR:37814,COMPRESSED_RGBA_ASTC_8X8_KHR:37815,COMPRESSED_RGBA_ASTC_10X5_KHR:37816,COMPRESSED_RGBA_ASTC_10X6_KHR:37817,COMPRESSED_RGBA_ASTC_10X8_KHR:37818,COMPRESSED_RGBA_ASTC_10X10_KHR:37819,COMPRESSED_RGBA_ASTC_12X10_KHR:37820,COMPRESSED_RGBA_ASTC_12X12_KHR:37821,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:37840,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:37841,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:37842,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:37843,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:37844,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:37845,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:37846,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:37847,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:37848,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:37849,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:37850,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:37851,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:37852,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:37853,COMPRESSED_RED_RGTC1_EXT:36283,COMPRESSED_SIGNED_RED_RGTC1_EXT:36284,COMPRESSED_RED_GREEN_RGTC2_EXT:36285,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:36286,COMPRESSED_SRGB_S3TC_DXT1_EXT:35916,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:35917,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:35918,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:35919},BROWSER_PREFIXES=["","WEBKIT_","MOZ_"],WEBGL_EXTENSIONS={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 formats=null;function getSupportedGPUTextureFormats(t){if(!formats){t=t||getWebGLContext()||void 0,formats=new Set;for(const e of BROWSER_PREFIXES)for(const n in WEBGL_EXTENSIONS)if(t&&t.getExtension("".concat(e).concat(n))){formats.add(WEBGL_EXTENSIONS[n])}}return formats}function getWebGLContext(){try{return document.createElement("canvas").getContext("webgl")}catch(t){return null}}var n,i,s,a,r,o,l,f,t;t=n||(n={}),t[t.NONE=0]="NONE",t[t.BASISLZ=1]="BASISLZ",t[t.ZSTD=2]="ZSTD",t[t.ZLIB=3]="ZLIB",function(t){t[t.BASICFORMAT=0]="BASICFORMAT"}(i||(i={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ETC1S=163]="ETC1S",t[t.UASTC=166]="UASTC"}(s||(s={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SRGB=1]="SRGB"}(a||(a={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LINEAR=1]="LINEAR",t[t.SRGB=2]="SRGB",t[t.ITU=3]="ITU",t[t.NTSC=4]="NTSC",t[t.SLOG=5]="SLOG",t[t.SLOG2=6]="SLOG2"}(r||(r={})),function(t){t[t.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",t[t.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(o||(o={})),function(t){t[t.RGB=0]="RGB",t[t.RRR=3]="RRR",t[t.GGG=4]="GGG",t[t.AAA=15]="AAA"}(l||(l={})),function(t){t[t.RGB=0]="RGB",t[t.RGBA=3]="RGBA",t[t.RRR=4]="RRR",t[t.RRRG=5]="RRRG"}(f||(f={}));const KTX2_ID=[171,75,84,88,32,50,48,187,13,10,26,10];function isKTX(t){const e=new Uint8Array(t);return!(e.byteLength<KTX2_ID.length||e[0]!==KTX2_ID[0]||e[1]!==KTX2_ID[1]||e[2]!==KTX2_ID[2]||e[3]!==KTX2_ID[3]||e[4]!==KTX2_ID[4]||e[5]!==KTX2_ID[5]||e[6]!==KTX2_ID[6]||e[7]!==KTX2_ID[7]||e[8]!==KTX2_ID[8]||e[9]!==KTX2_ID[9]||e[10]!==KTX2_ID[10]||e[11]!==KTX2_ID[11])}const OutputFormat={etc1:{basisFormat:0,compressed:!0,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:!0,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT},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:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},"astc-4x4":{basisFormat:10,compressed:!0,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR},"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}};async function parseBasis(t,e){if("auto"===e.basis.containerFormat){if(isKTX(t)){return parseKTX2File((await loadBasisEncoderModule(e)).KTX2File,t,e)}const{BasisFile:n}=await loadBasisTrascoderModule(e);return parseBasisFile(n,t,e)}if("encoder"===e.basis.module){const n=await loadBasisEncoderModule(e);return"ktx2"===e.basis.containerFormat?parseKTX2File(n.KTX2File,t,e):parseBasisFile(n.BasisFile,t,e)}{const{BasisFile:n}=await loadBasisTrascoderModule(e);return parseBasisFile(n,t,e)}}function parseBasisFile(t,e,n){const i=new t(new Uint8Array(e));try{if(!i.startTranscoding())throw new Error("Failed to start basis transcoding");const t=i.getNumImages(),e=[];for(let r=0;r<t;r++){const t=i.getNumLevels(r),o=[];for(let e=0;e<t;e++)o.push(transcodeImage(i,r,e,n));e.push(o)}return e}finally{i.close(),i.delete()}}function transcodeImage(t,e,n,i){const r=t.getImageWidth(e,n),o=t.getImageHeight(e,n),s=t.getHasAlpha(),{compressed:a,format:l,basisFormat:c}=getBasisOptions(i,s),u=t.getImageTranscodedSizeInBytes(e,n,c),h=new Uint8Array(u);if(!t.transcodeImage(h,e,n,c,0,0))throw new Error("failed to start Basis transcoding");return{width:r,height:o,data:h,compressed:a,format:l,hasAlpha:s}}function parseKTX2File(t,e,n){const i=new t(new Uint8Array(e));try{if(!i.startTranscoding())throw new Error("failed to start KTX2 transcoding");const t=i.getLevels(),e=[];for(let r=0;r<t;r++){e.push(transcodeKTX2Image(i,r,n));break}return[e]}finally{i.close(),i.delete()}}function transcodeKTX2Image(t,e,n){const{alphaFlag:i,height:r,width:o}=t.getImageLevelInfo(e,0,0),{compressed:s,format:a,basisFormat:l}=getBasisOptions(n,i),c=t.getImageTranscodedSizeInBytes(e,0,0,l),u=new Uint8Array(c);if(!t.transcodeImage(u,e,0,0,l,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:o,height:r,data:u,compressed:s,levelSize:c,hasAlpha:i,format:a}}function getBasisOptions(t,e){let n=t&&t.basis&&t.basis.format;return"auto"===n&&(n=selectSupportedBasisFormat()),"object"==typeof n&&(n=e?n.alpha:n.noAlpha),n=n.toLowerCase(),OutputFormat[n]}function selectSupportedBasisFormat(){const t=getSupportedGPUTextureFormats();return t.has("astc")?"astc-4x4":t.has("dxt")?{alpha:"bc3",noAlpha:"bc1"}:t.has("pvrtc")?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:t.has("etc1")?"etc1":t.has("etc2")?"etc2":"rgb565"}const BasisWorkerLoader={name:"Basis",id:isBrowser$2?"basis":"basis-nodejs",module:"textures",version:VERSION$3,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"}}},BasisLoader={...BasisWorkerLoader,parse:parseBasis};function assert$2(t,e){if(!t)throw new Error(e||"assert failed: gltf")}function resolveUrl(t,e){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;const n=e.baseUri||e.uri;if(!n)throw new Error("'baseUri' must be provided to resolve relative url ".concat(t));return n.substr(0,n.lastIndexOf("/")+1)+t}function getTypedArrayForBufferView(t,e,n){const i=t.bufferViews[n];assert$2(i);const r=e[i.buffer];assert$2(r);return new Uint8Array(r.arrayBuffer,(i.byteOffset||0)+r.byteOffset,i.byteLength)}const TYPES=["SCALAR","VEC2","VEC3","VEC4"],ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],ARRAY_TO_COMPONENT_TYPE=new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT),ATTRIBUTE_TYPE_TO_COMPONENTS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function getAccessorTypeFromSize(t){return TYPES[t-1]||TYPES[0]}function getComponentTypeFromArray(t){const e=ARRAY_TO_COMPONENT_TYPE.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function getAccessorArrayTypeAndLength(t,e){const n=ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[t.componentType],i=ATTRIBUTE_TYPE_TO_COMPONENTS[t.type],r=t.count*i,o=t.count*i*ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[t.componentType];return assert$2(o>=0&&o<=e.byteLength),{ArrayType:n,length:r,byteLength:o}}function getMemoryUsageGLTF(t){let{images:e,bufferViews:n}=t;e=e||[],n=n||[];const i=e.map((t=>t.bufferView));n=n.filter((t=>!i.includes(t)));const r=n.reduce(((t,e)=>t+e.byteLength),0),o=e.reduce(((t,e)=>{const{width:n,height:i}=e.image;return t+n*i}),0);return r+Math.ceil(4*o*1.33)}const DEFAULT_GLTF_JSON={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class GLTFScenegraph{constructor(t){_defineProperty(this,"gltf",void 0),_defineProperty(this,"sourceBuffers",void 0),_defineProperty(this,"byteLength",void 0),this.gltf=t||{json:{...DEFAULT_GLTF_JSON},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(t){return this.json[t]}getExtraData(t){return(this.json.extras||{})[t]}getExtension(t){const e=this.getUsedExtensions().find((e=>e===t));return e?(this.json.extensions||{})[t]||!0:null}getRequiredExtension(t){const e=this.getRequiredExtensions().find((e=>e===t));return e?this.getExtension(t):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(t,e){return(t.extensions||{})[e]}getScene(t){return this.getObject("scenes",t)}getNode(t){return this.getObject("nodes",t)}getSkin(t){return this.getObject("skins",t)}getMesh(t){return this.getObject("meshes",t)}getMaterial(t){return this.getObject("materials",t)}getAccessor(t){return this.getObject("accessors",t)}getTexture(t){return this.getObject("textures",t)}getSampler(t){return this.getObject("samplers",t)}getImage(t){return this.getObject("images",t)}getBufferView(t){return this.getObject("bufferViews",t)}getBuffer(t){return this.getObject("buffers",t)}getObject(t,e){if("object"==typeof e)return e;const n=this.json[t]&&this.json[t][e];if(!n)throw new Error("glTF file error: Could not find ".concat(t,"[").concat(e,"]"));return n}getTypedArrayForBufferView(t){t=this.getBufferView(t);const e=this.gltf.buffers[t.buffer];assert$2(e);return new Uint8Array(e.arrayBuffer,(t.byteOffset||0)+e.byteOffset,t.byteLength)}getTypedArrayForAccessor(t){t=this.getAccessor(t);const e=this.getBufferView(t.bufferView),n=this.getBuffer(e.buffer).data,{ArrayType:i,length:r}=getAccessorArrayTypeAndLength(t,e);return new i(n,e.byteOffset+t.byteOffset,r)}getTypedArrayForImageData(t){t=this.getAccessor(t);const e=this.getBufferView(t.bufferView),n=this.getBuffer(e.buffer);return new Uint8Array(n.data,e.byteOffset||0,e.byteLength)}addApplicationData(t,e){return this.json[t]=e,this}addExtraData(t,e){return this.json.extras=this.json.extras||{},this.json.extras[t]=e,this}addObjectExtension(t,e,n){return t.extensions=t.extensions||{},t.extensions[e]=n,this.registerUsedExtension(e),this}setObjectExtension(t,e,n){(t.extensions||{})[e]=n}removeObjectExtension(t,e){const n=t.extensions||{},i=n[e];return delete n[e],i}addExtension(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return assert$2(e),this.json.extensions=this.json.extensions||{},this.json.extensions[t]=e,this.registerUsedExtension(t),e}addRequiredExtension(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return assert$2(e),this.addExtension(t,e),this.registerRequiredExtension(t),e}registerUsedExtension(t){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((e=>e===t))||this.json.extensionsUsed.push(t)}registerRequiredExtension(t){this.registerUsedExtension(t),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((e=>e===t))||this.json.extensionsRequired.push(t)}removeExtension(t){if(!this.getExtension(t))return;this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,t),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,t),this.json.extensions&&delete this.json.extensions[t],Array.isArray(this.json.extensionsRemoved)||(this.json.extensionsRemoved=[]);const e=this.json.extensionsRemoved;e.includes(t)||e.push(t)}setDefaultScene(t){this.json.scene=t}addScene(t){const{nodeIndices:e}=t;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:e}),this.json.scenes.length-1}addNode(t){const{meshIndex:e,matrix:n}=t;this.json.nodes=this.json.nodes||[];const i={mesh:e};return n&&(i.matrix=n),this.json.nodes.push(i),this.json.nodes.length-1}addMesh(t){const{attributes:e,indices:n,material:i,mode:r=4}=t,o={primitives:[{attributes:this._addAttributes(e),mode:r}]};if(n){const t=this._addIndices(n);o.primitives[0].indices=t}return Number.isFinite(i)&&(o.primitives[0].material=i),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(t){const e={primitives:[{attributes:this._addAttributes(t),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(e),this.json.meshes.length-1}addImage(t,e){const n=getBinaryImageMetadata(t),i=e||(null==n?void 0:n.mimeType),r={bufferView:this.addBufferView(t),mimeType:i};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(t){const e=t.byteLength;assert$2(Number.isFinite(e)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(t);const n={buffer:0,byteOffset:this.byteLength,byteLength:e};return this.byteLength+=padToNBytes(e,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(n),this.json.bufferViews.length-1}addAccessor(t,e){const n={bufferView:t,type:getAccessorTypeFromSize(e.size),componentType:e.componentType,count:e.count,max:e.max,min:e.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{size:3};const n=this.addBufferView(t);let i={min:e.min,max:e.max};i.min&&i.max||(i=this._getAccessorMinMax(t,e.size));const r={size:e.size,componentType:getComponentTypeFromArray(t),count:Math.round(t.length/e.size),min:i.min,max:i.max};return this.addAccessor(n,Object.assign(r,e))}addTexture(t){const{imageIndex:e}=t,n={source:e};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(t){return this.json.materials=this.json.materials||[],this.json.materials.push(t),this.json.materials.length-1}createBinaryChunk(){var t,e;this.gltf.buffers=[];const n=this.byteLength,i=new ArrayBuffer(n),r=new Uint8Array(i);let o=0;for(const t of this.sourceBuffers||[])o=copyToArray(t,r,o);null!==(t=this.json)&&void 0!==t&&null!==(e=t.buffers)&&void 0!==e&&e[0]?this.json.buffers[0].byteLength=n:this.json.buffers=[{byteLength:n}],this.gltf.binary=i,this.sourceBuffers=[i]}_removeStringFromArray(t,e){let n=!0;for(;n;){const i=t.indexOf(e);i>-1?t.splice(i,1):n=!1}}_addAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={};for(const n in t){const i=t[n],r=this._getGltfAttributeName(n),o=this.addBinaryBuffer(i.value,i);e[r]=o}return e}_addIndices(t){return this.addBinaryBuffer(t,{size:1})}_getGltfAttributeName(t){switch(t.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 t}}_getAccessorMinMax(t,e){const n={min:null,max:null};if(t.length<e)return n;n.min=[],n.max=[];const i=t.subarray(0,e);for(const t of i)n.min.push(t),n.max.push(t);for(let i=e;i<t.length;i+=e)for(let r=0;r<e;r++)n.min[0+r]=Math.min(n.min[0+r],t[i+r]),n.max[0+r]=Math.max(n.max[0+r],t[i+r]);return n}}const wasm_base="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",wasm_simd="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",detector=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]),wasmpack=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]),FILTERS={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},DECODERS={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function meshoptDecodeGltfBuffer(t,e,n,i,r){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"NONE";const s=await loadWasmInstance();decode$8(s,s.exports[DECODERS[r]],t,e,n,i,s.exports[FILTERS[o||"NONE"]])}let wasmPromise;async function loadWasmInstance(){return wasmPromise||(wasmPromise=loadWasmModule()),wasmPromise}async function loadWasmModule(){let t=wasm_base;WebAssembly.validate(detector)&&(t=wasm_simd);const e=await WebAssembly.instantiate(unpack(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function unpack(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;++n){const i=t.charCodeAt(n);e[n]=i>96?i-71:i>64?i-65:i>47?i+4:i>46?63:62}let n=0;for(let i=0;i<t.length;++i)e[n++]=e[i]<60?wasmpack[e[i]]:64*(e[i]-60)+e[++i];return e.buffer.slice(0,n)}function decode$8(t,e,n,i,r,o,s){const a=t.exports.sbrk,l=i+3&-4,c=a(l*r),u=a(o.length),h=new Uint8Array(t.exports.memory.buffer);h.set(o,u);const d=e(c,i,r,u,o.length);if(0===d&&s&&s(c,l,r),n.set(h.subarray(c,c+i*r)),a(c-a(0)),0!==d)throw new Error("Malformed buffer data: ".concat(d))}const EXT_MESHOPT_COMPRESSION="EXT_meshopt_compression",name$8=EXT_MESHOPT_COMPRESSION;async function decode$7(t,e){var n;const i=new GLTFScenegraph(t);if(null==e||null===(n=e.gltf)||void 0===n||!n.decompressMeshes)return;const r=[];for(const e of t.json.bufferViews||[])r.push(decodeMeshoptBufferView(i,e));await Promise.all(r),i.removeExtension(EXT_MESHOPT_COMPRESSION)}async function decodeMeshoptBufferView(t,e){const n=t.getObjectExtension(e,EXT_MESHOPT_COMPRESSION);if(n){const{byteOffset:i=0,byteLength:r=0,byteStride:o,count:s,mode:a,filter:l="NONE",buffer:c}=n,u=t.gltf.buffers[c],h=new Uint8Array(u.arrayBuffer,u.byteOffset+i,r),d=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);return await meshoptDecodeGltfBuffer(d,s,o,h,a,l),d}return null}var EXT_meshopt_compression=Object.freeze({__proto__:null,decode:decode$7,name:name$8});let supportedImageFormats;getSupportedImageFormats().then((t=>{supportedImageFormats=t}));const EXT_TEXTURE_WEBP="EXT_texture_webp",name$7=EXT_TEXTURE_WEBP;function preprocess$3(t,e){const n=new GLTFScenegraph(t);if(!supportedImageFormats.has("image/webp")){if(n.getRequiredExtensions().includes(EXT_TEXTURE_WEBP))throw new Error("gltf: Required extension ".concat(EXT_TEXTURE_WEBP," not supported by browser"));return}const{json:i}=n;for(const t of i.textures||[]){const e=n.getObjectExtension(t,EXT_TEXTURE_WEBP);e&&(t.source=e.source),n.removeObjectExtension(t,EXT_TEXTURE_WEBP)}n.removeExtension(EXT_TEXTURE_WEBP)}var EXT_texture_webp=Object.freeze({__proto__:null,name:name$7,preprocess:preprocess$3});const KHR_TEXTURE_BASISU="KHR_texture_basisu",name$6=KHR_TEXTURE_BASISU;function preprocess$2(t,e){const n=new GLTFScenegraph(t),{json:i}=n;for(const t of i.textures||[]){const e=n.getObjectExtension(t,KHR_TEXTURE_BASISU);e&&(t.source=e.source),n.removeObjectExtension(t,KHR_TEXTURE_BASISU)}n.removeExtension(KHR_TEXTURE_BASISU)}var KHR_texture_basisu=Object.freeze({__proto__:null,name:name$6,preprocess:preprocess$2});const VERSION$1="3.4.15",DEFAULT_DRACO_OPTIONS={draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},DracoLoader$1={name:"Draco",id:isBrowser$2?"draco":"draco-nodejs",module:"draco",shapes:["mesh"],version:VERSION$1,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:DEFAULT_DRACO_OPTIONS};function getDracoSchema(t,e,n){const i=makeMetadata(e.metadata),r=[],o=transformAttributesLoaderData(e.attributes);for(const e in t){const n=getArrowFieldFromAttribute(e,t[e],o[e]);r.push(n)}if(n){const t=getArrowFieldFromAttribute("indices",n);r.push(t)}return new Schema(r,i)}function transformAttributesLoaderData(t){const e={};for(const n in t){const i=t[n];e[i.name||"undefined"]=i}return e}function getArrowFieldFromAttribute(t,e,n){return deduceMeshField(t,e,n?makeMetadata(n.metadata):void 0)}function makeMetadata(t){const e=new Map;for(const n in t)e.set("".concat(n,".string"),JSON.stringify(t[n]));return e}const DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},INDEX_ITEM_SIZE=4;class DracoParser{constructor(t){_defineProperty(this,"draco",void 0),_defineProperty(this,"decoder",void 0),_defineProperty(this,"metadataQuerier",void 0),this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new this.draco.DecoderBuffer;n.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);const i=this.decoder.GetEncodedGeometryType(n),r=i===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let t;switch(i){case this.draco.TRIANGULAR_MESH:t=this.decoder.DecodeBufferToMesh(n,r);break;case this.draco.POINT_CLOUD:t=this.decoder.DecodeBufferToPointCloud(n,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!t.ok()||!r.ptr){const e="DRACO decompression failed: ".concat(t.error_msg());throw new Error(e)}const o=this._getDracoLoaderData(r,i,e),s=this._getMeshData(r,o,e),a=getMeshBoundingBox(s.attributes),l=getDracoSchema(s.attributes,o,s.indices);return{loader:"draco",loaderData:o,header:{vertexCount:r.num_points(),boundingBox:a},...s,schema:l}}finally{this.draco.destroy(n),r&&this.draco.destroy(r)}}_getDracoLoaderData(t,e,n){const i=this._getTopLevelMetadata(t),r=this._getDracoAttributes(t,n);return{geometry_type:e,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:i,attributes:r}}_getDracoAttributes(t,e){const n={};for(let i=0;i<t.num_attributes();i++){const r=this.decoder.GetAttribute(t,i),o=this._getAttributeMetadata(t,i);n[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:i,metadata:o};const s=this._getQuantizationTransform(r,e);s&&(n[r.unique_id()].quantization_transform=s);const a=this._getOctahedronTransform(r,e);a&&(n[r.unique_id()].octahedron_transform=a)}return n}_getMeshData(t,e,n){const i=this._getMeshAttributes(e,t,n);if(!i.POSITION)throw new Error("DRACO: No position attribute found.");return t instanceof this.draco.Mesh?"triangle-strip"===n.topology?{topology:"triangle-strip",mode:4,attributes:i,indices:{value:this._getTriangleStripIndices(t),size:1}}:{topology:"triangle-list",mode:5,attributes:i,indices:{value:this._getTriangleListIndices(t),size:1}}:{topology:"point-list",mode:0,attributes:i}}_getMeshAttributes(t,e,n){const i={};for(const r of Object.values(t.attributes)){const t=this._deduceAttributeName(r,n);r.name=t;const{value:o,size:s}=this._getAttributeValues(e,r);i[t]={value:o,size:s,byteOffset:r.byte_offset,byteStride:r.byte_stride,normalized:r.normalized}}return i}_getTriangleListIndices(t){const e=3*t.num_faces(),n=e*INDEX_ITEM_SIZE,i=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(t,n,i),new Uint32Array(this.draco.HEAPF32.buffer,i,e).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(t){const e=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,e),getUint32Array(e)}finally{this.draco.destroy(e)}}_getAttributeValues(t,e){const n=DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[e.data_type],i=e.num_components,r=t.num_points()*i,o=r*n.BYTES_PER_ELEMENT,s=getDracoDataType(this.draco,n);let a;const l=this.draco._malloc(o);try{const i=this.decoder.GetAttribute(t,e.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,i,s,o,l),a=new n(this.draco.HEAPF32.buffer,l,r).slice()}finally{this.draco._free(l)}return{value:a,size:i}}_deduceAttributeName(t,e){const n=t.unique_id;for(const[t,i]of Object.entries(e.extraAttributes||{}))if(i===n)return t;const i=t.attribute_type;for(const t in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP){if(this.draco[t]===i)return DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP[t]}const r=e.attributeNameEntry||"name";return t.metadata[r]?t.metadata[r].string:"CUSTOM_ATTRIBUTE_".concat(n)}_getTopLevelMetadata(t){const e=this.decoder.GetMetadata(t);return this._getDracoMetadata(e)}_getAttributeMetadata(t,e){const n=this.decoder.GetAttributeMetadata(t,e);return this._getDracoMetadata(n)}_getDracoMetadata(t){if(!t||!t.ptr)return{};const e={},n=this.metadataQuerier.NumEntries(t);for(let i=0;i<n;i++){const n=this.metadataQuerier.GetEntryName(t,i);e[n]=this._getDracoMetadataField(t,n)}return e}_getDracoMetadataField(t,e){const n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,e,n);const i=getInt32Array(n);return{int:this.metadataQuerier.GetIntEntry(t,e),string:this.metadataQuerier.GetStringEntry(t,e),double:this.metadataQuerier.GetDoubleEntry(t,e),intArray:i}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(t){const{quantizedAttributes:e=[],octahedronAttributes:n=[]}=t,i=[...e,...n];for(const t of i)this.decoder.SkipAttributeTransform(this.draco[t])}_getQuantizationTransform(t,e){const{quantizedAttributes:n=[]}=e,i=t.attribute_type();if(n.map((t=>this.decoder[t])).includes(i)){const e=new this.draco.AttributeQuantizationTransform;try{if(e.InitFromAttribute(t))return{quantization_bits:e.quantization_bits(),range:e.range(),min_values:new Float32Array([1,2,3]).map((t=>e.min_value(t)))}}finally{this.draco.destroy(e)}}return null}_getOctahedronTransform(t,e){const{octahedronAttributes:n=[]}=e,i=t.attribute_type();if(n.map((t=>this.decoder[t])).includes(i)){const e=new this.draco.AttributeQuantizationTransform;try{if(e.InitFromAttribute(t))return{quantization_bits:e.quantization_bits()}}finally{this.draco.destroy(e)}}return null}}function getDracoDataType(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function getInt32Array(t){const e=t.size(),n=new Int32Array(e);for(let i=0;i<e;i++)n[i]=t.GetValue(i);return n}function getUint32Array(t){const e=t.size(),n=new Int32Array(e);for(let i=0;i<e;i++)n[i]=t.GetValue(i);return n}const DRACO_DECODER_VERSION="1.5.5",STATIC_DECODER_URL="https://www.gstatic.com/draco/versioned/decoders/".concat(DRACO_DECODER_VERSION),DRACO_JS_DECODER_URL="".concat(STATIC_DECODER_URL,"/draco_decoder.js"),DRACO_WASM_WRAPPER_URL="".concat(STATIC_DECODER_URL,"/draco_wasm_wrapper.js"),DRACO_WASM_DECODER_URL="".concat(STATIC_DECODER_URL,"/draco_decoder.wasm");let loadDecoderPromise;async function loadDracoDecoderModule(t){const e=t.modules||{};return loadDecoderPromise=e.draco3d?loadDecoderPromise||e.draco3d.createDecoderModule({}).then((t=>({draco:t}))):loadDecoderPromise||loadDracoDecoder(t),await loadDecoderPromise}async function loadDracoDecoder(t){let e,n;if("js"===(t.draco&&t.draco.decoderType))e=await loadLibrary(DRACO_JS_DECODER_URL,"draco",t);else[e,n]=await Promise.all([await loadLibrary(DRACO_WASM_WRAPPER_URL,"draco",t),await loadLibrary(DRACO_WASM_DECODER_URL,"draco",t)]);return e=e||globalThis.DracoDecoderModule,await initializeDracoDecoder(e,n)}function initializeDracoDecoder(t,e){const n={};return e&&(n.wasmBinary=e),new Promise((e=>{t({...n,onModuleLoaded:t=>e({draco:t})})}))}const DracoLoader={...DracoLoader$1,parse:parse$2};async function parse$2(t,e){const{draco:n}=await loadDracoDecoderModule(e),i=new DracoParser(n);try{return i.parseSync(t,null==e?void 0:e.draco)}finally{i.destroy()}}function getGLTFAccessors(t){const e={};for(const n in t){if("indices"!==n){const i=getGLTFAccessor(t[n]);e[n]=i}}return e}function getGLTFAccessor(t){const{buffer:e,size:n,count:i}=getAccessorData(t);return{value:e,size:n,byteOffset:0,count:i,type:getAccessorTypeFromSize(n),componentType:getComponentTypeFromArray(e)}}function getAccessorData(t){let e=t,n=1,i=0;return t&&t.value&&(e=t.value,n=t.size||1),e&&(ArrayBuffer.isView(e)||(e=toTypedArray(e,Float32Array)),i=e.length/n),{buffer:e,size:n,count:i}}function toTypedArray(t,e){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t?Array.isArray(t)?new e(t):!n||t instanceof e?t:new e(t):null}const KHR_DRACO_MESH_COMPRESSION="KHR_draco_mesh_compression",name$5=KHR_DRACO_MESH_COMPRESSION;function preprocess$1(t,e,n){const i=new GLTFScenegraph(t);for(const t of makeMeshPrimitiveIterator(i))i.getObjectExtension(t,KHR_DRACO_MESH_COMPRESSION)}async function decode$6(t,e,n){var i;if(null==e||null===(i=e.gltf)||void 0===i||!i.decompressMeshes)return;const r=new GLTFScenegraph(t),o=[];for(const t of makeMeshPrimitiveIterator(r))r.getObjectExtension(t,KHR_DRACO_MESH_COMPRESSION)&&o.push(decompressPrimitive(r,t,e,n));await Promise.all(o),r.removeExtension(KHR_DRACO_MESH_COMPRESSION)}function encode$3(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new GLTFScenegraph(t);for(const t of n.json.meshes||[])compressMesh(t,e),n.addRequiredExtension(KHR_DRACO_MESH_COMPRESSION)}async function decompressPrimitive(t,e,n,i){const r=t.getObjectExtension(e,KHR_DRACO_MESH_COMPRESSION);if(!r)return;const o=t.getTypedArrayForBufferView(r.bufferView),s=sliceArrayBuffer(o.buffer,o.byteOffset),{parse:a}=i,l={...n};delete l["3d-tiles"];const c=await a(s,DracoLoader,l,i),u=getGLTFAccessors(c.attributes);for(const[n,i]of Object.entries(u))if(n in e.attributes){const r=t.getAccessor(e.attributes[n]);null!=r&&r.min&&null!=r&&r.max&&(i.min=r.min,i.max=r.max)}e.attributes=u,c.indices&&(e.indices=getGLTFAccessor(c.indices)),checkPrimitive(e)}function compressMesh(t,e){var n;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const s=r.DracoWriter.encodeSync({attributes:t}),a=null==o||null===(n=o.parseSync)||void 0===n?void 0:n.call(o,{attributes:t}),l=r._addFauxAttributes(a.attributes),c=r.addBufferView(s);return{primitives:[{attributes:l,mode:i,extensions:{[KHR_DRACO_MESH_COMPRESSION]:{bufferView:c,attributes:l}}}]}}function checkPrimitive(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*makeMeshPrimitiveIterator(t){for(const e of t.json.meshes||[])for(const t of e.primitives)yield t}var KHR_draco_mesh_compression=Object.freeze({__proto__:null,decode:decode$6,encode:encode$3,name:name$5,preprocess:preprocess$1});const COMPONENTS$1={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},BYTES$1={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},EXT_MESHOPT_TRANSFORM="KHR_texture_transform",name$4=EXT_MESHOPT_TRANSFORM,scratchVector$5=new Vector3$1,scratchRotationMatrix=new Matrix3$1,scratchScaleMatrix=new Matrix3$1;async function decode$5(t,e){if(!new GLTFScenegraph(t).getExtension(EXT_MESHOPT_TRANSFORM))return;const n=t.json.materials||[];for(let e=0;e<n.length;e++)transformTexCoords(e,t)}function transformTexCoords(t,e){var n,i,r;const o=[],s=null===(n=e.json.materials)||void 0===n?void 0:n[t],a=null==s||null===(i=s.pbrMetallicRoughness)||void 0===i?void 0:i.baseColorTexture;a&&transformPrimitives(e,t,a,o);const l=null==s?void 0:s.emissiveTexture;l&&transformPrimitives(e,t,l,o);const c=null==s?void 0:s.normalTexture;c&&transformPrimitives(e,t,c,o);const u=null==s?void 0:s.occlusionTexture;u&&transformPrimitives(e,t,u,o);const h=null==s||null===(r=s.pbrMetallicRoughness)||void 0===r?void 0:r.metallicRoughnessTexture;h&&transformPrimitives(e,t,h,o)}function transformPrimitives(t,e,n,i){const r=getTransformParameters(n,i);if(!r)return;const o=t.json.meshes||[];for(const n of o)for(const i of n.primitives){const n=i.material;Number.isFinite(n)&&e===n&&transformPrimitive(t,i,r)}}function getTransformParameters(t,e){var n;const i=null===(n=t.extensions)||void 0===n?void 0:n[EXT_MESHOPT_TRANSFORM],{texCoord:r=0}=t,{texCoord:o=r}=i;if(!(-1!==e.findIndex((t=>{let[e,n]=t;return e===r&&n===o})))){const n=makeTransformationMatrix(i);return r!==o&&(t.texCoord=o),e.push([r,o]),{originalTexCoord:r,texCoord:o,matrix:n}}return null}function transformPrimitive(t,e,n){const{originalTexCoord:i,texCoord:r,matrix:o}=n,s=e.attributes["TEXCOORD_".concat(i)];if(Number.isFinite(s)){var a;const n=null===(a=t.json.accessors)||void 0===a?void 0:a[s];if(n&&n.bufferView){var l;const s=null===(l=t.json.bufferViews)||void 0===l?void 0:l[n.bufferView];if(s){const{arrayBuffer:a,byteOffset:l}=t.buffers[s.buffer],c=(l||0)+(n.byteOffset||0)+(s.byteOffset||0),{ArrayType:u,length:h}=getAccessorArrayTypeAndLength(n,s),d=COMPONENTS$1[n.type],p=s.byteStride||BYTES$1[n.componentType]*d,f=new Float32Array(h);for(let t=0;t<n.count;t++){const e=new u(a,c+t*p,2);scratchVector$5.set(e[0],e[1],1),scratchVector$5.transformByMatrix3(o),f.set([scratchVector$5[0],scratchVector$5[1]],t*d)}i===r?updateGltf(n,s,t.buffers,f):createAttribute(r,n,e,t,f)}}}}function updateGltf(t,e,n,i){t.componentType=5126,n.push({arrayBuffer:i.buffer,byteOffset:0,byteLength:i.buffer.byteLength}),e.buffer=n.length-1,e.byteLength=i.buffer.byteLength,e.byteOffset=0,delete e.byteStride}function createAttribute(t,e,n,i,r){i.buffers.push({arrayBuffer:r.buffer,byteOffset:0,byteLength:r.buffer.byteLength});const o=i.json.bufferViews;if(!o)return;o.push({buffer:i.buffers.length-1,byteLength:r.buffer.byteLength,byteOffset:0});const s=i.json.accessors;s&&(s.push({bufferView:(null==o?void 0:o.length)-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),n.attributes["TEXCOORD_".concat(t)]=s.length-1)}function makeTransformationMatrix(t){const{offset:e=[0,0],rotation:n=0,scale:i=[1,1]}=t,r=(new Matrix3$1).set(1,0,0,0,1,0,e[0],e[1],1),o=scratchRotationMatrix.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),s=scratchScaleMatrix.set(i[0],0,0,0,i[1],0,0,0,1);return r.multiplyRight(o).multiplyRight(s)}var KHR_texture_transform=Object.freeze({__proto__:null,decode:decode$5,name:name$4});const KHR_LIGHTS_PUNCTUAL="KHR_lights_punctual",name$3=KHR_LIGHTS_PUNCTUAL;async function decode$4(t){const e=new GLTFScenegraph(t),{json:n}=e,i=e.getExtension(KHR_LIGHTS_PUNCTUAL);i&&(e.json.lights=i.lights,e.removeExtension(KHR_LIGHTS_PUNCTUAL));for(const t of n.nodes||[]){const n=e.getObjectExtension(t,KHR_LIGHTS_PUNCTUAL);n&&(t.light=n.light),e.removeObjectExtension(t,KHR_LIGHTS_PUNCTUAL)}}async function encode$2(t){const e=new GLTFScenegraph(t),{json:n}=e;if(n.lights){const t=e.addExtension(KHR_LIGHTS_PUNCTUAL);assert$2(!t.lights),t.lights=n.lights,delete n.lights}if(e.json.lights){for(const t of e.json.lights){e.addObjectExtension(t.node,KHR_LIGHTS_PUNCTUAL,t)}delete e.json.lights}}var KHR_lights_punctual=Object.freeze({__proto__:null,decode:decode$4,encode:encode$2,name:name$3});const KHR_MATERIALS_UNLIT="KHR_materials_unlit",name$2=KHR_MATERIALS_UNLIT;async function decode$3(t){const e=new GLTFScenegraph(t),{json:n}=e;for(const t of n.materials||[]){t.extensions&&t.extensions.KHR_materials_unlit&&(t.unlit=!0),e.removeObjectExtension(t,KHR_MATERIALS_UNLIT)}e.removeExtension(KHR_MATERIALS_UNLIT)}function encode$1(t){const e=new GLTFScenegraph(t),{json:n}=e;if(e.materials)for(const t of n.materials||[])t.unlit&&(delete t.unlit,e.addObjectExtension(t,KHR_MATERIALS_UNLIT,{}),e.addExtension(KHR_MATERIALS_UNLIT))}var KHR_materials_unlit=Object.freeze({__proto__:null,decode:decode$3,encode:encode$1,name:name$2});const KHR_TECHNIQUES_WEBGL="KHR_techniques_webgl",name$1=KHR_TECHNIQUES_WEBGL;async function decode$2(t){const e=new GLTFScenegraph(t),{json:n}=e,i=e.getExtension(KHR_TECHNIQUES_WEBGL);if(i){const t=resolveTechniques(i,e);for(const i of n.materials||[]){const n=e.getObjectExtension(i,KHR_TECHNIQUES_WEBGL);n&&(i.technique=Object.assign({},n,t[n.technique]),i.technique.values=resolveValues(i.technique,e)),e.removeObjectExtension(i,KHR_TECHNIQUES_WEBGL)}e.removeExtension(KHR_TECHNIQUES_WEBGL)}}async function encode(t,e){}function resolveTechniques(t,e){const{programs:n=[],shaders:i=[],techniques:r=[]}=t,o=new TextDecoder;return i.forEach((t=>{if(!Number.isFinite(t.bufferView))throw new Error("KHR_techniques_webgl: no shader code");t.code=o.decode(e.getTypedArrayForBufferView(t.bufferView))})),n.forEach((t=>{t.fragmentShader=i[t.fragmentShader],t.vertexShader=i[t.vertexShader]})),r.forEach((t=>{t.program=n[t.program]})),r}function resolveValues(t,e){const n=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach((e=>{t.uniforms[e].value&&!(e in n)&&(n[e]=t.uniforms[e].value)})),Object.keys(n).forEach((t=>{"object"==typeof n[t]&&void 0!==n[t].index&&(n[t].texture=e.getTexture(n[t].index))})),n}var KHR_techniques_webgl=Object.freeze({__proto__:null,decode:decode$2,encode:encode,name:name$1});const EXT_FEATURE_METADATA="EXT_feature_metadata",name=EXT_FEATURE_METADATA;async function decode$1(t){decodeExtFeatureMetadata(new GLTFScenegraph(t))}function decodeExtFeatureMetadata(t){var e;const n=t.getExtension(EXT_FEATURE_METADATA),i=null==n||null===(e=n.schema)||void 0===e?void 0:e.classes,r=null==n?void 0:n.featureTables;if(i&&r)for(const e in i){const n=i[e],o=findFeatureTableByName(r,e);o&&handleFeatureTableProperties(t,o,n)}}function handleFeatureTableProperties(t,e,n){for(const r in n.properties){var i;const o=null==e||null===(i=e.properties)||void 0===i?void 0:i[r];if(o){const i=getPropertyDataFromBinarySource(t,n.properties[r],e.count,o);o.data=i}}}function getPropertyDataFromBinarySource(t,e,n,i){let r=t.getTypedArrayForBufferView(i.bufferView);switch(e.type){case"STRING":r=getStringAttributes(r,t.getTypedArrayForBufferView(i.stringOffsetBufferView),n);break}return r}function findFeatureTableByName(t,e){for(const n in t){const i=t[n];if(i.class===e)return i}return null}function getStringAttributes(t,e,n){const i=[],r=new TextDecoder("utf8");let o=0;for(let s=0;s<n;s++){const n=e[4*(s+1)]-e[4*s],a=t.subarray(o,n+o),l=r.decode(a);i.push(l),o+=n}return i}var EXT_feature_metadata=Object.freeze({__proto__:null,decode:decode$1,name:name});const EXTENSIONS$1=[EXT_meshopt_compression,EXT_texture_webp,KHR_texture_basisu,KHR_draco_mesh_compression,KHR_lights_punctual,KHR_materials_unlit,KHR_techniques_webgl,KHR_texture_transform,EXT_feature_metadata];function preprocessExtensions(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const i=EXTENSIONS$1.filter((t=>useExtension(t.name,e)));for(const o of i){var r;null===(r=o.preprocess)||void 0===r||r.call(o,t,e,n)}}async function decodeExtensions(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const i=EXTENSIONS$1.filter((t=>useExtension(t.name,e)));for(const o of i){var r;await(null===(r=o.decode)||void 0===r?void 0:r.call(o,t,e,n))}}function useExtension(t,e){var n;const i=(null==e||null===(n=e.gltf)||void 0===n?void 0:n.excludeExtensions)||{};return!(t in i&&!i[t])}const KHR_BINARY_GLTF="KHR_binary_glTF";function preprocess(t){const e=new GLTFScenegraph(t),{json:n}=e;for(const t of n.images||[]){const n=e.getObjectExtension(t,KHR_BINARY_GLTF);n&&Object.assign(t,n),e.removeObjectExtension(t,KHR_BINARY_GLTF)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,e.removeExtension(KHR_BINARY_GLTF)}const GLTF_ARRAYS={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},GLTF_KEYS={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 GLTFV1Normalizer{constructor(){_defineProperty(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),_defineProperty(this,"json",void 0)}normalize(t,e){this.json=t.json;const n=t.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return}if(!e.normalize)throw new Error("glTF v1 is not supported.");this._addAsset(n),this._convertTopLevelObjectsToArrays(n),preprocess(t),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(t){t.asset=t.asset||{},t.asset.version="2.0",t.asset.generator=t.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(t){for(const e in GLTF_ARRAYS)this._convertTopLevelObjectToArray(t,e)}_convertTopLevelObjectToArray(t,e){const n=t[e];if(n&&!Array.isArray(n)){t[e]=[];for(const i in n){const r=n[i];r.id=r.id||i;const o=t[e].length;t[e].push(r),this.idToIndexMap[e][i]=o}}}_convertObjectIdsToArrayIndices(t){for(const e in GLTF_ARRAYS)this._convertIdsToIndices(t,e);"scene"in t&&(t.scene=this._convertIdToIndex(t.scene,"scene"));for(const e of t.textures)this._convertTextureIds(e);for(const e of t.meshes)this._convertMeshIds(e);for(const e of t.nodes)this._convertNodeIds(e);for(const e of t.scenes)this._convertSceneIds(e)}_convertTextureIds(t){t.source&&(t.source=this._convertIdToIndex(t.source,"image"))}_convertMeshIds(t){for(const e of t.primitives){const{attributes:t,indices:n,material:i}=e;for(const e in t)t[e]=this._convertIdToIndex(t[e],"accessor");n&&(e.indices=this._convertIdToIndex(n,"accessor")),i&&(e.material=this._convertIdToIndex(i,"material"))}}_convertNodeIds(t){t.children&&(t.children=t.children.map((t=>this._convertIdToIndex(t,"node")))),t.meshes&&(t.meshes=t.meshes.map((t=>this._convertIdToIndex(t,"mesh"))))}_convertSceneIds(t){t.nodes&&(t.nodes=t.nodes.map((t=>this._convertIdToIndex(t,"node"))))}_convertIdsToIndices(t,e){t[e]||(t[e]=[]);for(const n of t[e])for(const t in n){const e=this._convertIdToIndex(n[t],t);n[t]=e}}_convertIdToIndex(t,e){const n=GLTF_KEYS[e];if(n in this.idToIndexMap){const i=this.idToIndexMap[n][t];if(!Number.isFinite(i))throw new Error("gltf v1: failed to resolve ".concat(e," with id ").concat(t));return i}return t}_updateObjects(t){for(const t of this.json.buffers)delete t.type}_updateMaterial(t){for(const r of t.materials){var e,n,i;r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const o=(null===(e=r.values)||void 0===e?void 0:e.tex)||(null===(n=r.values)||void 0===n?void 0:n.texture2d_0)||(null===(i=r.values)||void 0===i?void 0:i.diffuseTex),s=t.textures.findIndex((t=>t.id===o));-1!==s&&(r.pbrMetallicRoughness.baseColorTexture={index:s})}}}function normalizeGLTFV1(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(new GLTFV1Normalizer).normalize(t,e)}const COMPONENTS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},BYTES={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},GL_SAMPLER={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},SAMPLER_PARAMETER_GLTF_TO_GL={magFilter:GL_SAMPLER.TEXTURE_MAG_FILTER,minFilter:GL_SAMPLER.TEXTURE_MIN_FILTER,wrapS:GL_SAMPLER.TEXTURE_WRAP_S,wrapT:GL_SAMPLER.TEXTURE_WRAP_T},DEFAULT_SAMPLER={[GL_SAMPLER.TEXTURE_MAG_FILTER]:GL_SAMPLER.LINEAR,[GL_SAMPLER.TEXTURE_MIN_FILTER]:GL_SAMPLER.NEAREST_MIPMAP_LINEAR,[GL_SAMPLER.TEXTURE_WRAP_S]:GL_SAMPLER.REPEAT,[GL_SAMPLER.TEXTURE_WRAP_T]:GL_SAMPLER.REPEAT};function getBytesFromComponentType(t){return BYTES[t]}function getSizeFromAccessorType(t){return COMPONENTS[t]}class GLTFPostProcessor{constructor(){_defineProperty(this,"baseUri",""),_defineProperty(this,"json",{}),_defineProperty(this,"buffers",[]),_defineProperty(this,"images",[])}postProcess(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{json:n,buffers:i=[],images:r=[],baseUri:o=""}=t;return assert$2(n),this.baseUri=o,this.json=n,this.buffers=i,this.images=r,this._resolveTree(this.json,e),this.json}_resolveTree(t){t.bufferViews&&(t.bufferViews=t.bufferViews.map(((t,e)=>this._resolveBufferView(t,e)))),t.images&&(t.images=t.images.map(((t,e)=>this._resolveImage(t,e)))),t.samplers&&(t.samplers=t.samplers.map(((t,e)=>this._resolveSampler(t,e)))),t.textures&&(t.textures=t.textures.map(((t,e)=>this._resolveTexture(t,e)))),t.accessors&&(t.accessors=t.accessors.map(((t,e)=>this._resolveAccessor(t,e)))),t.materials&&(t.materials=t.materials.map(((t,e)=>this._resolveMaterial(t,e)))),t.meshes&&(t.meshes=t.meshes.map(((t,e)=>this._resolveMesh(t,e)))),t.nodes&&(t.nodes=t.nodes.map(((t,e)=>this._resolveNode(t,e)))),t.skins&&(t.skins=t.skins.map(((t,e)=>this._resolveSkin(t,e)))),t.scenes&&(t.scenes=t.scenes.map(((t,e)=>this._resolveScene(t,e)))),void 0!==t.scene&&(t.scene=t.scenes[this.json.scene])}getScene(t){return this._get("scenes",t)}getNode(t){return this._get("nodes",t)}getSkin(t){return this._get("skins",t)}getMesh(t){return this._get("meshes",t)}getMaterial(t){return this._get("materials",t)}getAccessor(t){return this._get("accessors",t)}getCamera(t){return null}getTexture(t){return this._get("textures",t)}getSampler(t){return this._get("samplers",t)}getImage(t){return this._get("images",t)}getBufferView(t){return this._get("bufferViews",t)}getBuffer(t){return this._get("buffers",t)}_get(t,e){if("object"==typeof e)return e;return this.json[t]&&this.json[t][e]}_resolveScene(t,e){return t.id=t.id||"scene-".concat(e),t.nodes=(t.nodes||[]).map((t=>this.getNode(t))),t}_resolveNode(t,e){return t.id=t.id||"node-".concat(e),t.children&&(t.children=t.children.map((t=>this.getNode(t)))),void 0!==t.mesh?t.mesh=this.getMesh(t.mesh):void 0!==t.meshes&&t.meshes.length&&(t.mesh=t.meshes.reduce(((t,e)=>{const n=this.getMesh(e);return t.id=n.id,t.primitives=t.primitives.concat(n.primitives),t}),{primitives:[]})),void 0!==t.camera&&(t.camera=this.getCamera(t.camera)),void 0!==t.skin&&(t.skin=this.getSkin(t.skin)),t}_resolveSkin(t,e){return t.id=t.id||"skin-".concat(e),t.inverseBindMatrices=this.getAccessor(t.inverseBindMatrices),t}_resolveMesh(t,e){return t.id=t.id||"mesh-".concat(e),t.primitives&&(t.primitives=t.primitives.map((t=>{const e=(t={...t}).attributes;t.attributes={};for(const n in e)t.attributes[n]=this.getAccessor(e[n]);return void 0!==t.indices&&(t.indices=this.getAccessor(t.indices)),void 0!==t.material&&(t.material=this.getMaterial(t.material)),t}))),t}_resolveMaterial(t,e){if(t.id=t.id||"material-".concat(e),t.normalTexture&&(t.normalTexture={...t.normalTexture},t.normalTexture.texture=this.getTexture(t.normalTexture.index)),t.occlusionTexture&&(t.occlustionTexture={...t.occlustionTexture},t.occlusionTexture.texture=this.getTexture(t.occlusionTexture.index)),t.emissiveTexture&&(t.emmisiveTexture={...t.emmisiveTexture},t.emissiveTexture.texture=this.getTexture(t.emissiveTexture.index)),t.emissiveFactor||(t.emissiveFactor=t.emmisiveTexture?[1,1,1]:[0,0,0]),t.pbrMetallicRoughness){t.pbrMetallicRoughness={...t.pbrMetallicRoughness};const e=t.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return t}_resolveAccessor(t,e){if(t.id=t.id||"accessor-".concat(e),void 0!==t.bufferView&&(t.bufferView=this.getBufferView(t.bufferView)),t.bytesPerComponent=getBytesFromComponentType(t.componentType),t.components=getSizeFromAccessorType(t.type),t.bytesPerElement=t.bytesPerComponent*t.components,t.bufferView){const e=t.bufferView.buffer,{ArrayType:n,byteLength:i}=getAccessorArrayTypeAndLength(t,t.bufferView),r=(t.bufferView.byteOffset||0)+(t.byteOffset||0)+e.byteOffset;let o=e.arrayBuffer.slice(r,r+i);t.bufferView.byteStride&&(o=this._getValueFromInterleavedBuffer(e,r,t.bufferView.byteStride,t.bytesPerElement,t.count)),t.value=new n(o)}return t}_getValueFromInterleavedBuffer(t,e,n,i,r){const o=new Uint8Array(r*i);for(let s=0;s<r;s++){const r=e+s*n;o.set(new Uint8Array(t.arrayBuffer.slice(r,r+i)),s*i)}return o.buffer}_resolveTexture(t,e){return t.id=t.id||"texture-".concat(e),t.sampler="sampler"in t?this.getSampler(t.sampler):DEFAULT_SAMPLER,t.source=this.getImage(t.source),t}_resolveSampler(t,e){t.id=t.id||"sampler-".concat(e),t.parameters={};for(const e in t){const n=this._enumSamplerParameter(e);void 0!==n&&(t.parameters[n]=t[e])}return t}_enumSamplerParameter(t){return SAMPLER_PARAMETER_GLTF_TO_GL[t]}_resolveImage(t,e){t.id=t.id||"image-".concat(e),void 0!==t.bufferView&&(t.bufferView=this.getBufferView(t.bufferView));const n=this.images[e];return n&&(t.image=n),t}_resolveBufferView(t,e){const n=t.buffer,i={id:"bufferView-".concat(e),...t,buffer:this.buffers[n]};let r=this.buffers[n].byteOffset||0;return"byteOffset"in t&&(r+=t.byteOffset),i.data=new Uint8Array(this.buffers[n].arrayBuffer,r,t.byteLength),i}_resolveCamera(t,e){return t.id=t.id||"camera-".concat(e),t}}function postProcessGLTF(t,e){return(new GLTFPostProcessor).postProcess(t,e)}const MAGIC_glTF=1735152710,GLB_FILE_HEADER_SIZE=12,GLB_CHUNK_HEADER_SIZE=8,GLB_CHUNK_TYPE_JSON=1313821514,GLB_CHUNK_TYPE_BIN=5130562,GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED=0,GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED=1,GLB_V1_CONTENT_FORMAT_JSON=0,LE=!0;function getMagicString$1(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return"".concat(String.fromCharCode(t.getUint8(e+0))).concat(String.fromCharCode(t.getUint8(e+1))).concat(String.fromCharCode(t.getUint8(e+2))).concat(String.fromCharCode(t.getUint8(e+3)))}function isGLB(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new DataView(t),{magic:r=MAGIC_glTF}=n,o=i.getUint32(e,!1);return o===r||o===MAGIC_glTF}function parseGLBSync(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const i=new DataView(e),r=getMagicString$1(i,n+0),o=i.getUint32(n+4,LE),s=i.getUint32(n+8,LE);switch(Object.assign(t,{header:{byteOffset:n,byteLength:s,hasBinChunk:!1},type:r,version:o,json:{},binChunks:[]}),n+=GLB_FILE_HEADER_SIZE,t.version){case 1:return parseGLBV1(t,i,n);case 2:return parseGLBV2(t,i,n,{});default:throw new Error("Invalid GLB version ".concat(t.version,". Only supports v1 and v2."))}}function parseGLBV1(t,e,n){assert$c(t.header.byteLength>GLB_FILE_HEADER_SIZE+GLB_CHUNK_HEADER_SIZE);const i=e.getUint32(n+0,LE),r=e.getUint32(n+4,LE);return n+=GLB_CHUNK_HEADER_SIZE,assert$c(r===GLB_V1_CONTENT_FORMAT_JSON),parseJSONChunk(t,e,n,i),n+=i,n+=parseBINChunk(t,e,n,t.header.byteLength)}function parseGLBV2(t,e,n,i){return assert$c(t.header.byteLength>GLB_FILE_HEADER_SIZE+GLB_CHUNK_HEADER_SIZE),parseGLBChunksSync(t,e,n,i),n+t.header.byteLength}function parseGLBChunksSync(t,e,n,i){for(;n+8<=t.header.byteLength;){const r=e.getUint32(n+0,LE),o=e.getUint32(n+4,LE);switch(n+=GLB_CHUNK_HEADER_SIZE,o){case GLB_CHUNK_TYPE_JSON:parseJSONChunk(t,e,n,r);break;case GLB_CHUNK_TYPE_BIN:parseBINChunk(t,e,n,r);break;case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:i.strict||parseJSONChunk(t,e,n,r);break;case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:i.strict||parseBINChunk(t,e,n,r)}n+=padToNBytes(r,4)}return n}function parseJSONChunk(t,e,n,i){const r=new Uint8Array(e.buffer,n,i),o=new TextDecoder("utf8").decode(r);return t.json=JSON.parse(o),padToNBytes(i,4)}function parseBINChunk(t,e,n,i){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:n,byteLength:i,arrayBuffer:e.buffer}),padToNBytes(i,4)}async function parseGLTF(t,e){var n,i,r,o;let s=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;parseGLTFContainerSync(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s),normalizeGLTFV1(t,{normalize:null==s||null===(n=s.gltf)||void 0===n?void 0:n.normalize}),preprocessExtensions(t,s,a);const l=[];if(null!=s&&null!==(i=s.gltf)&&void 0!==i&&i.loadBuffers&&t.json.buffers&&await loadBuffers(t,s,a),null!=s&&null!==(r=s.gltf)&&void 0!==r&&r.loadImages){const e=loadImages(t,s,a);l.push(e)}const c=decodeExtensions(t,s,a);return l.push(c),await Promise.all(l),null!=s&&null!==(o=s.gltf)&&void 0!==o&&o.postProcess?postProcessGLTF(t,s):t}function parseGLTFContainerSync(t,e,n,i){if(i.uri&&(t.baseUri=i.uri),e instanceof ArrayBuffer&&!isGLB(e,n,i)){e=(new TextDecoder).decode(e)}if("string"==typeof e)t.json=parseJSON(e);else if(e instanceof ArrayBuffer){const r={};n=parseGLBSync(r,e,n,i.glb),assert$2("glTF"===r.type,"Invalid GLB magic string ".concat(r.type)),t._glb=r,t.json=r.json}else assert$2(!1,"GLTF: must be ArrayBuffer or string");if(t.buffers=new Array((t.json.buffers||[]).length).fill(null),t._glb&&t._glb.header.hasBinChunk){const{binChunks:e}=t._glb;t.buffers[0]={arrayBuffer:e[0].arrayBuffer,byteOffset:e[0].byteOffset,byteLength:e[0].byteLength}}t.images=new Array((t.json.images||[]).length).fill({})}async function loadBuffers(t,e,n){const i=t.json.buffers||[];for(let s=0;s<i.length;++s){const a=i[s];if(a.uri){var r,o;const{fetch:i}=n;assert$2(i);const l=resolveUrl(a.uri,e),c=await(null==n||null===(r=n.fetch)||void 0===r?void 0:r.call(n,l)),u=await(null==c||null===(o=c.arrayBuffer)||void 0===o?void 0:o.call(c));t.buffers[s]={arrayBuffer:u,byteOffset:0,byteLength:u.byteLength},delete a.uri}else null===t.buffers[s]&&(t.buffers[s]={arrayBuffer:new ArrayBuffer(a.byteLength),byteOffset:0,byteLength:a.byteLength})}}async function loadImages(t,e,n){const i=getReferencesImageIndices(t),r=t.json.images||[],o=[];for(const s of i)o.push(loadImage(t,r[s],s,e,n));return await Promise.all(o)}function getReferencesImageIndices(t){const e=new Set,n=t.json.textures||[];for(const t of n)void 0!==t.source&&e.add(t.source);return Array.from(e).sort()}async function loadImage(t,e,n,i,r){const{fetch:o,parse:s}=r;let a;if(e.uri&&!e.hasOwnProperty("bufferView")){const t=resolveUrl(e.uri,i),n=await o(t);a=await n.arrayBuffer(),e.bufferView={data:a}}if(Number.isFinite(e.bufferView)){const n=getTypedArrayForBufferView(t.json,t.buffers,e.bufferView);a=sliceArrayBuffer(n.buffer,n.byteOffset,n.byteLength)}assert$2(a,"glTF image has no data");let l=await s(a,[ImageLoader$1,BasisLoader],{mimeType:e.mimeType,basis:i.basis||{format:selectSupportedBasisFormat()}},r);l&&l[0]&&(l={compressed:!0,mipmaps:!1,width:l[0].width,height:l[0].height,data:l[0]}),t.images=t.images||[],t.images[n]=l}const GLTFLoader$1={name:"glTF",id:"gltf",module:"gltf",version:VERSION$4,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:parse$1,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 parse$1(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;e={...GLTFLoader$1.options,...e},e.gltf={...GLTFLoader$1.options.gltf,...e.gltf};const{byteOffset:i=0}=e;return await parseGLTF({},t,i,e,n)}async function waitForGLTFAssets(t){const e=[];return t.scenes.forEach((t=>{t.traverse((t=>{Object.values(t.model.getUniforms()).forEach((t=>{!1===t.loaded&&e.push(t)}))}))})),await waitWhileCondition((()=>e.some((t=>!t.loaded))))}async function waitWhileCondition(t){for(;t();)await new Promise((t=>requestAnimationFrame(t)))}var vs$1="#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$1="#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";const DEFAULT_COLOR=[255,255,255,255],defaultProps$2={scenegraph:{type:"object",value:null,async:!0},getScene:t=>t&&t.scenes?"object"==typeof t.scene?t.scene:t.scenes[t.scene||0]:t,getAnimator:t=>t&&t.animator,_animations:null,sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:DEFAULT_COLOR},_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:[GLTFLoader$1]};class ScenegraphLayer extends Layer{constructor(...t){super(...t),_defineProperty(this,"state",void 0)}getShaders(){const t=[project32,picking];return"pbr"===this.props._lighting&&t.push(pbr),super.getShaders({vs:vs$1,fs:fs$1,modules:t})}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:DEFAULT_COLOR,transition:!0},instanceModelMatrix:MATRIX_ATTRIBUTES})}updateState(t){super.updateState(t);const{props:e,oldProps:n}=t;e.scenegraph!==n.scenegraph?this._updateScenegraph():e._animations!==n._animations&&this._applyAnimationsProp(this.state.scenegraph,this.state.animator,e._animations)}finalizeState(t){super.finalizeState(t),this._deleteScenegraph()}get isLoaded(){var t;return(null===(t=this.state)||void 0===t?void 0:t.scenegraph)&&super.isLoaded}_updateScenegraph(){const t=this.props,{gl:e}=this.context;let n=null;if(t.scenegraph instanceof ScenegraphNode)n={scenes:[t.scenegraph]};else if(t.scenegraph&&!t.scenegraph.gltf){const i=t.scenegraph,r=createGLTFObjects(e,i,this._getModelOptions());n={gltf:i,...r},waitForGLTFAssets(r).then((()=>this.setNeedsRedraw()))}else t.scenegraph&&(log$2.deprecated("ScenegraphLayer.props.scenegraph","Use GLTFLoader instead of GLTFScenegraphLoader")(),n=t.scenegraph);const i={layer:this,gl:e},r=t.getScene(n,i),o=t.getAnimator(n,i);r instanceof ScenegraphNode?(this._deleteScenegraph(),this._applyAllAttributes(r),this._applyAnimationsProp(r,o,t._animations),this.setState({scenegraph:r,animator:o})):null!==r&&log$2.warn("invalid scenegraph:",r)()}_applyAllAttributes(t){if(this.state.attributesAvailable){const e=this.getAttributeManager().getAttributes();t.traverse((t=>{this._setModelAttributes(t.model,e)}))}}_applyAnimationsProp(t,e,n){if(!t||!e||!n)return;const i=e.getAnimations();Object.keys(n).sort().forEach((t=>{const e=n[t];if("*"===t)i.forEach((t=>{Object.assign(t,e)}));else if(Number.isFinite(Number(t))){const n=Number(t);n>=0&&n<i.length?Object.assign(i[n],e):log$2.warn("animation ".concat(t," not found"))()}else{const n=i.find((({name:e})=>e===t));n?Object.assign(n,e):log$2.warn("animation ".concat(t," not found"))()}}))}_deleteScenegraph(){const{scenegraph:t}=this.state;t instanceof ScenegraphNode&&t.delete()}_getModelOptions(){const{_imageBasedLightingEnvironment:t}=this.props;let e=null;return t&&(e="function"==typeof t?t({gl:this.context.gl,layer:this}):t),{gl:this.context.gl,waitForFullLoad:!0,imageBasedLightingEnvironment:e,modelOptions:{isInstanced:!0,transpileToGLSL100:!isWebGL2$1(this.context.gl),...this.getShaders()},useTangents:!1}}updateAttributes(t){this.setState({attributesAvailable:!0}),this.state.scenegraph&&this.state.scenegraph.traverse((e=>{this._setModelAttributes(e.model,t)}))}draw({moduleParameters:t=null,parameters:e={},context:n}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(n.timeline.getTime()),this.setNeedsRedraw());const{viewport:i}=this.context,{sizeScale:r,sizeMinPixels:o,sizeMaxPixels:s,opacity:a,coordinateSystem:l}=this.props,c=this.getNumInstances();this.state.scenegraph.traverse(((n,{worldMatrix:u})=>{n.model.setInstanceCount(c),n.updateModuleSettings(t),n.draw({parameters:e,uniforms:{sizeScale:r,opacity:a,sizeMinPixels:o,sizeMaxPixels:s,composeModelMatrix:shouldComposeModelMatrix(i,l),sceneModelMatrix:u,u_Camera:n.model.getUniforms().project_uCameraPosition}})}))}}_defineProperty(ScenegraphLayer,"defaultProps",defaultProps$2),_defineProperty(ScenegraphLayer,"layerName","ScenegraphLayer");var 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";function validateGeometryAttributes(t){t.COLOR_0||t.colors||(t.colors={constant:!0,value:new Float32Array([1,1,1])})}const defaultProps$1={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};class MeshLayer extends SimpleMeshLayer{getShaders(){const t=super.getShaders();return t.modules.push(pbr),{...t,vs:vs,fs:fs}}initializeState(){const{featureIds:t}=this.props;super.initializeState();const e=this.getAttributeManager();t&&e.add({featureIdsPickingColors:{type:5121,size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(t){super.updateState(t);const{props:e,oldProps:n}=t;e.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(e.pbrMaterial)}draw(t){const{featureIds:e}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.getUniforms().project_uCameraPosition,pickFeatureIds:Boolean(e)}),super.draw(t))}getModel(t){const{id:e,pbrMaterial:n}=this.props,i=this.parseMaterial(n,t);this.setState({materialParser:i});const r=this.getShaders();validateGeometryAttributes(t.attributes);return new Model(this.context.gl,{...this.getShaders(),id:e,geometry:t,defines:{...r.defines,...null==i?void 0:i.defines,HAS_UV_REGIONS:t.attributes.uvRegions},parameters:null==i?void 0:i.parameters,isInstanced:!0})}updatePbrMaterialUniforms(t){const{model:e}=this.state;if(e){const{mesh:n}=this.props,i=this.parseMaterial(t,n);this.setState({materialParser:i}),e.setUniforms(i.uniforms)}}parseMaterial(t,e){var n;const i=Boolean(t.pbrMetallicRoughness&&t.pbrMetallicRoughness.baseColorTexture);return null===(n=this.state.materialParser)||void 0===n||n.delete(),new GLTFMaterialParser(this.context.gl,{attributes:{NORMAL:e.attributes.normals,TEXCOORD_0:e.attributes.texCoords},material:{unlit:i,...t},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(t){const e=this.props.featureIds,n=new Uint8ClampedArray(e.length*t.size),i=[];for(let t=0;t<e.length;t++)this.encodePickingColor(e[t],i),n[3*t]=i[0],n[3*t+1]=i[1],n[3*t+2]=i[2];t.value=n}finalizeState(t){var e;super.finalizeState(t),null===(e=this.state.materialParser)||void 0===e||e.delete(),this.setState({materialParser:null})}}_defineProperty(MeshLayer,"layerName","MeshLayer"),_defineProperty(MeshLayer,"defaultProps",defaultProps$1);const WGS84_RADIUS_X$1=6378137,WGS84_RADIUS_Y$1=6378137,WGS84_RADIUS_Z$1=6356752.314245179;function identity(t){return t}function fromCartographic(t,e=[],n=identity){return"longitude"in t?(e[0]=n(t.longitude),e[1]=n(t.latitude),e[2]=t.height):"x"in t?(e[0]=n(t.x),e[1]=n(t.y),e[2]=t.z):(e[0]=n(t[0]),e[1]=n(t[1]),e[2]=t[2]),e}function fromCartographicToRadians(t,e=[]){return fromCartographic(t,e,config._cartographicRadians?identity:toRadians)}function toCartographic(t,e,n=identity){return"longitude"in e?(e.longitude=n(t[0]),e.latitude=n(t[1]),e.height=t[2]):"x"in e?(e.x=n(t[0]),e.y=n(t[1]),e.z=t[2]):(e[0]=n(t[0]),e[1]=n(t[1]),e[2]=t[2]),e}function toCartographicFromRadians(t,e){return toCartographic(t,e,config._cartographicRadians?identity:toDegrees)}new Vector3$1;const scratchVector$4=new Vector3$1,scaleToGeodeticSurfaceIntersection=new Vector3$1,scaleToGeodeticSurfaceGradient=new Vector3$1;function scaleToGeodeticSurface(t,e,n=[]){const{oneOverRadii:i,oneOverRadiiSquared:r,centerToleranceSquared:o}=e;scratchVector$4.from(t);const s=scratchVector$4.x,a=scratchVector$4.y,l=scratchVector$4.z,c=i.x,u=i.y,h=i.z,d=s*s*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 _=scaleToGeodeticSurfaceIntersection;if(_.copy(t).scale(g),m<o)return _.to(n);const y=r.x,v=r.y,x=r.z,b=scaleToGeodeticSurfaceGradient;b.set(_.x*y*2,_.y*v*2,_.z*x*2);let T,E,S,w,A=(1-g)*scratchVector$4.len()/(.5*b.len()),M=0;do{A-=M,T=1/(1+A*y),E=1/(1+A*v),S=1/(1+A*x);const t=T*T,e=E*E,n=S*S;w=d*t+p*e+f*n-1;M=w/(-2*(d*(t*T)*y+p*(e*E)*v+f*(n*S)*x))}while(Math.abs(w)>_MathUtils.EPSILON12);return scratchVector$4.scale([T,E,S]).to(n)}const EPSILON14=1e-14,scratchOrigin=new Vector3$1,VECTOR_PRODUCT_LOCAL_FRAME={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"}},degeneratePositionLocalFrame={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},scratchAxisVectors={east:new Vector3$1,north:new Vector3$1,up:new Vector3$1,west:new Vector3$1,south:new Vector3$1,down:new Vector3$1},scratchVector1=new Vector3$1,scratchVector2=new Vector3$1,scratchVector3=new Vector3$1;function localFrameToFixedFrame(t,e,n,i,r,o){const s=VECTOR_PRODUCT_LOCAL_FRAME[e]&&VECTOR_PRODUCT_LOCAL_FRAME[e][n];let a,l,c;assert$6(s&&(!i||i===s));const u=scratchOrigin.copy(r);if(equals$1(u.x,0,EPSILON14)&&equals$1(u.y,0,EPSILON14)){const t=Math.sign(u.z);a=scratchVector1.fromArray(degeneratePositionLocalFrame[e]),"east"!==e&&"west"!==e&&a.scale(t),l=scratchVector2.fromArray(degeneratePositionLocalFrame[n]),"east"!==n&&"west"!==n&&l.scale(t),c=scratchVector3.fromArray(degeneratePositionLocalFrame[i]),"east"!==i&&"west"!==i&&c.scale(t)}else{const{up:r,east:o,north:s}=scratchAxisVectors;o.set(-u.y,u.x,0).normalize(),t.geodeticSurfaceNormal(u,r),s.copy(r).cross(o);const{down:h,west:d,south:p}=scratchAxisVectors;h.copy(r).scale(-1),d.copy(o).scale(-1),p.copy(s).scale(-1),a=scratchAxisVectors[e],l=scratchAxisVectors[n],c=scratchAxisVectors[i]}return o[0]=a.x,o[1]=a.y,o[2]=a.z,o[3]=0,o[4]=l.x,o[5]=l.y,o[6]=l.z,o[7]=0,o[8]=c.x,o[9]=c.y,o[10]=c.z,o[11]=0,o[12]=u.x,o[13]=u.y,o[14]=u.z,o[15]=1,o}const scratchVector$3=new Vector3$1,scratchNormal$1=new Vector3$1,scratchK=new Vector3$1,scratchPosition$1=new Vector3$1,scratchHeight=new Vector3$1,scratchCartesian=new Vector3$1;class Ellipsoid{constructor(t=0,e=0,n=0){_defineProperty(this,"radii",void 0),_defineProperty(this,"radiiSquared",void 0),_defineProperty(this,"radiiToTheFourth",void 0),_defineProperty(this,"oneOverRadii",void 0),_defineProperty(this,"oneOverRadiiSquared",void 0),_defineProperty(this,"minimumRadius",void 0),_defineProperty(this,"maximumRadius",void 0),_defineProperty(this,"centerToleranceSquared",_MathUtils.EPSILON1),_defineProperty(this,"squaredXOverSquaredZ",void 0),assert$6(t>=0),assert$6(e>=0),assert$6(n>=0),this.radii=new Vector3$1(t,e,n),this.radiiSquared=new Vector3$1(t*t,e*e,n*n),this.radiiToTheFourth=new Vector3$1(t*t*t*t,e*e*e*e,n*n*n*n),this.oneOverRadii=new Vector3$1(0===t?0:1/t,0===e?0:1/e,0===n?0:1/n),this.oneOverRadiiSquared=new Vector3$1(0===t?0:1/(t*t),0===e?0:1/(e*e),0===n?0:1/(n*n)),this.minimumRadius=Math.min(t,e,n),this.maximumRadius=Math.max(t,e,n),0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||Boolean(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,e=[0,0,0]){const n=scratchNormal$1,i=scratchK,[,,r]=t;this.geodeticSurfaceNormalCartographic(t,n),i.copy(this.radiiSquared).scale(n);const o=Math.sqrt(n.dot(i));return i.scale(1/o),n.scale(r),i.add(n),i.to(e)}cartesianToCartographic(t,e=[0,0,0]){scratchCartesian.from(t);const n=this.scaleToGeodeticSurface(scratchCartesian,scratchPosition$1);if(!n)return;const i=this.geodeticSurfaceNormal(n,scratchNormal$1),r=scratchHeight;r.copy(scratchCartesian).subtract(n);return toCartographicFromRadians([Math.atan2(i.y,i.x),Math.asin(i.z),Math.sign(dot$2(r,scratchCartesian))*length$2(r)],e)}eastNorthUpToFixedFrame(t,e=new Matrix4$1){return localFrameToFixedFrame(this,"east","north","up",t,e)}localFrameToFixedFrame(t,e,n,i,r=new Matrix4$1){return localFrameToFixedFrame(this,t,e,n,i,r)}geocentricSurfaceNormal(t,e=[0,0,0]){return scratchVector$3.from(t).normalize().to(e)}geodeticSurfaceNormalCartographic(t,e=[0,0,0]){const n=fromCartographicToRadians(t),i=n[0],r=n[1],o=Math.cos(r);return scratchVector$3.set(o*Math.cos(i),o*Math.sin(i),Math.sin(r)).normalize(),scratchVector$3.to(e)}geodeticSurfaceNormal(t,e=[0,0,0]){return scratchVector$3.from(t).scale(this.oneOverRadiiSquared).normalize().to(e)}scaleToGeodeticSurface(t,e){return scaleToGeodeticSurface(t,this,e)}scaleToGeocentricSurface(t,e=[0,0,0]){scratchPosition$1.from(t);const n=scratchPosition$1.x,i=scratchPosition$1.y,r=scratchPosition$1.z,o=this.oneOverRadiiSquared,s=1/Math.sqrt(n*n*o.x+i*i*o.y+r*r*o.z);return scratchPosition$1.multiplyScalar(s).to(e)}transformPositionToScaledSpace(t,e=[0,0,0]){return scratchPosition$1.from(t).scale(this.oneOverRadii).to(e)}transformPositionFromScaledSpace(t,e=[0,0,0]){return scratchPosition$1.from(t).scale(this.radii).to(e)}getSurfaceNormalIntersectionWithZAxis(t,e=0,n=[0,0,0]){assert$6(equals$1(this.radii.x,this.radii.y,_MathUtils.EPSILON15)),assert$6(this.radii.z>0),scratchPosition$1.from(t);const i=scratchPosition$1.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-e))return scratchPosition$1.set(0,0,i).to(n)}}_defineProperty(Ellipsoid,"WGS84",new Ellipsoid(WGS84_RADIUS_X$1,WGS84_RADIUS_Y$1,WGS84_RADIUS_Z$1));class DoublyLinkedListNode{constructor(t,e,n){_defineProperty(this,"item",void 0),_defineProperty(this,"previous",void 0),_defineProperty(this,"next",void 0),this.item=t,this.previous=e,this.next=n}}class DoublyLinkedList{constructor(){_defineProperty(this,"head",null),_defineProperty(this,"tail",null),_defineProperty(this,"_length",0)}get length(){return this._length}add(t){const e=new DoublyLinkedListNode(t,this.tail,null);return this.tail?(this.tail.next=e,this.tail=e):(this.head=e,this.tail=e),++this._length,e}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,e){t!==e&&(this.remove(e),this._insert(t,e))}_insert(t,e){const n=t.next;t.next=e,this.tail===t?this.tail=e:n.previous=e,e.next=n,e.previous=t,++this._length}}class TilesetCache{constructor(){_defineProperty(this,"_list",void 0),_defineProperty(this,"_sentinel",void 0),_defineProperty(this,"_trimTiles",void 0),this._list=new DoublyLinkedList,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){const e=t._cacheNode;e&&this._list.splice(this._sentinel,e)}add(t,e,n){e._cacheNode||(e._cacheNode=this._list.add(e),n&&n(t,e))}unloadTile(t,e,n){const i=e._cacheNode;i&&(this._list.remove(i),e._cacheNode=null,n&&n(t,e))}unloadTiles(t,e){const n=this._trimTiles;this._trimTiles=!1;const i=1024*t.maximumMemoryUsage*1024,r=this._sentinel;let o=this._list.head;for(;o!==r&&(t.gpuMemoryUsageInBytes>i||n);){const n=o.item;o=o.next,this.unloadTile(t,n,e)}}trim(){this._trimTiles=!0}}function calculateTransformProps(t,e){assert$c(t),assert$c(e);const{rtcCenter:n,gltfUpAxis:i}=e,{computedTransform:r,boundingVolume:{center:o}}=t;let s=new Matrix4$1(r);switch(n&&s.translate(n),i){case"Z":break;case"Y":const t=(new Matrix4$1).rotateX(Math.PI/2);s=s.multiplyRight(t);break;case"X":const e=(new Matrix4$1).rotateY(-Math.PI/2);s=s.multiplyRight(e)}e.isQuantized&&s.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);const a=new Vector3$1(o);e.cartesianModelMatrix=s,e.cartesianOrigin=a;const l=Ellipsoid.WGS84.cartesianToCartographic(a,new Vector3$1),c=Ellipsoid.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=c.multiplyRight(s),e.cartographicOrigin=l,e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}const scratchVector$2=new Vector3$1,scratchPosition=new Vector3$1,cullingVolume=new CullingVolume([new Plane,new Plane,new Plane,new Plane,new Plane,new Plane]);function getFrameState(t,e){const{cameraDirection:n,cameraUp:i,height:r}=t,{metersPerUnit:o}=t.distanceScales,s=worldToCartesian(t,t.center),a=Ellipsoid.WGS84.eastNorthUpToFixedFrame(s),l=t.unprojectPosition(t.cameraPosition),c=Ellipsoid.WGS84.cartographicToCartesian(l,new Vector3$1),u=new Vector3$1(a.transformAsVector(new Vector3$1(n).scale(o))).normalize(),h=new Vector3$1(a.transformAsVector(new Vector3$1(i).scale(o))).normalize();commonSpacePlanesToWGS84(t);const d=t.constructor,{longitude:p,latitude:f,width:m,bearing:g,zoom:_}=t;return{camera:{position:c,direction:u,up:h},viewport:t,topDownViewport:new d({longitude:p,latitude:f,height:r,width:m,bearing:g,zoom:_,pitch:0}),height:r,cullingVolume:cullingVolume,frameNumber:e,sseDenominator:1.15}}function limitSelectedTiles(t,e,n){if(0===n||t.length<=n)return[t,[]];const i=[],{longitude:r,latitude:o}=e.viewport;for(const[e,n]of t.entries()){const[t,s]=n.header.mbs,a=Math.abs(r-t),l=Math.abs(o-s),c=Math.sqrt(l*l+a*a);i.push([e,c])}const s=i.sort(((t,e)=>t[1]-e[1])),a=[];for(let e=0;e<n;e++)a.push(t[s[e][0]]);const l=[];for(let e=n;e<s.length;e++)l.push(t[s[e][0]]);return[a,l]}function commonSpacePlanesToWGS84(t){const e=t.getFrustumPlanes(),n=closestPointOnPlane(e.near,t.cameraPosition),i=worldToCartesian(t,n),r=worldToCartesian(t,t.cameraPosition,scratchPosition);let o=0;cullingVolume.planes[o++].fromPointNormal(i,scratchVector$2.copy(i).subtract(r));for(const r in e){if("near"===r)continue;const s=worldToCartesian(t,closestPointOnPlane(e[r],n,scratchPosition),scratchPosition);cullingVolume.planes[o++].fromPointNormal(s,scratchVector$2.copy(i).subtract(s))}}function closestPointOnPlane(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Vector3$1;const i=t.normal.dot(e);return n.copy(t.normal).scale(t.distance-i).add(e),n}function worldToCartesian(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Vector3$1;const i=t.unprojectPosition(e);return Ellipsoid.WGS84.cartographicToCartesian(i,n)}const WGS84_RADIUS_X=6378137,WGS84_RADIUS_Y=6378137,WGS84_RADIUS_Z=6356752.314245179,scratchVector$1=new Vector3$1;function getZoomFromBoundingVolume(t,e){if(t instanceof OrientedBoundingBox){const{halfAxes:n}=t,i=getObbSize(n);return Math.log2(WGS84_RADIUS_Z/(i+e[2]))}if(t instanceof BoundingSphere){const{radius:n}=t;return Math.log2(WGS84_RADIUS_Z/(n+e[2]))}if(t.width&&t.height){const{width:e,height:n}=t;return(Math.log2(WGS84_RADIUS_X/e)+Math.log2(WGS84_RADIUS_Y/n))/2}return 1}function getZoomFromFullExtent(t,e,n){const i=Ellipsoid.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],new Vector3$1),r=Math.sqrt(Math.pow(i[0]-n[0],2)+Math.pow(i[1]-n[1],2)+Math.pow(i[2]-n[2],2));return Math.log2(WGS84_RADIUS_Z/(r+e[2]))}function getZoomFromExtent(t,e,n){const[i,r,o,s]=t;return getZoomFromFullExtent({xmin:i,xmax:o,ymin:r,ymax:s,zmin:0,zmax:0},e,n)}function getObbSize(t){t.getColumn(0,scratchVector$1);const e=t.getColumn(1),n=t.getColumn(2);return scratchVector$1.add(e).add(n).len()}const TILE_CONTENT_STATE={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},TILE_REFINEMENT={ADD:1,REPLACE:2},TILE_TYPE={EMPTY:"empty",SCENEGRAPH:"scenegraph",POINTCLOUD:"pointcloud",MESH:"mesh"},TILESET_TYPE={I3S:"I3S",TILES3D:"TILES3D"},LOD_METRIC_TYPE={GEOMETRIC_ERROR:"geometricError",MAX_SCREEN_THRESHOLD:"maxScreenThreshold"},TILE3D_OPTIMIZATION_HINT={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function defined$3(t){return null!=t}const scratchPoint=new Vector3$1,scratchScale=new Vector3$1,scratchNorthWest=new Vector3$1,scratchSouthEast=new Vector3$1;function createBoundingVolume(t,e,n){if(assert$c(t,"3D Tile: boundingVolume must be defined"),t.box)return createBox(t.box,e,n);if(t.region){const[e,n,i,r,o,s]=t.region,a=Ellipsoid.WGS84.cartographicToCartesian([degrees(e),degrees(r),o],scratchNorthWest),l=Ellipsoid.WGS84.cartographicToCartesian([degrees(i),degrees(n),s],scratchSouthEast),c=(new Vector3$1).addVectors(a,l).multiplyScalar(.5),u=(new Vector3$1).subVectors(a,l).len()/2;return createSphere([c[0],c[1],c[2],u],new Matrix4$1)}if(t.sphere)return createSphere(t.sphere,e,n);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function getCartographicBounds(t,e){if(t.box)return orientedBoundingBoxToCartographicBounds(e);if(t.region){const[e,n,i,r,o,s]=t.region;return[[degrees(e),degrees(n),o],[degrees(i),degrees(r),s]]}if(t.sphere)return boundingSphereToCartographicBounds(e);throw new Error("Unkown boundingVolume type")}function createBox(t,e,n){const i=new Vector3$1(t[0],t[1],t[2]);e.transform(i,i);let r=[];if(10===t.length){const e=t.slice(3,6),n=new Quaternion$1;n.fromArray(t,6);const i=new Vector3$1([1,0,0]),o=new Vector3$1([0,1,0]),s=new Vector3$1([0,0,1]);i.transformByQuaternion(n),i.scale(e[0]),o.transformByQuaternion(n),o.scale(e[1]),s.transformByQuaternion(n),s.scale(e[2]),r=[...i.toArray(),...o.toArray(),...s.toArray()]}else r=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];const o=e.transformAsVector(r.slice(0,3)),s=e.transformAsVector(r.slice(3,6)),a=e.transformAsVector(r.slice(6,9)),l=new Matrix3$1([o[0],o[1],o[2],s[0],s[1],s[2],a[0],a[1],a[2]]);return defined$3(n)?(n.center=i,n.halfAxes=l,n):new OrientedBoundingBox(i,l)}function createSphere(t,e,n){const i=new Vector3$1(t[0],t[1],t[2]);e.transform(i,i);const r=e.getScale(scratchScale),o=Math.max(Math.max(r[0],r[1]),r[2]),s=t[3]*o;return defined$3(n)?(n.center=i,n.radius=s,n):new BoundingSphere(i,s)}function orientedBoundingBoxToCartographicBounds(t){const e=emptyCartographicBounds(),{halfAxes:n}=t,i=new Vector3$1(n.getColumn(0)),r=new Vector3$1(n.getColumn(1)),o=new Vector3$1(n.getColumn(2));for(let n=0;n<2;n++){for(let n=0;n<2;n++){for(let n=0;n<2;n++)scratchPoint.copy(t.center),scratchPoint.add(i),scratchPoint.add(r),scratchPoint.add(o),addToCartographicBounds(e,scratchPoint),o.negate();r.negate()}i.negate()}return e}function boundingSphereToCartographicBounds(t){const e=emptyCartographicBounds(),{center:n,radius:i}=t,r=Ellipsoid.WGS84.scaleToGeodeticSurface(n,scratchPoint);let o;o=r?Ellipsoid.WGS84.geodeticSurfaceNormal(r):new Vector3$1(0,0,1);let s=new Vector3$1(o[2],-o[1],0);s.len()>0?s.normalize():s=new Vector3$1(0,1,0);const a=s.clone().cross(o);for(const t of[s,a,o]){scratchScale.copy(t).scale(i);for(let t=0;t<2;t++)scratchPoint.copy(n),scratchPoint.add(scratchScale),addToCartographicBounds(e,scratchPoint),scratchScale.negate()}return e}function emptyCartographicBounds(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function addToCartographicBounds(t,e){Ellipsoid.WGS84.cartesianToCartographic(e,scratchPoint),t[0][0]=Math.min(t[0][0],scratchPoint[0]),t[0][1]=Math.min(t[0][1],scratchPoint[1]),t[0][2]=Math.min(t[0][2],scratchPoint[2]),t[1][0]=Math.max(t[1][0],scratchPoint[0]),t[1][1]=Math.max(t[1][1],scratchPoint[1]),t[1][2]=Math.max(t[1][2],scratchPoint[2])}function fog(t,e){const n=t*e;return 1-Math.exp(-n*n)}function getDynamicScreenSpaceError(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){const n=t.dynamicScreenSpaceErrorFactor;return fog(e,t.dynamicScreenSpaceErrorComputedDensity)*n}return 0}function getTiles3DScreenSpaceError(t,e,n){const i=t.tileset,r=n?t.parent&&t.parent.lodMetricValue||t.lodMetricValue:t.lodMetricValue;if(0===r)return 0;const o=Math.max(t._distanceToCamera,1e-7),{height:s,sseDenominator:a}=e,{viewDistanceScale:l}=i.options;let c=r*s*(l||1)/(o*a);return c-=getDynamicScreenSpaceError(i,o),c}new Vector3$1,new Vector3$1,new Matrix4$1,new Vector3$1,new Vector3$1,new Vector3$1;const cameraPositionCartesian=new Vector3$1,toEye=new Vector3$1,cameraPositionEnu=new Vector3$1,extraVertexEnu=new Vector3$1,projectedOriginVector=new Vector3$1,enuToCartesianMatrix=new Matrix4$1,cartesianToEnuMatrix=new Matrix4$1;function getLodStatus(t,e){if(0===t.lodMetricValue||isNaN(t.lodMetricValue))return"DIG";const n=2*getProjectedRadius(t,e);return n<2?"OUT":!t.header.children||n<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function getProjectedRadius(t,e){const{topDownViewport:n}=e,i=t.header.mbs[1],r=t.header.mbs[0],o=t.header.mbs[2],s=t.header.mbs[3],a=[...t.boundingVolume.center],l=n.unprojectPosition(n.cameraPosition);Ellipsoid.WGS84.cartographicToCartesian(l,cameraPositionCartesian),toEye.copy(cameraPositionCartesian).subtract(a).normalize(),Ellipsoid.WGS84.eastNorthUpToFixedFrame(a,enuToCartesianMatrix),cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert(),cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);const c=Math.sqrt(cameraPositionEnu[0]*cameraPositionEnu[0]+cameraPositionEnu[1]*cameraPositionEnu[1]);extraVertexEnu.copy([cameraPositionEnu[0],cameraPositionEnu[1],c*c/cameraPositionEnu[2]]);const u=extraVertexEnu.transform(enuToCartesianMatrix).subtract(a).normalize(),h=toEye.cross(u).normalize().scale(s).add(a),d=Ellipsoid.WGS84.cartesianToCartographic(h),p=n.project([r,i,o]),f=n.project(d);return projectedOriginVector.copy(p).subtract(f).magnitude()}function get3dTilesOptions(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}class ManagedArray{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;_defineProperty(this,"_map",new Map),_defineProperty(this,"_array",void 0),_defineProperty(this,"_length",void 0),this._array=new Array(t),this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return assert$c(t<this._array.length),this._array[t]}set(t,e){assert$c(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=e,this._map.set(e,t)}delete(t){const e=this._map.get(t);e>=0&&(this._array.splice(e,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){const e=this.length++;this._array[e]=t,this._map.set(t,e)}}pop(){const t=this._array[--this.length];return this._map.delete(t),t}reserve(t){assert$c(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){assert$c(t>=0),this.length=t}trim(t){null==t&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}}const DEFAULT_PROPS$1={loadSiblings:!1,skipLevelOfDetail:!1,maximumScreenSpaceError:2,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class TilesetTraverser{traversalFinished(t){return!0}constructor(t){_defineProperty(this,"options",void 0),_defineProperty(this,"root",null),_defineProperty(this,"selectedTiles",{}),_defineProperty(this,"requestedTiles",{}),_defineProperty(this,"emptyTiles",{}),_defineProperty(this,"lastUpdate",(new Date).getTime()),_defineProperty(this,"updateDebounceTime",1e3),_defineProperty(this,"_traversalStack",new ManagedArray),_defineProperty(this,"_emptyTraversalStack",new ManagedArray),_defineProperty(this,"_frameNumber",null),this.options={...DEFAULT_PROPS$1,...t}}traverse(t,e,n){this.root=t,this.options={...this.options,...n},this.reset(),this.updateTile(t,e),this._frameNumber=e.frameNumber,this.executeTraversal(t,e)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,e){const n=this._traversalStack;for(t._selectionDepth=1,n.push(t);n.length>0;){const t=n.pop();let i=!1;this.canTraverse(t,e)&&(this.updateChildTiles(t,e),i=this.updateAndPushChildren(t,e,n,t.hasRenderContent?t._selectionDepth+1:t._selectionDepth));const r=t.parent,o=Boolean(!r||r._shouldRefine),s=!i;t.hasRenderContent?t.refine===TILE_REFINEMENT.ADD?(this.loadTile(t,e),this.selectTile(t,e)):t.refine===TILE_REFINEMENT.REPLACE&&(this.loadTile(t,e),s&&this.selectTile(t,e)):(this.emptyTiles[t.id]=t,this.loadTile(t,e),s&&this.selectTile(t,e)),this.touchTile(t,e),t._shouldRefine=i&&o}const i=(new Date).getTime();(this.traversalFinished(e)||i-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=i,this.options.onTraversalEnd(e))}updateChildTiles(t,e){const n=t.children;for(const t of n)this.updateTile(t,e)}updateAndPushChildren(t,e,n,i){const{loadSiblings:r,skipLevelOfDetail:o}=this.options,s=t.children;s.sort(this.compareDistanceToCamera.bind(this));const a=t.refine===TILE_REFINEMENT.REPLACE&&t.hasRenderContent&&!o;let l=!1,c=!0;for(const t of s)if(t._selectionDepth=i,t.isVisibleAndInRequestVolume?(n.find(t)&&n.delete(t),n.push(t),l=!0):(a||r)&&(this.loadTile(t,e),this.touchTile(t,e)),a){let n;if(n=!!t._inRequestVolume&&(t.hasRenderContent?t.contentAvailable:this.executeEmptyTraversal(t,e)),c=c&&n,!c)return!1}return l||(c=!1),c}updateTile(t,e){this.updateTileVisibility(t,e)}selectTile(t,e){this.shouldSelectTile(t)&&(t._selectedFrame=e.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,e){this.shouldLoadTile(t)&&(t._requestedFrame=e.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,e){t.tileset._cache.touch(t),t._touchedFrame=e.frameNumber}canTraverse(t,e){return!!t.hasChildren&&(t.hasTilesetContent?!t.contentExpired:!(!(arguments.length>3&&void 0!==arguments[3]&&arguments[3])&&!t.isVisibleAndInRequestVolume)&&this.shouldRefine(t,e,arguments.length>2&&void 0!==arguments[2]&&arguments[2]))}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,e){let n=t._screenSpaceError;return arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&(n=t.getScreenSpaceError(e,!0)),n>this.options.maximumScreenSpaceError}updateTileVisibility(t,e){const n=[];if(this.options.viewportTraversersMap)for(const t in this.options.viewportTraversersMap){this.options.viewportTraversersMap[t]===e.viewport.id&&n.push(t)}else n.push(e.viewport.id);t.updateVisibility(e,n)}compareDistanceToCamera(t,e){return t._distanceToCamera-e._distanceToCamera}anyChildrenVisible(t,e){let n=!1;for(const i of t.children)i.updateVisibility(e),n=n||i.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(t,e){let n=!0;const i=this._emptyTraversalStack;for(i.push(t);i.length>0&&n;){const t=i.pop();this.updateTile(t,e),t.isVisibleAndInRequestVolume||this.loadTile(t,e),this.touchTile(t,e);if(!t.hasRenderContent&&this.canTraverse(t,e,!1,!0)){const e=t.children;for(const t of e)i.find(t)&&i.delete(t),i.push(t)}else t.contentAvailable||t.hasEmptyContent||(n=!1)}return n}}const scratchVector=new Vector3$1;function defined$2(t){return null!=t}class Tile3D{constructor(t,e,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";_defineProperty(this,"tileset",void 0),_defineProperty(this,"header",void 0),_defineProperty(this,"id",void 0),_defineProperty(this,"url",void 0),_defineProperty(this,"parent",void 0),_defineProperty(this,"refine",void 0),_defineProperty(this,"type",void 0),_defineProperty(this,"contentUrl",void 0),_defineProperty(this,"lodMetricType","geometricError"),_defineProperty(this,"lodMetricValue",0),_defineProperty(this,"boundingVolume",null),_defineProperty(this,"content",null),_defineProperty(this,"contentState",TILE_CONTENT_STATE.UNLOADED),_defineProperty(this,"gpuMemoryUsageInBytes",0),_defineProperty(this,"children",[]),_defineProperty(this,"depth",0),_defineProperty(this,"viewportIds",[]),_defineProperty(this,"transform",new Matrix4$1),_defineProperty(this,"extensions",null),_defineProperty(this,"implicitTiling",null),_defineProperty(this,"userData",{}),_defineProperty(this,"computedTransform",void 0),_defineProperty(this,"hasEmptyContent",!1),_defineProperty(this,"hasTilesetContent",!1),_defineProperty(this,"traverser",new TilesetTraverser({})),_defineProperty(this,"_cacheNode",null),_defineProperty(this,"_frameNumber",null),_defineProperty(this,"_expireDate",null),_defineProperty(this,"_expiredContent",null),_defineProperty(this,"_boundingBox",void 0),_defineProperty(this,"_distanceToCamera",0),_defineProperty(this,"_screenSpaceError",0),_defineProperty(this,"_visibilityPlaneMask",void 0),_defineProperty(this,"_visible",void 0),_defineProperty(this,"_contentBoundingVolume",void 0),_defineProperty(this,"_viewerRequestVolume",void 0),_defineProperty(this,"_initialTransform",new Matrix4$1),_defineProperty(this,"_priority",0),_defineProperty(this,"_selectedFrame",0),_defineProperty(this,"_requestedFrame",0),_defineProperty(this,"_selectionDepth",0),_defineProperty(this,"_touchedFrame",0),_defineProperty(this,"_centerZDepth",0),_defineProperty(this,"_shouldRefine",!1),_defineProperty(this,"_stackLength",0),_defineProperty(this,"_visitedFrame",0),_defineProperty(this,"_inRequestVolume",!1),_defineProperty(this,"_lodJudge",null),this.header=e,this.tileset=t,this.id=i||e.id,this.url=e.url,this.parent=n,this.refine=this._getRefine(e.refine),this.type=e.type,this.contentUrl=e.contentUrl,this._initializeLodMetric(e),this._initializeTransforms(e),this._initializeBoundingVolumes(e),this._initializeContent(e),this._initializeRenderingState(e),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===TILE_CONTENT_STATE.READY||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===TILE_CONTENT_STATE.UNLOADED}get contentExpired(){return this.contentState===TILE_CONTENT_STATE.EXPIRED}get contentFailed(){return this.contentState===TILE_CONTENT_STATE.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=getCartographicBounds(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,e){switch(this.tileset.type){case TILESET_TYPE.I3S:return getProjectedRadius(this,t);case TILESET_TYPE.TILES3D:return getTiles3DScreenSpaceError(this,t,e);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){const t=this.tileset._traverser,{skipLevelOfDetail:e}=t.options,n=this.refine===TILE_REFINEMENT.ADD||e;if(n&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===TILE_CONTENT_STATE.UNLOADED)return-1;const i=this.parent;return Math.max((t.root?t.root._screenSpaceError:0)-(i&&(!n||0===this._screenSpaceError||i.hasTilesetContent)?i._screenSpaceError:this._screenSpaceError),0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=TILE_CONTENT_STATE.LOADING;const t=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!t)return this.contentState=TILE_CONTENT_STATE.UNLOADED,!1;try{const t=this.tileset.getTileUrl(this.contentUrl),e=this.tileset.loader,n={...this.tileset.loadOptions,[e.id]:{...this.tileset.loadOptions[e.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(e.id)}};return this.content=await load(t,e,n),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=TILE_CONTENT_STATE.READY,this._onContentLoaded(),!0}catch(t){throw this.contentState=TILE_CONTENT_STATE.FAILED,t}finally{t.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=TILE_CONTENT_STATE.UNLOADED,!0}updateVisibility(t,e){if(this._frameNumber===t.frameNumber)return;const n=this.parent,i=n?n._visibilityPlaneMask:CullingVolume.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){this._updateTransform(n?n.computedTransform:this.tileset.modelMatrix)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,i),this._visible=this._visibilityPlaneMask!==CullingVolume.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=e}visibility(t,e){const{cullingVolume:n}=t,{boundingVolume:i}=this;return n.computeVisibilityWithPlaneMask(i,e)}contentVisibility(){return!0}distanceToTile(t){return Math.sqrt(Math.max(this.boundingVolume.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth(t){let{camera:e}=t;return scratchVector.subVectors(this.boundingVolume.center,e.position),e.direction.dot(scratchVector)}insideViewerRequestVolume(t){const e=this._viewerRequestVolume;return!e||e.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(defined$2(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){const t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=TILE_CONTENT_STATE.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){this.lodMetricType="lodMetricType"in t?t.lodMetricType:this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,this.lodMetricValue="lodMetricValue"in t?t.lodMetricValue:this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue}_initializeTransforms(t){this.transform=t.transform?new Matrix4$1(t.transform):new Matrix4$1;const e=this.parent,n=this.tileset,i=e&&e.computedTransform?e.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new Matrix4$1(i).multiplyRight(this.transform);const r=e&&e._initialTransform?e._initialTransform.clone():new Matrix4$1;this._initialTransform=new Matrix4$1(r).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=TILE_CONTENT_STATE.UNLOADED,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=CullingVolume.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(t){return t||this.parent&&this.parent.refine||TILE_REFINEMENT.REPLACE}_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(t){this.boundingVolume=createBoundingVolume(t.boundingVolume,this.computedTransform,this.boundingVolume);const e=t.content;e&&(e.boundingVolume&&(this._contentBoundingVolume=createBoundingVolume(e.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=createBoundingVolume(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Matrix4$1).clone().multiplyRight(this.transform);!t.equals(this.computedTransform)&&(this.computedTransform=t,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){return"i3s"===t?{...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}:get3dTilesOptions(this.tileset.tileset)}}class Tileset3DTraverser extends TilesetTraverser{compareDistanceToCamera(t,e){return 0===e._distanceToCamera&&0===t._distanceToCamera?e._centerZDepth-t._centerZDepth:e._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,e){if(super.updateTileVisibility(t,e),!t.isVisibleAndInRequestVolume)return;const n=t.children.length>0;if(t.hasTilesetContent&&n){const n=t.children[0];return this.updateTileVisibility(n,e),void(t._visible=n._visible)}if(this.meetsScreenSpaceErrorEarly(t,e))return void(t._visible=!1);t.refine===TILE_REFINEMENT.REPLACE&&t._optimChildrenWithinParent===TILE3D_OPTIMIZATION_HINT.USE_OPTIMIZATION&&n&&!this.anyChildrenVisible(t,e)&&(t._visible=!1)}meetsScreenSpaceErrorEarly(t,e){const{parent:n}=t;return!(!n||n.hasTilesetContent||n.refine!==TILE_REFINEMENT.ADD)&&!this.shouldRefine(t,e,!0)}}class I3SPendingTilesRegister{constructor(){_defineProperty(this,"frameNumberMap",new Map)}register(t,e){const n=this.frameNumberMap.get(t)||new Map,i=n.get(e)||0;n.set(e,i+1),this.frameNumberMap.set(t,n)}deregister(t,e){const n=this.frameNumberMap.get(t);if(!n)return;const i=n.get(e)||1;n.set(e,i-1)}isZero(t,e){var n;return 0===((null===(n=this.frameNumberMap.get(t))||void 0===n?void 0:n.get(e))||0)}}const STATUS={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"};class I3STileManager{constructor(){_defineProperty(this,"_statusMap",void 0),_defineProperty(this,"pendingTilesRegister",new I3SPendingTilesRegister),this._statusMap={}}add(t,e,n,i){if(!this._statusMap[e]){const{frameNumber:r,viewport:{id:o}}=i;this._statusMap[e]={request:t,callback:n,key:e,frameState:i,status:STATUS.REQUESTED},this.pendingTilesRegister.register(o,r),t().then((t=>{this._statusMap[e].status=STATUS.COMPLETED;const{frameNumber:n,viewport:{id:r}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(r,n),this._statusMap[e].callback(t,i)})).catch((t=>{this._statusMap[e].status=STATUS.ERROR;const{frameNumber:i,viewport:{id:r}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(r,i),n(t)}))}}update(t,e){if(this._statusMap[t]){const{frameNumber:n,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,n);const{frameNumber:r,viewport:{id:o}}=e;this.pendingTilesRegister.register(o,r),this._statusMap[t].frameState=e}}find(t){return this._statusMap[t]}hasPendingTiles(t,e){return!this.pendingTilesRegister.isZero(t,e)}}class I3STilesetTraverser extends TilesetTraverser{constructor(t){super(t),_defineProperty(this,"_tileManager",void 0),this._tileManager=new I3STileManager}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,e){return t._lodJudge=getLodStatus(t,e),"DIG"===t._lodJudge}updateChildTiles(t,e){const n=t.header.children||[],i=t.children,r=t.tileset;for(const o of n){const n="".concat(o.id,"-").concat(e.viewport.id),s=i&&i.find((t=>t.id===n));if(s)s&&this.updateTile(s,e);else{let i=()=>this._loadTile(o.id,r);this._tileManager.find(n)?this._tileManager.update(n,e):(r.tileset.nodePages&&(i=()=>r.tileset.nodePagesTile.formTileFromNodePages(o.id)),this._tileManager.add(i,n,(e=>this._onTileLoad(e,t,n)),e))}}return!1}async _loadTile(t,e){const{loader:n}=e,i=e.getTileUrl("".concat(e.url,"/nodes/").concat(t)),r={...e.loadOptions,i3s:{...e.loadOptions.i3s,isTileHeader:!0}};return await load(i,n,r)}_onTileLoad(t,e,n){const i=new Tile3D(e.tileset,t,e,n);e.children.push(i);const r=this._tileManager.find(i.id).frameState;this.updateTile(i,r),this._frameNumber===r.frameNumber&&(this.traversalFinished(r)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(i,r)}}const DEFAULT_PROPS={description:"",ellipsoid:Ellipsoid.WGS84,modelMatrix:new Matrix4$1,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},TILES_TOTAL="Tiles In Tileset(s)",TILES_IN_MEMORY="Tiles In Memory",TILES_IN_VIEW="Tiles In View",TILES_RENDERABLE="Tiles To Render",TILES_LOADED="Tiles Loaded",TILES_LOADING="Tiles Loading",TILES_UNLOADED="Tiles Unloaded",TILES_LOAD_FAILED="Failed Tile Loads",POINTS_COUNT="Points/Vertices",TILES_GPU_MEMORY="Tile Memory Use";class Tileset3D{constructor(t,e){_defineProperty(this,"options",void 0),_defineProperty(this,"loadOptions",void 0),_defineProperty(this,"type",void 0),_defineProperty(this,"tileset",void 0),_defineProperty(this,"loader",void 0),_defineProperty(this,"url",void 0),_defineProperty(this,"basePath",void 0),_defineProperty(this,"modelMatrix",void 0),_defineProperty(this,"ellipsoid",void 0),_defineProperty(this,"lodMetricType",void 0),_defineProperty(this,"lodMetricValue",void 0),_defineProperty(this,"refine",void 0),_defineProperty(this,"root",null),_defineProperty(this,"roots",{}),_defineProperty(this,"asset",{}),_defineProperty(this,"description",""),_defineProperty(this,"properties",void 0),_defineProperty(this,"extras",null),_defineProperty(this,"attributions",{}),_defineProperty(this,"credits",{}),_defineProperty(this,"stats",void 0),_defineProperty(this,"contentFormats",{draco:!1,meshopt:!1,dds:!1,ktx2:!1}),_defineProperty(this,"cartographicCenter",null),_defineProperty(this,"cartesianCenter",null),_defineProperty(this,"zoom",1),_defineProperty(this,"boundingVolume",null),_defineProperty(this,"dynamicScreenSpaceErrorComputedDensity",0),_defineProperty(this,"maximumMemoryUsage",32),_defineProperty(this,"gpuMemoryUsageInBytes",0),_defineProperty(this,"_frameNumber",0),_defineProperty(this,"_queryParams",{}),_defineProperty(this,"_extensionsUsed",[]),_defineProperty(this,"_tiles",{}),_defineProperty(this,"_pendingCount",0),_defineProperty(this,"selectedTiles",[]),_defineProperty(this,"traverseCounter",0),_defineProperty(this,"geometricError",0),_defineProperty(this,"lastUpdatedVieports",null),_defineProperty(this,"_requestedTiles",[]),_defineProperty(this,"_emptyTiles",[]),_defineProperty(this,"frameStateData",{}),_defineProperty(this,"_traverser",void 0),_defineProperty(this,"_cache",new TilesetCache),_defineProperty(this,"_requestScheduler",void 0),_defineProperty(this,"updatePromise",null),_defineProperty(this,"tilesetInitializationPromise",void 0),this.options={...DEFAULT_PROPS,...e},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new RequestScheduler({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.stats=new Stats({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(t)}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(t){this.options={...this.options,...t}}setOptions(t){this.options={...this.options,...t}}getTileUrl(t){return t.startsWith("data:")?t:"".concat(t).concat(t.includes("?")?"&":"?").concat(this.queryParams)}hasExtension(t){return Boolean(this._extensionsUsed.indexOf(t)>-1)}update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.tilesetInitializationPromise.then((()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)}))}async selectTiles(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),this.updatePromise||(this.updatePromise=new Promise((t=>{setTimeout((()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),t(this._frameNumber),this.updatePromise=null}),this.options.debounceTime)}))),this.updatePromise}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;const e=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=e.length;const n=[];for(const t of e){const e=t.id;this._needTraverse(e)?n.push(e):this.traverseCounter--}for(const t of e){const e=t.id;if(this.roots[e]||(this.roots[e]=this._initializeTileHeaders(this.tileset,null)),!n.includes(e))continue;const i=getFrameState(t,this._frameNumber);this._traverser.traverse(this.roots[e],i,this.options)}}_needTraverse(t){let e=t;return this.options.viewportTraversersMap&&(e=this.options.viewportTraversersMap[t]),e===t}_onTraversalEnd(t){const e=t.viewport.id;this.frameStateData[e]||(this.frameStateData[e]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const n=this.frameStateData[e],i=Object.values(this._traverser.selectedTiles),[r,o]=limitSelectedTiles(i,t,this.options.maximumTilesSelected);n.selectedTiles=r;for(const t of o)t.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,this.traverseCounter>0||this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const t in this.frameStateData){const e=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(e.selectedTiles),this._requestedTiles=this._requestedTiles.concat(e._requestedTiles),this._emptyTiles=this._emptyTiles.concat(e._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,e){if(t.length!==e.length)return!0;const n=new Set(t.map((t=>t.id))),i=new Set(e.map((t=>t.id)));let r=t.filter((t=>!i.has(t.id))).length>0;return r=r||e.filter((t=>!n.has(t.id))).length>0,r}_loadTiles(){for(const t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,((t,e)=>t._unloadTile(e)))}_updateStats(){let t=0,e=0;for(const n of this.selectedTiles)n.contentAvailable&&n.content&&(t++,e+=n.content.pointCount?n.content.pointCount:n.content.vertexCount);this.stats.get(TILES_IN_VIEW).count=this.selectedTiles.length,this.stats.get(TILES_RENDERABLE).count=t,this.stats.get(POINTS_COUNT).count=e}async _initializeTileSet(t){this.type===TILESET_TYPE.I3S&&(this.calculateViewPropsI3S(),t.root=await t.root),this.root=this._initializeTileHeaders(t,null),this.type===TILESET_TYPE.TILES3D&&(this._initializeTiles3DTileset(t),this.calculateViewPropsTiles3D()),this.type===TILESET_TYPE.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){var t;const e=this.tileset.fullExtent;if(e){const{xmin:t,xmax:n,ymin:i,ymax:r,zmin:o,zmax:s}=e;return this.cartographicCenter=new Vector3$1(t+(n-t)/2,i+(r-i)/2,o+(s-o)/2),this.cartesianCenter=Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter,new Vector3$1),void(this.zoom=getZoomFromFullExtent(e,this.cartographicCenter,this.cartesianCenter))}const n=null===(t=this.tileset.store)||void 0===t?void 0:t.extent;if(n){const[t,e,i,r]=n;return this.cartographicCenter=new Vector3$1(t+(i-t)/2,e+(r-e)/2,0),this.cartesianCenter=Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter,new Vector3$1),void(this.zoom=getZoomFromExtent(n,this.cartographicCenter,this.cartesianCenter))}this.cartographicCenter=new Vector3$1,this.zoom=1}calculateViewPropsTiles3D(){const t=this.root,{center:e}=t.boundingVolume;if(!e)return this.cartographicCenter=new Vector3$1,void(this.zoom=1);this.cartographicCenter=0!==e[0]||0!==e[1]||0!==e[2]?Ellipsoid.WGS84.cartesianToCartographic(e,new Vector3$1):new Vector3$1(0,0,-Ellipsoid.WGS84.radii[0]),this.cartesianCenter=e,this.zoom=getZoomFromBoundingVolume(t.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(TILES_TOTAL),this.stats.get(TILES_LOADING),this.stats.get(TILES_IN_MEMORY),this.stats.get(TILES_IN_VIEW),this.stats.get(TILES_RENDERABLE),this.stats.get(TILES_LOADED),this.stats.get(TILES_UNLOADED),this.stats.get(TILES_LOAD_FAILED),this.stats.get(POINTS_COUNT),this.stats.get(TILES_GPU_MEMORY,"memory")}_initializeTileHeaders(t,e){const n=new Tile3D(this,t.root,e);if(e&&(e.children.push(n),n.depth=e.depth+1),this.type===TILESET_TYPE.TILES3D){const t=[];for(t.push(n);t.length>0;){const e=t.pop();this.stats.get(TILES_TOTAL).incrementCount();const n=e.header.children||[];for(const r of n){var i;const n=new Tile3D(this,r,e);if(null!==(i=n.contentUrl)&&void 0!==i&&i.includes("?session=")){const t=new URL(n.contentUrl).searchParams.get("session");t&&(this._queryParams.session=t)}e.children.push(n),n.depth=e.depth+1,t.push(n)}}}return n}_initializeTraverser(){let t;switch(this.type){case TILESET_TYPE.TILES3D:t=Tileset3DTraverser;break;case TILESET_TYPE.I3S:t=I3STilesetTraverser;break;default:t=TilesetTraverser}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let e;try{this._onStartTileLoading(),e=await t.loadContent()}catch(e){this._onTileLoadError(t,e instanceof Error?e:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(t,e)}}_onTileLoadError(t,e){this.stats.get(TILES_LOAD_FAILED).incrementCount();const n=e.message||e.toString();this.options.onTileError(t,n,t.url)}_onTileLoad(t,e){if(e){if(this.type===TILESET_TYPE.I3S){var n,i;const t=(null===(n=this.tileset)||void 0===n||null===(i=n.nodePagesTile)||void 0===i?void 0:i.nodesInNodePages)||0;this.stats.get(TILES_TOTAL).reset(),this.stats.get(TILES_TOTAL).addCount(t)}t&&t.content&&calculateTransformProps(t,t.content),this.updateContentTypes(t),this._addTileToCache(t),this.options.onTileLoad(t)}}updateContentTypes(t){if(this.type===TILESET_TYPE.I3S)switch(t.header.isDracoGeometry&&(this.contentFormats.draco=!0),t.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0}else if(this.type===TILESET_TYPE.TILES3D){var e;const{extensionsRemoved:n=[]}=(null===(e=t.content)||void 0===e?void 0:e.gltf)||{};n.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),n.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),n.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(TILES_LOADING).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(TILES_LOADING).decrementCount()}_addTileToCache(t){this._cache.add(this,t,(e=>e._updateCacheStats(t)))}_updateCacheStats(t){this.stats.get(TILES_LOADED).incrementCount(),this.stats.get(TILES_IN_MEMORY).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(TILES_GPU_MEMORY).count=this.gpuMemoryUsageInBytes}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(TILES_IN_MEMORY).decrementCount(),this.stats.get(TILES_UNLOADED).incrementCount(),this.stats.get(TILES_GPU_MEMORY).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){const t=[];for(this.root&&t.push(this.root);t.length>0;){const e=t.pop();for(const n of e.children)t.push(n);this._destroyTile(e)}this.root=null}_destroySubtree(t){const e=t,n=[];for(n.push(e);n.length>0;){t=n.pop();for(const e of t.children)n.push(e);t!==e&&this._destroyTile(t)}e.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeTiles3DTileset(t){if(t.queryString){const e=new URLSearchParams(t.queryString),n=Object.fromEntries(e.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=t.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=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed||[],this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const VERSION="3.4.15",TILE3D_TYPE={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"};function getStringFromArrayBuffer(t,e,n){assert$c(t instanceof ArrayBuffer);const i=new TextDecoder("utf8"),r=new Uint8Array(t,e,n);return i.decode(r)}function getMagicString(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=new DataView(t);return"".concat(String.fromCharCode(n.getUint8(e+0))).concat(String.fromCharCode(n.getUint8(e+1))).concat(String.fromCharCode(n.getUint8(e+2))).concat(String.fromCharCode(n.getUint8(e+3)))}const GL_PRIMITIVE_MODE={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},GL_TYPE={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},GL$1={...GL_PRIMITIVE_MODE,...GL_TYPE},GL_TYPE_TO_ARRAY_TYPE={[GL_TYPE.DOUBLE]:Float64Array,[GL_TYPE.FLOAT]:Float32Array,[GL_TYPE.UNSIGNED_SHORT]:Uint16Array,[GL_TYPE.UNSIGNED_INT]:Uint32Array,[GL_TYPE.UNSIGNED_BYTE]:Uint8Array,[GL_TYPE.BYTE]:Int8Array,[GL_TYPE.SHORT]:Int16Array,[GL_TYPE.INT]:Int32Array},NAME_TO_GL_TYPE={DOUBLE:GL_TYPE.DOUBLE,FLOAT:GL_TYPE.FLOAT,UNSIGNED_SHORT:GL_TYPE.UNSIGNED_SHORT,UNSIGNED_INT:GL_TYPE.UNSIGNED_INT,UNSIGNED_BYTE:GL_TYPE.UNSIGNED_BYTE,BYTE:GL_TYPE.BYTE,SHORT:GL_TYPE.SHORT,INT:GL_TYPE.INT},ERR_TYPE_CONVERSION="Failed to convert GL type";class GLType{static fromTypedArray(t){t=ArrayBuffer.isView(t)?t.constructor:t;for(const e in GL_TYPE_TO_ARRAY_TYPE){if(GL_TYPE_TO_ARRAY_TYPE[e]===t)return e}throw new Error(ERR_TYPE_CONVERSION)}static fromName(t){const e=NAME_TO_GL_TYPE[t];if(!e)throw new Error(ERR_TYPE_CONVERSION);return e}static getArrayType(t){switch(t){case GL_TYPE.UNSIGNED_SHORT_5_6_5:case GL_TYPE.UNSIGNED_SHORT_4_4_4_4:case GL_TYPE.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const e=GL_TYPE_TO_ARRAY_TYPE[t];if(!e)throw new Error(ERR_TYPE_CONVERSION);return e}}static getByteSize(t){return GLType.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return Boolean(GLType.getArrayType(t))}static createTypedArray(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;void 0===i&&(i=(e.byteLength-n)/GLType.getByteSize(t));return new(GLType.getArrayType(t))(e,n,i)}}function assert$1(t,e){if(!t)throw new Error("math.gl assertion failed. ".concat(e))}function decodeRGB565(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];const n=t>>5&63,i=31&t;return e[0]=(t>>11&31)<<3,e[1]=n<<2,e[2]=i<<3,e}function fromSNorm(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:255;return clamp$2(t,0,e)/e*2-1}function signNotZero(t){return t<0?-1:1}function octDecodeInRange(t,e,n,i){if(assert$1(i),t<0||t>n||e<0||e>n)throw new Error("x and y must be unsigned normalized integers between 0 and ".concat(n));if(i.x=fromSNorm(t,n),i.y=fromSNorm(e,n),i.z=1-(Math.abs(i.x)+Math.abs(i.y)),i.z<0){const t=i.x;i.x=(1-Math.abs(i.y))*signNotZero(t),i.y=(1-Math.abs(t))*signNotZero(i.y)}return i.normalize()}function octDecode(t,e,n){return octDecodeInRange(t,e,255,n)}new Vector2$1,new Vector3$1,new Vector2$1,new Vector2$1;class Tile3DFeatureTable{constructor(t,e){_defineProperty(this,"json",void 0),_defineProperty(this,"buffer",void 0),_defineProperty(this,"featuresLength",0),_defineProperty(this,"_cachedTypedArrays",{}),this.json=t,this.buffer=e}getExtension(t){return this.json.extensions&&this.json.extensions[t]}hasProperty(t){return Boolean(this.json[t])}getGlobalProperty(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:GL$1.UNSIGNED_INT,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const i=this.json[t];return i&&Number.isFinite(i.byteOffset)?this._getTypedArrayFromBinary(t,e,n,1,i.byteOffset):i}getPropertyArray(t,e,n){const i=this.json[t];return i&&Number.isFinite(i.byteOffset)?("componentType"in i&&(e=GLType.fromName(i.componentType)),this._getTypedArrayFromBinary(t,e,n,this.featuresLength,i.byteOffset)):this._getTypedArrayFromArray(t,e,i)}getProperty(t,e,n,i,r){const o=this.json[t];if(!o)return o;const s=this.getPropertyArray(t,e,n);if(1===n)return s[i];for(let t=0;t<n;++t)r[t]=s[n*i+t];return r}_getTypedArrayFromBinary(t,e,n,i,r){const o=this._cachedTypedArrays;let s=o[t];return s||(s=GLType.createTypedArray(e,this.buffer.buffer,this.buffer.byteOffset+r,i*n),o[t]=s),s}_getTypedArrayFromArray(t,e,n){const i=this._cachedTypedArrays;let r=i[t];return r||(r=GLType.createTypedArray(e,n),i[t]=r),r}}const COMPONENTS_PER_ATTRIBUTE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},UNPACKER={SCALAR:(t,e)=>t[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},PACKER={SCALAR:(t,e,n)=>{e[n]=t},VEC2:(t,e,n)=>{e[2*n+0]=t[0],e[2*n+1]=t[1]},VEC3:(t,e,n)=>{e[3*n+0]=t[0],e[3*n+1]=t[1],e[3*n+2]=t[2]},VEC4:(t,e,n)=>{e[4*n+0]=t[0],e[4*n+1]=t[1],e[4*n+2]=t[2],e[4*n+3]=t[3]},MAT2:(t,e,n)=>{e[4*n+0]=t[0],e[4*n+1]=t[1],e[4*n+2]=t[2],e[4*n+3]=t[3]},MAT3:(t,e,n)=>{e[9*n+0]=t[0],e[9*n+1]=t[1],e[9*n+2]=t[2],e[9*n+3]=t[3],e[9*n+4]=t[4],e[9*n+5]=t[5],e[9*n+6]=t[6],e[9*n+7]=t[7],e[9*n+8]=t[8],e[9*n+9]=t[9]},MAT4:(t,e,n)=>{e[16*n+0]=t[0],e[16*n+1]=t[1],e[16*n+2]=t[2],e[16*n+3]=t[3],e[16*n+4]=t[4],e[16*n+5]=t[5],e[16*n+6]=t[6],e[16*n+7]=t[7],e[16*n+8]=t[8],e[16*n+9]=t[9],e[16*n+10]=t[10],e[16*n+11]=t[11],e[16*n+12]=t[12],e[16*n+13]=t[13],e[16*n+14]=t[14],e[16*n+15]=t[15]}};function createTypedArrayFromAccessor(t,e,n,i){const{componentType:r}=t;assert$c(t.componentType);const o="string"==typeof r?GLType.fromName(r):r,s=COMPONENTS_PER_ATTRIBUTE[t.type],a=UNPACKER[t.type],l=PACKER[t.type];return{values:GLType.createTypedArray(o,e,n+=t.byteOffset,s*i),type:o,size:s,unpacker:a,packer:l}}const defined$1=t=>void 0!==t;function initializeHierarchy(t,e,n){if(!e)return null;let i=t.getExtension("3DTILES_batch_table_hierarchy");const r=e.HIERARCHY;return r&&(e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=r,i=r),i?initializeHierarchyValues(i,n):null}function initializeHierarchyValues(t,e){let n,i,r;const o=t.instancesLength,s=t.classes;let a,l=t.classIds,c=t.parentCounts,u=t.parentIds,h=o;if(defined$1(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,r=getBinaryAccessor(l),l=r.createArrayBufferView(e.buffer,e.byteOffset+l.byteOffset,o)),defined$1(c))for(defined$1(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,r=getBinaryAccessor(c),c=r.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,o)),a=new Uint16Array(o),h=0,n=0;n<o;++n)a[n]=h,h+=c[n];defined$1(u)&&defined$1(u.byteOffset)&&(u.componentType=defaultValue(u.componentType,GL.UNSIGNED_SHORT),u.type=AttributeType.SCALAR,r=getBinaryAccessor(u),u=r.createArrayBufferView(e.buffer,e.byteOffset+u.byteOffset,h));const d=s.length;for(n=0;n<d;++n){const t=s[n].instances,i=getBinaryProperties(s[n].length,t,e);s[n].instances=combine(i,t)}const p=new Array(d).fill(0),f=new Uint16Array(o);for(n=0;n<o;++n)i=l[n],f[n]=p[i],++p[i];const m={classes:s,classIds:l,classIndexes:f,parentCounts:c,parentIndexes:a,parentIds:u};return validateHierarchy(m),m}function traverseHierarchy(t,e,n){if(!t)return;const i=t.parentCounts;return t.parentIds?n(t,e):i>0?traverseHierarchyMultipleParents(t,e,n):traverseHierarchySingleParent(t,e,n)}function traverseHierarchyMultipleParents(t,e,n){const i=t.parentCounts,r=t.parentIds,o=t.parentIndexes,s=scratchVisited;s.length=Math.max(s.length,t.classIds.length);const a=++marker,l=scratchStack;for(l.length=0,l.push(e);l.length>0;){if(s[e=l.pop()]===a)continue;s[e]=a;const c=n(t,e);if(defined$1(c))return c;const u=i[e],h=o[e];for(let t=0;t<u;++t){const n=r[h+t];n!==e&&l.push(n)}}return null}function traverseHierarchySingleParent(t,e,n){let i=!0;for(;i;){const r=n(t,e);if(defined$1(r))return r;const o=t.parentIds[e];i=o!==e,e=o}throw new Error("traverseHierarchySingleParent")}function validateHierarchy(t){const e=t.classIds.length;for(let n=0;n<e;++n)validateInstance(t,n,stack)}function validateInstance(t,e,n){const i=t.parentCounts,r=t.parentIds,o=t.parentIndexes,s=t.classIds.length;if(!defined$1(r))return;assert(e<s,"Parent index ".concat(e," exceeds the total number of instances: ").concat(s)),assert(-1===n.indexOf(e),"Circular dependency detected in the batch table hierarchy."),n.push(e);const a=defined$1(i)?i[e]:1,l=defined$1(i)?o[e]:e;for(let i=0;i<a;++i){const o=r[l+i];o!==e&&validateInstance(t,o,n)}n.pop(e)}function defined(t){return null!=t}const clone=(t,e)=>t,IGNORED_PROPERTY_FIELDS={HIERARCHY:!0,extensions:!0,extras:!0};class Tile3DBatchTableParser{constructor(t,e,n){var i;let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};_defineProperty(this,"json",void 0),_defineProperty(this,"binary",void 0),_defineProperty(this,"featureCount",void 0),_defineProperty(this,"_extensions",void 0),_defineProperty(this,"_properties",void 0),_defineProperty(this,"_binaryProperties",void 0),_defineProperty(this,"_hierarchy",void 0),assert$c(n>=0),this.json=t||{},this.binary=e,this.featureCount=n,this._extensions=(null===(i=this.json)||void 0===i?void 0:i.extensions)||{},this._properties={};for(const t in this.json)IGNORED_PROPERTY_FIELDS[t]||(this._properties[t]=this.json[t]);this._binaryProperties=this._initializeBinaryProperties(),r["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=initializeHierarchy(this,this.json,this.binary))}getExtension(t){return this.json&&this.json.extensions&&this.json.extensions[t]}memorySizeInBytes(){return 0}isClass(t,e){if(this._checkBatchId(t),assert$c("string"==typeof e,e),this._hierarchy){return defined(traverseHierarchy(this._hierarchy,t,((t,n)=>t.classes[t.classIds[n]].name===e)))}return!1}isExactClass(t,e){return assert$c("string"==typeof e,e),this.getExactClassName(t)===e}getExactClassName(t){if(this._checkBatchId(t),this._hierarchy){return this._hierarchy.classes[this._hierarchy.classIds[t]].name}}hasProperty(t,e){return this._checkBatchId(t),assert$c("string"==typeof e,e),defined(this._properties[e])||this._hasPropertyInHierarchy(t,e)}getPropertyNames(t,e){this._checkBatchId(t),(e=defined(e)?e:[]).length=0;const n=Object.keys(this._properties);return e.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(t,e),e}getProperty(t,e){if(this._checkBatchId(t),assert$c("string"==typeof e,e),this._binaryProperties){const n=this._binaryProperties[e];if(defined(n))return this._getBinaryProperty(n,t)}const n=this._properties[e];if(defined(n))return clone(n[t]);if(this._hierarchy){const n=this._getHierarchyProperty(t,e);if(defined(n))return n}}setProperty(t,e,n){const i=this.featureCount;if(this._checkBatchId(t),assert$c("string"==typeof e,e),this._binaryProperties){const i=this._binaryProperties[e];if(i)return void this._setBinaryProperty(i,t,n)}if(this._hierarchy&&this._setHierarchyProperty(this,t,e,n))return;let r=this._properties[e];defined(r)||(this._properties[e]=new Array(i),r=this._properties[e]),r[t]=clone(n)}_checkBatchId(t){if(!(t>=0&&t<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(t,e){return t.unpack(t.typedArray,e)}_setBinaryProperty(t,e,n){t.pack(n,t.typedArray,e)}_initializeBinaryProperties(){let t=null;for(const e in this._properties){const n=this._initializeBinaryProperty(e,this._properties[e]);n&&(t=t||{},t[e]=n)}return t}_initializeBinaryProperty(t,e){if("byteOffset"in e){const n=e;assert$c(this.binary,"Property ".concat(t," requires a batch table binary.")),assert$c(n.type,"Property ".concat(t," requires a type."));const i=createTypedArrayFromAccessor(n,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:i.values,componentCount:i.size,unpack:i.unpacker,pack:i.packer}}return null}_hasPropertyInHierarchy(t,e){if(!this._hierarchy)return!1;const n=traverseHierarchy(this._hierarchy,t,((t,n)=>defined(t.classes[t.classIds[n]].instances[e])));return defined(n)}_getPropertyNamesInHierarchy(t,e){traverseHierarchy(this._hierarchy,t,((t,n)=>{const i=t.classes[t.classIds[n]].instances;for(const t in i)i.hasOwnProperty(t)&&-1===e.indexOf(t)&&e.push(t)}))}_getHierarchyProperty(t,e){return traverseHierarchy(this._hierarchy,t,((t,n)=>{const i=t.classIndexes[n],r=t.classes[t.classIds[n]].instances[e];return defined(r)?defined(r.typedArray)?this._getBinaryProperty(r,i):clone(r[i]):null}))}_setHierarchyProperty(t,e,n,i){const r=traverseHierarchy(this._hierarchy,e,((t,r)=>{const o=t.classIndexes[r],s=t.classes[t.classIds[r]].instances[n];return!!defined(s)&&(assert$c(r===e,'Inherited property "'.concat(n,'" is read-only.')),defined(s.typedArray)?this._setBinaryProperty(s,o,i):s[o]=clone(i),!0)}));return defined(r)}}const SIZEOF_UINT32$1=4;function parse3DTileHeaderSync(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const i=new DataView(e);if(t.magic=i.getUint32(n,!0),n+=SIZEOF_UINT32$1,t.version=i.getUint32(n,!0),n+=SIZEOF_UINT32$1,t.byteLength=i.getUint32(n,!0),n+=SIZEOF_UINT32$1,1!==t.version)throw new Error("3D Tile Version ".concat(t.version," not supported"));return n}const SIZEOF_UINT32=4;function parse3DTileTablesHeaderSync(t,e,n){const i=new DataView(e);let r;t.header=t.header||{};let o=i.getUint32(n,!0),s=i.getUint32(n+=SIZEOF_UINT32,!0),a=i.getUint32(n+=SIZEOF_UINT32,!0),l=i.getUint32(n+=SIZEOF_UINT32,!0);return n+=SIZEOF_UINT32,a>=570425344?(n-=2*SIZEOF_UINT32,r=o,a=s,l=0,o=0,s=0):l>=570425344&&(n-=SIZEOF_UINT32,r=a,a=o,l=s,o=0,s=0),t.header.featureTableJsonByteLength=o,t.header.featureTableBinaryByteLength=s,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=l,t.header.batchLength=r,n}function parse3DTileTablesSync(t,e,n,i){return n=parse3DTileBatchTable(t,e,n=parse3DTileFeatureTable(t,e,n))}function parse3DTileFeatureTable(t,e,n,i){const{featureTableJsonByteLength:r,featureTableBinaryByteLength:o,batchLength:s}=t.header;if(t.featureTableJson={BATCH_LENGTH:s||0},r>0){const i=getStringFromArrayBuffer(e,n,r);t.featureTableJson=JSON.parse(i)}return n+=r,t.featureTableBinary=new Uint8Array(e,n,o),n+=o}function parse3DTileBatchTable(t,e,n,i){const{batchTableJsonByteLength:r,batchTableBinaryByteLength:o}=t.header;if(r>0){const i=getStringFromArrayBuffer(e,n,r);t.batchTableJson=JSON.parse(i),n+=r,o>0&&(t.batchTableBinary=new Uint8Array(e,n,o),t.batchTableBinary=new Uint8Array(t.batchTableBinary),n+=o)}return n}function normalize3DTileColorAttribute(t,e,n){if(!(e||t&&t.batchIds&&n))return null;const{batchIds:i,isRGB565:r,pointCount:o}=t;if(i&&n){const t=new Uint8ClampedArray(3*o);for(let e=0;e<o;e++){const r=n.getProperty(i[e],"dimensions").map((t=>255*t));t[3*e]=r[0],t[3*e+1]=r[1],t[3*e+2]=r[2]}return{type:GL$1.UNSIGNED_BYTE,value:t,size:3,normalized:!0}}if(r){const t=new Uint8ClampedArray(3*o);for(let n=0;n<o;n++){const i=decodeRGB565(e[n]);t[3*n]=i[0],t[3*n+1]=i[1],t[3*n+2]=i[2]}return{type:GL$1.UNSIGNED_BYTE,value:t,size:3,normalized:!0}}return e&&e.length===3*o?{type:GL$1.UNSIGNED_BYTE,value:e,size:3,normalized:!0}:{type:GL$1.UNSIGNED_BYTE,value:e,size:4,normalized:!0}}const scratchNormal=new Vector3$1;function normalize3DTileNormalAttribute(t,e){if(!e)return null;if(t.isOctEncoded16P){const n=new Float32Array(3*t.pointsLength);for(let i=0;i<t.pointsLength;i++)octDecode(e[2*i],e[2*i+1],scratchNormal),scratchNormal.toArray(n,3*i);return{type:GL$1.FLOAT,size:2,value:n}}return{type:GL$1.FLOAT,size:2,value:e}}function normalize3DTilePositionAttribute(t,e,n){return t.isQuantized?n["3d-tiles"]&&n["3d-tiles"].decodeQuantizedPositions?(t.isQuantized=!1,decodeQuantizedPositions(t,e)):{type:GL$1.UNSIGNED_SHORT,value:e,size:3,normalized:!0}:e}function decodeQuantizedPositions(t,e){const n=new Vector3$1,i=new Float32Array(3*t.pointCount);for(let r=0;r<t.pointCount;r++)n.set(e[3*r],e[3*r+1],e[3*r+2]).scale(1/t.quantizedRange).multiply(t.quantizedVolumeScale).add(t.quantizedVolumeOffset).toArray(i,3*r);return i}async function parsePointCloud3DTile(t,e,n,i,r){n=parse3DTileTablesSync(t,e,n=parse3DTileTablesHeaderSync(t,e,n=parse3DTileHeaderSync(t,e,n))),initializeTile(t);const{featureTable:o,batchTable:s}=parsePointCloudTables(t);return await parseDraco(t,o,s,i,r),parsePositions(t,o,i),parseColors(t,o,s),parseNormals(t,o),n}function initializeTile(t){t.attributes={positions:null,colors:null,normals:null,batchIds:null},t.isQuantized=!1,t.isTranslucent=!1,t.isRGB565=!1,t.isOctEncoded16P=!1}function parsePointCloudTables(t){const e=new Tile3DFeatureTable(t.featureTableJson,t.featureTableBinary),n=e.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(n))throw new Error("POINTS_LENGTH must be defined");e.featuresLength=n,t.featuresLength=n,t.pointsLength=n,t.pointCount=n,t.rtcCenter=e.getGlobalProperty("RTC_CENTER",GL$1.FLOAT,3);return{featureTable:e,batchTable:parseBatchIds(t,e)}}function parsePositions(t,e,n){if(!t.attributes.positions)if(e.hasProperty("POSITION"))t.attributes.positions=e.getPropertyArray("POSITION",GL$1.FLOAT,3);else if(e.hasProperty("POSITION_QUANTIZED")){const i=e.getPropertyArray("POSITION_QUANTIZED",GL$1.UNSIGNED_SHORT,3);if(t.isQuantized=!0,t.quantizedRange=65535,t.quantizedVolumeScale=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",GL$1.FLOAT,3),!t.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(t.quantizedVolumeOffset=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",GL$1.FLOAT,3),!t.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");t.attributes.positions=normalize3DTilePositionAttribute(t,i,n)}if(!t.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function parseColors(t,e,n){if(!t.attributes.colors){let i=null;e.hasProperty("RGBA")?(i=e.getPropertyArray("RGBA",GL$1.UNSIGNED_BYTE,4),t.isTranslucent=!0):e.hasProperty("RGB")?i=e.getPropertyArray("RGB",GL$1.UNSIGNED_BYTE,3):e.hasProperty("RGB565")&&(i=e.getPropertyArray("RGB565",GL$1.UNSIGNED_SHORT,1),t.isRGB565=!0),t.attributes.colors=normalize3DTileColorAttribute(t,i,n)}e.hasProperty("CONSTANT_RGBA")&&(t.constantRGBA=e.getGlobalProperty("CONSTANT_RGBA",GL$1.UNSIGNED_BYTE,4))}function parseNormals(t,e){if(!t.attributes.normals){let n=null;e.hasProperty("NORMAL")?n=e.getPropertyArray("NORMAL",GL$1.FLOAT,3):e.hasProperty("NORMAL_OCT16P")&&(n=e.getPropertyArray("NORMAL_OCT16P",GL$1.UNSIGNED_BYTE,2),t.isOctEncoded16P=!0),t.attributes.normals=normalize3DTileNormalAttribute(t,n)}}function parseBatchIds(t,e){let n=null;if(!t.batchIds&&e.hasProperty("BATCH_ID")&&(t.batchIds=e.getPropertyArray("BATCH_ID",GL$1.UNSIGNED_SHORT,1),t.batchIds)){const i=e.getGlobalProperty("BATCH_LENGTH");if(!i)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:r,batchTableBinary:o}=t;n=new Tile3DBatchTableParser(r,o,i)}return n}async function parseDraco(t,e,n,i,r){let o,s,a;const l=t.batchTableJson&&t.batchTableJson.extensions&&t.batchTableJson.extensions["3DTILES_draco_point_compression"];l&&(a=l.properties);const c=e.getExtension("3DTILES_draco_point_compression");if(c){s=c.properties;const e=c.byteOffset,n=c.byteLength;if(!s||!Number.isFinite(e)||!n)throw new Error("Draco properties, byteOffset, and byteLength must be defined");o=t.featureTableBinary.slice(e,e+n),t.hasPositions=Number.isFinite(s.POSITION),t.hasColors=Number.isFinite(s.RGB)||Number.isFinite(s.RGBA),t.hasNormals=Number.isFinite(s.NORMAL),t.hasBatchIds=Number.isFinite(s.BATCH_ID),t.isTranslucent=Number.isFinite(s.RGBA)}if(!o)return!0;const u={buffer:o,properties:{...s,...a},featureTableProperties:s,batchTableProperties:a,dequantizeInShader:!1};return await loadDraco(t,u,i,r)}async function loadDraco(t,e,n,i){const{parse:r}=i,o={...n,draco:{...n.draco,extraAttributes:e.batchTableProperties||{}}};delete o["3d-tiles"];const s=await r(e.buffer,DracoLoader,o),a=s.attributes.POSITION&&s.attributes.POSITION.value,l=s.attributes.COLOR_0&&s.attributes.COLOR_0.value,c=s.attributes.NORMAL&&s.attributes.NORMAL.value,u=s.attributes.BATCH_ID&&s.attributes.BATCH_ID.value,h=c&&s.attributes.NORMAL.value.quantization;if(a&&s.attributes.POSITION.value.quantization){const e=s.POSITION.data.quantization,n=e.range;t.quantizedVolumeScale=new Vector3$1(n,n,n),t.quantizedVolumeOffset=new Vector3$1(e.minValues),t.quantizedRange=(1<<e.quantizationBits)-1,t.isQuantizedDraco=!0}h&&(t.octEncodedRange=(1<<s.NORMAL.data.quantization.quantizationBits)-1,t.isOctEncodedDraco=!0);const d={};if(e.batchTableProperties)for(const t of Object.keys(e.batchTableProperties))s.attributes[t]&&s.attributes[t].value&&(d[t.toLowerCase()]=s.attributes[t].value);t.attributes={positions:a,colors:normalize3DTileColorAttribute(t,l,void 0),normals:c,batchIds:u,...d}}const GLTF_FORMAT={URI:0,EMBEDDED:1};function parse3DTileGLTFViewSync(t,e,n,i){t.rotateYtoZ=!0;const r=t.byteOffset+t.byteLength-n;if(0===r)throw new Error("glTF byte length must be greater than 0.");return t.gltfUpAxis=i["3d-tiles"]&&i["3d-tiles"].assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",t.gltfArrayBuffer=sliceArrayBuffer(e,n,r),t.gltfByteOffset=0,t.gltfByteLength=r,t.byteOffset+t.byteLength}async function extractGLTF(t,e,n,i){const r=n["3d-tiles"]||{};if(extractGLTFBufferOrURL(t,e),r.loadGLTF){const{parse:e,fetch:r}=i;t.gltfUrl&&(t.gltfArrayBuffer=await r(t.gltfUrl,n),t.gltfByteOffset=0),t.gltfArrayBuffer&&(t.gltf=await e(t.gltfArrayBuffer,GLTFLoader$1,n,i),t.gpuMemoryUsageInBytes=getMemoryUsageGLTF(t.gltf),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength)}}function extractGLTFBufferOrURL(t,e,n){switch(e){case GLTF_FORMAT.URI:const e=new Uint8Array(t.gltfArrayBuffer,t.gltfByteOffset),n=(new TextDecoder).decode(e);t.gltfUrl=n.replace(/[\s\0]+$/,""),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength;break;case GLTF_FORMAT.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function parseBatchedModel3DTile(t,e,n,i,r){var o;n=parseBatchedModel(t,e,n,i),await extractGLTF(t,GLTF_FORMAT.EMBEDDED,i,r);const s=null==t||null===(o=t.gltf)||void 0===o?void 0:o.extensions;return s&&s.CESIUM_RTC&&(t.rtcCenter=s.CESIUM_RTC.center),n}function parseBatchedModel(t,e,n,i,r){n=parse3DTileGLTFViewSync(t,e,n=parse3DTileTablesSync(t,e,n=parse3DTileTablesHeaderSync(t,e,n=parse3DTileHeaderSync(t,e,n))),i);const o=new Tile3DFeatureTable(t.featureTableJson,t.featureTableBinary);return t.rtcCenter=o.getGlobalProperty("RTC_CENTER",GL$1.FLOAT,3),n}async function parseInstancedModel3DTile(t,e,n,i,r){return n=parseInstancedModel(t,e,n,i),await extractGLTF(t,t.gltfFormat,i,r),n}function parseInstancedModel(t,e,n,i,r){if(n=parse3DTileHeaderSync(t,e,n),1!==t.version)throw new Error("Instanced 3D Model version ".concat(t.version," is not supported"));n=parse3DTileTablesHeaderSync(t,e,n);const o=new DataView(e);if(t.gltfFormat=o.getUint32(n,!0),n=parse3DTileGLTFViewSync(t,e,n=parse3DTileTablesSync(t,e,n+=4),i),0===t.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const s=new Tile3DFeatureTable(t.featureTableJson,t.featureTableBinary),a=s.getGlobalProperty("INSTANCES_LENGTH");if(s.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");t.eastNorthUp=s.getGlobalProperty("EAST_NORTH_UP"),t.rtcCenter=s.getGlobalProperty("RTC_CENTER",GL$1.FLOAT,3);return extractInstancedAttributes(t,s,new Tile3DBatchTableParser(t.batchTableJson,t.batchTableBinary,a),a),n}function extractInstancedAttributes(t,e,n,i){const r={instances:new Array(i),batchTable:t._batchTable,cull:!1,url:void 0,gltf:void 0,basePath:void 0,incrementallyLoadTextures:!1,forwardAxis:[1,0,0]}.instances,o=new Vector3$1;new Vector3$1,new Vector3$1,new Vector3$1;const s=new Matrix3$1,a=new Quaternion$1,l=new Vector3$1,c={},u=new Matrix4$1,h=[],d=[],p=new Vector3$1,f=new Vector3$1;for(let n=0;n<i;n++){let i;if(e.hasProperty("POSITION"))i=e.getProperty("POSITION",GL$1.FLOAT,3,n,o);else if(e.hasProperty("POSITION_QUANTIZED")){i=e.getProperty("POSITION_QUANTIZED",GL$1.UNSIGNED_SHORT,3,n,o);const t=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",GL$1.FLOAT,3,p);if(!t)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const r=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",GL$1.FLOAT,3,f);if(!r)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const s=65535;for(let e=0;e<3;e++)i[e]=i[e]/s*r[e]+t[e]}if(!i)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(o.copy(i),c.translation=o,t.normalUp=e.getProperty("NORMAL_UP",GL$1.FLOAT,3,n,h),t.normalRight=e.getProperty("NORMAL_RIGHT",GL$1.FLOAT,3,n,d),t.normalUp){if(!t.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");t.hasCustomOrientation=!0}else{if(t.octNormalUp=e.getProperty("NORMAL_UP_OCT32P",GL$1.UNSIGNED_SHORT,2,h),t.octNormalRight=e.getProperty("NORMAL_RIGHT_OCT32P",GL$1.UNSIGNED_SHORT,2,d),t.octNormalUp){if(!t.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")}t.eastNorthUp?(Ellipsoid.WGS84.eastNorthUpToFixedFrame(o,u),u.getRotationMatrix3(s)):s.identity()}a.fromMatrix3(s),c.rotation=a,l.set(1,1,1);const m=e.getProperty("SCALE",GL$1.FLOAT,1,n);Number.isFinite(m)&&l.multiplyByScalar(m);const g=e.getProperty("SCALE_NON_UNIFORM",GL$1.FLOAT,3,n,h);g&&l.scale(g),c.scale=l;let _=e.getProperty("BATCH_ID",GL$1.UNSIGNED_SHORT,1,n);void 0===_&&(_=n);const y=(new Matrix4$1).fromQuaternion(c.rotation);u.identity(),u.translate(c.translation),u.multiplyRight(y),u.scale(c.scale);const v=u.clone();r[n]={modelMatrix:v,batchId:_}}t.instances=r}async function parseComposite3DTile(t,e,n,i,r,o){n=parse3DTileHeaderSync(t,e,n);const s=new DataView(e);for(t.tilesLength=s.getUint32(n,!0),n+=4,t.tiles=[];t.tiles.length<t.tilesLength&&t.byteLength-n>12;){const s={};t.tiles.push(s),n=await o(e,n,i,r,s)}return n}async function parseGltf3DTile(t,e,n,i){t.rotateYtoZ=!0,t.gltfUpAxis=n["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y";const{parse:r}=i;t.gltf=await r(e,GLTFLoader$1,n,i),t.gpuMemoryUsageInBytes=getMemoryUsageGLTF(t.gltf)}async function parse3DTile(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};switch(r.byteOffset=e,r.type=getMagicString(t,e),r.type){case TILE3D_TYPE.COMPOSITE:return await parseComposite3DTile(r,t,e,n,i,parse3DTile);case TILE3D_TYPE.BATCHED_3D_MODEL:return await parseBatchedModel3DTile(r,t,e,n,i);case TILE3D_TYPE.GLTF:return await parseGltf3DTile(r,t,n,i);case TILE3D_TYPE.INSTANCED_3D_MODEL:return await parseInstancedModel3DTile(r,t,e,n,i);case TILE3D_TYPE.POINT_CLOUD:return await parsePointCloud3DTile(r,t,e,n,i);default:throw new Error("3DTileLoader: unknown type ".concat(r.type))}}const SUBTREE_FILE_MAGIC=1952609651,SUBTREE_FILE_VERSION=1;async function parse3DTilesSubtree(t,e,n){if(new Uint32Array(t.slice(0,4))[0]!==SUBTREE_FILE_MAGIC)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==SUBTREE_FILE_VERSION)throw new Error("Wrong subtree file verson, must be 1");const i=parseUint64Value(t.slice(8,16)),r=new Uint8Array(t,24,i),o=new TextDecoder("utf8").decode(r),s=JSON.parse(o),a=parseUint64Value(t.slice(16,24));let l=new ArrayBuffer(0);return a&&(l=t.slice(24+i)),"bufferView"in s.tileAvailability&&(s.tileAvailability.explicitBitstream=await getExplicitBitstream(s,"tileAvailability",l,n)),"bufferView"in s.contentAvailability&&(s.contentAvailability.explicitBitstream=await getExplicitBitstream(s,"contentAvailability",l,n)),"bufferView"in s.childSubtreeAvailability&&(s.childSubtreeAvailability.explicitBitstream=await getExplicitBitstream(s,"childSubtreeAvailability",l,n)),s}function resolveBufferUri(t,e){if(e.startsWith("http")){const n=new URL(t,e);return decodeURI(n.toString())}const n="http://".concat(e),i=new URL(t,n);return"/".concat(i.host).concat(i.pathname)}async function getExplicitBitstream(t,e,n,i){const r=t.bufferViews[t[e].bufferView],o=t.buffers[r.buffer];if(null==i||!i.url||!i.fetch)throw new Error("Url is not provided");if(!i.fetch)throw new Error("fetch is not provided");if(o.uri){const t=resolveBufferUri(o.uri,null==i?void 0:i.url),e=await i.fetch(t),n=await e.arrayBuffer();return new Uint8Array(n,r.byteOffset,r.byteLength)}return new Uint8Array(n,r.byteOffset,r.byteLength)}function parseUint64Value(t){const e=new DataView(t);return e.getUint32(0,!0)+2**32*e.getUint32(4,!0)}const Tile3DSubtreeLoader={id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:VERSION,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:parse3DTilesSubtree,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 wasm=null;try{wasm=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(t){}function Long(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function isLong(t){return!0===(t&&t.__isLong__)}function ctz32(t){var e=Math.clz32(t&-t);return t?31-e:e}Object.defineProperty(Long.prototype,"__isLong__",{value:!0}),Long.isLong=isLong;var INT_CACHE={},UINT_CACHE={};function fromInt(t,e){var n,i,r;return e?(r=0<=(t>>>=0)&&t<256)&&(i=UINT_CACHE[t])?i:(n=fromBits(t,0,!0),r&&(UINT_CACHE[t]=n),n):(r=-128<=(t|=0)&&t<128)&&(i=INT_CACHE[t])?i:(n=fromBits(t,t<0?-1:0,!1),r&&(INT_CACHE[t]=n),n)}function fromNumber(t,e){if(isNaN(t))return e?UZERO:ZERO;if(e){if(t<0)return UZERO;if(t>=TWO_PWR_64_DBL)return MAX_UNSIGNED_VALUE}else{if(t<=-TWO_PWR_63_DBL)return MIN_VALUE;if(t+1>=TWO_PWR_63_DBL)return MAX_VALUE}return t<0?fromNumber(-t,e).neg():fromBits(t%TWO_PWR_32_DBL|0,t/TWO_PWR_32_DBL|0,e)}function fromBits(t,e,n){return new Long(t,e,n)}Long.fromInt=fromInt,Long.fromNumber=fromNumber,Long.fromBits=fromBits;var pow_dbl=Math.pow;function fromString(t,e,n){if(0===t.length)throw Error("empty string");if("number"==typeof e?(n=e,e=!1):e=!!e,"NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e?UZERO:ZERO;if((n=n||10)<2||36<n)throw RangeError("radix");var i;if((i=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return fromString(t.substring(1),e,n).neg();for(var r=fromNumber(pow_dbl(n,8)),o=ZERO,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),l=parseInt(t.substring(s,s+a),n);if(a<8){var c=fromNumber(pow_dbl(n,a));o=o.mul(c).add(fromNumber(l))}else o=(o=o.mul(r)).add(fromNumber(l))}return o.unsigned=e,o}function fromValue(t,e){return"number"==typeof t?fromNumber(t,e):"string"==typeof t?fromString(t,e):fromBits(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}Long.fromString=fromString,Long.fromValue=fromValue;var TWO_PWR_16_DBL=65536,TWO_PWR_24_DBL=1<<24,TWO_PWR_32_DBL=TWO_PWR_16_DBL*TWO_PWR_16_DBL,TWO_PWR_64_DBL=TWO_PWR_32_DBL*TWO_PWR_32_DBL,TWO_PWR_63_DBL=TWO_PWR_64_DBL/2,TWO_PWR_24=fromInt(TWO_PWR_24_DBL),ZERO=fromInt(0);Long.ZERO=ZERO;var UZERO=fromInt(0,!0);Long.UZERO=UZERO;var ONE=fromInt(1);Long.ONE=ONE;var UONE=fromInt(1,!0);Long.UONE=UONE;var NEG_ONE=fromInt(-1);Long.NEG_ONE=NEG_ONE;var MAX_VALUE=fromBits(-1,2147483647,!1);Long.MAX_VALUE=MAX_VALUE;var MAX_UNSIGNED_VALUE=fromBits(-1,-1,!0);Long.MAX_UNSIGNED_VALUE=MAX_UNSIGNED_VALUE;var MIN_VALUE=fromBits(0,-2147483648,!1);Long.MIN_VALUE=MIN_VALUE;var LongPrototype=Long.prototype;LongPrototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},LongPrototype.toNumber=function(){return this.unsigned?(this.high>>>0)*TWO_PWR_32_DBL+(this.low>>>0):this.high*TWO_PWR_32_DBL+(this.low>>>0)},LongPrototype.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(MIN_VALUE)){var e=fromNumber(t),n=this.div(e),i=n.mul(e).sub(this);return n.toString(t)+i.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var r=fromNumber(pow_dbl(t,6),this.unsigned),o=this,s="";;){var a=o.div(r),l=(o.sub(a.mul(r)).toInt()>>>0).toString(t);if((o=a).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},LongPrototype.getHighBits=function(){return this.high},LongPrototype.getHighBitsUnsigned=function(){return this.high>>>0},LongPrototype.getLowBits=function(){return this.low},LongPrototype.getLowBitsUnsigned=function(){return this.low>>>0},LongPrototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(MIN_VALUE)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&!(t&1<<e);e--);return 0!=this.high?e+33:e+1},LongPrototype.isZero=function(){return 0===this.high&&0===this.low},LongPrototype.eqz=LongPrototype.isZero,LongPrototype.isNegative=function(){return!this.unsigned&&this.high<0},LongPrototype.isPositive=function(){return this.unsigned||this.high>=0},LongPrototype.isOdd=function(){return!(1&~this.low)},LongPrototype.isEven=function(){return!(1&this.low)},LongPrototype.equals=function(t){return isLong(t)||(t=fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},LongPrototype.eq=LongPrototype.equals,LongPrototype.notEquals=function(t){return!this.eq(t)},LongPrototype.neq=LongPrototype.notEquals,LongPrototype.ne=LongPrototype.notEquals,LongPrototype.lessThan=function(t){return this.comp(t)<0},LongPrototype.lt=LongPrototype.lessThan,LongPrototype.lessThanOrEqual=function(t){return this.comp(t)<=0},LongPrototype.lte=LongPrototype.lessThanOrEqual,LongPrototype.le=LongPrototype.lessThanOrEqual,LongPrototype.greaterThan=function(t){return this.comp(t)>0},LongPrototype.gt=LongPrototype.greaterThan,LongPrototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},LongPrototype.gte=LongPrototype.greaterThanOrEqual,LongPrototype.ge=LongPrototype.greaterThanOrEqual,LongPrototype.compare=function(t){if(isLong(t)||(t=fromValue(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},LongPrototype.comp=LongPrototype.compare,LongPrototype.negate=function(){return!this.unsigned&&this.eq(MIN_VALUE)?MIN_VALUE:this.not().add(ONE)},LongPrototype.neg=LongPrototype.negate,LongPrototype.add=function(t){isLong(t)||(t=fromValue(t));var e=0,n=0,i=0,r=0;return i+=(r+=(65535&this.low)+(65535&t.low))>>>16,n+=(i+=(this.low>>>16)+(t.low>>>16))>>>16,e+=(n+=(65535&this.high)+(65535&t.high))>>>16,e+=(this.high>>>16)+(t.high>>>16),fromBits((i&=65535)<<16|(r&=65535),(e&=65535)<<16|(n&=65535),this.unsigned)},LongPrototype.subtract=function(t){return isLong(t)||(t=fromValue(t)),this.add(t.neg())},LongPrototype.sub=LongPrototype.subtract,LongPrototype.multiply=function(t){if(this.isZero())return this;if(isLong(t)||(t=fromValue(t)),wasm)return fromBits(wasm.mul(this.low,this.high,t.low,t.high),wasm.get_high(),this.unsigned);if(t.isZero())return this.unsigned?UZERO:ZERO;if(this.eq(MIN_VALUE))return t.isOdd()?MIN_VALUE:ZERO;if(t.eq(MIN_VALUE))return this.isOdd()?MIN_VALUE:ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(TWO_PWR_24)&&t.lt(TWO_PWR_24))return fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var e=65535&this.high,n=this.low>>>16,i=65535&this.low,r=65535&t.high,o=t.low>>>16,s=65535&t.low,a=0,l=0,c=0,u=0;return c+=(u+=i*s)>>>16,l+=(c+=n*s)>>>16,c&=65535,l+=(c+=i*o)>>>16,a+=(l+=e*s)>>>16,l&=65535,a+=(l+=n*o)>>>16,l&=65535,a+=(l+=i*r)>>>16,a+=(this.high>>>16)*s+e*o+n*r+i*(t.high>>>16),fromBits((c&=65535)<<16|(u&=65535),(a&=65535)<<16|(l&=65535),this.unsigned)},LongPrototype.mul=LongPrototype.multiply,LongPrototype.divide=function(t){if(isLong(t)||(t=fromValue(t)),t.isZero())throw Error("division by zero");var e,n,i;if(wasm)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?fromBits((this.unsigned?wasm.div_u:wasm.div_s)(this.low,this.high,t.low,t.high),wasm.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?UZERO:ZERO;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return UZERO;if(t.gt(this.shru(1)))return UONE;i=UZERO}else{if(this.eq(MIN_VALUE))return t.eq(ONE)||t.eq(NEG_ONE)?MIN_VALUE:t.eq(MIN_VALUE)?ONE:(e=this.shr(1).div(t).shl(1)).eq(ZERO)?t.isNegative()?ONE:NEG_ONE:(n=this.sub(t.mul(e)),i=e.add(n.div(t)));if(t.eq(MIN_VALUE))return this.unsigned?UZERO:ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=ZERO}for(n=this;n.gte(t);){e=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var r=Math.ceil(Math.log(e)/Math.LN2),o=r<=48?1:pow_dbl(2,r-48),s=fromNumber(e),a=s.mul(t);a.isNegative()||a.gt(n);)a=(s=fromNumber(e-=o,this.unsigned)).mul(t);s.isZero()&&(s=ONE),i=i.add(s),n=n.sub(a)}return i},LongPrototype.div=LongPrototype.divide,LongPrototype.modulo=function(t){return isLong(t)||(t=fromValue(t)),wasm?fromBits((this.unsigned?wasm.rem_u:wasm.rem_s)(this.low,this.high,t.low,t.high),wasm.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},LongPrototype.mod=LongPrototype.modulo,LongPrototype.rem=LongPrototype.modulo,LongPrototype.not=function(){return fromBits(~this.low,~this.high,this.unsigned)},LongPrototype.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},LongPrototype.clz=LongPrototype.countLeadingZeros,LongPrototype.countTrailingZeros=function(){return this.low?ctz32(this.low):ctz32(this.high)+32},LongPrototype.ctz=LongPrototype.countTrailingZeros,LongPrototype.and=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low&t.low,this.high&t.high,this.unsigned)},LongPrototype.or=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low|t.low,this.high|t.high,this.unsigned)},LongPrototype.xor=function(t){return isLong(t)||(t=fromValue(t)),fromBits(this.low^t.low,this.high^t.high,this.unsigned)},LongPrototype.shiftLeft=function(t){return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):fromBits(0,this.low<<t-32,this.unsigned)},LongPrototype.shl=LongPrototype.shiftLeft,LongPrototype.shiftRight=function(t){return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},LongPrototype.shr=LongPrototype.shiftRight,LongPrototype.shiftRightUnsigned=function(t){return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?fromBits(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):fromBits(32===t?this.high:this.high>>>t-32,0,this.unsigned)},LongPrototype.shru=LongPrototype.shiftRightUnsigned,LongPrototype.shr_u=LongPrototype.shiftRightUnsigned,LongPrototype.rotateLeft=function(t){var e;return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?fromBits(this.high,this.low,this.unsigned):t<32?fromBits(this.low<<t|this.high>>>(e=32-t),this.high<<t|this.low>>>e,this.unsigned):fromBits(this.high<<(t-=32)|this.low>>>(e=32-t),this.low<<t|this.high>>>e,this.unsigned)},LongPrototype.rotl=LongPrototype.rotateLeft,LongPrototype.rotateRight=function(t){var e;return isLong(t)&&(t=t.toInt()),0==(t&=63)?this:32===t?fromBits(this.high,this.low,this.unsigned):t<32?fromBits(this.high<<(e=32-t)|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned):fromBits(this.low<<(e=32-(t-=32))|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)},LongPrototype.rotr=LongPrototype.rotateRight,LongPrototype.toSigned=function(){return this.unsigned?fromBits(this.low,this.high,!1):this},LongPrototype.toUnsigned=function(){return this.unsigned?this:fromBits(this.low,this.high,!0)},LongPrototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},LongPrototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},LongPrototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},Long.fromBytes=function(t,e,n){return n?Long.fromBytesLE(t,e):Long.fromBytesBE(t,e)},Long.fromBytesLE=function(t,e){return new Long(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},Long.fromBytesBE=function(t,e){return new Long(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)};const MAXIMUM_TOKEN_LENGTH=16;function getS2CellIdFromToken(t){"X"===t&&(t="");const e=t.padEnd(MAXIMUM_TOKEN_LENGTH,"0");return Long.fromString(e,!0,16)}function getS2TokenFromCellId(t){if(t.isZero())return"X";let e=t.countTrailingZeros();e=(e-e%4)/4;const n=e;e*=4;const i=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-n-i.length).join("0")+i}function getS2ChildCellId(t,e){const n=lsb(t).shiftRightUnsigned(2);return t.add(Long.fromNumber(2*e+1-4).multiply(n))}function lsb(t){return t.and(t.not().add(1))}const FACE_BITS=3,MAX_LEVEL=30,POS_BITS=2*MAX_LEVEL+1,RADIAN_TO_DEGREE=180/Math.PI;function getS2CellFromQuadKey(t){if(0===t.length)throw new Error("Invalid Hilbert quad key ".concat(t));const e=t.split("/"),n=parseInt(e[0],10),i=e[1],r=i.length;let o=0;const s=[0,0];for(let t=r-1;t>=0;t--){o=r-t;const e=i[t];let n=0,a=0;"1"===e?a=1:"2"===e?(n=1,a=1):"3"===e&&(n=1);const l=Math.pow(2,o-1);rotateAndFlipQuadrant(l,s,n,a),s[0]+=l*n,s[1]+=l*a}if(n%2==1){const t=s[0];s[0]=s[1],s[1]=t}return{face:n,ij:s,level:o}}function getS2QuadkeyFromCellId(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length<FACE_BITS+POS_BITS;)e="0"+e;const n=e.lastIndexOf("1"),i=e.substring(0,3),r=e.substring(3,n),o=r.length/2,s=Long.fromString(i,!0,2).toString(10);let a="";if(0!==o)for(a=Long.fromString(r,!0,2).toString(4);a.length<o;)a="0"+a;return"".concat(s,"/").concat(a)}function IJToST(t,e,n){const i=1<<e;return[(t[0]+n[0])/i,(t[1]+n[1])/i]}function singleSTtoUV(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function STToUV(t){return[singleSTtoUV(t[0]),singleSTtoUV(t[1])]}function FaceUVToXYZ(t,e){let[n,i]=e;switch(t){case 0:return[1,n,i];case 1:return[-n,1,i];case 2:return[-n,-i,1];case 3:return[-1,-i,-n];case 4:return[i,-1,-n];case 5:return[i,n,-1];default:throw new Error("Invalid face")}}function XYZToLngLat(t){let[e,n,i]=t;const r=Math.atan2(i,Math.sqrt(e*e+n*n));return[Math.atan2(n,e)*RADIAN_TO_DEGREE,r*RADIAN_TO_DEGREE]}function rotateAndFlipQuadrant(t,e,n,i){if(0===i){1===n&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);const i=e[0];e[0]=e[1],e[1]=i}}function getS2LngLatFromS2Cell(t){const e=STToUV(IJToST(t.ij,t.level,[.5,.5]));return XYZToLngLat(FaceUVToXYZ(t.face,e))}const MAX_RESOLUTION=100;function getS2BoundaryFlatFromS2Cell(t){const{face:e,ij:n,level:i}=t,r=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(MAX_RESOLUTION*Math.pow(2,-i))),s=new Float64Array(4*o*2+2);let a=0,l=0;for(let t=0;t<4;t++){const c=r[t].slice(0),u=r[t+1],h=(u[0]-c[0])/o,d=(u[1]-c[1])/o;for(let t=0;t<o;t++){c[0]+=h,c[1]+=d;const t=XYZToLngLat(FaceUVToXYZ(e,STToUV(IJToST(n,i,c))));Math.abs(t[1])>89.999&&(t[0]=l);const r=t[0]-l;t[0]+=r>180?-360:r<-180?360:0,s[a++]=t[0],s[a++]=t[1],l=t[0]}}return s[a++]=s[0],s[a++]=s[1],s}function getS2Cell(t){return getS2CellFromQuadKey(getS2QuadKey(t))}function getS2QuadKey(t){if(t.indexOf("/")>0)return t;return getS2QuadkeyFromCellId(getS2CellIdFromToken(t))}function getS2LngLat(t){return getS2LngLatFromS2Cell(getS2Cell(t))}function getS2Region(t){let e;if(2===t.face||5===t.face){let n=null,i=0;for(let e=0;e<4;e++){const r=getS2BoundaryFlatFromS2Cell(getS2Cell("".concat(t.face,"/").concat(e)));null==n&&(n=new Float64Array(4*r.length)),n.set(r,i),i+=r.length}e=get2DRegionFromS2Corners(n)}else{e=get2DRegionFromS2Corners(getS2BoundaryFlatFromS2Cell(t))}return e}function get2DRegionFromS2Corners(t){if(t.length%2!=0)throw new Error("Invalid corners");const e=[],n=[];for(let i=0;i<t.length;i+=2)e.push(t[i]),n.push(t[i+1]);return e.sort(((t,e)=>t-e)),n.sort(((t,e)=>t-e)),{west:e[0],east:e[e.length-1],north:n[n.length-1],south:n[0]}}function getS2OrientedBoundingBoxCornerPoints(t,e){const n=(null==e?void 0:e.minimumHeight)||0,i=(null==e?void 0:e.maximumHeight)||0,r=getS2Region(getS2Cell(t)),o=r.west,s=r.south,a=r.east,l=r.north,c=[];return c.push(new Vector3$1(o,l,n)),c.push(new Vector3$1(a,l,n)),c.push(new Vector3$1(a,s,n)),c.push(new Vector3$1(o,s,n)),c.push(new Vector3$1(o,l,i)),c.push(new Vector3$1(a,l,i)),c.push(new Vector3$1(a,s,i)),c.push(new Vector3$1(o,s,i)),c}function convertS2BoundingVolumetoOBB(t){const e=t.token,n={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},i=getS2OrientedBoundingBoxCornerPoints(e,n),r=getS2LngLat(e),o=Ellipsoid.WGS84.cartographicToCartesian([r[0],r[1],n.maximumHeight]),s=new Vector3$1(o[0],o[1],o[2]);i.push(s);const a=makeOrientedBoundingBoxFromPoints(i);return[...a.center,...a.halfAxes]}const QUADTREE_DEVISION_COUNT=4,OCTREE_DEVISION_COUNT=8,SUBDIVISION_COUNT_MAP={QUADTREE:QUADTREE_DEVISION_COUNT,OCTREE:OCTREE_DEVISION_COUNT};function getChildS2VolumeBox(t,e,n){if(null!=t&&t.box){const i=getS2TokenFromCellId(getS2ChildCellId(getS2CellIdFromToken(t.s2VolumeInfo.token),e)),r={...t.s2VolumeInfo};if(r.token=i,"OCTREE"===n){const e=t.s2VolumeInfo,n=e.maximumHeight-e.minimumHeight,i=n/2,r=e.minimumHeight+n/2;e.minimumHeight=r-i,e.maximumHeight=r+i}return{box:convertS2BoundingVolumetoOBB(r),s2VolumeInfo:r}}}async function parseImplicitTiles(t){const{options:e,parentData:n={mortonIndex:0,x:0,y:0,z:0},childIndex:i=0,globalData:r={level:0,mortonIndex:0,x:0,y:0,z:0},s2VolumeBox:o}=t;let{subtree:s,level:a=0}=t;const{subdivisionScheme:l,subtreeLevels:c,maximumLevel:u,contentUrlTemplate:h,subtreesUriTemplate:d,basePath:p}=e,f={children:[],lodMetricValue:0,contentUrl:""},m=SUBDIVISION_COUNT_MAP[l],g=1&i,_=i>>1&1,y=i>>2&1,v=(m**a-1)/(m-1);let x=concatBits(n.mortonIndex,i),b=v+x,T=concatBits(n.x,g),E=concatBits(n.y,_),S=concatBits(n.z,y),w=!1;a+1>c&&(w=getAvailabilityResult(s.childSubtreeAvailability,x));const A=concatBits(r.x,T),M=concatBits(r.y,E),C=concatBits(r.z,S),I=a+r.level;if(w){const t=replaceContentUrlTemplate("".concat(p,"/").concat(d),I,A,M,C);s=await load(t,Tile3DSubtreeLoader),r.mortonIndex=x,r.x=T,r.y=E,r.z=S,r.level=a,x=0,b=0,T=0,E=0,S=0,a=0}if(!getAvailabilityResult(s.tileAvailability,b)||a>u)return f;getAvailabilityResult(s.contentAvailability,b)&&(f.contentUrl=replaceContentUrlTemplate(h,I,A,M,C));const P=a+1,L={mortonIndex:x,x:T,y:E,z:S};for(let t=0;t<m;t++){const n=getChildS2VolumeBox(o,t,l),i=await parseImplicitTiles({subtree:s,options:e,parentData:L,childIndex:t,level:P,globalData:r,s2VolumeBox:n});if(i.contentUrl||i.children.length){const t=formatTileData(i,I+1,{childTileX:T,childTileY:E,childTileZ:S},e,o);f.children.push(t)}}return f}function getAvailabilityResult(t,e){return"constant"in t?Boolean(t.constant):!!t.explicitBitstream&&getBooleanValueFromBitstream(e,t.explicitBitstream)}function formatTileData(t,e,n,i,r){const{basePath:o,refine:s,getRefine:a,lodMetricType:l,getTileType:c,rootLodMetricValue:u,rootBoundingVolume:h}=i,d=t.contentUrl&&t.contentUrl.replace("".concat(o,"/"),""),p=u/2**e,f=calculateBoundingVolumeForChildTile(e,null!=r&&r.box?{box:r.box}:h,n);return{children:t.children,contentUrl:t.contentUrl,content:{uri:d},id:t.contentUrl,refine:a(s),type:c(t),lodMetricType:l,lodMetricValue:p,geometricError:p,transform:t.transform,boundingVolume:f}}function calculateBoundingVolumeForChildTile(t,e,n){if(e.region){const{childTileX:i,childTileY:r,childTileZ:o}=n,[s,a,l,c,u,h]=e.region,d=2**t,p=(l-s)/d,f=(c-a)/d,m=(h-u)/d,[g,_]=[s+p*i,s+p*(i+1)],[y,v]=[a+f*r,a+f*(r+1)],[x,b]=[u+m*o,u+m*(o+1)];return{region:[g,y,_,v,x,b]}}if(e.box)return e;throw new Error("Unsupported bounding volume type ".concat(e))}function concatBits(t,e){return parseInt(t.toString(2)+e.toString(2),2)}function replaceContentUrlTemplate(t,e,n,i,r){const o=generateMapUrl({level:e,x:n,y:i,z:r});return t.replace(/{level}|{x}|{y}|{z}/gi,(t=>o[t]))}function generateMapUrl(t){const e={};for(const n in t)e["{".concat(n,"}")]=t[n];return e}function getBooleanValueFromBitstream(t,e){return 1===(e[Math.floor(t/8)]>>t%8&1)}function getTileType(t){if(!t.contentUrl)return TILE_TYPE.EMPTY;const e=t.contentUrl.split("?")[0].split(".").pop();switch(e){case"pnts":return TILE_TYPE.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return TILE_TYPE.SCENEGRAPH;default:return e}}function getRefine(t){switch(t){case"REPLACE":case"replace":return TILE_REFINEMENT.REPLACE;case"ADD":case"add":return TILE_REFINEMENT.ADD;default:return t}}function resolveUri(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){const n=new URL(t,"".concat(e,"/"));return decodeURI(n.toString())}return t.startsWith("/")?t:"".concat(e,"/").concat(t)}function normalizeTileData(t,e){if(!t)return null;if(t.content){t.contentUrl=resolveUri(t.content.uri||t.content.url,e.basePath)}return t.id=t.contentUrl,t.lodMetricType=LOD_METRIC_TYPE.GEOMETRIC_ERROR,t.lodMetricValue=t.geometricError,t.transformMatrix=t.transform,t.type=getTileType(t),t.refine=getRefine(t.refine),t}async function normalizeTileHeaders(t,e){const n=t.basePath;let i;const r=getImplicitTilingExtensionData(null==t?void 0:t.root);i=r&&t.root?await normalizeImplicitTileHeaders(t.root,t,r,e):normalizeTileData(t.root,t);const o=[];for(o.push(i);o.length>0;){const i=(o.pop()||{}).children||[];for(let r of i){const i=getImplicitTilingExtensionData(r);i?r=await normalizeImplicitTileHeaders(r,t,i,e):normalizeTileData(r,{basePath:n}),o.push(r)}}return i}async function normalizeImplicitTileHeaders(t,e,n,i){var r,o;const s=e.basePath,{subdivisionScheme:a,maximumLevel:l,subtreeLevels:c,subtrees:{uri:u}}=n,h=resolveUri(replaceContentUrlTemplate(u,0,0,0,0),s),d=await load(h,Tile3DSubtreeLoader,i),p=resolveUri(t.content.uri,s),f=null==e||null===(r=e.root)||void 0===r?void 0:r.refine,m=t.geometricError,g=null===(o=t.boundingVolume.extensions)||void 0===o?void 0:o["3DTILES_bounding_volume_S2"];if(g){const e=convertS2BoundingVolumetoOBB(g);t.boundingVolume={box:e,s2VolumeInfo:g}}const _={contentUrlTemplate:p,subtreesUriTemplate:u,subdivisionScheme:a,subtreeLevels:c,maximumLevel:l,refine:f,basePath:s,lodMetricType:LOD_METRIC_TYPE.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:t.boundingVolume,getTileType:getTileType,getRefine:getRefine};return await normalizeImplicitTileData(t,d,_)}async function normalizeImplicitTileData(t,e,n){if(!t)return null;t.lodMetricType=LOD_METRIC_TYPE.GEOMETRIC_ERROR,t.lodMetricValue=t.geometricError,t.transformMatrix=t.transform;const{children:i,contentUrl:r}=await parseImplicitTiles({subtree:e,options:n,s2VolumeBox:t});return r&&(t.contentUrl=r,t.content={uri:r.replace("".concat(n.basePath,"/"),"")}),t.refine=getRefine(t.refine),t.type=getTileType(t),t.children=i,t.id=t.contentUrl,t}function getImplicitTilingExtensionData(t){var e;return(null==t||null===(e=t.extensions)||void 0===e?void 0:e["3DTILES_implicit_tiling"])||(null==t?void 0:t.implicitTiling)}const Tiles3DLoader={id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:VERSION,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:parse,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};function getBaseUri(t){return dirname(t.url)}async function parseTile(t,e,n){const i={featureIds:null};return await parse3DTile(t,0,e,n,i),i}async function parseTileset(t,e,n){var i;const r=JSON.parse((new TextDecoder).decode(t));return r.loader=e.loader||Tiles3DLoader,r.url=n.url,r.queryString=n.queryString,r.basePath=getBaseUri(r),r.root=await normalizeTileHeaders(r,e),r.type=TILESET_TYPE.TILES3D,r.lodMetricType=LOD_METRIC_TYPE.GEOMETRIC_ERROR,r.lodMetricValue=(null===(i=r.root)||void 0===i?void 0:i.lodMetricValue)||0,r}async function parse(t,e,n){const i=e["3d-tiles"]||{};let r;return r="auto"===i.isTileset?n.url&&-1!==n.url.indexOf(".json"):i.isTileset,t=r?await parseTileset(t,e,n):await parseTile(t,e,n)}const SINGLE_DATA=[0],defaultProps={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Tiles3DLoader,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,n)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}};let Tile3DLayer$1=class extends CompositeLayer{constructor(...t){super(...t),_defineProperty(this,"state",void 0)}initializeState(){"onTileLoadFail"in this.props&&log$2.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){var t,e;return Boolean((null===(t=this.state)||void 0===t||null===(e=t.tileset3d)||void 0===e?void 0:e.isLoaded())&&super.isLoaded)}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({props:t,oldProps:e,changeFlags:n}){if(t.data&&t.data!==e.data&&this._loadTileset(t.data),n.viewportChanged){const{activeViewports:t}=this.state;Object.keys(t).length&&(this._updateTileset(t),this.state.lastUpdatedViewports=t,this.state.activeViewports={})}if(n.propsChanged){const{layerMap:t}=this.state;for(const e in t)t[e].needsUpdate=!0}}activateViewport(t){const{activeViewports:e,lastUpdatedViewports:n}=this.state;this.internalState.viewport=t,e[t.id]=t;const i=null==n?void 0:n[t.id];i&&t.equals(i)||(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:t,sourceLayer:e}){const n=e&&e.props.tile;return t.picked&&(t.object=n),t.sourceTile=n,t}filterSubLayer({layer:t,viewport:e}){const{tile:n}=t.props,{id:i}=e;return n.selected&&n.viewportIds.includes(i)}_updateAutoHighlight(t){const e=t.sourceTile,n=this.state.layerMap[null==e?void 0:e.id];n&&n.layer&&n.layer.updateAutoHighlight(t)}async _loadTileset(t){const{loadOptions:e={}}=this.props;let n=this.props.loader||this.props.loaders;Array.isArray(n)&&(n=n[0]);const i={loadOptions:{...e}};let r=t;if(n.preload){const o=await n.preload(t,e);o.url&&(r=o.url),o.headers&&(i.loadOptions.fetch={...i.loadOptions.fetch,headers:o.headers}),Object.assign(i,o)}const o=await load(r,n,i.loadOptions),s=new Tileset3D(o,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...i});this.setState({tileset3d:s,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(s)}_onTileLoad(t){const{lastUpdatedViewports:e}=this.state;this.props.onTileLoad(t),this._updateTileset(e),this.setNeedsUpdate()}_onTileUnload(t){delete this.state.layerMap[t.id],this.props.onTileUnload(t)}_updateTileset(t){if(!t)return;const{tileset3d:e}=this.state,{timeline:n}=this.context,i=Object.keys(t).length;n&&i&&e&&e.selectTiles(Object.values(t)).then((t=>{this.state.frameNumber!==t&&this.setState({frameNumber:t})}))}_getSubLayer(t,e){if(!t.content)return null;switch(t.type){case TILE_TYPE.POINTCLOUD:return this._makePointCloudLayer(t,e);case TILE_TYPE.SCENEGRAPH:return this._make3DModelLayer(t);case TILE_TYPE.MESH:return this._makeSimpleMeshLayer(t,e);default:throw new Error("Tile3DLayer: Failed to render layer of type ".concat(t.content.type))}}_makePointCloudLayer(t,e){const{attributes:n,pointCount:i,constantRGBA:r,cartographicOrigin:o,modelMatrix:s}=t.content,{positions:a,normals:l,colors:c}=n;if(!a)return null;const u=e&&e.props.data||{header:{vertexCount:i},attributes:{POSITION:a,NORMAL:l,COLOR_0:c}},{pointSize:h,getPointColor:d}=this.props;return new(this.getSubLayerClass("pointcloud",PointCloudLayer))({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:"".concat(this.id,"-pointcloud-").concat(t.id),tile:t,data:u,coordinateSystem:COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:o,modelMatrix:s,getColor:r||d,_offset:0})}_make3DModelLayer(t){const{gltf:e,instances:n,cartographicOrigin:i,modelMatrix:r}=t.content;return new(this.getSubLayerClass("scenegraph",ScenegraphLayer))({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:"".concat(this.id,"-scenegraph-").concat(t.id),tile:t,data:n||SINGLE_DATA,scenegraph:e,coordinateSystem:COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:i,modelMatrix:r,getTransformMatrix:t=>t.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(t,e){const n=t.content,{attributes:i,indices:r,modelMatrix:o,cartographicOrigin:s,coordinateSystem:a=COORDINATE_SYSTEM.METER_OFFSETS,material:l,featureIds:c}=n,{_getMeshColor:u}=this.props,h=e&&e.props.mesh||new Geometry({drawMode:4,attributes:getMeshGeometry(i),indices:r});return new(this.getSubLayerClass("mesh",MeshLayer))(this.getSubLayerProps({id:"mesh"}),{id:"".concat(this.id,"-mesh-").concat(t.id),tile:t,mesh:h,data:SINGLE_DATA,getColor:u(t),pbrMaterial:l,modelMatrix:o,coordinateOrigin:s,coordinateSystem:a,featureIds:c,_offset:0})}renderLayers(){const{tileset3d:t,layerMap:e}=this.state;return t?t.tiles.map((t=>{const n=e[t.id]=e[t.id]||{tile:t};let{layer:i}=n;return t.selected&&(i?n.needsUpdate&&(i=this._getSubLayer(t,i),n.needsUpdate=!1):i=this._getSubLayer(t)),n.layer=i,i})).filter(Boolean):null}};function getMeshGeometry(t){const e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}_defineProperty(Tile3DLayer$1,"defaultProps",defaultProps),_defineProperty(Tile3DLayer$1,"layerName","Tile3DLayer");class Tile3DLayer{constructor(t){const e=this;e.implementation=t,e._tick=e._tick.bind(e)}onAdd(t,e){const n=this,i=n.implementation,r=Object.assign({},i,{type:Tile3DLayer$1}),o=i.lightColor,s=n.ambientLight=new AmbientLight$1({color:o,intensity:3}),a=n.directionalLight=new DirectionalLight$1({color:o,intensity:9,direction:[0,0,-1]}),l=t.map;n.map=t,delete r.lightColor,delete r.minzoom,delete r.maxzoom,l.addLayer(new MapboxLayer(r),e||"poi"),l.setLayerZoomRange(i.id,i.minzoom,i.maxzoom),l.__deck.props.effects=[new LightingEffect({ambientLight:s,directionalLight:a})],void 0===o&&n._tick()}_tick(){const t=this,{map:e,ambientLight:n,directionalLight:i}=t,r=e.clock.getTime();if(Math.floor(r/6e4)!==Math.floor(t.lastRefresh/6e4)){const{r:o,g:s,b:a}=e.getLightColor(),l=[Math.round(255*o),Math.round(255*s),Math.round(255*a)],c=e.getCenter(),u=SunCalc.getPosition(r,c.lat,c.lng),h=Math.PI+u.azimuth,d=-u.altitude;n.color=l,i.color=l,i.direction=[Math.sin(h)*Math.cos(d),Math.cos(h)*Math.cos(d),-Math.sin(d)],t.lastRefresh=r}e.map.getLayer(t.implementation.id)&&requestAnimationFrame(t._tick)}}class MeshSet{constructor(t){this.uniforms={zoom:{type:"f",value:t.zoom},cameraZ:{type:"f",value:t.cameraZ},modelScale:{type:"f",value:t.modelScale}}}getUniforms(){const t=this.uniforms;return{zoom:t.zoom,cameraZ:t.cameraZ,modelScale:t.modelScale}}getMesh(){return this.mesh}getPickingMesh(){return this.pickingMesh}getOutlineMesh(){return this.outlineMesh}addInstance(t){this.geometry.addInstance(t)}removeInstance(t){this.geometry.removeInstance(t)}setInstanceAttributes(t,e){this.geometry.setInstanceAttributes(t,e)}getInstanceAttributes(t){return this.geometry.getInstanceAttributes(t)}setOpacity(t){this.material.opacity=t}getOpacity(){return this.material.opacity}refreshCameraParams(t){const e=this.uniforms;e.zoom.value=t.zoom,e.cameraZ.value=t.cameraZ}}class InstancedGeometry extends InstancedBufferGeometry{constructor(t,e,n,i){super();const r=this,{attributes:o,index:s}=t,a=r.userData,l=a.attributes={},c=a.buffers=[];r.instanceCount=0;for(const t of Object.keys(o))r.attributes[t]=o[t].clone();s&&(r.index=s.clone());const u=new Uint8Array(3*e),h=new InstancedBufferAttribute(u,3,!0);for(let t=0;t<e;t++)u.set([255&n,t>>8&255,255&t],3*t);r.setAttribute("idColor",h);const d={};for(const t of Object.keys(i)){const e=i[t];if(e instanceof InterleavedBufferAttribute)r.setAttribute(t,e);else{const{type:e,itemSize:n,normalized:r}=i[t],o=d[e]=d[e]||{type:e,size:0,keys:[]};l[t]={itemSize:n,offset:o.size,normalized:r},o.size+=n,o.keys.push(t)}}for(const t of Object.keys(d)){const{type:n,size:i,keys:o}=d[t],s=new n(e*i),a=new InstancedInterleavedBuffer(s,i).setUsage(DynamicDrawUsage);for(const t of o){const e=l[t],{itemSize:n,offset:i,normalized:o}=e;r.setAttribute(t,new InterleavedBufferAttribute(a,n,i,o)),e.buffer=a}c.push(a)}}addInstance(t={}){this.setInstanceAttributes(this.instanceCount++,t)}removeInstance(t){const e=this,n=e.instanceCount;for(const i of e.userData.buffers){const e=i.stride;i.set(i.array.subarray((t+1)*e,n*e),t*e),i.needsUpdate=!0}e.instanceCount--}setInstanceAttributes(t,e){const n=this;for(const i of Object.keys(e)){const{offset:r,buffer:o}=n.userData.attributes[i],s=e[i],a=t*o.stride+r;isNaN(s)?o.set(s,a):o.array[a]=s,o.needsUpdate=!0}}getInstanceAttributes(t){const e=this.userData.attributes,n={};for(const i of Object.keys(e)){const{itemSize:r,offset:o,buffer:s}=e[i],a=s.array,l=t*s.stride+o;n[i]=r>1?a.subarray(l,l+r):a[l]}return n}}function mergeGeometries(t,e=!1){const n=null!==t[0].index,i=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),o={},s={},a=t[0].morphTargetsRelative,l=new BufferGeometry;let c=0;for(let u=0;u<t.length;++u){const h=t[u];let d=0;if(n!==(null!==h.index))return null;for(const t in h.attributes){if(!i.has(t))return null;void 0===o[t]&&(o[t]=[]),o[t].push(h.attributes[t]),d++}if(d!==i.size)return null;if(a!==h.morphTargetsRelative)return null;for(const t in h.morphAttributes){if(!r.has(t))return null;void 0===s[t]&&(s[t]=[]),s[t].push(h.morphAttributes[t])}if(e){let t;if(n)t=h.index.count;else{if(void 0===h.attributes.position)return null;t=h.attributes.position.count}l.addGroup(c,t,u),c+=t}}if(n){let e=0;const n=[];for(let i=0;i<t.length;++i){const r=t[i].index;for(let t=0;t<r.count;++t)n.push(r.getX(t)+e);e+=t[i].attributes.position.count}l.setIndex(n)}for(const t in o){const e=mergeAttributes(o[t]);if(!e)return null;l.setAttribute(t,e)}for(const t in s){const e=s[t][0].length;if(0===e)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[t]=[];for(let n=0;n<e;++n){const e=[];for(let i=0;i<s[t].length;++i)e.push(s[t][i][n]);const i=mergeAttributes(e);if(!i)return null;l.morphAttributes[t].push(i)}}return l}function mergeAttributes(t){let e,n,i,r=-1,o=0;for(let s=0;s<t.length;++s){const a=t[s];if(void 0===e&&(e=a.array.constructor),e!==a.array.constructor)return null;if(void 0===n&&(n=a.itemSize),n!==a.itemSize)return null;if(void 0===i&&(i=a.normalized),i!==a.normalized)return null;if(-1===r&&(r=a.gpuType),r!==a.gpuType)return null;o+=a.count*n}const s=new e(o),a=new BufferAttribute(s,n,i);let l=0;for(let e=0;e<t.length;++e){const i=t[e];if(i.isInterleavedBufferAttribute){const t=l/n;for(let e=0,r=i.count;e<r;e++)for(let r=0;r<n;r++){const n=i.getComponent(e,r);a.setComponent(e+t,r,n)}}else s.set(i.array,l);l+=i.count*n}return void 0!==r&&(a.gpuType=r),a}function toTrianglesDrawMode(t,e){if(e===TrianglesDrawMode)return t;if(e===TriangleFanDrawMode||e===TriangleStripDrawMode){let n=t.getIndex();if(null===n){const e=[],i=t.getAttribute("position");if(void 0===i)return t;for(let t=0;t<i.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const i=n.count-2,r=[];if(e===TriangleFanDrawMode)for(let t=1;t<=i;t++)r.push(n.getX(0)),r.push(n.getX(t)),r.push(n.getX(t+1));else for(let t=0;t<i;t++)t%2==0?(r.push(n.getX(t)),r.push(n.getX(t+1)),r.push(n.getX(t+2))):(r.push(n.getX(t+2)),r.push(n.getX(t+1)),r.push(n.getX(t)));const o=t.clone();return o.setIndex(r),o.clearGroups(),o}return t}const commonVariables="\nuniform float zoom;\nuniform float modelScale;\nattribute vec3 translation;\n\nfloat getScale( float zoom, float modelScale) {\n    return pow( 2.0, 14.0 - clamp( zoom, 13.0, 19.0 ) ) * modelScale * 100.0;\n}\n\n#ifdef TRANSFORM\nuniform float cameraZ;\nattribute float rotationX;\nattribute float rotationZ;\nattribute vec3 idColor;\n\n#ifdef AIRCRAFT\nattribute float groupIndex;\n#endif\n\n#ifndef BUS\nmat3 rotateX( float angle ) {\n    float s = sin( angle );\n    float c = cos( angle );\n    return mat3(\n        1.0, 0.0, 0.0,\n        0.0, c, s,\n        0.0, -s, c\n    );\n}\n#endif\n\nmat3 rotateZ( float angle ) {\n    float s = sin( angle );\n    float c = cos( angle );\n    return mat3(\n        c, s, 0.0,\n        -s, c, 0.0,\n        0.0, 0.0, 1.0\n    );\n}\n#endif\n",vInstanceColor="\nvarying vec3 vInstanceColor;\n",vIntensity="\nvarying float vIntensity;\n",vInstanceOpacity="\nvarying float vInstanceOpacity;\n",vIdColor="\nvarying vec3 vIdColor;\n",transformPosition="\nfloat zoom0 = zoom + log2( cameraZ / abs( cameraZ - translation.z ) );\nfloat scale0 = getScale( zoom0, modelScale );\n\n#ifdef AIRCRAFT\nfloat scale = 0.06 / 0.285 * modelScale * 100.0;\nfloat offsetY = groupIndex == 2.0 ? 0.44 - 1.32 * max( scale / scale0, 1.0 ) : 0.0;\nfloat offsetZ = groupIndex == 2.0 ? 0.88 : 0.0;\nfloat scaleX = groupIndex == 1.0 ? max( scale0, scale ) : scale0;\nfloat scaleY = groupIndex == 0.0 ? max( scale0, scale ) : scale0;\nvec3 position0 = ( position + vec3( 0.0, offsetY, offsetZ ) ) * vec3( scaleX, scaleY, scale0 );\n#else\nvec3 position0 = position * scale0;\n#endif\n\nposition0 = position0 * ( 1.0 + idColor.b * 0.03 );\n\n#ifdef OUTLINE\nposition0 = position0 + 0.1 * scale0 * sign( position );\n#endif\n\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\n",common=`\n#include <common>\n#define TRANSFORM\n\n${commonVariables}\n\n#ifdef BUS\nattribute vec3 color;\n#else\nattribute vec3 color0;\nattribute vec3 color1;\n#ifdef CAR\nattribute vec3 color2;\nattribute vec3 color3;\nattribute float groupIndex;\n#endif\n#endif\n\nattribute float opacity0;\n\n${vInstanceColor}\n${vInstanceOpacity}\n`,beginNormalVertex="\n#ifdef BUS\nvec3 objectNormal = rotateZ( rotationZ ) * vec3( normal );\n#else\nvec3 objectNormal = rotateZ( rotationZ ) * rotateX( rotationX ) * vec3( normal );\n#endif\n",colorVertex="\n#include <color_vertex>\n\n#ifdef CAR\nfloat mod3 = mod( groupIndex, 3.0 );\nvec3 null = vec3( 0.0, 1.0, 0.0 );\nvInstanceColor = groupIndex >= 3.0 && color3 != null ? color3 : mod3 == 0.0 ? color0 : mod3 == 1.0 ? color1 : color2;\n#endif\n\n#ifdef AIRCRAFT\nvInstanceColor = groupIndex < 2.0 ? color0 : color1;\n#endif\n\n#ifdef BUS\nvInstanceColor = color;\n#endif\n\nvInstanceOpacity = opacity0;\n";function updateVertexShader(t){return t.replace("#include <common>",common).replace("#include <begin_vertex>",transformPosition).replace("#include <beginnormal_vertex>",beginNormalVertex).replace("#include <color_vertex>",colorVertex)}const packing=`\n#include <packing>\n\n${vInstanceColor}\n${vInstanceOpacity}\n`,diffuseColorFragment="\nvec4 diffuseColor = vec4( diffuse * vInstanceColor, opacity * vInstanceOpacity );\n";function updateFragmentShader(t){return t.replace("#include <packing>",packing).replace("vec4 diffuseColor = vec4( diffuse, opacity );",diffuseColorFragment)}const pickingVertexShader=`\n#define TRANSFORM\n\n${commonVariables}\n${vIdColor}\n\nvoid main() {\n    ${transformPosition}\n    gl_Position = projectionMatrix * modelViewMatrix * vec4( transformed, 1.0 );\n    vIdColor = idColor;\n}\n`,pickingFragmentShader=`\n${vIdColor}\n\nvoid main() {\n    gl_FragColor = vec4( vIdColor, 1.0 );\n}\n`,delayMarkerVertexShader=`\n${commonVariables}\nuniform float opacity;\nattribute float opacity0;\nattribute float delay;\n${vIntensity}\n\nvoid main() {\n    float scale = getScale( zoom, modelScale );\n    vec3 transformed = position * scale + translation + vec3( 0.0, 0.0, 0.44 * scale );\n    gl_Position = projectionMatrix * modelViewMatrix * vec4( transformed, delay );\n    vec3 vNormal = normalize( normalMatrix * normal );\n    vec3 vNormel = normalize( vec3( modelViewMatrix * vec4( transformed, 1.0 ) ) );\n    vIntensity = ( 1.0 + dot( vNormal, vNormel ) ) * opacity * opacity0;\n}\n`,delayMarkerFragmentShader=`\nuniform float base;\n${vIntensity}\n\nvoid main() {\n    vec3 color = mix( vec3( base ), vec3( 1.0, 0.6, 0.0 ), vIntensity );\n    gl_FragColor = vec4( color, 1.0 );\n}\n`,outlineVertexShader=`\n#define TRANSFORM\n#define OUTLINE\n\n${commonVariables}\nattribute float outline;\n${vInstanceOpacity}\n\nvoid main() {\n    ${transformPosition}\n    gl_Position = projectionMatrix * modelViewMatrix * vec4( transformed, outline > 0.0 ? 1.0 : 0.0 );\n    vInstanceOpacity = outline;\n}\n`,outlineFragmentShader=`\n${vInstanceOpacity}\n\nvoid main() {\n    gl_FragColor = vec4( 1.0, 1.0, 1.0, vInstanceOpacity );\n}\n`;function define(t,e){return`#define ${t}\n${e}`}const groupIndices$1=new Float32Array([].concat(...[0,1,2].map((t=>Array(24).fill(t)))));class AircraftMeshSet extends MeshSet{constructor(t,e){super(e);const n=this,i=[new BoxGeometry(.88,2.64,.88),new BoxGeometry(2.64,.88,.1),new BoxGeometry(.1,.88,.88)],r=mergeGeometries(i);r.setAttribute("groupIndex",new BufferAttribute(groupIndices$1,1));const o=n.geometry=new InstancedGeometry(r,t,e.index,{translation:{type:Float32Array,itemSize:3},rotationX:{type:Float32Array,itemSize:1},rotationZ:{type:Float32Array,itemSize:1},opacity0:{type:Float32Array,itemSize:1},outline:{type:Float32Array,itemSize:1},color0:{type:Uint8Array,itemSize:3,normalized:!0},color1:{type:Uint8Array,itemSize:3,normalized:!0}});i.forEach((t=>t.dispose())),r.dispose();const s=n.material=new MeshLambertMaterial({opacity:e.opacity,transparent:!0});s.onBeforeCompile=t=>{t.uniforms=Object.assign(t.uniforms,n.getUniforms()),t.vertexShader=define("AIRCRAFT",updateVertexShader(t.vertexShader)),t.fragmentShader=updateFragmentShader(t.fragmentShader)};const a=n.mesh=new Mesh(o,s);a.updateMatrix(),a.matrixAutoUpdate=!1,a.frustumCulled=!1;const l=n.pickingMaterial=new ShaderMaterial({uniforms:n.getUniforms(),vertexShader:define("AIRCRAFT",pickingVertexShader),fragmentShader:pickingFragmentShader}),c=n.pickingMesh=new Mesh(o,l);c.updateMatrix(),c.matrixAutoUpdate=!1,c.frustumCulled=!1;const u=n.outlineMaterial=new ShaderMaterial({uniforms:n.getUniforms(),vertexShader:define("AIRCRAFT",outlineVertexShader),fragmentShader:outlineFragmentShader,transparent:!0,side:BackSide}),h=n.outlineMesh=new Mesh(o,u);h.updateMatrix(),h.matrixAutoUpdate=!1,h.frustumCulled=!1}dispose(){const t=this;t.geometry.dispose(),t.material.dispose(),t.pickingMaterial.dispose(),t.outlineMaterial.dispose()}}class BusMeshSet extends MeshSet{constructor(t,e){super(e);const n=this,i=new BoxGeometry(.6,1.2,.6),r=n.geometry=new InstancedGeometry(i,t,e.index,{translation:{type:Float32Array,itemSize:3},rotationZ:{type:Float32Array,itemSize:1},opacity0:{type:Float32Array,itemSize:1},outline:{type:Float32Array,itemSize:1},color:{type:Uint8Array,itemSize:3,normalized:!0}});i.dispose();const o=n.material=new MeshLambertMaterial({opacity:e.opacity,transparent:!0});o.onBeforeCompile=t=>{t.uniforms=Object.assign(t.uniforms,n.getUniforms()),t.vertexShader=define("BUS",updateVertexShader(t.vertexShader)),t.fragmentShader=updateFragmentShader(t.fragmentShader)};const s=n.mesh=new Mesh(r,o);s.updateMatrix(),s.matrixAutoUpdate=!1,s.frustumCulled=!1;const a=n.pickingMaterial=new ShaderMaterial({uniforms:n.getUniforms(),vertexShader:define("BUS",pickingVertexShader),fragmentShader:pickingFragmentShader}),l=n.pickingMesh=new Mesh(r,a);l.updateMatrix(),l.matrixAutoUpdate=!1,l.frustumCulled=!1;const c=n.outlineMaterial=new ShaderMaterial({uniforms:n.getUniforms(),vertexShader:define("BUS",outlineVertexShader),fragmentShader:outlineFragmentShader,transparent:!0,side:BackSide}),u=n.outlineMesh=new Mesh(r,c);u.updateMatrix(),u.matrixAutoUpdate=!1,u.frustumCulled=!1}dispose(){const t=this;t.geometry.dispose(),t.material.dispose(),t.pickingMaterial.dispose(),t.outlineMaterial.dispose()}}const groupIndices=new Float32Array([].concat(...[0,1,2,2,1,0,5,4,3,3,4,5,0,3].map((t=>Array(6).fill(t)))));class CarMeshSet extends MeshSet{constructor(t,e){super(e);const n=this,{index:i,opacity:r,dark:o}=e,s=new BoxGeometry(.88,1.76,.88,1,1,3),a=s.toNonIndexed();a.setAttribute("groupIndex",new BufferAttribute(groupIndices,1));const l=n.geometry=new InstancedGeometry(a,t,i,{translation:{type:Float32Array,itemSize:3},rotationX:{type:Float32Array,itemSize:1},rotationZ:{type:Float32Array,itemSize:1},opacity0:{type:Float32Array,itemSize:1},delay:{type:Float32Array,itemSize:1},outline:{type:Float32Array,itemSize:1},color0:{type:Uint8Array,itemSize:3,normalized:!0},color1:{type:Uint8Array,itemSize:3,normalized:!0},color2:{type:Uint8Array,itemSize:3,normalized:!0},color3:{type:Uint8Array,itemSize:3,normalized:!0}});s.dispose(),a.dispose(),Object.assign(n.uniforms,{opacity:{type:"f",value:r},base:{type:"f",value:o?0:1}});const c=n.material=new MeshLambertMaterial({opacity:r,transparent:!0});c.onBeforeCompile=t=>{t.uniforms=Object.assign(t.uniforms,n.getUniforms()),t.vertexShader=define("CAR",updateVertexShader(t.vertexShader)),t.fragmentShader=updateFragmentShader(t.fragmentShader)};const u=n.mesh=new Mesh(l,c);u.updateMatrix(),u.matrixAutoUpdate=!1,u.frustumCulled=!1;const h=n.pickingMaterial=new ShaderMaterial({uniforms:n.getUniforms(),vertexShader:define("CAR",pickingVertexShader),fragmentShader:pickingFragmentShader}),d=n.pickingMesh=new Mesh(l,h);d.updateMatrix(),d.matrixAutoUpdate=!1,d.frustumCulled=!1;const p=new SphereGeometry(1.8,32,32),f=n.delayMarkerGeometry=new InstancedGeometry(p,t,i,{translation:l.getAttribute("translation"),opacity0:l.getAttribute("opacity0"),delay:l.getAttribute("delay")});p.dispose();const m=n.delayMarkerMaterial=new ShaderMaterial({uniforms:n.getUniforms(!0),vertexShader:define("CAR",delayMarkerVertexShader),fragmentShader:delayMarkerFragmentShader,blending:o?AdditiveBlending:MultiplyBlending,depthWrite:!1}),g=n.delayMarkerMesh=new Mesh(f,m);g.updateMatrix(),g.matrixAutoUpdate=!1,g.frustumCulled=!1;const _=n.outlineMaterial=new ShaderMaterial({uniforms:n.getUniforms(),vertexShader:define("CAR",outlineVertexShader),fragmentShader:outlineFragmentShader,transparent:!0,side:BackSide}),y=n.outlineMesh=new Mesh(l,_);y.updateMatrix(),y.matrixAutoUpdate=!1,y.frustumCulled=!1}getUniforms(t){return t?Object.assign({},this.uniforms):super.getUniforms()}getDelayMarkerMesh(){return this.delayMarkerMesh}addInstance(t){super.addInstance(t),this.delayMarkerGeometry.addInstance()}removeInstance(t){super.removeInstance(t),this.delayMarkerGeometry.removeInstance(t)}setOpacity(t){super.setOpacity(t),this.uniforms.opacity.value=this.delayMarkerMaterial.opacity=t}refreshDelayMarkerMesh(t){this.uniforms.base.value=t?0:1,this.delayMarkerMaterial.blending=t?AdditiveBlending:MultiplyBlending}dispose(){const t=this;t.geometry.dispose(),t.material.dispose(),t.pickingMaterial.dispose(),t.delayMarkerGeometry.dispose(),t.delayMarkerMaterial.dispose(),t.outlineMaterial.dispose()}}const MAX_UG_CARS=2e3,MAX_OG_CARS=4e3,MAX_AIRCRAFTS=200,MAX_BUSES=4e3;class TrafficLayer{constructor(t){const e=this;e.id=t.id,e.type="three",e.lightColor="white",e.ugObjects=[],e.ogObjects=[],e.aircraftObjects=[],e.busObjects=[]}onAdd(t,e){const n=this,i=e.scene,r=t.getZoom(),o=t.map.getFreeCameraOptions().position.z,s=t.getModelScale();n.map=t,n.context=e;const a=n.ugCarMeshSet=new CarMeshSet(MAX_UG_CARS,{index:0,zoom:r,cameraZ:o,modelScale:s,opacity:.225}),l=n.ogCarMeshSet=new CarMeshSet(MAX_OG_CARS,{index:1,zoom:r,cameraZ:o,modelScale:s,opacity:.9}),c=n.aircraftMeshSet=new AircraftMeshSet(MAX_AIRCRAFTS,{index:2,zoom:r,cameraZ:o,modelScale:s,opacity:.9}),u=n.busMeshSet=new BusMeshSet(MAX_BUSES,{index:3,zoom:r,cameraZ:o,modelScale:s,opacity:.9});i.add(a.getMesh()),i.add(l.getMesh()),i.add(c.getMesh()),i.add(u.getMesh()),i.add(a.getDelayMarkerMesh()),i.add(l.getDelayMarkerMesh()),i.add(a.getOutlineMesh()),i.add(l.getOutlineMesh()),i.add(c.getOutlineMesh()),i.add(u.getOutlineMesh());const h=n.ugPickingScene=new Scene;h.background=new Color(16777215),h.add(a.getPickingMesh());const d=n.ogPickingScene=new Scene;d.background=new Color(16777215),d.add(l.getPickingMesh()),d.add(c.getPickingMesh()),d.add(u.getPickingMesh()),n.pickingTexture=new WebGLRenderTarget(1,1),n.pixelBuffer=new Uint8Array(4),t.on("zoom",n.onCameraChanged.bind(n)),t.on("pitch",n.onCameraChanged.bind(n))}onCameraChanged(){const t=this,e=t.map,n={zoom:e.getZoom(),cameraZ:e.map.getFreeCameraOptions().position.z};t.ugCarMeshSet.refreshCameraParams(n),t.ogCarMeshSet.refreshCameraParams(n),t.aircraftMeshSet.refreshCameraParams(n),t.busMeshSet.refreshCameraParams(n)}setMode(t,e){const n=this,i=n.ugCarMeshSet.getOpacity(),r=n.ogCarMeshSet.getOpacity();let o,s;"none"!==e&&"edit"!==e?o=s=.1:"underground"===t?(o=.9,s=.225):(o=.225,s=.9),animation.start({callback:(t,e)=>{n.ugCarMeshSet.setOpacity(lerp$5(i,o,t/e)),n.ogCarMeshSet.setOpacity(lerp$5(r,s,t/e)),n.aircraftMeshSet.setOpacity(lerp$5(r,s,t/e)),n.busMeshSet.setOpacity(lerp$5(r,s,t/e)),n.refreshDelayMarkers(!0)},duration:configs.transitionDuration})}addObject(t){const e=this,{type:n,altitude:i}=t,r="train"===n?i<0?0:1:"flight"===n?2:3,o=[e.ugCarMeshSet,e.ogCarMeshSet,e.aircraftMeshSet,e.busMeshSet][r],s=[e.ugObjects,e.ogObjects,e.aircraftObjects,e.busObjects][r],{x:a,y:l,z:c}=e.map.getModelPosition(t.coord,i),u=Array.isArray(t.color)?t.color:[t.color],h={translation:[a,l,c],rotationZ:MathUtils.degToRad(-t.bearing),opacity0:0,outline:t.outline};"train"===n?(h.rotationX=t.pitch,h.delay=t.delay,h.color0=colorToRGBArray(u[0]),h.color1=colorToRGBArray(u[1]||u[0]),h.color2=colorToRGBArray(u[2]||u[0]),h.color3=colorToRGBArray(u[3]||"#00ff00")):"flight"===n?(h.rotationX=t.pitch,h.color0=colorToRGBArray(u[0]),h.color1=colorToRGBArray(u[1])):h.color=colorToRGBArray(u[0]),o.addInstance(h),t.meshIndex=r,t.instanceIndex=s.length,s.push(t),t.animationID=animation.start({callback:(e,n)=>{o.setInstanceAttributes(t.instanceIndex,{opacity0:e/n})},complete:()=>{delete t.animationID},duration:configs.fadeDuration})}updateObject(t){if(!t||void 0===t.instanceIndex)return;const e=this,{meshIndex:n,instanceIndex:i,altitude:r,type:o,animationID:s}=t,a=[e.ugCarMeshSet,e.ogCarMeshSet,e.aircraftMeshSet,e.busMeshSet],l=[e.ugObjects,e.ogObjects,e.aircraftObjects,e.busObjects],c=a[n],u=l[n],{x:h,y:d,z:p}=e.map.getModelPosition(t.coord,r),f={translation:[h,d,p],rotationZ:MathUtils.degToRad(-t.bearing),outline:t.outline},m=r<0?0:1;if("train"===o?(f.rotationX=t.pitch,f.delay=t.delay):"flight"===o&&(f.rotationX=t.pitch),c.setInstanceAttributes(i,f),"train"===o&&m!==n){const e=a[m],n=l[m],r=c.getInstanceAttributes(i).opacity0*c.getOpacity();let o;s&&animation.stop(s),e.addInstance(c.getInstanceAttributes(i)),t.meshIndex=m,t.instanceIndex=o=n.length,n.push(t),c.removeInstance(i),u.splice(i,1);for(let t=i;t<u.length;t++)u[t].instanceIndex--;e.setInstanceAttributes(o,{opacity0:r/e.getOpacity()}),t.animationID=animation.start({callback:(n,i)=>{e.setInstanceAttributes(t.instanceIndex,{opacity0:lerp$5(r/e.getOpacity(),1,n/i)})},complete:()=>{delete t.animationID},duration:configs.fadeDuration})}}removeObject(t){if(!t||void 0===t.instanceIndex)return;const e=this,{meshIndex:n,animationID:i}=t,r=[e.ugCarMeshSet,e.ogCarMeshSet,e.aircraftMeshSet,e.busMeshSet][n],o=[e.ugObjects,e.ogObjects,e.aircraftObjects,e.busObjects][n];i&&animation.stop(i),t.removing=!0,t.animationID=animation.start({callback:(e,n)=>{r.setInstanceAttributes(t.instanceIndex,{opacity0:1-e/n})},complete:()=>{const e=t.instanceIndex;r.removeInstance(e),delete t.meshIndex,delete t.instanceIndex,delete t.animationID,delete t.removing,o.splice(e,1);for(let t=e;t<o.length;t++)o[t].instanceIndex--},duration:configs.fadeDuration})}pickObject(t,e){const n=this,{pickingTexture:i,pixelBuffer:r}=n,{renderer:o,camera:s}=n.context,a=o.getContext(),l=window.devicePixelRatio,c="underground"===t?n.ugPickingScene:n.ogPickingScene;s.setViewOffset(a.drawingBufferWidth,a.drawingBufferHeight,e.x*l|0,e.y*l|0,1,1),o.resetState(),o.setRenderTarget(i),o.render(c,s),o.setRenderTarget(null),o.resetState(),s.clearViewOffset(),o.readRenderTargetPixels(i,0,0,1,1,r);const u=[n.ugObjects,n.ogObjects,n.aircraftObjects,n.busObjects][r[0]];if(u)return u[r[1]<<8|r[2]]}refreshDelayMarkers(t){const e=this,n=hasDarkBackground(e.map.map,t);e.ugCarMeshSet.refreshDelayMarkerMesh(n),e.ogCarMeshSet.refreshDelayMarkerMesh(n)}project(t,e){const{map:n,context:i}=this,{width:r,height:o}=n.map.transform,{x:s,y:a,z:l}=n.getModelPosition(t,e),{x:c,y:u}=new Vector3(s,a,l).project(i.camera);return new mapboxGlExports.Point((c+1)/2*r,(1-u)/2*o)}}
/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */const proxyMarker=Symbol("Comlink.proxy"),createEndpoint=Symbol("Comlink.endpoint"),releaseProxy=Symbol("Comlink.releaseProxy"),finalizer=Symbol("Comlink.finalizer"),throwMarker=Symbol("Comlink.thrown"),isObject$2=t=>"object"==typeof t&&null!==t||"function"==typeof t,proxyTransferHandler={canHandle:t=>isObject$2(t)&&t[proxyMarker],serialize(t){const{port1:e,port2:n}=new MessageChannel;return expose(t,e),[n,[n]]},deserialize:t=>(t.start(),wrap(t))},throwTransferHandler={canHandle:t=>isObject$2(t)&&throwMarker 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}},transferHandlers=new Map([["proxy",proxyTransferHandler],["throw",throwTransferHandler]]);function isAllowedOrigin(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}function expose(t,e=globalThis,n=["*"]){e.addEventListener("message",(function i(r){if(!r||!r.data)return;if(!isAllowedOrigin(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),l=(r.data.argumentList||[]).map(fromWireValue);let c;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":c=n;break;case"SET":e[a.slice(-1)[0]]=fromWireValue(r.data.value),c=!0;break;case"APPLY":c=n.apply(e,l);break;case"CONSTRUCT":c=proxy(new n(...l));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;expose(t,n),c=transfer(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[throwMarker]:0}}Promise.resolve(c).catch((t=>({value:t,[throwMarker]:0}))).then((n=>{const[r,a]=toWireValue(n);e.postMessage(Object.assign(Object.assign({},r),{id:o}),a),"RELEASE"===s&&(e.removeEventListener("message",i),closeEndPoint(e),finalizer in t&&"function"==typeof t[finalizer]&&t[finalizer]())})).catch((t=>{const[n,i]=toWireValue({value:new TypeError("Unserializable return value"),[throwMarker]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),i)}))})),e.start&&e.start()}function isMessagePort(t){return"MessagePort"===t.constructor.name}function closeEndPoint(t){isMessagePort(t)&&t.close()}function wrap(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)}})),createProxy(t,n,[],e)}function throwIfProxyReleased(t){if(t)throw new Error("Proxy has been released and is not useable")}function releaseEndpoint(t){return requestResponseMessage(t,new Map,{type:"RELEASE"}).then((()=>{closeEndPoint(t)}))}const proxyCounter=new WeakMap,proxyFinalizers="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(proxyCounter.get(t)||0)-1;proxyCounter.set(t,e),0===e&&releaseEndpoint(t)}));function registerProxy(t,e){const n=(proxyCounter.get(e)||0)+1;proxyCounter.set(e,n),proxyFinalizers&&proxyFinalizers.register(t,e,t)}function unregisterProxy(t){proxyFinalizers&&proxyFinalizers.unregister(t)}function createProxy(t,e,n=[],i=function(){}){let r=!1;const o=new Proxy(i,{get(i,s){if(throwIfProxyReleased(r),s===releaseProxy)return()=>{unregisterProxy(o),releaseEndpoint(t),e.clear(),r=!0};if("then"===s){if(0===n.length)return{then:()=>o};const i=requestResponseMessage(t,e,{type:"GET",path:n.map((t=>t.toString()))}).then(fromWireValue);return i.then.bind(i)}return createProxy(t,e,[...n,s])},set(i,o,s){throwIfProxyReleased(r);const[a,l]=toWireValue(s);return requestResponseMessage(t,e,{type:"SET",path:[...n,o].map((t=>t.toString())),value:a},l).then(fromWireValue)},apply(i,o,s){throwIfProxyReleased(r);const a=n[n.length-1];if(a===createEndpoint)return requestResponseMessage(t,e,{type:"ENDPOINT"}).then(fromWireValue);if("bind"===a)return createProxy(t,e,n.slice(0,-1));const[l,c]=processArguments(s);return requestResponseMessage(t,e,{type:"APPLY",path:n.map((t=>t.toString())),argumentList:l},c).then(fromWireValue)},construct(i,o){throwIfProxyReleased(r);const[s,a]=processArguments(o);return requestResponseMessage(t,e,{type:"CONSTRUCT",path:n.map((t=>t.toString())),argumentList:s},a).then(fromWireValue)}});return registerProxy(o,t),o}function myFlat(t){return Array.prototype.concat.apply([],t)}function processArguments(t){const e=t.map(toWireValue);return[e.map((t=>t[0])),myFlat(e.map((t=>t[1])))]}const transferCache=new WeakMap;function transfer(t,e){return transferCache.set(t,e),t}function proxy(t){return Object.assign(t,{[proxyMarker]:!0})}function toWireValue(t){for(const[e,n]of transferHandlers)if(n.canHandle(t)){const[i,r]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},r]}return[{type:"RAW",value:t},transferCache.get(t)||[]]}function fromWireValue(t){switch(t.type){case"HANDLER":return transferHandlers.get(t.name).deserialize(t.value);case"RAW":return t.value}}function requestResponseMessage(t,e,n,i){return new Promise((r=>{const o=generateUUID();e.set(o,r),t.start&&t.start(),t.postMessage(Object.assign({id:o},n),i)}))}function generateUUID(){return new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-")}var geobuf$1={},encode_1,hasRequiredEncode,decode_1,hasRequiredDecode,hasRequiredGeobuf;function requireEncode(){if(hasRequiredEncode)return encode_1;hasRequiredEncode=1,encode_1=function(s,l){t={},n=[],e=0,i=0,r=1,a(s),r=Math.min(r,o);for(var c=Math.ceil(Math.log(r)/Math.LN10),u=0;u<n.length;u++)l.writeStringField(1,n[u]);2!==i&&l.writeVarintField(2,i);6!==c&&l.writeVarintField(3,c);"FeatureCollection"===s.type?l.writeMessage(4,d,s):"Feature"===s.type?l.writeMessage(5,p,s):l.writeMessage(6,f,s);return t=null,l.finish()};var t,e,n,i,r,o=1e6,s={Point:0,MultiPoint:1,LineString:2,MultiLineString:3,Polygon:4,MultiPolygon:5,GeometryCollection:6};function a(t){var e,n;if("FeatureCollection"===t.type)for(e=0;e<t.features.length;e++)a(t.features[e]);else if("Feature"===t.type)for(n in null!==t.geometry&&a(t.geometry),t.properties)h(n);else if("Point"===t.type)u(t.coordinates);else if("MultiPoint"===t.type)c(t.coordinates);else if("GeometryCollection"===t.type)for(e=0;e<t.geometries.length;e++)a(t.geometries[e]);else if("LineString"===t.type)c(t.coordinates);else if("Polygon"===t.type||"MultiLineString"===t.type)l(t.coordinates);else if("MultiPolygon"===t.type)for(e=0;e<t.coordinates.length;e++)l(t.coordinates[e]);for(n in t)x(n,t.type)||h(n)}function l(t){for(var e=0;e<t.length;e++)c(t[e])}function c(t){for(var e=0;e<t.length;e++)u(t[e])}function u(t){i=Math.max(i,t.length);for(var e=0;e<t.length;e++)for(;Math.round(t[e]*r)/r!==t[e]&&r<o;)r*=10}function h(i){void 0===t[i]&&(n.push(i),t[i]=e++)}function d(t,e){for(var n=0;n<t.features.length;n++)e.writeMessage(1,p,t.features[n]);m(t,e,!0)}function p(t,e){null!==t.geometry&&e.writeMessage(1,f,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&&m(t.properties,e),m(t,e,!0)}function f(t,e){e.writeVarintField(1,s[t.type]);var n=t.coordinates;if("Point"===t.type)!function(t,e){for(var n=[],o=0;o<i;o++)n.push(Math.round(t[o]*r));e.writePackedSVarint(3,n)}(n,e);else if("MultiPoint"===t.type)_(n,e);else if("LineString"===t.type)_(n,e);else if("MultiLineString"===t.type)y(n,e);else if("Polygon"===t.type)y(n,e,!0);else if("MultiPolygon"===t.type)!function(t,e){var n,i,r=t.length;if(1!==r||1!==t[0].length){var o=[r];for(n=0;n<r;n++)for(o.push(t[n].length),i=0;i<t[n].length;i++)o.push(t[n][i].length-1);e.writePackedVarint(2,o)}var s=[];for(n=0;n<r;n++)for(i=0;i<t[n].length;i++)v(s,t[n][i],!0);e.writePackedSVarint(3,s)}(n,e);else if("GeometryCollection"===t.type)for(var o=0;o<t.geometries.length;o++)e.writeMessage(4,f,t.geometries[o]);m(t,e,!0)}function m(e,n,i){var r=[],o=0;for(var s in e)i&&x(s,e.type)||(n.writeMessage(13,g,e[s]),r.push(t[s]),r.push(o++));n.writePackedVarint(i?15:14,r)}function g(t,e){if(null!==t){var 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 _(t,e){var n=[];v(n,t),e.writePackedSVarint(3,n)}function y(t,e,n){var i,r=t.length;if(1!==r){var o=[];for(i=0;i<r;i++)o.push(t[i].length-(n?1:0));e.writePackedVarint(2,o)}var s=[];for(i=0;i<r;i++)v(s,t[i],n);e.writePackedSVarint(3,s)}function v(t,e,n){var o,s,a=e.length-(n?1:0),l=new Array(i);for(s=0;s<i;s++)l[s]=0;for(o=0;o<a;o++)for(s=0;s<i;s++){var c=Math.round(e[o][s]*r)-l[s];t.push(c),l[s]+=c}}function x(t,e){if("type"===t)return!0;if("FeatureCollection"===e){if("features"===t)return!0}else if("Feature"===e){if("id"===t||"properties"===t||"geometry"===t)return!0}else if("GeometryCollection"===e){if("geometries"===t)return!0}else if("coordinates"===t)return!0;return!1}return encode_1}function requireDecode(){if(hasRequiredDecode)return decode_1;var t,e,n,i,r;hasRequiredDecode=1;var o=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon","GeometryCollection"];function s(e,n,o){1===e?t.push(o.readString()):2===e?i=o.readVarint():3===e?r=Math.pow(10,o.readVarint()):4===e?function(t,e){e.type="FeatureCollection",e.features=[],t.readMessage(c,e)}(o,n):5===e?a(o,n):6===e&&l(o,n)}function a(t,e){e.type="Feature";var n=t.readMessage(u,e);return"geometry"in n||(n.geometry=null),n}function l(t,e){return e.type="Point",t.readMessage(h,e)}function c(t,n,i){1===t?n.features.push(a(i,{})):13===t?e.push(d(i)):15===t&&p(i,n)}function u(t,n,i){1===t?n.geometry=l(i,{}):11===t?n.id=i.readString():12===t?n.id=i.readSVarint():13===t?e.push(d(i)):14===t?n.properties=p(i,{}):15===t&&p(i,n)}function h(t,i,s){1===t?i.type=o[s.readVarint()]:2===t?n=s.readPackedVarint():3===t?function(t,e,i){"Point"===i?t.coordinates=function(t){var e=t.readVarint()+t.pos,n=[];for(;t.pos<e;)n.push(t.readSVarint()/r);return n}(e):"MultiPoint"===i||"LineString"===i?t.coordinates=m(e):"MultiLineString"===i?t.coordinates=g(e):"Polygon"===i?t.coordinates=g(e,!0):"MultiPolygon"===i&&(t.coordinates=function(t){var e=t.readVarint()+t.pos;if(!n)return[[f(t,e,null,!0)]];for(var i=[],r=1,o=0;o<n[0];o++){for(var s=[],a=0;a<n[r];a++)s.push(f(t,e,n[r+1+a],!0));r+=n[r]+1,i.push(s)}return n=null,i}(e))}(i,s,i.type):4===t?(i.geometries=i.geometries||[],i.geometries.push(l(s,{}))):13===t?e.push(d(s)):15===t&&p(s,i)}function d(t){for(var e=t.readVarint()+t.pos,n=null;t.pos<e;){var i=t.readVarint()>>3;1===i?n=t.readString():2===i?n=t.readDouble():3===i?n=t.readVarint():4===i?n=-t.readVarint():5===i?n=t.readBoolean():6===i&&(n=JSON.parse(t.readString()))}return n}function p(n,i){for(var r=n.readVarint()+n.pos;n.pos<r;)i[t[n.readVarint()]]=e[n.readVarint()];return e=[],i}function f(t,e,n,o){var s,a,l=0,c=[],u=[];for(a=0;a<i;a++)u[a]=0;for(;n?l<n:t.pos<e;){for(s=[],a=0;a<i;a++)u[a]+=t.readSVarint(),s[a]=u[a]/r;c.push(s),l++}return o&&c.push(c[0]),c}function m(t){return f(t,t.readVarint()+t.pos)}function g(t,e){var i=t.readVarint()+t.pos;if(!n)return[f(t,i,null,e)];for(var r=[],o=0;o<n.length;o++)r.push(f(t,i,n[o],e));return n=null,r}return decode_1=function(o){i=2,r=Math.pow(10,6),n=null,t=[],e=[];var a=o.readFields(s,{});return t=null,a}}function requireGeobuf(){return hasRequiredGeobuf||(hasRequiredGeobuf=1,geobuf$1.encode=requireEncode(),geobuf$1.decode=requireDecode()),geobuf$1}var geobufExports=requireGeobuf(),geobuf=getDefaultExportFromCjs(geobufExports),indexMinimal={},minimal$1={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;return hasRequiredAspromise=1,aspromise=function(t,e){var n=new Array(arguments.length-1),i=0,r=2,o=!0;for(;r<arguments.length;)n[i++]=arguments[r++];return new Promise((function(r,s){n[i]=function(t){if(o)if(o=!1,t)s(t);else{for(var e=new Array(arguments.length-1),n=0;n<e.length;)e[n++]=arguments[n];r.apply(null,e)}};try{t.apply(e||null,n)}catch(t){o&&(o=!1,s(t))}}))},aspromise}var base64={},hasRequiredBase64,eventemitter,hasRequiredEventemitter,float,hasRequiredFloat,inquire_1,hasRequiredInquire;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,function(t){var e=t;e.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&"="===t.charAt(e);)++n;return Math.ceil(3*t.length)/4-n};for(var n=new Array(64),i=new Array(123),r=0;r<64;)i[n[r]=r<26?r+65:r<52?r+71:r<62?r-4:r-59|43]=r++;e.encode=function(t,e,i){for(var r,o=null,s=[],a=0,l=0;e<i;){var c=t[e++];switch(l){case 0:s[a++]=n[c>>2],r=(3&c)<<4,l=1;break;case 1:s[a++]=n[r|c>>4],r=(15&c)<<2,l=2;break;case 2:s[a++]=n[r|c>>6],s[a++]=n[63&c],l=0}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0)}return l&&(s[a++]=n[r],s[a++]=61,1===l&&(s[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var o="invalid encoding";e.decode=function(t,e,n){for(var r,s=n,a=0,l=0;l<t.length;){var c=t.charCodeAt(l++);if(61===c&&a>1)break;if(void 0===(c=i[c]))throw Error(o);switch(a){case 0:r=c,a=1;break;case 1:e[n++]=r<<2|(48&c)>>4,r=c,a=2;break;case 2:e[n++]=(15&r)<<4|(60&c)>>2,r=c,a=3;break;case 3:e[n++]=(3&r)<<6|c,a=0}}if(1===a)throw Error(o);return n-s},e.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}}(base64)),base64}function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;function t(){this._listeners={}}return hasRequiredEventemitter=1,eventemitter=t,t.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this},t.prototype.off=function(t,e){if(void 0===t)this._listeners={};else if(void 0===e)this._listeners[t]=[];else for(var n=this._listeners[t],i=0;i<n.length;)n[i].fn===e?n.splice(i,1):++i;return this},t.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<e.length;)e[i].fn.apply(e[i++].ctx,n)}return this},eventemitter}function requireFloat(){if(hasRequiredFloat)return float;function t(t){return"undefined"!=typeof Float32Array?function(){var e=new Float32Array([-0]),n=new Uint8Array(e.buffer),i=128===n[3];function r(t,i,r){e[0]=t,i[r]=n[0],i[r+1]=n[1],i[r+2]=n[2],i[r+3]=n[3]}function o(t,i,r){e[0]=t,i[r]=n[3],i[r+1]=n[2],i[r+2]=n[1],i[r+3]=n[0]}function s(t,i){return n[0]=t[i],n[1]=t[i+1],n[2]=t[i+2],n[3]=t[i+3],e[0]}function a(t,i){return n[3]=t[i],n[2]=t[i+1],n[1]=t[i+2],n[0]=t[i+3],e[0]}t.writeFloatLE=i?r:o,t.writeFloatBE=i?o:r,t.readFloatLE=i?s:a,t.readFloatBE=i?a:s}():function(){function o(t,e,n,i){var r=e<0?1:0;if(r&&(e=-e),0===e)t(1/e>0?0:2147483648,n,i);else if(isNaN(e))t(2143289344,n,i);else if(e>34028234663852886e22)t((r<<31|2139095040)>>>0,n,i);else if(e<11754943508222875e-54)t((r<<31|Math.round(e/1401298464324817e-60))>>>0,n,i);else{var o=Math.floor(Math.log(e)/Math.LN2);t((r<<31|o+127<<23|8388607&Math.round(e*Math.pow(2,-o)*8388608))>>>0,n,i)}}function s(t,e,n){var i=t(e,n),r=2*(i>>31)+1,o=i>>>23&255,s=8388607&i;return 255===o?s?NaN:r*(1/0):0===o?1401298464324817e-60*r*s:r*Math.pow(2,o-150)*(s+8388608)}t.writeFloatLE=o.bind(null,e),t.writeFloatBE=o.bind(null,n),t.readFloatLE=s.bind(null,i),t.readFloatBE=s.bind(null,r)}(),"undefined"!=typeof Float64Array?function(){var e=new Float64Array([-0]),n=new Uint8Array(e.buffer),i=128===n[7];function r(t,i,r){e[0]=t,i[r]=n[0],i[r+1]=n[1],i[r+2]=n[2],i[r+3]=n[3],i[r+4]=n[4],i[r+5]=n[5],i[r+6]=n[6],i[r+7]=n[7]}function o(t,i,r){e[0]=t,i[r]=n[7],i[r+1]=n[6],i[r+2]=n[5],i[r+3]=n[4],i[r+4]=n[3],i[r+5]=n[2],i[r+6]=n[1],i[r+7]=n[0]}function s(t,i){return n[0]=t[i],n[1]=t[i+1],n[2]=t[i+2],n[3]=t[i+3],n[4]=t[i+4],n[5]=t[i+5],n[6]=t[i+6],n[7]=t[i+7],e[0]}function a(t,i){return n[7]=t[i],n[6]=t[i+1],n[5]=t[i+2],n[4]=t[i+3],n[3]=t[i+4],n[2]=t[i+5],n[1]=t[i+6],n[0]=t[i+7],e[0]}t.writeDoubleLE=i?r:o,t.writeDoubleBE=i?o:r,t.readDoubleLE=i?s:a,t.readDoubleBE=i?a:s}():function(){function o(t,e,n,i,r,o){var s=i<0?1:0;if(s&&(i=-i),0===i)t(0,r,o+e),t(1/i>0?0:2147483648,r,o+n);else if(isNaN(i))t(0,r,o+e),t(2146959360,r,o+n);else if(i>17976931348623157e292)t(0,r,o+e),t((s<<31|2146435072)>>>0,r,o+n);else{var a;if(i<22250738585072014e-324)t((a=i/5e-324)>>>0,r,o+e),t((s<<31|a/4294967296)>>>0,r,o+n);else{var l=Math.floor(Math.log(i)/Math.LN2);1024===l&&(l=1023),t(4503599627370496*(a=i*Math.pow(2,-l))>>>0,r,o+e),t((s<<31|l+1023<<20|1048576*a&1048575)>>>0,r,o+n)}}}function s(t,e,n,i,r){var o=t(i,r+e),s=t(i,r+n),a=2*(s>>31)+1,l=s>>>20&2047,c=4294967296*(1048575&s)+o;return 2047===l?c?NaN:a*(1/0):0===l?5e-324*a*c:a*Math.pow(2,l-1075)*(c+4503599627370496)}t.writeDoubleLE=o.bind(null,e,0,4),t.writeDoubleBE=o.bind(null,n,4,0),t.readDoubleLE=s.bind(null,i,0,4),t.readDoubleBE=s.bind(null,r,4,0)}(),t}function e(t,e,n){e[n]=255&t,e[n+1]=t>>>8&255,e[n+2]=t>>>16&255,e[n+3]=t>>>24}function n(t,e,n){e[n]=t>>>24,e[n+1]=t>>>16&255,e[n+2]=t>>>8&255,e[n+3]=255&t}function i(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function r(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}return hasRequiredFloat=1,float=t(t)}function requireInquire(){if(hasRequiredInquire)return inquire_1;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(t){}return null}return hasRequiredInquire=1,inquire_1=inquire,inquire_1}var utf8={},hasRequiredUtf8,pool_1,hasRequiredPool,longbits,hasRequiredLongbits,hasRequiredMinimal$1,writer,hasRequiredWriter,writer_buffer,hasRequiredWriter_buffer,reader,hasRequiredReader,reader_buffer,hasRequiredReader_buffer;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,function(t){var e=t;e.length=function(t){for(var e=0,n=0,i=0;i<t.length;++i)(n=t.charCodeAt(i))<128?e+=1:n<2048?e+=2:55296==(64512&n)&&56320==(64512&t.charCodeAt(i+1))?(++i,e+=4):e+=3;return e},e.read=function(t,e,n){if(n-e<1)return"";for(var i,r=null,o=[],s=0;e<n;)(i=t[e++])<128?o[s++]=i:i>191&&i<224?o[s++]=(31&i)<<6|63&t[e++]:i>239&&i<365?(i=((7&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,o[s++]=55296+(i>>10),o[s++]=56320+(1023&i)):o[s++]=(15&i)<<12|(63&t[e++])<<6|63&t[e++],s>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,o)),s=0);return r?(s&&r.push(String.fromCharCode.apply(String,o.slice(0,s))),r.join("")):String.fromCharCode.apply(String,o.slice(0,s))},e.write=function(t,e,n){for(var i,r,o=n,s=0;s<t.length;++s)(i=t.charCodeAt(s))<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=63&i|128):55296==(64512&i)&&56320==(64512&(r=t.charCodeAt(s+1)))?(++s,e[n++]=(i=65536+((1023&i)<<10)+(1023&r))>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=63&i|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=63&i|128);return n-o}}(utf8)),utf8}function requirePool(){if(hasRequiredPool)return pool_1;return hasRequiredPool=1,pool_1=function(t,e,n){var i=n||8192,r=i>>>1,o=null,s=i;return function(n){if(n<1||n>r)return t(n);s+n>i&&(o=t(i),s=0);var a=e.call(o,s,s+=n);return 7&s&&(s=1+(7|s)),a}}}function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=e;var t=requireMinimal$1();function e(t,e){this.lo=t>>>0,this.hi=e>>>0}var n=e.zero=new e(0,0);n.toNumber=function(){return 0},n.zzEncode=n.zzDecode=function(){return this},n.length=function(){return 1};var i=e.zeroHash="\0\0\0\0\0\0\0\0";e.fromNumber=function(t){if(0===t)return n;var i=t<0;i&&(t=-t);var r=t>>>0,o=(t-r)/4294967296>>>0;return i&&(o=~o>>>0,r=~r>>>0,++r>4294967295&&(r=0,++o>4294967295&&(o=0))),new e(r,o)},e.from=function(i){if("number"==typeof i)return e.fromNumber(i);if(t.isString(i)){if(!t.Long)return e.fromNumber(parseInt(i,10));i=t.Long.fromString(i)}return i.low||i.high?new e(i.low>>>0,i.high>>>0):n},e.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=1+~this.lo>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+4294967296*n)}return this.lo+4294967296*this.hi},e.prototype.toLong=function(e){return t.Long?new t.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var r=String.prototype.charCodeAt;return e.fromHash=function(t){return t===i?n:new e((r.call(t,0)|r.call(t,1)<<8|r.call(t,2)<<16|r.call(t,3)<<24)>>>0,(r.call(t,4)|r.call(t,5)<<8|r.call(t,6)<<16|r.call(t,7)<<24)>>>0)},e.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)},e.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},e.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},e.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===e?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10},longbits}function requireMinimal$1(){return hasRequiredMinimal$1||(hasRequiredMinimal$1=1,function(t){var e=t;function n(t,e,n){for(var i=Object.keys(e),r=0;r<i.length;++r)void 0!==t[i[r]]&&n||(t[i[r]]=e[i[r]]);return t}function i(t){function e(t,i){if(!(this instanceof e))return new e(t,i);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),i&&n(this,i)}return e.prototype=Object.create(Error.prototype,{constructor:{value:e,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return t},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),e}e.asPromise=requireAspromise(),e.base64=requireBase64(),e.EventEmitter=requireEventemitter(),e.float=requireFloat(),e.inquire=requireInquire(),e.utf8=requireUtf8(),e.pool=requirePool(),e.LongBits=requireLongbits(),e.isNode=Boolean(void 0!==commonjsGlobal&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),e.global=e.isNode&&commonjsGlobal||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||minimal$1,e.emptyArray=Object.freeze?Object.freeze([]):[],e.emptyObject=Object.freeze?Object.freeze({}):{},e.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},e.isString=function(t){return"string"==typeof t||t instanceof String},e.isObject=function(t){return t&&"object"==typeof t},e.isset=e.isSet=function(t,e){var n=t[e];return!(null==n||!t.hasOwnProperty(e))&&("object"!=typeof n||(Array.isArray(n)?n.length:Object.keys(n).length)>0)},e.Buffer=function(){try{var t=e.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),e._Buffer_from=null,e._Buffer_allocUnsafe=null,e.newBuffer=function(t){return"number"==typeof t?e.Buffer?e._Buffer_allocUnsafe(t):new e.Array(t):e.Buffer?e._Buffer_from(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},e.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,e.Long=e.global.dcodeIO&&e.global.dcodeIO.Long||e.global.Long||e.inquire("long"),e.key2Re=/^true|false|0|1$/,e.key32Re=/^-?(?:0|[1-9][0-9]*)$/,e.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,e.longToHash=function(t){return t?e.LongBits.from(t).toHash():e.LongBits.zeroHash},e.longFromHash=function(t,n){var i=e.LongBits.fromHash(t);return e.Long?e.Long.fromBits(i.lo,i.hi,n):i.toNumber(Boolean(n))},e.merge=n,e.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},e.newError=i,e.ProtocolError=i("ProtocolError"),e.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var t=Object.keys(this),n=t.length-1;n>-1;--n)if(1===e[t[n]]&&null!=this[t[n]])return t[n]}},e.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}},e.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},e._configure=function(){var t=e.Buffer;t?(e._Buffer_from=t.from!==Uint8Array.from&&t.from||function(e,n){return new t(e,n)},e._Buffer_allocUnsafe=t.allocUnsafe||function(e){return new t(e)}):e._Buffer_from=e._Buffer_allocUnsafe=null}}(minimal$1)),minimal$1}function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=l;var t,e=requireMinimal$1(),n=e.LongBits,i=e.base64,r=e.utf8;function o(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}function s(){}function a(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function l(){this.len=0,this.head=new o(s,0,0),this.tail=this.head,this.states=null}var c=function(){return e.Buffer?function(){return(l.create=function(){return new t})()}:function(){return new l}};function u(t,e,n){e[n]=255&t}function h(t,e){this.len=t,this.next=void 0,this.val=e}function d(t,e,n){for(;t.hi;)e[n++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[n++]=127&t.lo|128,t.lo=t.lo>>>7;e[n++]=t.lo}function p(t,e,n){e[n]=255&t,e[n+1]=t>>>8&255,e[n+2]=t>>>16&255,e[n+3]=t>>>24}l.create=c(),l.alloc=function(t){return new e.Array(t)},e.Array!==Array&&(l.alloc=e.pool(l.alloc,e.Array.prototype.subarray)),l.prototype._push=function(t,e,n){return this.tail=this.tail.next=new o(t,e,n),this.len+=e,this},(h.prototype=Object.create(o.prototype)).fn=function(t,e,n){for(;t>127;)e[n++]=127&t|128,t>>>=7;e[n]=t},l.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new h((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},l.prototype.int32=function(t){return t<0?this._push(d,10,n.fromNumber(t)):this.uint32(t)},l.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},l.prototype.uint64=function(t){var e=n.from(t);return this._push(d,e.length(),e)},l.prototype.int64=l.prototype.uint64,l.prototype.sint64=function(t){var e=n.from(t).zzEncode();return this._push(d,e.length(),e)},l.prototype.bool=function(t){return this._push(u,1,t?1:0)},l.prototype.sfixed32=l.prototype.fixed32=function(t){return this._push(p,4,t>>>0)},l.prototype.fixed64=function(t){var e=n.from(t);return this._push(p,4,e.lo)._push(p,4,e.hi)},l.prototype.sfixed64=l.prototype.fixed64,l.prototype.float=function(t){return this._push(e.float.writeFloatLE,4,t)},l.prototype.double=function(t){return this._push(e.float.writeDoubleLE,8,t)};var f=e.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var i=0;i<t.length;++i)e[n+i]=t[i]};return l.prototype.bytes=function(t){var n=t.length>>>0;if(!n)return this._push(u,1,0);if(e.isString(t)){var r=l.alloc(n=i.length(t));i.decode(t,r,0),t=r}return this.uint32(n)._push(f,n,t)},l.prototype.string=function(t){var e=r.length(t);return e?this.uint32(e)._push(r.write,e,t):this._push(u,1,0)},l.prototype.fork=function(){return this.states=new a(this),this.head=this.tail=new o(s,0,0),this.len=0,this},l.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new o(s,0,0),this.len=0),this},l.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this},l.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e},l._configure=function(e){t=e,l.create=c(),t._configure()},writer}function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=n;var t=requireWriter();(n.prototype=Object.create(t.prototype)).constructor=n;var e=requireMinimal$1();function n(){t.call(this)}function i(t,n,i){t.length<40?e.utf8.write(t,n,i):n.utf8Write?n.utf8Write(t,i):n.write(t,i)}return n._configure=function(){n.alloc=e._Buffer_allocUnsafe,n.writeBytesBuffer=e.Buffer&&e.Buffer.prototype instanceof Uint8Array&&"set"===e.Buffer.prototype.set.name?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var i=0;i<t.length;)e[n++]=t[i++]}},n.prototype.bytes=function(t){e.isString(t)&&(t=e._Buffer_from(t,"base64"));var i=t.length>>>0;return this.uint32(i),i&&this._push(n.writeBytesBuffer,i,t),this},n.prototype.string=function(t){var n=e.Buffer.byteLength(t);return this.uint32(n),n&&this._push(i,n,t),this},n._configure(),writer_buffer}function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=o;var t,e=requireMinimal$1(),n=e.LongBits,i=e.utf8;function r(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function o(t){this.buf=t,this.pos=0,this.len=t.length}var s,a="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new o(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new o(t);throw Error("illegal buffer")},l=function(){return e.Buffer?function(n){return(o.create=function(n){return e.Buffer.isBuffer(n)?new t(n):a(n)})(n)}:a};function c(){var t=new n(0,0),e=0;if(!(this.len-this.pos>4)){for(;e<3;++e){if(this.pos>=this.len)throw r(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*e)>>>0,t}for(;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(e=0,this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw r(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function u(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function h(){if(this.pos+8>this.len)throw r(this,8);return new n(u(this.buf,this.pos+=4),u(this.buf,this.pos+=4))}return o.create=l(),o.prototype._slice=e.Array.prototype.subarray||e.Array.prototype.slice,o.prototype.uint32=(s=4294967295,function(){if(s=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return s;if(s=(s|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return s;if(s=(s|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return s;if(s=(s|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return s;if(s=(s|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return s;if((this.pos+=5)>this.len)throw this.pos=this.len,r(this,10);return s}),o.prototype.int32=function(){return 0|this.uint32()},o.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)},o.prototype.bool=function(){return 0!==this.uint32()},o.prototype.fixed32=function(){if(this.pos+4>this.len)throw r(this,4);return u(this.buf,this.pos+=4)},o.prototype.sfixed32=function(){if(this.pos+4>this.len)throw r(this,4);return 0|u(this.buf,this.pos+=4)},o.prototype.float=function(){if(this.pos+4>this.len)throw r(this,4);var t=e.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},o.prototype.double=function(){if(this.pos+8>this.len)throw r(this,4);var t=e.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},o.prototype.bytes=function(){var t=this.uint32(),n=this.pos,i=this.pos+t;if(i>this.len)throw r(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(n,i);if(n===i){var o=e.Buffer;return o?o.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,n,i)},o.prototype.string=function(){var t=this.bytes();return i.read(t,0,t.length)},o.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw r(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw r(this)}while(128&this.buf[this.pos++]);return this},o.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},o._configure=function(n){t=n,o.create=l(),t._configure();var i=e.Long?"toLong":"toNumber";e.merge(o.prototype,{int64:function(){return c.call(this)[i](!1)},uint64:function(){return c.call(this)[i](!0)},sint64:function(){return c.call(this).zzDecode()[i](!1)},fixed64:function(){return h.call(this)[i](!0)},sfixed64:function(){return h.call(this)[i](!1)}})},reader}function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=n;var t=requireReader();(n.prototype=Object.create(t.prototype)).constructor=n;var e=requireMinimal$1();function n(e){t.call(this,e)}return n._configure=function(){e.Buffer&&(n.prototype._slice=e.Buffer.prototype.slice)},n.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},n._configure(),reader_buffer}var rpc={},service,hasRequiredService,hasRequiredRpc,roots,hasRequiredRoots,hasRequiredIndexMinimal,minimal,hasRequiredMinimal,gtfsRealtime,hasRequiredGtfsRealtime;function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=e;var t=requireMinimal$1();function e(e,n,i){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");t.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(n),this.responseDelimited=Boolean(i)}return(e.prototype=Object.create(t.EventEmitter.prototype)).constructor=e,e.prototype.rpcCall=function e(n,i,r,o,s){if(!o)throw TypeError("request must be specified");var a=this;if(!s)return t.asPromise(e,a,n,i,r,o);if(a.rpcImpl)try{return a.rpcImpl(n,i[a.requestDelimited?"encodeDelimited":"encode"](o).finish(),(function(t,e){if(t)return a.emit("error",t,n),s(t);if(null!==e){if(!(e instanceof r))try{e=r[a.responseDelimited?"decodeDelimited":"decode"](e)}catch(t){return a.emit("error",t,n),s(t)}return a.emit("data",e,n),s(null,e)}a.end(!0)}))}catch(t){return a.emit("error",t,n),void setTimeout((function(){s(t)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},e.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service}function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,function(t){t.Service=requireService()}(rpc)),rpc}function requireRoots(){return hasRequiredRoots?roots:(hasRequiredRoots=1,roots={})}function requireIndexMinimal(){return hasRequiredIndexMinimal||(hasRequiredIndexMinimal=1,function(t){var e=t;function n(){e.util._configure(),e.Writer._configure(e.BufferWriter),e.Reader._configure(e.BufferReader)}e.build="minimal",e.Writer=requireWriter(),e.BufferWriter=requireWriter_buffer(),e.Reader=requireReader(),e.BufferReader=requireReader_buffer(),e.util=requireMinimal$1(),e.rpc=requireRpc(),e.roots=requireRoots(),e.configure=n,n()}(indexMinimal)),indexMinimal}function requireMinimal(){return hasRequiredMinimal?minimal:(hasRequiredMinimal=1,minimal=requireIndexMinimal())}function requireGtfsRealtime(){if(hasRequiredGtfsRealtime)return gtfsRealtime;hasRequiredGtfsRealtime=1;var t,e=requireMinimal(),n=e.Reader,i=e.Writer,r=e.util,o=e.roots.default||(e.roots.default={});return o.transit_realtime=((t={}).FeedMessage=function(){function t(t){if(this.entity=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.header=null,t.prototype.entity=r.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),o.transit_realtime.FeedHeader.encode(t.header,e.uint32(10).fork()).ldelim(),null!=t.entity&&t.entity.length)for(var n=0;n<t.entity.length;++n)o.transit_realtime.FeedEntity.encode(t.entity[n],e.uint32(18).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,s=new o.transit_realtime.FeedMessage;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:s.header=o.transit_realtime.FeedHeader.decode(t,t.uint32());break;case 2:s.entity&&s.entity.length||(s.entity=[]),s.entity.push(o.transit_realtime.FeedEntity.decode(t,t.uint32()));break;default:t.skipType(7&a)}}if(!s.hasOwnProperty("header"))throw r.ProtocolError("missing required 'header'",{instance:s});return s},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(n=o.transit_realtime.FeedHeader.verify(t.header))return"header."+n;if(null!=t.entity&&t.hasOwnProperty("entity")){if(!Array.isArray(t.entity))return"entity: array expected";for(var e=0;e<t.entity.length;++e){var n;if(n=o.transit_realtime.FeedEntity.verify(t.entity[e]))return"entity."+n}}return null},t.fromObject=function(t){if(t instanceof o.transit_realtime.FeedMessage)return t;var e=new o.transit_realtime.FeedMessage;if(null!=t.header){if("object"!=typeof t.header)throw TypeError(".transit_realtime.FeedMessage.header: object expected");e.header=o.transit_realtime.FeedHeader.fromObject(t.header)}if(t.entity){if(!Array.isArray(t.entity))throw TypeError(".transit_realtime.FeedMessage.entity: array expected");e.entity=[];for(var n=0;n<t.entity.length;++n){if("object"!=typeof t.entity[n])throw TypeError(".transit_realtime.FeedMessage.entity: object expected");e.entity[n]=o.transit_realtime.FeedEntity.fromObject(t.entity[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.entity=[]),e.defaults&&(n.header=null),null!=t.header&&t.hasOwnProperty("header")&&(n.header=o.transit_realtime.FeedHeader.toObject(t.header,e)),t.entity&&t.entity.length){n.entity=[];for(var i=0;i<t.entity.length;++i)n.entity[i]=o.transit_realtime.FeedEntity.toObject(t.entity[i],e)}return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.FeedMessage"},t}(),t.FeedHeader=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var s,a;return t.prototype.gtfsRealtimeVersion="",t.prototype.incrementality=0,t.prototype.timestamp=r.Long?r.Long.fromBits(0,0,!0):0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),e.uint32(10).string(t.gtfsRealtimeVersion),null!=t.incrementality&&Object.hasOwnProperty.call(t,"incrementality")&&e.uint32(16).int32(t.incrementality),null!=t.timestamp&&Object.hasOwnProperty.call(t,"timestamp")&&e.uint32(24).uint64(t.timestamp),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,s=new o.transit_realtime.FeedHeader;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:s.gtfsRealtimeVersion=t.string();break;case 2:s.incrementality=t.int32();break;case 3:s.timestamp=t.uint64();break;default:t.skipType(7&a)}}if(!s.hasOwnProperty("gtfsRealtimeVersion"))throw r.ProtocolError("missing required 'gtfsRealtimeVersion'",{instance:s});return s},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(!r.isString(t.gtfsRealtimeVersion))return"gtfsRealtimeVersion: string expected";if(null!=t.incrementality&&t.hasOwnProperty("incrementality"))switch(t.incrementality){default:return"incrementality: enum value expected";case 0:case 1:}return null!=t.timestamp&&t.hasOwnProperty("timestamp")&&!(r.isInteger(t.timestamp)||t.timestamp&&r.isInteger(t.timestamp.low)&&r.isInteger(t.timestamp.high))?"timestamp: integer|Long expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.FeedHeader)return t;var e=new o.transit_realtime.FeedHeader;switch(null!=t.gtfsRealtimeVersion&&(e.gtfsRealtimeVersion=String(t.gtfsRealtimeVersion)),t.incrementality){default:if("number"==typeof t.incrementality){e.incrementality=t.incrementality;break}break;case"FULL_DATASET":case 0:e.incrementality=0;break;case"DIFFERENTIAL":case 1:e.incrementality=1}return null!=t.timestamp&&(r.Long?(e.timestamp=r.Long.fromValue(t.timestamp)).unsigned=!0:"string"==typeof t.timestamp?e.timestamp=parseInt(t.timestamp,10):"number"==typeof t.timestamp?e.timestamp=t.timestamp:"object"==typeof t.timestamp&&(e.timestamp=new r.LongBits(t.timestamp.low>>>0,t.timestamp.high>>>0).toNumber(!0))),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults)if(n.gtfsRealtimeVersion="",n.incrementality=e.enums===String?"FULL_DATASET":0,r.Long){var i=new r.Long(0,0,!0);n.timestamp=e.longs===String?i.toString():e.longs===Number?i.toNumber():i}else n.timestamp=e.longs===String?"0":0;return null!=t.gtfsRealtimeVersion&&t.hasOwnProperty("gtfsRealtimeVersion")&&(n.gtfsRealtimeVersion=t.gtfsRealtimeVersion),null!=t.incrementality&&t.hasOwnProperty("incrementality")&&(n.incrementality=e.enums===String?void 0===o.transit_realtime.FeedHeader.Incrementality[t.incrementality]?t.incrementality:o.transit_realtime.FeedHeader.Incrementality[t.incrementality]:t.incrementality),null!=t.timestamp&&t.hasOwnProperty("timestamp")&&(n.timestamp="number"==typeof t.timestamp?e.longs===String?String(t.timestamp):t.timestamp:e.longs===String?r.Long.prototype.toString.call(t.timestamp):e.longs===Number?new r.LongBits(t.timestamp.low>>>0,t.timestamp.high>>>0).toNumber(!0):t.timestamp),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.FeedHeader"},t.Incrementality=(s={},(a=Object.create(s))[s[0]="FULL_DATASET"]=0,a[s[1]="DIFFERENTIAL"]=1,a),t}(),t.FeedEntity=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.id="",t.prototype.isDeleted=!1,t.prototype.tripUpdate=null,t.prototype.vehicle=null,t.prototype.alert=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),e.uint32(10).string(t.id),null!=t.isDeleted&&Object.hasOwnProperty.call(t,"isDeleted")&&e.uint32(16).bool(t.isDeleted),null!=t.tripUpdate&&Object.hasOwnProperty.call(t,"tripUpdate")&&o.transit_realtime.TripUpdate.encode(t.tripUpdate,e.uint32(26).fork()).ldelim(),null!=t.vehicle&&Object.hasOwnProperty.call(t,"vehicle")&&o.transit_realtime.VehiclePosition.encode(t.vehicle,e.uint32(34).fork()).ldelim(),null!=t.alert&&Object.hasOwnProperty.call(t,"alert")&&o.transit_realtime.Alert.encode(t.alert,e.uint32(42).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,s=new o.transit_realtime.FeedEntity;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:s.id=t.string();break;case 2:s.isDeleted=t.bool();break;case 3:s.tripUpdate=o.transit_realtime.TripUpdate.decode(t,t.uint32());break;case 4:s.vehicle=o.transit_realtime.VehiclePosition.decode(t,t.uint32());break;case 5:s.alert=o.transit_realtime.Alert.decode(t,t.uint32());break;default:t.skipType(7&a)}}if(!s.hasOwnProperty("id"))throw r.ProtocolError("missing required 'id'",{instance:s});return s},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":r.isString(t.id)?null!=t.isDeleted&&t.hasOwnProperty("isDeleted")&&"boolean"!=typeof t.isDeleted?"isDeleted: boolean expected":null!=t.tripUpdate&&t.hasOwnProperty("tripUpdate")&&(e=o.transit_realtime.TripUpdate.verify(t.tripUpdate))?"tripUpdate."+e:null!=t.vehicle&&t.hasOwnProperty("vehicle")&&(e=o.transit_realtime.VehiclePosition.verify(t.vehicle))?"vehicle."+e:null!=t.alert&&t.hasOwnProperty("alert")&&(e=o.transit_realtime.Alert.verify(t.alert))?"alert."+e:null:"id: string expected";var e},t.fromObject=function(t){if(t instanceof o.transit_realtime.FeedEntity)return t;var e=new o.transit_realtime.FeedEntity;if(null!=t.id&&(e.id=String(t.id)),null!=t.isDeleted&&(e.isDeleted=Boolean(t.isDeleted)),null!=t.tripUpdate){if("object"!=typeof t.tripUpdate)throw TypeError(".transit_realtime.FeedEntity.tripUpdate: object expected");e.tripUpdate=o.transit_realtime.TripUpdate.fromObject(t.tripUpdate)}if(null!=t.vehicle){if("object"!=typeof t.vehicle)throw TypeError(".transit_realtime.FeedEntity.vehicle: object expected");e.vehicle=o.transit_realtime.VehiclePosition.fromObject(t.vehicle)}if(null!=t.alert){if("object"!=typeof t.alert)throw TypeError(".transit_realtime.FeedEntity.alert: object expected");e.alert=o.transit_realtime.Alert.fromObject(t.alert)}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.id="",n.isDeleted=!1,n.tripUpdate=null,n.vehicle=null,n.alert=null),null!=t.id&&t.hasOwnProperty("id")&&(n.id=t.id),null!=t.isDeleted&&t.hasOwnProperty("isDeleted")&&(n.isDeleted=t.isDeleted),null!=t.tripUpdate&&t.hasOwnProperty("tripUpdate")&&(n.tripUpdate=o.transit_realtime.TripUpdate.toObject(t.tripUpdate,e)),null!=t.vehicle&&t.hasOwnProperty("vehicle")&&(n.vehicle=o.transit_realtime.VehiclePosition.toObject(t.vehicle,e)),null!=t.alert&&t.hasOwnProperty("alert")&&(n.alert=o.transit_realtime.Alert.toObject(t.alert,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.FeedEntity"},t}(),t.TripUpdate=function(){function t(t){if(this.stopTimeUpdate=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.trip=null,t.prototype.vehicle=null,t.prototype.stopTimeUpdate=r.emptyArray,t.prototype.timestamp=r.Long?r.Long.fromBits(0,0,!0):0,t.prototype.delay=0,t.prototype.tripProperties=null,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),o.transit_realtime.TripDescriptor.encode(t.trip,e.uint32(10).fork()).ldelim(),null!=t.stopTimeUpdate&&t.stopTimeUpdate.length)for(var n=0;n<t.stopTimeUpdate.length;++n)o.transit_realtime.TripUpdate.StopTimeUpdate.encode(t.stopTimeUpdate[n],e.uint32(18).fork()).ldelim();return null!=t.vehicle&&Object.hasOwnProperty.call(t,"vehicle")&&o.transit_realtime.VehicleDescriptor.encode(t.vehicle,e.uint32(26).fork()).ldelim(),null!=t.timestamp&&Object.hasOwnProperty.call(t,"timestamp")&&e.uint32(32).uint64(t.timestamp),null!=t.delay&&Object.hasOwnProperty.call(t,"delay")&&e.uint32(40).int32(t.delay),null!=t.tripProperties&&Object.hasOwnProperty.call(t,"tripProperties")&&o.transit_realtime.TripUpdate.TripProperties.encode(t.tripProperties,e.uint32(50).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,s=new o.transit_realtime.TripUpdate;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:s.trip=o.transit_realtime.TripDescriptor.decode(t,t.uint32());break;case 3:s.vehicle=o.transit_realtime.VehicleDescriptor.decode(t,t.uint32());break;case 2:s.stopTimeUpdate&&s.stopTimeUpdate.length||(s.stopTimeUpdate=[]),s.stopTimeUpdate.push(o.transit_realtime.TripUpdate.StopTimeUpdate.decode(t,t.uint32()));break;case 4:s.timestamp=t.uint64();break;case 5:s.delay=t.int32();break;case 6:s.tripProperties=o.transit_realtime.TripUpdate.TripProperties.decode(t,t.uint32());break;default:t.skipType(7&a)}}if(!s.hasOwnProperty("trip"))throw r.ProtocolError("missing required 'trip'",{instance:s});return s},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(n=o.transit_realtime.TripDescriptor.verify(t.trip))return"trip."+n;if(null!=t.vehicle&&t.hasOwnProperty("vehicle")&&(n=o.transit_realtime.VehicleDescriptor.verify(t.vehicle)))return"vehicle."+n;if(null!=t.stopTimeUpdate&&t.hasOwnProperty("stopTimeUpdate")){if(!Array.isArray(t.stopTimeUpdate))return"stopTimeUpdate: array expected";for(var e=0;e<t.stopTimeUpdate.length;++e){var n;if(n=o.transit_realtime.TripUpdate.StopTimeUpdate.verify(t.stopTimeUpdate[e]))return"stopTimeUpdate."+n}}return null!=t.timestamp&&t.hasOwnProperty("timestamp")&&!(r.isInteger(t.timestamp)||t.timestamp&&r.isInteger(t.timestamp.low)&&r.isInteger(t.timestamp.high))?"timestamp: integer|Long expected":null!=t.delay&&t.hasOwnProperty("delay")&&!r.isInteger(t.delay)?"delay: integer expected":null!=t.tripProperties&&t.hasOwnProperty("tripProperties")&&(n=o.transit_realtime.TripUpdate.TripProperties.verify(t.tripProperties))?"tripProperties."+n:null},t.fromObject=function(t){if(t instanceof o.transit_realtime.TripUpdate)return t;var e=new o.transit_realtime.TripUpdate;if(null!=t.trip){if("object"!=typeof t.trip)throw TypeError(".transit_realtime.TripUpdate.trip: object expected");e.trip=o.transit_realtime.TripDescriptor.fromObject(t.trip)}if(null!=t.vehicle){if("object"!=typeof t.vehicle)throw TypeError(".transit_realtime.TripUpdate.vehicle: object expected");e.vehicle=o.transit_realtime.VehicleDescriptor.fromObject(t.vehicle)}if(t.stopTimeUpdate){if(!Array.isArray(t.stopTimeUpdate))throw TypeError(".transit_realtime.TripUpdate.stopTimeUpdate: array expected");e.stopTimeUpdate=[];for(var n=0;n<t.stopTimeUpdate.length;++n){if("object"!=typeof t.stopTimeUpdate[n])throw TypeError(".transit_realtime.TripUpdate.stopTimeUpdate: object expected");e.stopTimeUpdate[n]=o.transit_realtime.TripUpdate.StopTimeUpdate.fromObject(t.stopTimeUpdate[n])}}if(null!=t.timestamp&&(r.Long?(e.timestamp=r.Long.fromValue(t.timestamp)).unsigned=!0:"string"==typeof t.timestamp?e.timestamp=parseInt(t.timestamp,10):"number"==typeof t.timestamp?e.timestamp=t.timestamp:"object"==typeof t.timestamp&&(e.timestamp=new r.LongBits(t.timestamp.low>>>0,t.timestamp.high>>>0).toNumber(!0))),null!=t.delay&&(e.delay=0|t.delay),null!=t.tripProperties){if("object"!=typeof t.tripProperties)throw TypeError(".transit_realtime.TripUpdate.tripProperties: object expected");e.tripProperties=o.transit_realtime.TripUpdate.TripProperties.fromObject(t.tripProperties)}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.stopTimeUpdate=[]),e.defaults){if(n.trip=null,n.vehicle=null,r.Long){var i=new r.Long(0,0,!0);n.timestamp=e.longs===String?i.toString():e.longs===Number?i.toNumber():i}else n.timestamp=e.longs===String?"0":0;n.delay=0,n.tripProperties=null}if(null!=t.trip&&t.hasOwnProperty("trip")&&(n.trip=o.transit_realtime.TripDescriptor.toObject(t.trip,e)),t.stopTimeUpdate&&t.stopTimeUpdate.length){n.stopTimeUpdate=[];for(var s=0;s<t.stopTimeUpdate.length;++s)n.stopTimeUpdate[s]=o.transit_realtime.TripUpdate.StopTimeUpdate.toObject(t.stopTimeUpdate[s],e)}return null!=t.vehicle&&t.hasOwnProperty("vehicle")&&(n.vehicle=o.transit_realtime.VehicleDescriptor.toObject(t.vehicle,e)),null!=t.timestamp&&t.hasOwnProperty("timestamp")&&(n.timestamp="number"==typeof t.timestamp?e.longs===String?String(t.timestamp):t.timestamp:e.longs===String?r.Long.prototype.toString.call(t.timestamp):e.longs===Number?new r.LongBits(t.timestamp.low>>>0,t.timestamp.high>>>0).toNumber(!0):t.timestamp),null!=t.delay&&t.hasOwnProperty("delay")&&(n.delay=t.delay),null!=t.tripProperties&&t.hasOwnProperty("tripProperties")&&(n.tripProperties=o.transit_realtime.TripUpdate.TripProperties.toObject(t.tripProperties,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TripUpdate"},t.StopTimeEvent=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.delay=0,t.prototype.time=r.Long?r.Long.fromBits(0,0,!1):0,t.prototype.uncertainty=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.delay&&Object.hasOwnProperty.call(t,"delay")&&e.uint32(8).int32(t.delay),null!=t.time&&Object.hasOwnProperty.call(t,"time")&&e.uint32(16).int64(t.time),null!=t.uncertainty&&Object.hasOwnProperty.call(t,"uncertainty")&&e.uint32(24).int32(t.uncertainty),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.TripUpdate.StopTimeEvent;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.delay=t.int32();break;case 2:r.time=t.int64();break;case 3:r.uncertainty=t.int32();break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.delay&&t.hasOwnProperty("delay")&&!r.isInteger(t.delay)?"delay: integer expected":null!=t.time&&t.hasOwnProperty("time")&&!(r.isInteger(t.time)||t.time&&r.isInteger(t.time.low)&&r.isInteger(t.time.high))?"time: integer|Long expected":null!=t.uncertainty&&t.hasOwnProperty("uncertainty")&&!r.isInteger(t.uncertainty)?"uncertainty: integer expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.TripUpdate.StopTimeEvent)return t;var e=new o.transit_realtime.TripUpdate.StopTimeEvent;return null!=t.delay&&(e.delay=0|t.delay),null!=t.time&&(r.Long?(e.time=r.Long.fromValue(t.time)).unsigned=!1:"string"==typeof t.time?e.time=parseInt(t.time,10):"number"==typeof t.time?e.time=t.time:"object"==typeof t.time&&(e.time=new r.LongBits(t.time.low>>>0,t.time.high>>>0).toNumber())),null!=t.uncertainty&&(e.uncertainty=0|t.uncertainty),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults){if(n.delay=0,r.Long){var i=new r.Long(0,0,!1);n.time=e.longs===String?i.toString():e.longs===Number?i.toNumber():i}else n.time=e.longs===String?"0":0;n.uncertainty=0}return null!=t.delay&&t.hasOwnProperty("delay")&&(n.delay=t.delay),null!=t.time&&t.hasOwnProperty("time")&&(n.time="number"==typeof t.time?e.longs===String?String(t.time):t.time:e.longs===String?r.Long.prototype.toString.call(t.time):e.longs===Number?new r.LongBits(t.time.low>>>0,t.time.high>>>0).toNumber():t.time),null!=t.uncertainty&&t.hasOwnProperty("uncertainty")&&(n.uncertainty=t.uncertainty),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TripUpdate.StopTimeEvent"},t}(),t.StopTimeUpdate=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var s,a;return t.prototype.stopSequence=0,t.prototype.stopId="",t.prototype.arrival=null,t.prototype.departure=null,t.prototype.scheduleRelationship=0,t.prototype.stopTimeProperties=null,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.stopSequence&&Object.hasOwnProperty.call(t,"stopSequence")&&e.uint32(8).uint32(t.stopSequence),null!=t.arrival&&Object.hasOwnProperty.call(t,"arrival")&&o.transit_realtime.TripUpdate.StopTimeEvent.encode(t.arrival,e.uint32(18).fork()).ldelim(),null!=t.departure&&Object.hasOwnProperty.call(t,"departure")&&o.transit_realtime.TripUpdate.StopTimeEvent.encode(t.departure,e.uint32(26).fork()).ldelim(),null!=t.stopId&&Object.hasOwnProperty.call(t,"stopId")&&e.uint32(34).string(t.stopId),null!=t.scheduleRelationship&&Object.hasOwnProperty.call(t,"scheduleRelationship")&&e.uint32(40).int32(t.scheduleRelationship),null!=t.stopTimeProperties&&Object.hasOwnProperty.call(t,"stopTimeProperties")&&o.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.encode(t.stopTimeProperties,e.uint32(50).fork()).ldelim(),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.TripUpdate.StopTimeUpdate;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.stopSequence=t.uint32();break;case 4:r.stopId=t.string();break;case 2:r.arrival=o.transit_realtime.TripUpdate.StopTimeEvent.decode(t,t.uint32());break;case 3:r.departure=o.transit_realtime.TripUpdate.StopTimeEvent.decode(t,t.uint32());break;case 5:r.scheduleRelationship=t.int32();break;case 6:r.stopTimeProperties=o.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.decode(t,t.uint32());break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.stopSequence&&t.hasOwnProperty("stopSequence")&&!r.isInteger(t.stopSequence))return"stopSequence: integer expected";if(null!=t.stopId&&t.hasOwnProperty("stopId")&&!r.isString(t.stopId))return"stopId: string expected";var e;if(null!=t.arrival&&t.hasOwnProperty("arrival")&&(e=o.transit_realtime.TripUpdate.StopTimeEvent.verify(t.arrival)))return"arrival."+e;if(null!=t.departure&&t.hasOwnProperty("departure")&&(e=o.transit_realtime.TripUpdate.StopTimeEvent.verify(t.departure)))return"departure."+e;if(null!=t.scheduleRelationship&&t.hasOwnProperty("scheduleRelationship"))switch(t.scheduleRelationship){default:return"scheduleRelationship: enum value expected";case 0:case 1:case 2:case 3:}return null!=t.stopTimeProperties&&t.hasOwnProperty("stopTimeProperties")&&(e=o.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.verify(t.stopTimeProperties))?"stopTimeProperties."+e:null},t.fromObject=function(t){if(t instanceof o.transit_realtime.TripUpdate.StopTimeUpdate)return t;var e=new o.transit_realtime.TripUpdate.StopTimeUpdate;if(null!=t.stopSequence&&(e.stopSequence=t.stopSequence>>>0),null!=t.stopId&&(e.stopId=String(t.stopId)),null!=t.arrival){if("object"!=typeof t.arrival)throw TypeError(".transit_realtime.TripUpdate.StopTimeUpdate.arrival: object expected");e.arrival=o.transit_realtime.TripUpdate.StopTimeEvent.fromObject(t.arrival)}if(null!=t.departure){if("object"!=typeof t.departure)throw TypeError(".transit_realtime.TripUpdate.StopTimeUpdate.departure: object expected");e.departure=o.transit_realtime.TripUpdate.StopTimeEvent.fromObject(t.departure)}switch(t.scheduleRelationship){default:if("number"==typeof t.scheduleRelationship){e.scheduleRelationship=t.scheduleRelationship;break}break;case"SCHEDULED":case 0:e.scheduleRelationship=0;break;case"SKIPPED":case 1:e.scheduleRelationship=1;break;case"NO_DATA":case 2:e.scheduleRelationship=2;break;case"UNSCHEDULED":case 3:e.scheduleRelationship=3}if(null!=t.stopTimeProperties){if("object"!=typeof t.stopTimeProperties)throw TypeError(".transit_realtime.TripUpdate.StopTimeUpdate.stopTimeProperties: object expected");e.stopTimeProperties=o.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.fromObject(t.stopTimeProperties)}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.stopSequence=0,n.arrival=null,n.departure=null,n.stopId="",n.scheduleRelationship=e.enums===String?"SCHEDULED":0,n.stopTimeProperties=null),null!=t.stopSequence&&t.hasOwnProperty("stopSequence")&&(n.stopSequence=t.stopSequence),null!=t.arrival&&t.hasOwnProperty("arrival")&&(n.arrival=o.transit_realtime.TripUpdate.StopTimeEvent.toObject(t.arrival,e)),null!=t.departure&&t.hasOwnProperty("departure")&&(n.departure=o.transit_realtime.TripUpdate.StopTimeEvent.toObject(t.departure,e)),null!=t.stopId&&t.hasOwnProperty("stopId")&&(n.stopId=t.stopId),null!=t.scheduleRelationship&&t.hasOwnProperty("scheduleRelationship")&&(n.scheduleRelationship=e.enums===String?void 0===o.transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship[t.scheduleRelationship]?t.scheduleRelationship:o.transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship[t.scheduleRelationship]:t.scheduleRelationship),null!=t.stopTimeProperties&&t.hasOwnProperty("stopTimeProperties")&&(n.stopTimeProperties=o.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.toObject(t.stopTimeProperties,e)),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TripUpdate.StopTimeUpdate"},t.ScheduleRelationship=(s={},(a=Object.create(s))[s[0]="SCHEDULED"]=0,a[s[1]="SKIPPED"]=1,a[s[2]="NO_DATA"]=2,a[s[3]="UNSCHEDULED"]=3,a),t.StopTimeProperties=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.assignedStopId="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.assignedStopId&&Object.hasOwnProperty.call(t,"assignedStopId")&&e.uint32(10).string(t.assignedStopId),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties;t.pos<i;){var s=t.uint32();s>>>3==1?r.assignedStopId=t.string():t.skipType(7&s)}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.assignedStopId&&t.hasOwnProperty("assignedStopId")&&!r.isString(t.assignedStopId)?"assignedStopId: string expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties)return t;var e=new o.transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties;return null!=t.assignedStopId&&(e.assignedStopId=String(t.assignedStopId)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.assignedStopId=""),null!=t.assignedStopId&&t.hasOwnProperty("assignedStopId")&&(n.assignedStopId=t.assignedStopId),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties"},t}(),t}(),t.TripProperties=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.tripId="",t.prototype.startDate="",t.prototype.startTime="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.tripId&&Object.hasOwnProperty.call(t,"tripId")&&e.uint32(10).string(t.tripId),null!=t.startDate&&Object.hasOwnProperty.call(t,"startDate")&&e.uint32(18).string(t.startDate),null!=t.startTime&&Object.hasOwnProperty.call(t,"startTime")&&e.uint32(26).string(t.startTime),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.TripUpdate.TripProperties;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.tripId=t.string();break;case 2:r.startDate=t.string();break;case 3:r.startTime=t.string();break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.tripId&&t.hasOwnProperty("tripId")&&!r.isString(t.tripId)?"tripId: string expected":null!=t.startDate&&t.hasOwnProperty("startDate")&&!r.isString(t.startDate)?"startDate: string expected":null!=t.startTime&&t.hasOwnProperty("startTime")&&!r.isString(t.startTime)?"startTime: string expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.TripUpdate.TripProperties)return t;var e=new o.transit_realtime.TripUpdate.TripProperties;return null!=t.tripId&&(e.tripId=String(t.tripId)),null!=t.startDate&&(e.startDate=String(t.startDate)),null!=t.startTime&&(e.startTime=String(t.startTime)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.tripId="",n.startDate="",n.startTime=""),null!=t.tripId&&t.hasOwnProperty("tripId")&&(n.tripId=t.tripId),null!=t.startDate&&t.hasOwnProperty("startDate")&&(n.startDate=t.startDate),null!=t.startTime&&t.hasOwnProperty("startTime")&&(n.startTime=t.startTime),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TripUpdate.TripProperties"},t}(),t}(),t.VehiclePosition=function(){function t(t){if(this.multiCarriageDetails=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var s,a;return t.prototype.trip=null,t.prototype.vehicle=null,t.prototype.position=null,t.prototype.currentStopSequence=0,t.prototype.stopId="",t.prototype.currentStatus=2,t.prototype.timestamp=r.Long?r.Long.fromBits(0,0,!0):0,t.prototype.congestionLevel=0,t.prototype.occupancyStatus=0,t.prototype.occupancyPercentage=0,t.prototype.multiCarriageDetails=r.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.trip&&Object.hasOwnProperty.call(t,"trip")&&o.transit_realtime.TripDescriptor.encode(t.trip,e.uint32(10).fork()).ldelim(),null!=t.position&&Object.hasOwnProperty.call(t,"position")&&o.transit_realtime.Position.encode(t.position,e.uint32(18).fork()).ldelim(),null!=t.currentStopSequence&&Object.hasOwnProperty.call(t,"currentStopSequence")&&e.uint32(24).uint32(t.currentStopSequence),null!=t.currentStatus&&Object.hasOwnProperty.call(t,"currentStatus")&&e.uint32(32).int32(t.currentStatus),null!=t.timestamp&&Object.hasOwnProperty.call(t,"timestamp")&&e.uint32(40).uint64(t.timestamp),null!=t.congestionLevel&&Object.hasOwnProperty.call(t,"congestionLevel")&&e.uint32(48).int32(t.congestionLevel),null!=t.stopId&&Object.hasOwnProperty.call(t,"stopId")&&e.uint32(58).string(t.stopId),null!=t.vehicle&&Object.hasOwnProperty.call(t,"vehicle")&&o.transit_realtime.VehicleDescriptor.encode(t.vehicle,e.uint32(66).fork()).ldelim(),null!=t.occupancyStatus&&Object.hasOwnProperty.call(t,"occupancyStatus")&&e.uint32(72).int32(t.occupancyStatus),null!=t.occupancyPercentage&&Object.hasOwnProperty.call(t,"occupancyPercentage")&&e.uint32(80).uint32(t.occupancyPercentage),null!=t.multiCarriageDetails&&t.multiCarriageDetails.length)for(var n=0;n<t.multiCarriageDetails.length;++n)o.transit_realtime.VehiclePosition.CarriageDetails.encode(t.multiCarriageDetails[n],e.uint32(90).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.VehiclePosition;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.trip=o.transit_realtime.TripDescriptor.decode(t,t.uint32());break;case 8:r.vehicle=o.transit_realtime.VehicleDescriptor.decode(t,t.uint32());break;case 2:r.position=o.transit_realtime.Position.decode(t,t.uint32());break;case 3:r.currentStopSequence=t.uint32();break;case 7:r.stopId=t.string();break;case 4:r.currentStatus=t.int32();break;case 5:r.timestamp=t.uint64();break;case 6:r.congestionLevel=t.int32();break;case 9:r.occupancyStatus=t.int32();break;case 10:r.occupancyPercentage=t.uint32();break;case 11:r.multiCarriageDetails&&r.multiCarriageDetails.length||(r.multiCarriageDetails=[]),r.multiCarriageDetails.push(o.transit_realtime.VehiclePosition.CarriageDetails.decode(t,t.uint32()));break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.trip&&t.hasOwnProperty("trip")&&(n=o.transit_realtime.TripDescriptor.verify(t.trip)))return"trip."+n;if(null!=t.vehicle&&t.hasOwnProperty("vehicle")&&(n=o.transit_realtime.VehicleDescriptor.verify(t.vehicle)))return"vehicle."+n;if(null!=t.position&&t.hasOwnProperty("position")&&(n=o.transit_realtime.Position.verify(t.position)))return"position."+n;if(null!=t.currentStopSequence&&t.hasOwnProperty("currentStopSequence")&&!r.isInteger(t.currentStopSequence))return"currentStopSequence: integer expected";if(null!=t.stopId&&t.hasOwnProperty("stopId")&&!r.isString(t.stopId))return"stopId: string expected";if(null!=t.currentStatus&&t.hasOwnProperty("currentStatus"))switch(t.currentStatus){default:return"currentStatus: enum value expected";case 0:case 1:case 2:}if(null!=t.timestamp&&t.hasOwnProperty("timestamp")&&!(r.isInteger(t.timestamp)||t.timestamp&&r.isInteger(t.timestamp.low)&&r.isInteger(t.timestamp.high)))return"timestamp: integer|Long expected";if(null!=t.congestionLevel&&t.hasOwnProperty("congestionLevel"))switch(t.congestionLevel){default:return"congestionLevel: enum value expected";case 0:case 1:case 2:case 3:case 4:}if(null!=t.occupancyStatus&&t.hasOwnProperty("occupancyStatus"))switch(t.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!=t.occupancyPercentage&&t.hasOwnProperty("occupancyPercentage")&&!r.isInteger(t.occupancyPercentage))return"occupancyPercentage: integer expected";if(null!=t.multiCarriageDetails&&t.hasOwnProperty("multiCarriageDetails")){if(!Array.isArray(t.multiCarriageDetails))return"multiCarriageDetails: array expected";for(var e=0;e<t.multiCarriageDetails.length;++e){var n;if(n=o.transit_realtime.VehiclePosition.CarriageDetails.verify(t.multiCarriageDetails[e]))return"multiCarriageDetails."+n}}return null},t.fromObject=function(t){if(t instanceof o.transit_realtime.VehiclePosition)return t;var e=new o.transit_realtime.VehiclePosition;if(null!=t.trip){if("object"!=typeof t.trip)throw TypeError(".transit_realtime.VehiclePosition.trip: object expected");e.trip=o.transit_realtime.TripDescriptor.fromObject(t.trip)}if(null!=t.vehicle){if("object"!=typeof t.vehicle)throw TypeError(".transit_realtime.VehiclePosition.vehicle: object expected");e.vehicle=o.transit_realtime.VehicleDescriptor.fromObject(t.vehicle)}if(null!=t.position){if("object"!=typeof t.position)throw TypeError(".transit_realtime.VehiclePosition.position: object expected");e.position=o.transit_realtime.Position.fromObject(t.position)}switch(null!=t.currentStopSequence&&(e.currentStopSequence=t.currentStopSequence>>>0),null!=t.stopId&&(e.stopId=String(t.stopId)),t.currentStatus){case"INCOMING_AT":case 0:e.currentStatus=0;break;case"STOPPED_AT":case 1:e.currentStatus=1;break;default:if("number"==typeof t.currentStatus){e.currentStatus=t.currentStatus;break}break;case"IN_TRANSIT_TO":case 2:e.currentStatus=2}switch(null!=t.timestamp&&(r.Long?(e.timestamp=r.Long.fromValue(t.timestamp)).unsigned=!0:"string"==typeof t.timestamp?e.timestamp=parseInt(t.timestamp,10):"number"==typeof t.timestamp?e.timestamp=t.timestamp:"object"==typeof t.timestamp&&(e.timestamp=new r.LongBits(t.timestamp.low>>>0,t.timestamp.high>>>0).toNumber(!0))),t.congestionLevel){default:if("number"==typeof t.congestionLevel){e.congestionLevel=t.congestionLevel;break}break;case"UNKNOWN_CONGESTION_LEVEL":case 0:e.congestionLevel=0;break;case"RUNNING_SMOOTHLY":case 1:e.congestionLevel=1;break;case"STOP_AND_GO":case 2:e.congestionLevel=2;break;case"CONGESTION":case 3:e.congestionLevel=3;break;case"SEVERE_CONGESTION":case 4:e.congestionLevel=4}switch(t.occupancyStatus){default:if("number"==typeof t.occupancyStatus){e.occupancyStatus=t.occupancyStatus;break}break;case"EMPTY":case 0:e.occupancyStatus=0;break;case"MANY_SEATS_AVAILABLE":case 1:e.occupancyStatus=1;break;case"FEW_SEATS_AVAILABLE":case 2:e.occupancyStatus=2;break;case"STANDING_ROOM_ONLY":case 3:e.occupancyStatus=3;break;case"CRUSHED_STANDING_ROOM_ONLY":case 4:e.occupancyStatus=4;break;case"FULL":case 5:e.occupancyStatus=5;break;case"NOT_ACCEPTING_PASSENGERS":case 6:e.occupancyStatus=6;break;case"NO_DATA_AVAILABLE":case 7:e.occupancyStatus=7;break;case"NOT_BOARDABLE":case 8:e.occupancyStatus=8}if(null!=t.occupancyPercentage&&(e.occupancyPercentage=t.occupancyPercentage>>>0),t.multiCarriageDetails){if(!Array.isArray(t.multiCarriageDetails))throw TypeError(".transit_realtime.VehiclePosition.multiCarriageDetails: array expected");e.multiCarriageDetails=[];for(var n=0;n<t.multiCarriageDetails.length;++n){if("object"!=typeof t.multiCarriageDetails[n])throw TypeError(".transit_realtime.VehiclePosition.multiCarriageDetails: object expected");e.multiCarriageDetails[n]=o.transit_realtime.VehiclePosition.CarriageDetails.fromObject(t.multiCarriageDetails[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.multiCarriageDetails=[]),e.defaults){if(n.trip=null,n.position=null,n.currentStopSequence=0,n.currentStatus=e.enums===String?"IN_TRANSIT_TO":2,r.Long){var i=new r.Long(0,0,!0);n.timestamp=e.longs===String?i.toString():e.longs===Number?i.toNumber():i}else n.timestamp=e.longs===String?"0":0;n.congestionLevel=e.enums===String?"UNKNOWN_CONGESTION_LEVEL":0,n.stopId="",n.vehicle=null,n.occupancyStatus=e.enums===String?"EMPTY":0,n.occupancyPercentage=0}if(null!=t.trip&&t.hasOwnProperty("trip")&&(n.trip=o.transit_realtime.TripDescriptor.toObject(t.trip,e)),null!=t.position&&t.hasOwnProperty("position")&&(n.position=o.transit_realtime.Position.toObject(t.position,e)),null!=t.currentStopSequence&&t.hasOwnProperty("currentStopSequence")&&(n.currentStopSequence=t.currentStopSequence),null!=t.currentStatus&&t.hasOwnProperty("currentStatus")&&(n.currentStatus=e.enums===String?void 0===o.transit_realtime.VehiclePosition.VehicleStopStatus[t.currentStatus]?t.currentStatus:o.transit_realtime.VehiclePosition.VehicleStopStatus[t.currentStatus]:t.currentStatus),null!=t.timestamp&&t.hasOwnProperty("timestamp")&&(n.timestamp="number"==typeof t.timestamp?e.longs===String?String(t.timestamp):t.timestamp:e.longs===String?r.Long.prototype.toString.call(t.timestamp):e.longs===Number?new r.LongBits(t.timestamp.low>>>0,t.timestamp.high>>>0).toNumber(!0):t.timestamp),null!=t.congestionLevel&&t.hasOwnProperty("congestionLevel")&&(n.congestionLevel=e.enums===String?void 0===o.transit_realtime.VehiclePosition.CongestionLevel[t.congestionLevel]?t.congestionLevel:o.transit_realtime.VehiclePosition.CongestionLevel[t.congestionLevel]:t.congestionLevel),null!=t.stopId&&t.hasOwnProperty("stopId")&&(n.stopId=t.stopId),null!=t.vehicle&&t.hasOwnProperty("vehicle")&&(n.vehicle=o.transit_realtime.VehicleDescriptor.toObject(t.vehicle,e)),null!=t.occupancyStatus&&t.hasOwnProperty("occupancyStatus")&&(n.occupancyStatus=e.enums===String?void 0===o.transit_realtime.VehiclePosition.OccupancyStatus[t.occupancyStatus]?t.occupancyStatus:o.transit_realtime.VehiclePosition.OccupancyStatus[t.occupancyStatus]:t.occupancyStatus),null!=t.occupancyPercentage&&t.hasOwnProperty("occupancyPercentage")&&(n.occupancyPercentage=t.occupancyPercentage),t.multiCarriageDetails&&t.multiCarriageDetails.length){n.multiCarriageDetails=[];for(var s=0;s<t.multiCarriageDetails.length;++s)n.multiCarriageDetails[s]=o.transit_realtime.VehiclePosition.CarriageDetails.toObject(t.multiCarriageDetails[s],e)}return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.VehiclePosition"},t.VehicleStopStatus=(s={},(a=Object.create(s))[s[0]="INCOMING_AT"]=0,a[s[1]="STOPPED_AT"]=1,a[s[2]="IN_TRANSIT_TO"]=2,a),t.CongestionLevel=function(){var t={},e=Object.create(t);return e[t[0]="UNKNOWN_CONGESTION_LEVEL"]=0,e[t[1]="RUNNING_SMOOTHLY"]=1,e[t[2]="STOP_AND_GO"]=2,e[t[3]="CONGESTION"]=3,e[t[4]="SEVERE_CONGESTION"]=4,e}(),t.OccupancyStatus=function(){var t={},e=Object.create(t);return e[t[0]="EMPTY"]=0,e[t[1]="MANY_SEATS_AVAILABLE"]=1,e[t[2]="FEW_SEATS_AVAILABLE"]=2,e[t[3]="STANDING_ROOM_ONLY"]=3,e[t[4]="CRUSHED_STANDING_ROOM_ONLY"]=4,e[t[5]="FULL"]=5,e[t[6]="NOT_ACCEPTING_PASSENGERS"]=6,e[t[7]="NO_DATA_AVAILABLE"]=7,e[t[8]="NOT_BOARDABLE"]=8,e}(),t.CarriageDetails=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.id="",t.prototype.label="",t.prototype.occupancyStatus=7,t.prototype.occupancyPercentage=-1,t.prototype.carriageSequence=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.id&&Object.hasOwnProperty.call(t,"id")&&e.uint32(10).string(t.id),null!=t.label&&Object.hasOwnProperty.call(t,"label")&&e.uint32(18).string(t.label),null!=t.occupancyStatus&&Object.hasOwnProperty.call(t,"occupancyStatus")&&e.uint32(24).int32(t.occupancyStatus),null!=t.occupancyPercentage&&Object.hasOwnProperty.call(t,"occupancyPercentage")&&e.uint32(32).int32(t.occupancyPercentage),null!=t.carriageSequence&&Object.hasOwnProperty.call(t,"carriageSequence")&&e.uint32(40).uint32(t.carriageSequence),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.VehiclePosition.CarriageDetails;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.id=t.string();break;case 2:r.label=t.string();break;case 3:r.occupancyStatus=t.int32();break;case 4:r.occupancyPercentage=t.int32();break;case 5:r.carriageSequence=t.uint32();break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.id&&t.hasOwnProperty("id")&&!r.isString(t.id))return"id: string expected";if(null!=t.label&&t.hasOwnProperty("label")&&!r.isString(t.label))return"label: string expected";if(null!=t.occupancyStatus&&t.hasOwnProperty("occupancyStatus"))switch(t.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!=t.occupancyPercentage&&t.hasOwnProperty("occupancyPercentage")&&!r.isInteger(t.occupancyPercentage)?"occupancyPercentage: integer expected":null!=t.carriageSequence&&t.hasOwnProperty("carriageSequence")&&!r.isInteger(t.carriageSequence)?"carriageSequence: integer expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.VehiclePosition.CarriageDetails)return t;var e=new o.transit_realtime.VehiclePosition.CarriageDetails;switch(null!=t.id&&(e.id=String(t.id)),null!=t.label&&(e.label=String(t.label)),t.occupancyStatus){case"EMPTY":case 0:e.occupancyStatus=0;break;case"MANY_SEATS_AVAILABLE":case 1:e.occupancyStatus=1;break;case"FEW_SEATS_AVAILABLE":case 2:e.occupancyStatus=2;break;case"STANDING_ROOM_ONLY":case 3:e.occupancyStatus=3;break;case"CRUSHED_STANDING_ROOM_ONLY":case 4:e.occupancyStatus=4;break;case"FULL":case 5:e.occupancyStatus=5;break;case"NOT_ACCEPTING_PASSENGERS":case 6:e.occupancyStatus=6;break;default:if("number"==typeof t.occupancyStatus){e.occupancyStatus=t.occupancyStatus;break}break;case"NO_DATA_AVAILABLE":case 7:e.occupancyStatus=7;break;case"NOT_BOARDABLE":case 8:e.occupancyStatus=8}return null!=t.occupancyPercentage&&(e.occupancyPercentage=0|t.occupancyPercentage),null!=t.carriageSequence&&(e.carriageSequence=t.carriageSequence>>>0),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.id="",n.label="",n.occupancyStatus=e.enums===String?"NO_DATA_AVAILABLE":7,n.occupancyPercentage=-1,n.carriageSequence=0),null!=t.id&&t.hasOwnProperty("id")&&(n.id=t.id),null!=t.label&&t.hasOwnProperty("label")&&(n.label=t.label),null!=t.occupancyStatus&&t.hasOwnProperty("occupancyStatus")&&(n.occupancyStatus=e.enums===String?void 0===o.transit_realtime.VehiclePosition.OccupancyStatus[t.occupancyStatus]?t.occupancyStatus:o.transit_realtime.VehiclePosition.OccupancyStatus[t.occupancyStatus]:t.occupancyStatus),null!=t.occupancyPercentage&&t.hasOwnProperty("occupancyPercentage")&&(n.occupancyPercentage=t.occupancyPercentage),null!=t.carriageSequence&&t.hasOwnProperty("carriageSequence")&&(n.carriageSequence=t.carriageSequence),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.VehiclePosition.CarriageDetails"},t}(),t}(),t.Alert=function(){function t(t){if(this.activePeriod=[],this.informedEntity=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var s,a;return t.prototype.activePeriod=r.emptyArray,t.prototype.informedEntity=r.emptyArray,t.prototype.cause=1,t.prototype.effect=8,t.prototype.url=null,t.prototype.headerText=null,t.prototype.descriptionText=null,t.prototype.ttsHeaderText=null,t.prototype.ttsDescriptionText=null,t.prototype.severityLevel=1,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.activePeriod&&t.activePeriod.length)for(var n=0;n<t.activePeriod.length;++n)o.transit_realtime.TimeRange.encode(t.activePeriod[n],e.uint32(10).fork()).ldelim();if(null!=t.informedEntity&&t.informedEntity.length)for(n=0;n<t.informedEntity.length;++n)o.transit_realtime.EntitySelector.encode(t.informedEntity[n],e.uint32(42).fork()).ldelim();return null!=t.cause&&Object.hasOwnProperty.call(t,"cause")&&e.uint32(48).int32(t.cause),null!=t.effect&&Object.hasOwnProperty.call(t,"effect")&&e.uint32(56).int32(t.effect),null!=t.url&&Object.hasOwnProperty.call(t,"url")&&o.transit_realtime.TranslatedString.encode(t.url,e.uint32(66).fork()).ldelim(),null!=t.headerText&&Object.hasOwnProperty.call(t,"headerText")&&o.transit_realtime.TranslatedString.encode(t.headerText,e.uint32(82).fork()).ldelim(),null!=t.descriptionText&&Object.hasOwnProperty.call(t,"descriptionText")&&o.transit_realtime.TranslatedString.encode(t.descriptionText,e.uint32(90).fork()).ldelim(),null!=t.ttsHeaderText&&Object.hasOwnProperty.call(t,"ttsHeaderText")&&o.transit_realtime.TranslatedString.encode(t.ttsHeaderText,e.uint32(98).fork()).ldelim(),null!=t.ttsDescriptionText&&Object.hasOwnProperty.call(t,"ttsDescriptionText")&&o.transit_realtime.TranslatedString.encode(t.ttsDescriptionText,e.uint32(106).fork()).ldelim(),null!=t.severityLevel&&Object.hasOwnProperty.call(t,"severityLevel")&&e.uint32(112).int32(t.severityLevel),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.Alert;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.activePeriod&&r.activePeriod.length||(r.activePeriod=[]),r.activePeriod.push(o.transit_realtime.TimeRange.decode(t,t.uint32()));break;case 5:r.informedEntity&&r.informedEntity.length||(r.informedEntity=[]),r.informedEntity.push(o.transit_realtime.EntitySelector.decode(t,t.uint32()));break;case 6:r.cause=t.int32();break;case 7:r.effect=t.int32();break;case 8:r.url=o.transit_realtime.TranslatedString.decode(t,t.uint32());break;case 10:r.headerText=o.transit_realtime.TranslatedString.decode(t,t.uint32());break;case 11:r.descriptionText=o.transit_realtime.TranslatedString.decode(t,t.uint32());break;case 12:r.ttsHeaderText=o.transit_realtime.TranslatedString.decode(t,t.uint32());break;case 13:r.ttsDescriptionText=o.transit_realtime.TranslatedString.decode(t,t.uint32());break;case 14:r.severityLevel=t.int32();break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.activePeriod&&t.hasOwnProperty("activePeriod")){if(!Array.isArray(t.activePeriod))return"activePeriod: array expected";for(var e=0;e<t.activePeriod.length;++e)if(n=o.transit_realtime.TimeRange.verify(t.activePeriod[e]))return"activePeriod."+n}if(null!=t.informedEntity&&t.hasOwnProperty("informedEntity")){if(!Array.isArray(t.informedEntity))return"informedEntity: array expected";for(e=0;e<t.informedEntity.length;++e)if(n=o.transit_realtime.EntitySelector.verify(t.informedEntity[e]))return"informedEntity."+n}if(null!=t.cause&&t.hasOwnProperty("cause"))switch(t.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:}if(null!=t.effect&&t.hasOwnProperty("effect"))switch(t.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!=t.url&&t.hasOwnProperty("url")&&(n=o.transit_realtime.TranslatedString.verify(t.url)))return"url."+n;if(null!=t.headerText&&t.hasOwnProperty("headerText")&&(n=o.transit_realtime.TranslatedString.verify(t.headerText)))return"headerText."+n;if(null!=t.descriptionText&&t.hasOwnProperty("descriptionText")&&(n=o.transit_realtime.TranslatedString.verify(t.descriptionText)))return"descriptionText."+n;if(null!=t.ttsHeaderText&&t.hasOwnProperty("ttsHeaderText")&&(n=o.transit_realtime.TranslatedString.verify(t.ttsHeaderText)))return"ttsHeaderText."+n;if(null!=t.ttsDescriptionText&&t.hasOwnProperty("ttsDescriptionText")&&(n=o.transit_realtime.TranslatedString.verify(t.ttsDescriptionText)))return"ttsDescriptionText."+n;if(null!=t.severityLevel&&t.hasOwnProperty("severityLevel"))switch(t.severityLevel){default:return"severityLevel: enum value expected";case 1:case 2:case 3:case 4:}return null},t.fromObject=function(t){if(t instanceof o.transit_realtime.Alert)return t;var e=new o.transit_realtime.Alert;if(t.activePeriod){if(!Array.isArray(t.activePeriod))throw TypeError(".transit_realtime.Alert.activePeriod: array expected");e.activePeriod=[];for(var n=0;n<t.activePeriod.length;++n){if("object"!=typeof t.activePeriod[n])throw TypeError(".transit_realtime.Alert.activePeriod: object expected");e.activePeriod[n]=o.transit_realtime.TimeRange.fromObject(t.activePeriod[n])}}if(t.informedEntity){if(!Array.isArray(t.informedEntity))throw TypeError(".transit_realtime.Alert.informedEntity: array expected");for(e.informedEntity=[],n=0;n<t.informedEntity.length;++n){if("object"!=typeof t.informedEntity[n])throw TypeError(".transit_realtime.Alert.informedEntity: object expected");e.informedEntity[n]=o.transit_realtime.EntitySelector.fromObject(t.informedEntity[n])}}switch(t.cause){default:if("number"==typeof t.cause){e.cause=t.cause;break}break;case"UNKNOWN_CAUSE":case 1:e.cause=1;break;case"OTHER_CAUSE":case 2:e.cause=2;break;case"TECHNICAL_PROBLEM":case 3:e.cause=3;break;case"STRIKE":case 4:e.cause=4;break;case"DEMONSTRATION":case 5:e.cause=5;break;case"ACCIDENT":case 6:e.cause=6;break;case"HOLIDAY":case 7:e.cause=7;break;case"WEATHER":case 8:e.cause=8;break;case"MAINTENANCE":case 9:e.cause=9;break;case"CONSTRUCTION":case 10:e.cause=10;break;case"POLICE_ACTIVITY":case 11:e.cause=11;break;case"MEDICAL_EMERGENCY":case 12:e.cause=12}switch(t.effect){case"NO_SERVICE":case 1:e.effect=1;break;case"REDUCED_SERVICE":case 2:e.effect=2;break;case"SIGNIFICANT_DELAYS":case 3:e.effect=3;break;case"DETOUR":case 4:e.effect=4;break;case"ADDITIONAL_SERVICE":case 5:e.effect=5;break;case"MODIFIED_SERVICE":case 6:e.effect=6;break;case"OTHER_EFFECT":case 7:e.effect=7;break;default:if("number"==typeof t.effect){e.effect=t.effect;break}break;case"UNKNOWN_EFFECT":case 8:e.effect=8;break;case"STOP_MOVED":case 9:e.effect=9;break;case"NO_EFFECT":case 10:e.effect=10;break;case"ACCESSIBILITY_ISSUE":case 11:e.effect=11}if(null!=t.url){if("object"!=typeof t.url)throw TypeError(".transit_realtime.Alert.url: object expected");e.url=o.transit_realtime.TranslatedString.fromObject(t.url)}if(null!=t.headerText){if("object"!=typeof t.headerText)throw TypeError(".transit_realtime.Alert.headerText: object expected");e.headerText=o.transit_realtime.TranslatedString.fromObject(t.headerText)}if(null!=t.descriptionText){if("object"!=typeof t.descriptionText)throw TypeError(".transit_realtime.Alert.descriptionText: object expected");e.descriptionText=o.transit_realtime.TranslatedString.fromObject(t.descriptionText)}if(null!=t.ttsHeaderText){if("object"!=typeof t.ttsHeaderText)throw TypeError(".transit_realtime.Alert.ttsHeaderText: object expected");e.ttsHeaderText=o.transit_realtime.TranslatedString.fromObject(t.ttsHeaderText)}if(null!=t.ttsDescriptionText){if("object"!=typeof t.ttsDescriptionText)throw TypeError(".transit_realtime.Alert.ttsDescriptionText: object expected");e.ttsDescriptionText=o.transit_realtime.TranslatedString.fromObject(t.ttsDescriptionText)}switch(t.severityLevel){default:if("number"==typeof t.severityLevel){e.severityLevel=t.severityLevel;break}break;case"UNKNOWN_SEVERITY":case 1:e.severityLevel=1;break;case"INFO":case 2:e.severityLevel=2;break;case"WARNING":case 3:e.severityLevel=3;break;case"SEVERE":case 4:e.severityLevel=4}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.activePeriod=[],n.informedEntity=[]),e.defaults&&(n.cause=e.enums===String?"UNKNOWN_CAUSE":1,n.effect=e.enums===String?"UNKNOWN_EFFECT":8,n.url=null,n.headerText=null,n.descriptionText=null,n.ttsHeaderText=null,n.ttsDescriptionText=null,n.severityLevel=e.enums===String?"UNKNOWN_SEVERITY":1),t.activePeriod&&t.activePeriod.length){n.activePeriod=[];for(var i=0;i<t.activePeriod.length;++i)n.activePeriod[i]=o.transit_realtime.TimeRange.toObject(t.activePeriod[i],e)}if(t.informedEntity&&t.informedEntity.length)for(n.informedEntity=[],i=0;i<t.informedEntity.length;++i)n.informedEntity[i]=o.transit_realtime.EntitySelector.toObject(t.informedEntity[i],e);return null!=t.cause&&t.hasOwnProperty("cause")&&(n.cause=e.enums===String?void 0===o.transit_realtime.Alert.Cause[t.cause]?t.cause:o.transit_realtime.Alert.Cause[t.cause]:t.cause),null!=t.effect&&t.hasOwnProperty("effect")&&(n.effect=e.enums===String?void 0===o.transit_realtime.Alert.Effect[t.effect]?t.effect:o.transit_realtime.Alert.Effect[t.effect]:t.effect),null!=t.url&&t.hasOwnProperty("url")&&(n.url=o.transit_realtime.TranslatedString.toObject(t.url,e)),null!=t.headerText&&t.hasOwnProperty("headerText")&&(n.headerText=o.transit_realtime.TranslatedString.toObject(t.headerText,e)),null!=t.descriptionText&&t.hasOwnProperty("descriptionText")&&(n.descriptionText=o.transit_realtime.TranslatedString.toObject(t.descriptionText,e)),null!=t.ttsHeaderText&&t.hasOwnProperty("ttsHeaderText")&&(n.ttsHeaderText=o.transit_realtime.TranslatedString.toObject(t.ttsHeaderText,e)),null!=t.ttsDescriptionText&&t.hasOwnProperty("ttsDescriptionText")&&(n.ttsDescriptionText=o.transit_realtime.TranslatedString.toObject(t.ttsDescriptionText,e)),null!=t.severityLevel&&t.hasOwnProperty("severityLevel")&&(n.severityLevel=e.enums===String?void 0===o.transit_realtime.Alert.SeverityLevel[t.severityLevel]?t.severityLevel:o.transit_realtime.Alert.SeverityLevel[t.severityLevel]:t.severityLevel),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.Alert"},t.Cause=(s={},(a=Object.create(s))[s[1]="UNKNOWN_CAUSE"]=1,a[s[2]="OTHER_CAUSE"]=2,a[s[3]="TECHNICAL_PROBLEM"]=3,a[s[4]="STRIKE"]=4,a[s[5]="DEMONSTRATION"]=5,a[s[6]="ACCIDENT"]=6,a[s[7]="HOLIDAY"]=7,a[s[8]="WEATHER"]=8,a[s[9]="MAINTENANCE"]=9,a[s[10]="CONSTRUCTION"]=10,a[s[11]="POLICE_ACTIVITY"]=11,a[s[12]="MEDICAL_EMERGENCY"]=12,a),t.Effect=function(){var t={},e=Object.create(t);return e[t[1]="NO_SERVICE"]=1,e[t[2]="REDUCED_SERVICE"]=2,e[t[3]="SIGNIFICANT_DELAYS"]=3,e[t[4]="DETOUR"]=4,e[t[5]="ADDITIONAL_SERVICE"]=5,e[t[6]="MODIFIED_SERVICE"]=6,e[t[7]="OTHER_EFFECT"]=7,e[t[8]="UNKNOWN_EFFECT"]=8,e[t[9]="STOP_MOVED"]=9,e[t[10]="NO_EFFECT"]=10,e[t[11]="ACCESSIBILITY_ISSUE"]=11,e}(),t.SeverityLevel=function(){var t={},e=Object.create(t);return e[t[1]="UNKNOWN_SEVERITY"]=1,e[t[2]="INFO"]=2,e[t[3]="WARNING"]=3,e[t[4]="SEVERE"]=4,e}(),t}(),t.TimeRange=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.start=r.Long?r.Long.fromBits(0,0,!0):0,t.prototype.end=r.Long?r.Long.fromBits(0,0,!0):0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.start&&Object.hasOwnProperty.call(t,"start")&&e.uint32(8).uint64(t.start),null!=t.end&&Object.hasOwnProperty.call(t,"end")&&e.uint32(16).uint64(t.end),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.TimeRange;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.start=t.uint64();break;case 2:r.end=t.uint64();break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.start&&t.hasOwnProperty("start")&&!(r.isInteger(t.start)||t.start&&r.isInteger(t.start.low)&&r.isInteger(t.start.high))?"start: integer|Long expected":null!=t.end&&t.hasOwnProperty("end")&&!(r.isInteger(t.end)||t.end&&r.isInteger(t.end.low)&&r.isInteger(t.end.high))?"end: integer|Long expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.TimeRange)return t;var e=new o.transit_realtime.TimeRange;return null!=t.start&&(r.Long?(e.start=r.Long.fromValue(t.start)).unsigned=!0:"string"==typeof t.start?e.start=parseInt(t.start,10):"number"==typeof t.start?e.start=t.start:"object"==typeof t.start&&(e.start=new r.LongBits(t.start.low>>>0,t.start.high>>>0).toNumber(!0))),null!=t.end&&(r.Long?(e.end=r.Long.fromValue(t.end)).unsigned=!0:"string"==typeof t.end?e.end=parseInt(t.end,10):"number"==typeof t.end?e.end=t.end:"object"==typeof t.end&&(e.end=new r.LongBits(t.end.low>>>0,t.end.high>>>0).toNumber(!0))),e},t.toObject=function(t,e){e||(e={});var n={};if(e.defaults){if(r.Long){var i=new r.Long(0,0,!0);n.start=e.longs===String?i.toString():e.longs===Number?i.toNumber():i}else n.start=e.longs===String?"0":0;r.Long?(i=new r.Long(0,0,!0),n.end=e.longs===String?i.toString():e.longs===Number?i.toNumber():i):n.end=e.longs===String?"0":0}return null!=t.start&&t.hasOwnProperty("start")&&(n.start="number"==typeof t.start?e.longs===String?String(t.start):t.start:e.longs===String?r.Long.prototype.toString.call(t.start):e.longs===Number?new r.LongBits(t.start.low>>>0,t.start.high>>>0).toNumber(!0):t.start),null!=t.end&&t.hasOwnProperty("end")&&(n.end="number"==typeof t.end?e.longs===String?String(t.end):t.end:e.longs===String?r.Long.prototype.toString.call(t.end):e.longs===Number?new r.LongBits(t.end.low>>>0,t.end.high>>>0).toNumber(!0):t.end),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TimeRange"},t}(),t.Position=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.latitude=0,t.prototype.longitude=0,t.prototype.bearing=0,t.prototype.odometer=0,t.prototype.speed=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),e.uint32(13).float(t.latitude),e.uint32(21).float(t.longitude),null!=t.bearing&&Object.hasOwnProperty.call(t,"bearing")&&e.uint32(29).float(t.bearing),null!=t.odometer&&Object.hasOwnProperty.call(t,"odometer")&&e.uint32(33).double(t.odometer),null!=t.speed&&Object.hasOwnProperty.call(t,"speed")&&e.uint32(45).float(t.speed),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,s=new o.transit_realtime.Position;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:s.latitude=t.float();break;case 2:s.longitude=t.float();break;case 3:s.bearing=t.float();break;case 4:s.odometer=t.double();break;case 5:s.speed=t.float();break;default:t.skipType(7&a)}}if(!s.hasOwnProperty("latitude"))throw r.ProtocolError("missing required 'latitude'",{instance:s});if(!s.hasOwnProperty("longitude"))throw r.ProtocolError("missing required 'longitude'",{instance:s});return s},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":"number"!=typeof t.latitude?"latitude: number expected":"number"!=typeof t.longitude?"longitude: number expected":null!=t.bearing&&t.hasOwnProperty("bearing")&&"number"!=typeof t.bearing?"bearing: number expected":null!=t.odometer&&t.hasOwnProperty("odometer")&&"number"!=typeof t.odometer?"odometer: number expected":null!=t.speed&&t.hasOwnProperty("speed")&&"number"!=typeof t.speed?"speed: number expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.Position)return t;var e=new o.transit_realtime.Position;return null!=t.latitude&&(e.latitude=Number(t.latitude)),null!=t.longitude&&(e.longitude=Number(t.longitude)),null!=t.bearing&&(e.bearing=Number(t.bearing)),null!=t.odometer&&(e.odometer=Number(t.odometer)),null!=t.speed&&(e.speed=Number(t.speed)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.latitude=0,n.longitude=0,n.bearing=0,n.odometer=0,n.speed=0),null!=t.latitude&&t.hasOwnProperty("latitude")&&(n.latitude=e.json&&!isFinite(t.latitude)?String(t.latitude):t.latitude),null!=t.longitude&&t.hasOwnProperty("longitude")&&(n.longitude=e.json&&!isFinite(t.longitude)?String(t.longitude):t.longitude),null!=t.bearing&&t.hasOwnProperty("bearing")&&(n.bearing=e.json&&!isFinite(t.bearing)?String(t.bearing):t.bearing),null!=t.odometer&&t.hasOwnProperty("odometer")&&(n.odometer=e.json&&!isFinite(t.odometer)?String(t.odometer):t.odometer),null!=t.speed&&t.hasOwnProperty("speed")&&(n.speed=e.json&&!isFinite(t.speed)?String(t.speed):t.speed),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.Position"},t}(),t.TripDescriptor=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}var s,a;return t.prototype.tripId="",t.prototype.routeId="",t.prototype.directionId=0,t.prototype.startTime="",t.prototype.startDate="",t.prototype.scheduleRelationship=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.tripId&&Object.hasOwnProperty.call(t,"tripId")&&e.uint32(10).string(t.tripId),null!=t.startTime&&Object.hasOwnProperty.call(t,"startTime")&&e.uint32(18).string(t.startTime),null!=t.startDate&&Object.hasOwnProperty.call(t,"startDate")&&e.uint32(26).string(t.startDate),null!=t.scheduleRelationship&&Object.hasOwnProperty.call(t,"scheduleRelationship")&&e.uint32(32).int32(t.scheduleRelationship),null!=t.routeId&&Object.hasOwnProperty.call(t,"routeId")&&e.uint32(42).string(t.routeId),null!=t.directionId&&Object.hasOwnProperty.call(t,"directionId")&&e.uint32(48).uint32(t.directionId),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.TripDescriptor;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.tripId=t.string();break;case 5:r.routeId=t.string();break;case 6:r.directionId=t.uint32();break;case 2:r.startTime=t.string();break;case 3:r.startDate=t.string();break;case 4:r.scheduleRelationship=t.int32();break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.tripId&&t.hasOwnProperty("tripId")&&!r.isString(t.tripId))return"tripId: string expected";if(null!=t.routeId&&t.hasOwnProperty("routeId")&&!r.isString(t.routeId))return"routeId: string expected";if(null!=t.directionId&&t.hasOwnProperty("directionId")&&!r.isInteger(t.directionId))return"directionId: integer expected";if(null!=t.startTime&&t.hasOwnProperty("startTime")&&!r.isString(t.startTime))return"startTime: string expected";if(null!=t.startDate&&t.hasOwnProperty("startDate")&&!r.isString(t.startDate))return"startDate: string expected";if(null!=t.scheduleRelationship&&t.hasOwnProperty("scheduleRelationship"))switch(t.scheduleRelationship){default:return"scheduleRelationship: enum value expected";case 0:case 1:case 2:case 3:case 5:case 6:}return null},t.fromObject=function(t){if(t instanceof o.transit_realtime.TripDescriptor)return t;var e=new o.transit_realtime.TripDescriptor;switch(null!=t.tripId&&(e.tripId=String(t.tripId)),null!=t.routeId&&(e.routeId=String(t.routeId)),null!=t.directionId&&(e.directionId=t.directionId>>>0),null!=t.startTime&&(e.startTime=String(t.startTime)),null!=t.startDate&&(e.startDate=String(t.startDate)),t.scheduleRelationship){default:if("number"==typeof t.scheduleRelationship){e.scheduleRelationship=t.scheduleRelationship;break}break;case"SCHEDULED":case 0:e.scheduleRelationship=0;break;case"ADDED":case 1:e.scheduleRelationship=1;break;case"UNSCHEDULED":case 2:e.scheduleRelationship=2;break;case"CANCELED":case 3:e.scheduleRelationship=3;break;case"REPLACEMENT":case 5:e.scheduleRelationship=5;break;case"DUPLICATED":case 6:e.scheduleRelationship=6}return e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.tripId="",n.startTime="",n.startDate="",n.scheduleRelationship=e.enums===String?"SCHEDULED":0,n.routeId="",n.directionId=0),null!=t.tripId&&t.hasOwnProperty("tripId")&&(n.tripId=t.tripId),null!=t.startTime&&t.hasOwnProperty("startTime")&&(n.startTime=t.startTime),null!=t.startDate&&t.hasOwnProperty("startDate")&&(n.startDate=t.startDate),null!=t.scheduleRelationship&&t.hasOwnProperty("scheduleRelationship")&&(n.scheduleRelationship=e.enums===String?void 0===o.transit_realtime.TripDescriptor.ScheduleRelationship[t.scheduleRelationship]?t.scheduleRelationship:o.transit_realtime.TripDescriptor.ScheduleRelationship[t.scheduleRelationship]:t.scheduleRelationship),null!=t.routeId&&t.hasOwnProperty("routeId")&&(n.routeId=t.routeId),null!=t.directionId&&t.hasOwnProperty("directionId")&&(n.directionId=t.directionId),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TripDescriptor"},t.ScheduleRelationship=(s={},(a=Object.create(s))[s[0]="SCHEDULED"]=0,a[s[1]="ADDED"]=1,a[s[2]="UNSCHEDULED"]=2,a[s[3]="CANCELED"]=3,a[s[5]="REPLACEMENT"]=5,a[s[6]="DUPLICATED"]=6,a),t}(),t.VehicleDescriptor=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.id="",t.prototype.label="",t.prototype.licensePlate="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.id&&Object.hasOwnProperty.call(t,"id")&&e.uint32(10).string(t.id),null!=t.label&&Object.hasOwnProperty.call(t,"label")&&e.uint32(18).string(t.label),null!=t.licensePlate&&Object.hasOwnProperty.call(t,"licensePlate")&&e.uint32(26).string(t.licensePlate),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.VehicleDescriptor;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.id=t.string();break;case 2:r.label=t.string();break;case 3:r.licensePlate=t.string();break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":null!=t.id&&t.hasOwnProperty("id")&&!r.isString(t.id)?"id: string expected":null!=t.label&&t.hasOwnProperty("label")&&!r.isString(t.label)?"label: string expected":null!=t.licensePlate&&t.hasOwnProperty("licensePlate")&&!r.isString(t.licensePlate)?"licensePlate: string expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.VehicleDescriptor)return t;var e=new o.transit_realtime.VehicleDescriptor;return null!=t.id&&(e.id=String(t.id)),null!=t.label&&(e.label=String(t.label)),null!=t.licensePlate&&(e.licensePlate=String(t.licensePlate)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.id="",n.label="",n.licensePlate=""),null!=t.id&&t.hasOwnProperty("id")&&(n.id=t.id),null!=t.label&&t.hasOwnProperty("label")&&(n.label=t.label),null!=t.licensePlate&&t.hasOwnProperty("licensePlate")&&(n.licensePlate=t.licensePlate),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.VehicleDescriptor"},t}(),t.EntitySelector=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.agencyId="",t.prototype.routeId="",t.prototype.routeType=0,t.prototype.trip=null,t.prototype.stopId="",t.prototype.directionId=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),null!=t.agencyId&&Object.hasOwnProperty.call(t,"agencyId")&&e.uint32(10).string(t.agencyId),null!=t.routeId&&Object.hasOwnProperty.call(t,"routeId")&&e.uint32(18).string(t.routeId),null!=t.routeType&&Object.hasOwnProperty.call(t,"routeType")&&e.uint32(24).int32(t.routeType),null!=t.trip&&Object.hasOwnProperty.call(t,"trip")&&o.transit_realtime.TripDescriptor.encode(t.trip,e.uint32(34).fork()).ldelim(),null!=t.stopId&&Object.hasOwnProperty.call(t,"stopId")&&e.uint32(42).string(t.stopId),null!=t.directionId&&Object.hasOwnProperty.call(t,"directionId")&&e.uint32(48).uint32(t.directionId),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.EntitySelector;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:r.agencyId=t.string();break;case 2:r.routeId=t.string();break;case 3:r.routeType=t.int32();break;case 4:r.trip=o.transit_realtime.TripDescriptor.decode(t,t.uint32());break;case 5:r.stopId=t.string();break;case 6:r.directionId=t.uint32();break;default:t.skipType(7&s)}}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.agencyId&&t.hasOwnProperty("agencyId")&&!r.isString(t.agencyId))return"agencyId: string expected";if(null!=t.routeId&&t.hasOwnProperty("routeId")&&!r.isString(t.routeId))return"routeId: string expected";if(null!=t.routeType&&t.hasOwnProperty("routeType")&&!r.isInteger(t.routeType))return"routeType: integer expected";if(null!=t.trip&&t.hasOwnProperty("trip")){var e=o.transit_realtime.TripDescriptor.verify(t.trip);if(e)return"trip."+e}return null!=t.stopId&&t.hasOwnProperty("stopId")&&!r.isString(t.stopId)?"stopId: string expected":null!=t.directionId&&t.hasOwnProperty("directionId")&&!r.isInteger(t.directionId)?"directionId: integer expected":null},t.fromObject=function(t){if(t instanceof o.transit_realtime.EntitySelector)return t;var e=new o.transit_realtime.EntitySelector;if(null!=t.agencyId&&(e.agencyId=String(t.agencyId)),null!=t.routeId&&(e.routeId=String(t.routeId)),null!=t.routeType&&(e.routeType=0|t.routeType),null!=t.trip){if("object"!=typeof t.trip)throw TypeError(".transit_realtime.EntitySelector.trip: object expected");e.trip=o.transit_realtime.TripDescriptor.fromObject(t.trip)}return null!=t.stopId&&(e.stopId=String(t.stopId)),null!=t.directionId&&(e.directionId=t.directionId>>>0),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.agencyId="",n.routeId="",n.routeType=0,n.trip=null,n.stopId="",n.directionId=0),null!=t.agencyId&&t.hasOwnProperty("agencyId")&&(n.agencyId=t.agencyId),null!=t.routeId&&t.hasOwnProperty("routeId")&&(n.routeId=t.routeId),null!=t.routeType&&t.hasOwnProperty("routeType")&&(n.routeType=t.routeType),null!=t.trip&&t.hasOwnProperty("trip")&&(n.trip=o.transit_realtime.TripDescriptor.toObject(t.trip,e)),null!=t.stopId&&t.hasOwnProperty("stopId")&&(n.stopId=t.stopId),null!=t.directionId&&t.hasOwnProperty("directionId")&&(n.directionId=t.directionId),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.EntitySelector"},t}(),t.TranslatedString=function(){function t(t){if(this.translation=[],t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.translation=r.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=i.create()),null!=t.translation&&t.translation.length)for(var n=0;n<t.translation.length;++n)o.transit_realtime.TranslatedString.Translation.encode(t.translation[n],e.uint32(10).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,r=new o.transit_realtime.TranslatedString;t.pos<i;){var s=t.uint32();s>>>3==1?(r.translation&&r.translation.length||(r.translation=[]),r.translation.push(o.transit_realtime.TranslatedString.Translation.decode(t,t.uint32()))):t.skipType(7&s)}return r},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.translation&&t.hasOwnProperty("translation")){if(!Array.isArray(t.translation))return"translation: array expected";for(var e=0;e<t.translation.length;++e){var n=o.transit_realtime.TranslatedString.Translation.verify(t.translation[e]);if(n)return"translation."+n}}return null},t.fromObject=function(t){if(t instanceof o.transit_realtime.TranslatedString)return t;var e=new o.transit_realtime.TranslatedString;if(t.translation){if(!Array.isArray(t.translation))throw TypeError(".transit_realtime.TranslatedString.translation: array expected");e.translation=[];for(var n=0;n<t.translation.length;++n){if("object"!=typeof t.translation[n])throw TypeError(".transit_realtime.TranslatedString.translation: object expected");e.translation[n]=o.transit_realtime.TranslatedString.Translation.fromObject(t.translation[n])}}return e},t.toObject=function(t,e){e||(e={});var n={};if((e.arrays||e.defaults)&&(n.translation=[]),t.translation&&t.translation.length){n.translation=[];for(var i=0;i<t.translation.length;++i)n.translation[i]=o.transit_realtime.TranslatedString.Translation.toObject(t.translation[i],e)}return n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TranslatedString"},t.Translation=function(){function t(t){if(t)for(var e=Object.keys(t),n=0;n<e.length;++n)null!=t[e[n]]&&(this[e[n]]=t[e[n]])}return t.prototype.text="",t.prototype.language="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=i.create()),e.uint32(10).string(t.text),null!=t.language&&Object.hasOwnProperty.call(t,"language")&&e.uint32(18).string(t.language),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof n||(t=n.create(t));for(var i=void 0===e?t.len:t.pos+e,s=new o.transit_realtime.TranslatedString.Translation;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:s.text=t.string();break;case 2:s.language=t.string();break;default:t.skipType(7&a)}}if(!s.hasOwnProperty("text"))throw r.ProtocolError("missing required 'text'",{instance:s});return s},t.decodeDelimited=function(t){return t instanceof n||(t=new n(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":r.isString(t.text)?null!=t.language&&t.hasOwnProperty("language")&&!r.isString(t.language)?"language: string expected":null:"text: string expected"},t.fromObject=function(t){if(t instanceof o.transit_realtime.TranslatedString.Translation)return t;var e=new o.transit_realtime.TranslatedString.Translation;return null!=t.text&&(e.text=String(t.text)),null!=t.language&&(e.language=String(t.language)),e},t.toObject=function(t,e){e||(e={});var n={};return e.defaults&&(n.text="",n.language=""),null!=t.text&&t.hasOwnProperty("text")&&(n.text=t.text),null!=t.language&&t.hasOwnProperty("language")&&(n.language=t.language),n},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t.getTypeUrl=function(t){return void 0===t&&(t="type.googleapis.com"),t+"/transit_realtime.TranslatedString.Translation"},t}(),t}(),t),gtfsRealtime=o}var gtfsRealtimeExports=requireGtfsRealtime(),GtfsRealtimeBindings=getDefaultExportFromCjs(gtfsRealtimeExports);const SHIFT_LEFT_32=4294967296,SHIFT_RIGHT_32=1/SHIFT_LEFT_32,TEXT_DECODER_MIN_LENGTH=12,utf8TextDecoder="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8"),PBF_VARINT=0,PBF_FIXED64=1,PBF_BYTES=2,PBF_FIXED32=5;class Pbf{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,n=this.length){for(;this.pos<n;){const n=this.readVarint(),i=n>>3,r=this.pos;this.type=7&n,t(i,e,this),this.pos===r&&this.skip(n)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*SHIFT_LEFT_32;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*SHIFT_LEFT_32;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let n,i;return i=e[this.pos++],n=127&i,i<128?n:(i=e[this.pos++],n|=(127&i)<<7,i<128?n:(i=e[this.pos++],n|=(127&i)<<14,i<128?n:(i=e[this.pos++],n|=(127&i)<<21,i<128?n:(i=e[this.pos],n|=(15&i)<<28,readVarintRemainder(n,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=TEXT_DECODER_MIN_LENGTH&&utf8TextDecoder?utf8TextDecoder.decode(this.buf.subarray(e,t)):readUtf8(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===PBF_BYTES?this.readVarint()+this.pos:this.pos+1}skip(t){const e=7&t;if(e===PBF_VARINT)for(;this.buf[this.pos++]>127;);else if(e===PBF_BYTES)this.pos=this.readVarint()+this.pos;else if(e===PBF_FIXED32)this.pos+=4;else{if(e!==PBF_FIXED64)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}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*SHIFT_RIGHT_32),!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*SHIFT_RIGHT_32),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?writeBigVarint(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=writeUtf8(this.buf,t,this.pos);const n=this.pos-e;n>=128&&makeRoomForExtraLength(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);for(let n=0;n<e;n++)this.buf[this.pos++]=t[n]}writeRawMessage(t,e){this.pos++;const n=this.pos;t(e,this);const i=this.pos-n;i>=128&&makeRoomForExtraLength(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i}writeMessage(t,e,n){this.writeTag(t,PBF_BYTES),this.writeRawMessage(e,n)}writePackedVarint(t,e){e.length&&this.writeMessage(t,writePackedVarint,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,writePackedSVarint,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,writePackedBoolean,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,writePackedFloat,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,writePackedDouble,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,writePackedFixed32,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,writePackedSFixed32,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,writePackedFixed64,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,writePackedSFixed64,e)}writeBytesField(t,e){this.writeTag(t,PBF_BYTES),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,PBF_FIXED32),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,PBF_FIXED32),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,PBF_FIXED64),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,PBF_FIXED64),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,PBF_VARINT),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,PBF_VARINT),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,PBF_BYTES),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,PBF_FIXED32),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,PBF_FIXED64),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function readVarintRemainder(t,e,n){const i=n.buf;let r,o;if(o=i[n.pos++],r=(112&o)>>4,o<128)return toNum(t,r,e);if(o=i[n.pos++],r|=(127&o)<<3,o<128)return toNum(t,r,e);if(o=i[n.pos++],r|=(127&o)<<10,o<128)return toNum(t,r,e);if(o=i[n.pos++],r|=(127&o)<<17,o<128)return toNum(t,r,e);if(o=i[n.pos++],r|=(127&o)<<24,o<128)return toNum(t,r,e);if(o=i[n.pos++],r|=(1&o)<<31,o<128)return toNum(t,r,e);throw new Error("Expected varint not more than 10 bytes")}function toNum(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function writeBigVarint(t,e){let n,i;if(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)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),writeBigVarintLow(n,i,e),writeBigVarintHigh(i,e)}function writeBigVarintLow(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,n.buf[n.pos]=127&(t>>>=7)}function writeBigVarintHigh(t,e){const n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}function makeRoomForExtraLength(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);for(let e=n.pos-1;e>=t;e--)n.buf[e+i]=n.buf[e]}function writePackedVarint(t,e){for(let n=0;n<t.length;n++)e.writeVarint(t[n])}function writePackedSVarint(t,e){for(let n=0;n<t.length;n++)e.writeSVarint(t[n])}function writePackedFloat(t,e){for(let n=0;n<t.length;n++)e.writeFloat(t[n])}function writePackedDouble(t,e){for(let n=0;n<t.length;n++)e.writeDouble(t[n])}function writePackedBoolean(t,e){for(let n=0;n<t.length;n++)e.writeBoolean(t[n])}function writePackedFixed32(t,e){for(let n=0;n<t.length;n++)e.writeFixed32(t[n])}function writePackedSFixed32(t,e){for(let n=0;n<t.length;n++)e.writeSFixed32(t[n])}function writePackedFixed64(t,e){for(let n=0;n<t.length;n++)e.writeFixed64(t[n])}function writePackedSFixed64(t,e){for(let n=0;n<t.length;n++)e.writeSFixed64(t[n])}function readUtf8(t,e,n){let i="",r=e;for(;r<n;){const e=t[r];let o,s,a,l=null,c=e>239?4:e>223?3:e>191?2:1;if(r+c>n)break;1===c?e<128&&(l=e):2===c?(o=t[r+1],128==(192&o)&&(l=(31&e)<<6|63&o,l<=127&&(l=null))):3===c?(o=t[r+1],s=t[r+2],128==(192&o)&&128==(192&s)&&(l=(15&e)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=t[r+1],s=t[r+2],a=t[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&e)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,i+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),i+=String.fromCharCode(l),r+=c}return i}function writeUtf8(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}function decode(t){return t.readFields(((t,e,n)=>{1===t&&(e.agency=n.readString()),2===t&&e.stops.push(n.readFields(((t,e,n)=>{1===t?e.id=n.readString():2===t?e.name=n.readString():3===t&&(e.coord=n.readPackedDouble())}),{},n.readVarint()+n.pos)),3===t&&e.trips.push(n.readFields(((t,e,n)=>{1===t?e.id=n.readString():2===t?e.shortName=n.readString():3===t?e.color=n.readString():4===t?e.textColor=n.readString():5===t?e.shape=n.readString():6===t?e.stops.push(n.readString()):7===t?n.readPackedVarint(e.stopSequences,!0):8===t&&e.headsigns.push(n.readString())}),{stops:[],stopSequences:[],headsigns:[]},n.readVarint()+n.pos)),4===t&&(e.version=n.readString())}),{stops:[],trips:[]})}const RAILWAYS_FOR_TRAINS={odpt:["Toei.Asakusa","Toei.Mita","Toei.Shinjuku","Toei.Oedo","Toei.Arakawa"],challenge2024:["JR-East.Yamanote","Keikyu.Main","Keikyu.Airport","Keikyu.Daishi","Keikyu.Zushi","Keikyu.Kurihama","Tobu.TobuSkytree","Tobu.TobuSkytreeBranch","Tobu.Isesaki","Tobu.Nikko","Tobu.TobuUrbanPark","Tobu.Kameido","Tobu.Daishi","Tobu.Tojo","Tobu.Ogose"]},OPERATORS_FOR_TRAININFORMATION={odpt:["TWR","TokyoMetro","Toei","YokohamaMunicipal","MIR","TamaMonorail"],challenge2024:["jre-is","Tokyu","Keikyu","Tobu","Seibu","Keio"]},RAILWAY_SOBURAPID="JR-East.SobuRapid",TRAINTYPE_JREAST_LIMITEDEXPRESS="JR-East.LimitedExpress";function getTimetableFileName(t){return`timetable-${"Weekday"===t.getCalendar()?"weekday":"holiday"}.json.gz`}function getExtraTimetableFileNames(t){const e=t.getCalendar();return"Saturday"===e?["timetable-saturday.json.gz"]:"Holiday"===e?["timetable-sunday-holiday.json.gz"]:[]}function adjustTrainID(t,e,n){return e===TRAINTYPE_JREAST_LIMITEDEXPRESS&&n[0].match(/NaritaAirportTerminal1|Takao|Ofuna|Omiya|Ikebukuro|Shinjuku/)?t.replace(/JR-East\.(NaritaAirportBranch|Narita|Sobu)/,RAILWAY_SOBURAPID):t}function loadStaticData(t,e,n){const i=getExtraTimetableFileNames(n);return Promise.all([`${t}/dictionary-${e}.json`,`${t}/railways.json.gz`,`${t}/stations.json.gz`,`${t}/features.json.gz`,`${t}/${getTimetableFileName(n)}`,`${t}/rail-directions.json.gz`,`${t}/train-types.json.gz`,`${t}/train-vehicles.json.gz`,`${t}/operators.json.gz`,`${t}/airports.json.gz`,`${t}/flight-statuses.json.gz`,`${t}/poi.json.gz`,...i.map((e=>`${t}/${e}`))].map(loadJSON)).then((t=>({dict:t[0],railwayData:t[1],stationData:t[2],featureCollection:t[3],timetableData:t[4].concat(...t.slice(12)),railDirectionData:t[5],trainTypeData:t[6],trainVehicleData:t[7],operatorData:t[8],airportData:t[9],flightStatusData:t[10],poiData:t[11]})))}function loadTimetableData(t,e){const n=getExtraTimetableFileNames(e);return Promise.all([`${t}/${getTimetableFileName(e)}`,...n.map((e=>`${t}/${e}`))].map(loadJSON)).then((t=>t[0].concat(...t.slice(1))))}function loadDynamicTrainData(t){const e=[],n=[],i=[];for(const e of Object.keys(RAILWAYS_FOR_TRAINS)){const n=configs.apiUrl[e],r=t[e];if("odpt"===e||"challenge2024"===e){const t=RAILWAYS_FOR_TRAINS[e].map((t=>`odpt.Railway:${t}`)).join(",");i.push(`${n}odpt:Train?odpt:railway=${t}&acl:consumerKey=${r}`)}}i.push(configs.tidUrl);for(const e of Object.keys(OPERATORS_FOR_TRAININFORMATION)){const n=configs.apiUrl[e],r=t[e];if("odpt"===e||"challenge2024"===e){const t=OPERATORS_FOR_TRAININFORMATION[e].map((t=>`odpt.Operator:${t}`)).join(",");i.push(`${n}odpt:TrainInformation?odpt:operator=${t}&acl:consumerKey=${r}`)}}return i.push(configs.trainInfoUrl),Promise.all(i.map(loadJSON)).then((t=>{for(const n of[...t.shift(),...t.shift()]){const t=removePrefix(n["odpt:trainType"]),i=removePrefix(n["odpt:destinationStation"]);e.push({id:adjustTrainID(removePrefix(n["owl:sameAs"]),t,i),o:removePrefix(n["odpt:operator"]),r:removePrefix(n["odpt:railway"]),y:t,n:n["odpt:trainNumber"],os:removePrefix(n["odpt:originStation"]),d:removePrefix(n["odpt:railDirection"]),ds:i,ts:removePrefix(n["odpt:toStation"]),fs:removePrefix(n["odpt:fromStation"]),delay:1e3*(n["odpt:delay"]||0),carComposition:n["odpt:carComposition"],date:n["dc:date"].replace(/([\d\-])T([\d:]+).*/,"$1 $2")})}for(const n of t.shift())e.push(n);for(const e of[...t.shift(),...t.shift()])n.push({operator:removePrefix(e["odpt:operator"]),railway:removePrefix(e["odpt:railway"]),status:e["odpt:trainInformationStatus"],text:e["odpt:trainInformationText"]});for(const e of t.shift())n.push(e);return{trainData:e,trainInfoData:n}}))}function loadDynamicFlightData(){return Promise.all([configs.atisUrl,configs.flightUrl].map(loadJSON)).then((t=>({atisData:t[0],flightData:t[1]})))}function loadBusData(t,e){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&&h(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&&h(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 h(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 p(t,e,n){if(null!==t)for(var i,r,o,s,a,u,l,c,h=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 x=0,I=0;if(null!==(s=c?l.geometries[v]:l)){u=s.coordinates;var E=s.type;switch(h=0,E){case null:break;case"Point":if(!1===e(u,f,m,x,I))return!1;f++,x++;break;case"LineString":case"MultiPoint":for(i=0;i<u.length;i++){if(!1===e(u[i],f,m,x,I))return!1;f++,"MultiPoint"===E&&x++}"LineString"===E&&x++;break;case"Polygon":case"MultiLineString":for(i=0;i<u.length;i++){for(r=0;r<u[i].length-h;r++){if(!1===e(u[i][r],f,m,x,I))return!1;f++}"MultiLineString"===E&&x++,"Polygon"===E&&I++}"Polygon"===E&&x++;break;case"MultiPolygon":for(i=0;i<u.length;i++){for("MultiPolygon"===E&&(I=0),r=0;r<u[i].length;r++){for(o=0;o<u[i][r].length-h;o++){if(!1===e(u[i][r][o],f,m,x,I))return!1;f++}I++}x++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===p(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,h,p=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,h=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,p,l,c,h))return!1;break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)if(!1===e(o.geometries[i],p,l,c,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,p,l,c,h))return!1;p++}}function d(t){var e=[1/0,1/0,-1/0,-1/0];return p(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}function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})})),n}var m,v={exports:{}};var x=(m||(m=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 h(){this.root_=null,this.size_=0}function p(){}function f(){this.array_=[],arguments[0]instanceof xt&&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(){},x={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)},x.MAX_VALUE.get=function(){return Number.MAX_VALUE},Object.defineProperties(v,x);var I=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[I,E,e]},w.prototype.getClass=function(){return w},w.hashCode=function(){if(1===arguments.length)return v.doubleToLongBits(arguments[0]),Math.trunc(0)},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 P=function(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1},T=function(){},M={LOG_10:{configurable:!0}};T.prototype.interfaces_=function(){return[]},T.prototype.getClass=function(){return T},T.log10=function(t){var e=Math.log(t);return v.isInfinite(e)||v.isNaN(e)?e:e/T.LOG_10},T.min=function(t,e,n,i){var r=t;return e<r&&(r=e),n<r&&(r=n),i<r&&(r=i),r},T.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}},T.wrap=function(t,e){return t<0?e- -t%e:t%e},T.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}},T.average=function(t,e){return(t+e)/2},M.LOG_10.get=function(){return Math.log(10)},Object.defineProperties(T,M);var R=function(t){this.str=t};R.prototype.append=function(t){this.str+=t},R.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},R.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 R,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,h=0;l>9?(c=!0,h="9"):h="0"+l,s.append(h),n=n.subtract(F.valueOf(l)).multiply(F.TEN),c&&n.selfAdd(F.TEN);var p=!0,f=F.magnitude(n._hi);if(f<0&&Math.abs(f)>=a-u&&(p=!1),!p)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,h=null,p=null,f=null,g=null,d=null;f=(p=this._hi+a)-(g=p-this._hi),h=(c=this._lo+u)-(d=c-this._lo);var y=(l=p+(g=(f=a-g+(this._hi-f))+c))+(g=(h=u-d+(this._lo-h))+(g+(p-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,I,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 h=t.substring(e);try{u=D.parseInt(h)}catch(e){throw e instanceof Error?new Error("Invalid exponent "+h+" in string "+t):e}break}throw new Error("Unexpected character \'"+l+"\' at position "+e+" in string "+t)}a=s}}var p=o,f=s-a-u;if(0===f)p=o;else if(f>0){var g=F.TEN.pow(f);p=o.divide(g)}else if(f<0){var d=F.TEN.pow(-f);p=o.multiply(d)}return i?p.negate():p},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 R,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(){},B={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(),h=F.valueOf(e.x).selfSubtract(t.x).selfMultiply(F.valueOf(t.y).selfSubtract(n.y)),p=F.valueOf(e.y).selfSubtract(t.y).selfMultiply(F.valueOf(t.x).selfSubtract(n.x)),f=h.subtract(p).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},B.DP_SAFE_EPSILON.get=function(){return 1e-15},Object.defineProperties(V,B);var q=function(){},k={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};k.X.get=function(){return 0},k.Y.get=function(){return 1},k.Z.get=function(){return 2},k.M.get=function(){return 3},q.prototype.setOrdinate=function(t,e,n){},q.prototype.size=function(){},q.prototype.getOrdinate=function(t,e){},q.prototype.getCoordinate=function(){},q.prototype.getCoordinateCopy=function(t){},q.prototype.getDimension=function(){},q.prototype.getX=function(t){},q.prototype.clone=function(){},q.prototype.expandEnvelope=function(t){},q.prototype.copy=function(){},q.prototype.getY=function(t){},q.prototype.toCoordinateArray=function(){},q.prototype.interfaces_=function(){return[E]},q.prototype.getClass=function(){return q},Object.defineProperties(q,k);var U=function(){},z=function(t){function e(){t.call(this,"Projective point not representable on the Cartesian plane.")}return e.__proto__=t,e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(U),Y=function(){};Y.arraycopy=function(t,e,n,i,r){for(var o=0,s=e;s<e+r;s++)n[i+o]=t[s],o++},Y.getProperty=function(t){return{"line.separator":"\\n"}[t]};var X=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],h=arguments[2],p=arguments[3],f=l.y-c.y,g=c.x-l.x,d=l.x*c.y-c.x*l.y,y=h.y-p.y,_=p.x-h.x,m=h.x*p.y-p.x*h.y;this.x=g*m-_*d,this.y=y*d-f*m,this.w=f*_-y*g}};X.prototype.getY=function(){var t=this.y/this.w;if(v.isNaN(t)||v.isInfinite(t))throw new z;return t},X.prototype.getX=function(){var t=this.x/this.w;if(v.isNaN(t)||v.isInfinite(t))throw new z;return t},X.prototype.getCoordinate=function(){var t=new w;return t.x=this.getX(),t.y=this.getY(),t},X.prototype.interfaces_=function(){return[]},X.prototype.getClass=function(){return X},X.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,h=(o*l-u*s)/c,p=(a*s-r*l)/c;if(v.isNaN(h)||v.isInfinite(h)||v.isNaN(p)||v.isInfinite(p))throw new z;return new w(h,p)};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[I,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(),$[n]&&(e=$[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(",")}},$={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($.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($.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=$.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($.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)}},Q=function(t){this.parser=new J(t)};Q.prototype.write=function(t){return this.parser.write(t)},Q.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 e.__proto__=t,e.prototype=Object.create(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 R;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 Q.toLineString(this._inputLines[0][0],this._inputLines[0][1])+" - "+Q.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 e.__proto__=t,e.prototype=Object.create(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=X.intersection(t,n,i,r)}catch(s){if(!(s instanceof z))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);Y.out.println("DD in env = "+s+"  --------------------- "+o),r.distance(o)>1e-4&&Y.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,h=n.x>i.x?n.x:i.x,p=n.y>i.y?n.y:i.y,f=((s>c?s:c)+(u<p?u:p))/2;r.x=((o>l?o:l)+(a<h?a:h))/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&&P(arguments[1],q)){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(P(arguments[0],q)){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,h=1;h<o-1;h++)s.y=a.y,a.x=u.x,a.y=u.y,r.getCoordinate(h+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?T.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()},ht={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,I,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},ht.serialVersionUID.get=function(){return 0x799ea46522854c00},ht.SORTINDEX_POINT.get=function(){return 0},ht.SORTINDEX_MULTIPOINT.get=function(){return 1},ht.SORTINDEX_LINESTRING.get=function(){return 2},ht.SORTINDEX_LINEARRING.get=function(){return 3},ht.SORTINDEX_MULTILINESTRING.get=function(){return 4},ht.SORTINDEX_POLYGON.get=function(){return 5},ht.SORTINDEX_MULTIPOLYGON.get=function(){return 6},ht.SORTINDEX_GEOMETRYCOLLECTION.get=function(){return 7},ht.geometryChangedFilter.get=function(){return pt},Object.defineProperties(ct,ht);var pt=function(){};pt.interfaces_=function(){return[lt]},pt.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 xt=function(){};xt.prototype.add=function(){},xt.prototype.addAll=function(){},xt.prototype.isEmpty=function(){},xt.prototype.iterator=function(){},xt.prototype.size=function(){},xt.prototype.toArray=function(){},xt.prototype.remove=function(){},(n.prototype=new Error).name="IndexOutOfBoundsException";var It=function(){};It.prototype.hasNext=function(){},It.prototype.next=function(){},It.prototype.remove=function(){};var Et=function(t){function e(){t.apply(this,arguments)}return e.__proto__=t,e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.prototype.get=function(){},e.prototype.set=function(){},e.prototype.isEmpty=function(){},e}(xt);(i.prototype=new Error).name="NoSuchElementException";var Nt=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof xt&&this.addAll(arguments[0])}return e.__proto__=t,e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.prototype.ensureCapacity=function(){},e.prototype.interfaces_=function(){return[t,xt]},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 e.__proto__=t,e.prototype=Object.create(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}(It),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)}}e.__proto__=t,(e.prototype=Object.create(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],h=arguments[2],p=arguments[3],f=1;h>p&&(f=-1);for(var g=h;g!==p;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);Y.arraycopy(t,n,i,0,t.length-n),Y.arraycopy(t,0,i,t.length-n,n),Y.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=T.clamp(e,0,t.length);var i=(n=T.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 Pt=function(){};Pt.prototype.get=function(){},Pt.prototype.put=function(){},Pt.prototype.size=function(){},Pt.prototype.values=function(){},Pt.prototype.entrySet=function(){};var Tt=function(t){function e(){t.apply(this,arguments)}return e.__proto__=t,e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e}(Pt);(r.prototype=new Error).name="OperationNotSupported",(o.prototype=new xt).contains=function(){};var Mt=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof xt&&this.addAll(arguments[0])}return e.__proto__=t,e.prototype=Object.create(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 Rt(this)},e}(o),Rt=function(t){function e(e){t.call(this),this.hashSet_=e,this.position_=0}return e.__proto__=t,e.prototype=Object.create(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}(It),Dt=0;(h.prototype=new Tt).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},h.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},h.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},h.prototype.values=function(){var t=new Nt,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=h.successor(e));)t.add(e.value);return t},h.prototype.entrySet=function(){var t=new Mt,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=h.successor(e));)t.add(e);return t},h.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}},h.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}},h.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t},h.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},h.prototype.size=function(){return this.size_};var At=function(){};At.prototype.interfaces_=function(){return[]},At.prototype.getClass=function(){return At},p.prototype=new o,(f.prototype=new p).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(){},Bt={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}};Bt.P.get=function(){return 0},Bt.L.get=function(){return 1},Bt.A.get=function(){return 2},Bt.FALSE.get=function(){return-1},Bt.TRUE.get=function(){return-2},Bt.DONTCARE.get=function(){return-3},Bt.SYM_FALSE.get=function(){return"F"},Bt.SYM_TRUE.get=function(){return"T"},Bt.SYM_DONTCARE.get=function(){return"*"},Bt.SYM_P.get=function(){return"0"},Bt.SYM_L.get=function(){return"1"},Bt.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,Bt);var qt=function(){};qt.prototype.filter=function(t){},qt.prototype.interfaces_=function(){return[]},qt.prototype.getClass=function(){return qt};var kt=function(){};kt.prototype.filter=function(t,e){},kt.prototype.isDone=function(){},kt.prototype.isGeometryChanged=function(){},kt.prototype.interfaces_=function(){return[]},kt.prototype.getClass=function(){return kt};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")}e.__proto__=t,(e.prototype=Object.create(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(P(arguments[0],ft))for(var t=arguments[0],e=0;e<this._geometries.length;e++)this._geometries[e].apply(t);else if(P(arguments[0],kt)){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(P(arguments[0],qt)){var r=arguments[0];r.filter(this);for(var o=0;o<this._geometries.length;o++)this._geometries[o].apply(r)}else if(P(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),zt=function(t){function e(){t.apply(this,arguments)}e.__proto__=t,(e.prototype=Object.create(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 Yt(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),Yt=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}};Yt.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)},Yt.prototype.getBoundary=function(){return this._geom instanceof Jt?this.boundaryLineString(this._geom):this._geom instanceof zt?this.boundaryMultiLineString(this._geom):this._geom.getBoundary()},Yt.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()])},Yt.prototype.getEmptyMultiPoint=function(){return this._geomFact.createMultiPoint()},Yt.prototype.computeBoundaryCoordinates=function(t){var e=new Nt;this._endpointMap=new h;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)},Yt.prototype.addEndpoint=function(t){var e=this._endpointMap.get(t);null===e&&(e=new Xt,this._endpointMap.put(t,e)),e.count++},Yt.prototype.interfaces_=function(){return[]},Yt.prototype.getClass=function(){return Yt},Yt.getBoundary=function(){return 1===arguments.length?new Yt(arguments[0]).getBoundary():2===arguments.length?new Yt(arguments[0],arguments[1]).getBoundary():void 0};var Xt=function(){this.count=null};Xt.prototype.interfaces_=function(){return[]},Xt.prototype.getClass=function(){return Xt};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 Y.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,q.X)===t.getOrdinate(e-1,q.X)&&t.getOrdinate(0,q.Y)===t.getOrdinate(e-1,q.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 R;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,q.X)===e.getOrdinate(n-1,q.X)&&e.getOrdinate(0,q.Y)===e.getOrdinate(n-1,q.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)}e.__proto__=t,(e.prototype=Object.create(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(P(arguments[0],ft))for(var t=arguments[0],e=0;e<this._points.size();e++)t.filter(this._points.getCoordinate(e));else if(P(arguments[0],kt)){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(P(arguments[0],qt)||P(arguments[0],lt))&&arguments[0].filter(this)},e.prototype.getBoundary=function(){return new Yt(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 $t=function(t){function e(e,n){t.call(this,n),this._coordinates=e||null,this.init(this._coordinates)}e.__proto__=t,(e.prototype=Object.create(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(P(arguments[0],ft)){var t=arguments[0];if(this.isEmpty())return null;t.filter(this.getCoordinate())}else if(P(arguments[0],kt)){var e=arguments[0];if(this.isEmpty())return null;e.filter(this._coordinates,0),e.isGeometryChanged()&&this.geometryChanged()}else(P(arguments[0],qt)||P(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),Qt=function(){};Qt.prototype.interfaces_=function(){return[]},Qt.prototype.getClass=function(){return Qt};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}e.__proto__=t,(e.prototype=Object.create(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);Y.arraycopy(e.getCoordinates(),0,i,0,i.length);var r=St.minCoordinate(e.getCoordinates());St.scroll(i,r),Y.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(P(t,ft)){this._shell.apply(t);for(var e=0;e<this._holes.length;e++)this._holes[e].apply(t)}else if(P(t,kt)){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(P(t,qt))t.filter(this);else if(P(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[Qt]},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)}e.__proto__=t,(e.prototype=Object.create(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()}e.__proto__=t,(e.prototype=Object.create(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)}e.__proto__=t,(e.prototype=Object.create(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[Qt]},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 $t||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()===zt?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 $t?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 $t?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(P(arguments[0],q)){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 q.X:this._coordinates[t].x=n;break;case q.Y:this._coordinates[t].y=n;break;case q.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 q.X:return this._coordinates[t].x;case q.Y:return this._coordinates[t].y;case q.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 R(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[q,e]},ue.prototype.getClass=function(){return ue},le.serialVersionUID.get=function(){return-0xcb44a778db18e00},Object.defineProperties(ue,le);var ce=function(){},he={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(P(arguments[0],q))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},he.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00},he.instanceObject.get=function(){return new ce},Object.defineProperties(ce,he);var pe=function(t){function e(){t.call(this),this.map_=new Map}return e.__proto__=t,e.prototype=Object.create(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 Mt;return this.map_.entries().forEach((function(e){return t.add(e)})),t},e.prototype.size=function(){return this.map_.size()},e}(Pt),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,I]},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 pe},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?P(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):P(t,q)?new Jt(t,this):void 0:new Jt(this.getCoordinateSequenceFactory().create([]),this)},_e.prototype.createMultiLineString=function(){return 0===arguments.length?new zt(null,this):1===arguments.length?new zt(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 $t)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(P(arguments[0],q))return new $t(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(P(arguments[0],q))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(P(arguments[0],q))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(P(arguments[0],q)){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"],xe=function(t){this.geometryFactory=t||new _e};xe.prototype.read=function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!Ie[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==ve.indexOf(n)?Ie[n].apply(this,[e.coordinates]):Ie[n].apply(this,"GeometryCollection"===n?[e.geometries]:[e])},xe.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 Ie={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){if(!Ie[t.geometry.type])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=Ie.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(Ie.Point.apply(this,[t[n]]));return this.geometryFactory.createMultiPoint(e)},LineString:function(t){var e=Ie.coordinates.apply(this,[t]);return this.geometryFactory.createLineString(e)},MultiLineString:function(t){for(var e=[],n=0;n<t.length;++n)e.push(Ie.LineString.apply(this,[t[n]]));return this.geometryFactory.createMultiLineString(e)},Polygon:function(t){for(var e=Ie.coordinates.apply(this,[t[0]]),n=this.geometryFactory.createLinearRing(e),i=[],r=1;r<t.length;++r){var o=Ie.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(Ie.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 xe(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 xe(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 e.__proto__=t,e.prototype=Object.create(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 Pe=function(){this._finder=null,this._dirEdgeList=new Nt,this._nodes=new Nt,this._rightMostCoord=null,this._env=null,this._finder=new be};Pe.prototype.clearVisitedEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();)t.next().setVisited(!1)},Pe.prototype.getRightmostCoordinate=function(){return this._rightMostCoord},Pe.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)}},Pe.prototype.computeDepth=function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.setEdgeDepths(Ce.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},Pe.prototype.create=function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()},Pe.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)}},Pe.prototype.computeDepths=function(t){var e=new Mt,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))}}}},Pe.prototype.compareTo=function(t){return this._rightMostCoord.x<t._rightMostCoord.x?-1:this._rightMostCoord.x>t._rightMostCoord.x?1:0},Pe.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},Pe.prototype.addReachable=function(t){var e=new y;for(e.add(t);!e.empty();){var n=e.pop();this.add(n,e)}},Pe.prototype.copySymDepths=function(t){var e=t.getSym();e.setDepth(Ce.LEFT,t.getDepth(Ce.RIGHT)),e.setDepth(Ce.RIGHT,t.getDepth(Ce.LEFT))},Pe.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)}},Pe.prototype.getNodes=function(){return this._nodes},Pe.prototype.getDirectedEdges=function(){return this._dirEdgeList},Pe.prototype.interfaces_=function(){return[I]},Pe.prototype.getClass=function(){return Pe};var Te=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}};Te.prototype.setAllLocations=function(t){for(var e=0;e<this.location.length;e++)this.location[e]=t},Te.prototype.isNull=function(){for(var t=0;t<this.location.length;t++)if(this.location[t]!==L.NONE)return!1;return!0},Te.prototype.setAllLocationsIfNull=function(t){for(var e=0;e<this.location.length;e++)this.location[e]===L.NONE&&(this.location[e]=t)},Te.prototype.isLine=function(){return 1===this.location.length},Te.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])},Te.prototype.getLocations=function(){return this.location},Te.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},Te.prototype.toString=function(){var t=new R;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()},Te.prototype.setLocations=function(t,e,n){this.location[Ce.ON]=t,this.location[Ce.LEFT]=e,this.location[Ce.RIGHT]=n},Te.prototype.get=function(t){return t<this.location.length?this.location[t]:L.NONE},Te.prototype.isArea=function(){return this.location.length>1},Te.prototype.isAnyNull=function(){for(var t=0;t<this.location.length;t++)if(this.location[t]===L.NONE)return!0;return!1},Te.prototype.setLocation=function(){1===arguments.length?this.setLocation(Ce.ON,arguments[0]):2===arguments.length&&(this.location[arguments[0]]=arguments[1])},Te.prototype.init=function(t){this.location=new Array(t).fill(null),this.setAllLocations(L.NONE)},Te.prototype.isEqualOnSide=function(t,e){return this.location[e]===t.location[e]},Te.prototype.allPositionsEqual=function(t){for(var e=0;e<this.location.length;e++)if(this.location[e]!==t)return!1;return!0},Te.prototype.interfaces_=function(){return[]},Te.prototype.getClass=function(){return Te};var Me=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 Te(e),this.elt[1]=new Te(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.elt[0]=new Te(n.elt[0]),this.elt[1]=new Te(n.elt[1])}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.elt[0]=new Te(L.NONE),this.elt[1]=new Te(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 Te(o,s,a),this.elt[1]=new Te(o,s,a)}else if(4===arguments.length){var u=arguments[0],l=arguments[1],c=arguments[2],h=arguments[3];this.elt[0]=new Te(L.NONE,L.NONE,L.NONE),this.elt[1]=new Te(L.NONE,L.NONE,L.NONE),this.elt[u].setLocations(l,c,h)}};Me.prototype.getGeometryCount=function(){var t=0;return this.elt[0].isNull()||t++,this.elt[1].isNull()||t++,t},Me.prototype.setAllLocations=function(t,e){this.elt[t].setAllLocations(e)},Me.prototype.isNull=function(t){return this.elt[t].isNull()},Me.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])},Me.prototype.isLine=function(t){return this.elt[t].isLine()},Me.prototype.merge=function(t){for(var e=0;e<2;e++)null===this.elt[e]&&null!==t.elt[e]?this.elt[e]=new Te(t.elt[e]):this.elt[e].merge(t.elt[e])},Me.prototype.flip=function(){this.elt[0].flip(),this.elt[1].flip()},Me.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},Me.prototype.toString=function(){var t=new R;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()},Me.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},Me.prototype.isAnyNull=function(t){return this.elt[t].isAnyNull()},Me.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])},Me.prototype.isEqualOnSide=function(t,e){return this.elt[0].isEqualOnSide(t.elt[0],e)&&this.elt[1].isEqualOnSide(t.elt[1],e)},Me.prototype.allPositionsEqual=function(t,e){return this.elt[t].allPositionsEqual(e)},Me.prototype.toLine=function(t){this.elt[t].isArea()&&(this.elt[t]=new Te(this.elt[t].location[0]))},Me.prototype.interfaces_=function(){return[]},Me.prototype.getClass=function(){return Me},Me.toLineLabel=function(t){for(var e=new Me(L.NONE),n=0;n<2;n++)e.setLocation(n,t.getLocation(n));return e};var Re=function(){this._startDe=null,this._maxNodeDegree=-1,this._edges=new Nt,this._pts=new Nt,this._label=new Me(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()};Re.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())},Re.prototype.isIsolated=function(){return 1===this._label.getGeometryCount()},Re.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)},Re.prototype.getLinearRing=function(){return this._ring},Re.prototype.getCoordinate=function(t){return this._pts.get(t)},Re.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},Re.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])}},Re.prototype.isHole=function(){return this._isHole},Re.prototype.setInResult=function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)},Re.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},Re.prototype.addHole=function(t){this._holes.add(t)},Re.prototype.isShell=function(){return null===this._shell},Re.prototype.getLabel=function(){return this._label},Re.prototype.getEdges=function(){return this._edges},Re.prototype.getMaxNodeDegree=function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree},Re.prototype.getShell=function(){return this._shell},Re.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}},Re.prototype.setShell=function(t){this._shell=t,null!==t&&t.addHole(this)},Re.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)},Re.prototype.interfaces_=function(){return[]},Re.prototype.getClass=function(){return Re};var De=function(t){function e(){t.call(this,arguments[0],arguments[1])}return e.__proto__=t,e.prototype=Object.create(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}(Re),Ae=function(t){function e(){t.call(this,arguments[0],arguments[1])}return e.__proto__=t,e.prototype=Object.create(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}(Re),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 Me(0,L.NONE)}return e.__proto__=t,e.prototype=Object.create(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 Me(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 Me)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 h,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 Be=function(){},qe={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};Be.prototype.interfaces_=function(){return[]},Be.prototype.getClass=function(){return Be},Be.isNorthern=function(t){return t===Be.NE||t===Be.NW},Be.isOpposite=function(t,e){return t!==e&&2==(t-e+4)%4},Be.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},Be.isInHalfPlane=function(t,e){return e===Be.SE?t===Be.SE||t===Be.SW:t===e||t===e+1},Be.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?Be.NE:Be.SE:e>=0?Be.NW:Be.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?Be.NE:Be.SE:i.y>=n.y?Be.NW:Be.SW}},qe.NE.get=function(){return 0},qe.NW.get=function(){return 1},qe.SW.get=function(){return 2},qe.SE.get=function(){return 3},Object.defineProperties(Be,qe);var ke=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}};ke.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)},ke.prototype.getDy=function(){return this._dy},ke.prototype.getCoordinate=function(){return this._p0},ke.prototype.setNode=function(t){this._node=t},ke.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)},ke.prototype.compareTo=function(t){return this.compareDirection(t)},ke.prototype.getDirectedCoordinate=function(){return this._p1},ke.prototype.getDx=function(){return this._dx},ke.prototype.getLabel=function(){return this._label},ke.prototype.getEdge=function(){return this._edge},ke.prototype.getQuadrant=function(){return this._quadrant},ke.prototype.getNode=function(){return this._node},ke.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},ke.prototype.computeLabel=function(t){},ke.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=Be.quadrant(this._dx,this._dy),et.isTrue(!(0===this._dx&&0===this._dy),"EdgeEnd with identical endpoints found")},ke.prototype.interfaces_=function(){return[I]},ke.prototype.getClass=function(){return ke};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 e.__proto__=t,e.prototype=Object.create(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 Me(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}(ke),ze=function(){};ze.prototype.createNode=function(t){return new Ge(t,null)},ze.prototype.interfaces_=function(){return[]},ze.prototype.getClass=function(){return ze};var Ye=function(){this._edges=new Nt,this._nodes=null,this._edgeEndList=new Nt,0===arguments.length?this._nodes=new Ve(new ze):1===arguments.length&&(this._nodes=new Ve(arguments[0]))};Ye.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)}},Ye.prototype.find=function(t){return this._nodes.find(t)},Ye.prototype.addNode=function(){return arguments[0]instanceof Ge||arguments[0]instanceof w?this._nodes.addNode(arguments[0]):void 0},Ye.prototype.getNodeIterator=function(){return this._nodes.iterator()},Ye.prototype.linkResultDirectedEdges=function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkResultDirectedEdges()},Ye.prototype.debugPrintln=function(t){Y.out.println(t)},Ye.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},Ye.prototype.linkAllDirectedEdges=function(){for(var t=this._nodes.iterator();t.hasNext();)t.next().getEdges().linkAllDirectedEdges()},Ye.prototype.matchInSameDirection=function(t,e,n,i){return!!t.equals(n)&&at.computeOrientation(t,e,i)===at.COLLINEAR&&Be.quadrant(t,e)===Be.quadrant(n,i)},Ye.prototype.getEdgeEnds=function(){return this._edgeEndList},Ye.prototype.debugPrint=function(t){Y.out.print(t)},Ye.prototype.getEdgeIterator=function(){return this._edges.iterator()},Ye.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},Ye.prototype.insertEdge=function(t){this._edges.add(t)},Ye.prototype.findEdgeEnd=function(t){for(var e=this.getEdgeEnds().iterator();e.hasNext();){var n=e.next();if(n.getEdge()===t)return n}return null},Ye.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)}},Ye.prototype.add=function(t){this._nodes.add(t),this._edgeEndList.add(t)},Ye.prototype.getNodes=function(){return this._nodes.values()},Ye.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},Ye.prototype.interfaces_=function(){return[]},Ye.prototype.getClass=function(){return Ye},Ye.linkResultDirectedEdges=function(t){for(var e=t.iterator();e.hasNext();)e.next().getEdges().linkResultDirectedEdges()};var Xe=function(){this._geometryFactory=null,this._shellList=new Nt,this._geometryFactory=arguments[0]};Xe.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)}},Xe.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},Xe.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)}}},Xe.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},Xe.prototype.containsPoint=function(t){for(var e=this._shellList.iterator();e.hasNext();)if(e.next().containsPoint(t))return!0;return!1},Xe.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},Xe.prototype.placePolygonHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(t)}},Xe.prototype.getPolygons=function(){return this.computePolygons(this._shellList)},Xe.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 h=!1;c.contains(i)&&at.isPointInRing(r,l.getCoordinates())&&(h=!0),h&&(null===o||s.contains(c))&&(o=u)}return o},Xe.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},Xe.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];Ye.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)}},Xe.prototype.interfaces_=function(){return[]},Xe.prototype.getClass=function(){return Xe};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 $e=function(){this._childBoundables=new Nt,this._bounds=null,this._level=null,0===arguments.length||1===arguments.length&&(this._level=arguments[0])},Qe={serialVersionUID:{configurable:!0}};$e.prototype.getLevel=function(){return this._level},$e.prototype.size=function(){return this._childBoundables.size()},$e.prototype.getChildBoundables=function(){return this._childBoundables},$e.prototype.addChildBoundable=function(t){et.isTrue(null===this._bounds),this._childBoundables.add(t)},$e.prototype.isEmpty=function(){return this._childBoundables.isEmpty()},$e.prototype.getBounds=function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds},$e.prototype.interfaces_=function(){return[je,e]},$e.prototype.getClass=function(){return $e},Qe.serialVersionUID.get=function(){return 0x5a1e55ec41369800},Object.defineProperties($e,Qe);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[I]},tn.prototype.getClass=function(){return tn},tn.area=function(t){return t.getBounds().getArea()},tn.isComposite=function(t){return t instanceof $e};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 $e?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 $e){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 $e?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(P(arguments[2],Je)&&arguments[0]instanceof Object&&arguments[1]instanceof $e)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 $e?this.query(r,u,o):u instanceof He?o.visitItem(u.getItem()):et.shouldNeverReachHere())}else if(P(arguments[2],Et)&&arguments[0]instanceof Object&&arguments[1]instanceof $e)for(var l=arguments[0],c=arguments[2],h=arguments[1].getChildBoundables(),p=0;p<h.size();p++){var f=h.get(p);this.getIntersectsOp().intersects(f.getBounds(),l)&&(f instanceof $e?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 $e&&(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 $e){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)}n.__proto__=t,(n.prototype=Object.create(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&&(P(arguments[2],Je)&&arguments[0]instanceof Object&&arguments[1]instanceof $e||P(arguments[2],Et)&&arguments[0]instanceof Object&&arguments[1]instanceof $e)&&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(P(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&&P(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(),h=c.getDistance();if(h>=a)break;c.isLeaves()?(a=h,u=c):c.expandToQueue(l,a)}return[u.getBoundable(0).getItem(),u.getBoundable(1).getItem()]}}else if(3===arguments.length){var p=arguments[2],f=new He(arguments[0],arguments[1]),g=new tn(this.getRoot(),f,p);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 e.__proto__=t,e.prototype=Object.create(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}($e),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[I]},ln.prototype.getClass=function(){return ln};var cn=function(){this._nodeMap=new h,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 hn=function(){};hn.prototype.interfaces_=function(){return[]},hn.prototype.getClass=function(){return hn},hn.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 hn.octant(s,a)}};var pn=function(){};pn.prototype.getCoordinates=function(){},pn.prototype.size=function(){},pn.prototype.getCoordinate=function(t){},pn.prototype.isClosed=function(){},pn.prototype.setData=function(t){},pn.prototype.getData=function(){},pn.prototype.interfaces_=function(){return[]},pn.prototype.getClass=function(){return pn};var fn=function(){};fn.prototype.addIntersection=function(t,e){},fn.prototype.interfaces_=function(){return[pn]},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:hn.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 Q.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 X.intersection(this.p0,this.p1,t.p0,t.p1)}catch(t){if(!(t instanceof z))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[I,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),h=Math.trunc((i+r)/2);t<c&&(i<h&&this.computeOverlapsInternal(t,c,n,i,h,o),h<r&&this.computeOverlapsInternal(t,c,n,h,r,o)),c<e&&(i<h&&this.computeOverlapsInternal(c,e,n,i,h,o),h<r&&this.computeOverlapsInternal(c,e,n,h,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=Be.quadrant(t[n],t[n+1]),r=e+1;r<t.length&&(t[r-1].equals2D(t[r])||Be.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 xn=function(){};xn.prototype.computeNodes=function(t){},xn.prototype.getNodedSubstrings=function(){},xn.prototype.interfaces_=function(){return[]},xn.prototype.getClass=function(){return xn};var In=function(){this._segInt=null,0===arguments.length||1===arguments.length&&this.setSegmentIntersector(arguments[0])};In.prototype.setSegmentIntersector=function(t){this._segInt=t},In.prototype.interfaces_=function(){return[xn]},In.prototype.getClass=function(){return In};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}e.__proto__=t,(e.prototype=Object.create(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}(In),Nn=function(t){function e(){t.call(this),this._si=null,this._si=arguments[0]}return e.__proto__=t,e.prototype=Object.create(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 Pn=function(){},Tn={PI_TIMES_2:{configurable:!0},PI_OVER_2:{configurable:!0},PI_OVER_4:{configurable:!0},COUNTERCLOCKWISE:{configurable:!0},CLOCKWISE:{configurable:!0},NONE:{configurable:!0}};Pn.prototype.interfaces_=function(){return[]},Pn.prototype.getClass=function(){return Pn},Pn.toDegrees=function(t){return 180*t/Math.PI},Pn.normalize=function(t){for(;t>Math.PI;)t-=Pn.PI_TIMES_2;for(;t<=-Math.PI;)t+=Pn.PI_TIMES_2;return t},Pn.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)}},Pn.isAcute=function(t,e,n){return(t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y)>0},Pn.isObtuse=function(t,e,n){return(t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y)<0},Pn.interiorAngle=function(t,e,n){var i=Pn.angle(e,t),r=Pn.angle(e,n);return Math.abs(r-i)},Pn.normalizePositive=function(t){if(t<0){for(;t<0;)t+=Pn.PI_TIMES_2;t>=Pn.PI_TIMES_2&&(t=0)}else{for(;t>=Pn.PI_TIMES_2;)t-=Pn.PI_TIMES_2;t<0&&(t=0)}return t},Pn.angleBetween=function(t,e,n){var i=Pn.angle(e,t),r=Pn.angle(e,n);return Pn.diff(i,r)},Pn.diff=function(t,e){var n=null;return(n=t<e?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n},Pn.toRadians=function(t){return t*Math.PI/180},Pn.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?Pn.COUNTERCLOCKWISE:n<0?Pn.CLOCKWISE:Pn.NONE},Pn.angleBetweenOriented=function(t,e,n){var i=Pn.angle(e,t),r=Pn.angle(e,n)-i;return r<=-Math.PI?r+Pn.PI_TIMES_2:r>Math.PI?r-Pn.PI_TIMES_2:r},Tn.PI_TIMES_2.get=function(){return 2*Math.PI},Tn.PI_OVER_2.get=function(){return Math.PI/2},Tn.PI_OVER_4.get=function(){return Math.PI/4},Tn.COUNTERCLOCKWISE.get=function(){return at.COUNTERCLOCKWISE},Tn.CLOCKWISE.get=function(){return at.CLOCKWISE},Tn.NONE.get=function(){return at.COLLINEAR},Object.defineProperties(Pn,Tn);var Mn=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)},Rn={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}};Mn.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)},Mn.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)}},Mn.prototype.getCoordinates=function(){return this._segList.getCoordinates()},Mn.prototype.addMitreJoin=function(t,e,n,i){var r=!0,o=null;try{o=X.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 z))throw t;o=new w(0,0),r=!1}r?this._segList.addPt(o):this.addLimitedMitreJoin(e,n,i,this._bufParams.getMitreLimit())},Mn.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)},Mn.prototype.addOutsideTurn=function(t,e){if(this._offset0.p1.distance(this._offset1.p0)<this._distance*Mn.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))},Mn.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()},Mn.prototype.addSegments=function(t,e){this._segList.addPts(t,e)},Mn.prototype.addFirstSegment=function(){this._segList.addPt(this._offset1.p0)},Mn.prototype.addLastSegment=function(){this._segList.addPt(this._offset1.p1)},Mn.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)},Mn.prototype.addLimitedMitreJoin=function(t,e,n,i){var r=this._seg0.p1,o=Pn.angle(r,this._seg0.p0),s=Pn.angleBetweenOriented(this._seg0.p0,r,this._seg1.p1)/2,a=Pn.normalize(o+s),u=Pn.normalize(a+Math.PI),l=i*n,c=n-l*Math.abs(Math.sin(s)),h=r.x+l*Math.cos(u),p=r.y+l*Math.sin(u),f=new w(h,p),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))},Mn.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},Mn.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 h=e+o*l;c.x=t.x+r*Math.cos(h),c.y=t.y+r*Math.sin(h),this._segList.addPt(c),l+=u}},Mn.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*Mn.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)}},Mn.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()},Mn.prototype.addBevelJoin=function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)},Mn.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*Mn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},Mn.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))},Mn.prototype.closeRing=function(){this._segList.closeRing()},Mn.prototype.hasNarrowConcaveAngle=function(){return this._hasNarrowConcaveAngle},Mn.prototype.interfaces_=function(){return[]},Mn.prototype.getClass=function(){return Mn},Rn.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return.001},Rn.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return.001},Rn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6},Rn.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80},Object.defineProperties(Mn,Rn);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 Mn(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(P(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 h=new Gn(this._seg,c);a.add(h)}}else if(P(arguments[2],Et)&&arguments[0]instanceof w&&P(arguments[1],Et))for(var p=arguments[0],f=arguments[2],g=arguments[1].iterator();g.hasNext();){var d=g.next();d.isForward()&&this.findStabbedSegments(p,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[I]},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,h=t.x-r,p=t.y-o;return e.z+(l*h-a*p)/c*(n.z-e.z)+(-u*h+s*p)/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!!Pn.isAcute(t,e,n)&&!!Pn.isAcute(e,n,t)&&!!Pn.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),h=Vn.det(o,o*o+s*s,a,a*a+u*u);return new w(i-c/l,r+h/l)},Vn.perpendicularBisector=function(t,e){var n=e.x-t.x,i=e.y-t.y,r=new X(t.x+n/2,t.y+i/2,1),o=new X(t.x-i+n/2,t.y+n+i/2,1);return new X(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,h=i*a-r*s;return Math.sqrt(l*l+c*c+h*h)/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 Bn=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};Bn.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)},Bn.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)}},Bn.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)},Bn.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)},Bn.prototype.addCurve=function(t,e,n){if(null===t||t.length<2)return null;var i=new gn(t,new Me(0,L.BOUNDARY,e,n));this._curveList.add(i)},Bn.prototype.getCurves=function(){return this.add(this._inputGeom),this._curveList},Bn.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)},Bn.prototype.add=function(t){if(t.isEmpty())return null;t instanceof Zt?this.addPolygon(t):t instanceof Jt?this.addLineString(t):t instanceof $t?this.addPoint(t):(t instanceof te||t instanceof zt||t instanceof ne||t instanceof Ut)&&this.addCollection(t)},Bn.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},Bn.prototype.addCollection=function(t){for(var e=0;e<t.getNumGeometries();e++){var n=t.getGeometryN(e);this.add(n)}},Bn.prototype.interfaces_=function(){return[]},Bn.prototype.getClass=function(){return Bn};var qn=function(){};qn.prototype.locate=function(t){},qn.prototype.interfaces_=function(){return[]},qn.prototype.getClass=function(){return qn};var kn=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()};kn.prototype.next=function(){if(this._atStart)return this._atStart=!1,kn.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 kn(t),this._subcollectionIterator.next()):t},kn.prototype.remove=function(){throw new Error(this.getClass().getName())},kn.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)},kn.prototype.interfaces_=function(){return[It]},kn.prototype.getClass=function(){return kn},kn.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[qn]},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 kn(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 zn=function(){this._edgeMap=new h,this._edgeList=null,this._ptInAreaLocation=[L.NONE,L.NONE]};zn.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)},zn.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)}}},zn.prototype.getCoordinate=function(){var t=this.iterator();return t.hasNext()?t.next().getCoordinate():null},zn.prototype.print=function(t){Y.out.println("EdgeEndStar:   "+this.getCoordinate());for(var e=this.iterator();e.hasNext();)e.next().print(t)},zn.prototype.isAreaLabelsConsistent=function(t){return this.computeEdgeEndLabels(t.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)},zn.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},zn.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},zn.prototype.iterator=function(){return this.getEdges().iterator()},zn.prototype.getEdges=function(){return null===this._edgeList&&(this._edgeList=new Nt(this._edgeMap.values())),this._edgeList},zn.prototype.getLocation=function(t,e,n){return this._ptInAreaLocation[t]===L.NONE&&(this._ptInAreaLocation[t]=Un.locate(e,n[t].getGeometry())),this._ptInAreaLocation[t]},zn.prototype.toString=function(){var t=new R;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()},zn.prototype.computeEdgeEndLabels=function(t){for(var e=this.iterator();e.hasNext();)e.next().computeLabel(t)},zn.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)}},zn.prototype.getDegree=function(){return this._edgeMap.size()},zn.prototype.insertEdgeEnd=function(t,e){this._edgeMap.put(t,e),this._edgeList=null},zn.prototype.interfaces_=function(){return[]},zn.prototype.getClass=function(){return zn};var Yn=function(t){function e(){t.call(this),this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}return e.__proto__=t,e.prototype=Object.create(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 Be.isNorthern(r)&&Be.isNorthern(o)?n:Be.isNorthern(r)||Be.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){Y.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 Me(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}(zn),Xn=function(t){function e(){t.apply(this,arguments)}return e.__proto__=t,e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.prototype.createNode=function(t){return new Ge(t,new Yn)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(ze),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[I]},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 h=(u+=r)===s,p=(l+=o)===a;if(h&&!p)return-1;if(!h&&p)return 1;if(h&&p)return 0}};var Hn=function(){this._edges=new Nt,this._ocaMap=new h};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[I]},Kn.prototype.getClass=function(){return Kn};var $n=function(){this._nodeMap=new h,this.edge=null,this.edge=arguments[0]};$n.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)},$n.prototype.iterator=function(){return this._nodeMap.values().iterator()},$n.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}},$n.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)},$n.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 Me(this.edge._label))},$n.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)},$n.prototype.isIntersection=function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1},$n.prototype.interfaces_=function(){return[]},$n.prototype.getClass=function(){return $n};var Qn=function(){};Qn.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 Qn.toIntArray(n)},Qn.prototype.findChainEnd=function(t,e){for(var n=Be.quadrant(t[e],t[e+1]),i=e+1;i<t.length&&Be.quadrant(t[i-1],t[i])===n;)i++;return i-1},Qn.prototype.interfaces_=function(){return[]},Qn.prototype.getClass=function(){return Qn},Qn.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 Qn;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],h=o.pts[s],p=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(h,p),!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 $n(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 e.__proto__=t,e.prototype=Object.create(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,Me.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 R;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 Me(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 Pe;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 Bn(t,e,i).getCurves();if(r.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(r,n),this._graph=new Ye(new Xn),this._graph.addEdges(this._edgeList.getEdges());var o=this.createSubgraphs(this._graph),s=new Xe(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 Me(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(P(arguments[0],xt))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])&&Y.out.println(n)}},ri.prototype.scale=function(){if(P(arguments[0],xt)){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[xn]},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],h=arguments[1],p=arguments[2],f=arguments[3];if(c===p&&h===f)return null;var g=c.getCoordinates()[h],d=c.getCoordinates()[h+1],y=p.getCoordinates()[f],_=p.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]},hi={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 pi(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},hi.HotPixelSnapAction.get=function(){return pi},Object.defineProperties(ci,hi);var pi=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 e.__proto__=t,e.prototype=Object.create(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(P(arguments[0],xt))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[xn]},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=T.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],h=arguments[1],p=arguments[2];if(c instanceof Jt)mi.computeDistance(c,h,p);else if(c instanceof Zt)mi.computeDistance(c,h,p);else if(c instanceof Ut)for(var f=c,g=0;g<f.getNumGeometries();g++){var d=f.getGeometryN(g);mi.computeDistance(d,h,p)}else p.setMinimum(c.getCoordinate(),h)}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},xi={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 Ii(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},xi.MaxPointDistanceFilter.get=function(){return Ii},xi.MaxMidpointDistanceFilter.get=function(){return Ei},Object.defineProperties(vi,xi);var Ii=function(t){this._maxPtDist=new _i,this._minPtDist=new _i,this._geom=t||null};Ii.prototype.filter=function(t){this._minPtDist.initialize(),mi.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},Ii.prototype.getMaxPointDistance=function(){return this._maxPtDist},Ii.prototype.interfaces_=function(){return[ft]},Ii.prototype.getClass=function(){return Ii};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[kt]},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[qt]},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(P(arguments[0],xt)&&P(arguments[1],xt)){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&&P(arguments[1],xt)){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]&&P(arguments[0],xt)&&P(arguments[1],xt)){for(var u=arguments[1],l=arguments[2],c=arguments[0].iterator();c.hasNext();){var h=c.next();wi.getLines(h,u,l)}return u}if("boolean"==typeof arguments[2]&&arguments[0]instanceof ct&&P(arguments[1],xt)){var p=arguments[1];return arguments[0].apply(new wi(p,arguments[2])),p}}};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 $t){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 $t&&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 zt)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 kn(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 $t&&this._pts.add(t)},Li.prototype.interfaces_=function(){return[qt]},Li.prototype.getClass=function(){return Li},Li.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof $t?Ze.singletonList(t):Li.getPoints(t,new Nt)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof $t?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 $t||t instanceof Jt||t instanceof Zt)&&this._locations.add(new Si(t,0,t.getCoordinate()))},Oi.prototype.interfaces_=function(){return[qt]},Oi.prototype.getClass=function(){return Oi},Oi.getLocations=function(t){var e=new Nt;return t.apply(new Oi(e)),e};var Pi=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}};Pi.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&&P(arguments[0],Et)&&P(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),h=0;h<a.size();h++)if(this.computeContainmentDistance(c,a.get(h),u),this._minDistance<=this._terminateDistance)return null}else if(arguments[2]instanceof Array&&arguments[0]instanceof Si&&arguments[1]instanceof Zt){var p=arguments[0],f=arguments[1],g=arguments[2],d=p.getCoordinate();if(L.EXTERIOR!==this._ptLocator.locate(d,f))return this._minDistance=0,g[0]=p,g[1]=new Si(f,d),null}},Pi.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}},Pi.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))))},Pi.prototype.nearestLocations=function(){return this.computeMinDistance(),this._minDistanceLocation},Pi.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])},Pi.prototype.nearestPoints=function(){return this.computeMinDistance(),[this._minDistanceLocation[0].getCoordinate(),this._minDistanceLocation[1].getCoordinate()]},Pi.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 $t){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 h=u.getCoordinates(),p=l.getCoordinates(),f=0;f<h.length-1;f++)for(var g=0;g<p.length-1;g++){var d=at.distanceLineLine(h[f],h[f+1],p[g],p[g+1]);if(d<this._minDistance){this._minDistance=d;var y=new dn(h[f],h[f+1]),_=new dn(p[g],p[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}}},Pi.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}},Pi.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)},Pi.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}},Pi.prototype.interfaces_=function(){return[]},Pi.prototype.getClass=function(){return Pi},Pi.distance=function(t,e){return new Pi(t,e).distance()},Pi.isWithinDistance=function(t,e,n){return new Pi(t,e,n).distance()<=n},Pi.nearestPoints=function(t,e){return new Pi(t,e).nearestPoints()};var Ti=function(){this._pt=[new w,new w],this._distance=v.NaN,this._isNull=!0};Ti.prototype.getCoordinates=function(){return this._pt},Ti.prototype.getCoordinate=function(t){return this._pt[t]},Ti.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)}},Ti.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}},Ti.prototype.toString=function(){return Q.toLineString(this._pt[0],this._pt[1])},Ti.prototype.getDistance=function(){return this._distance},Ti.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)}},Ti.prototype.interfaces_=function(){return[]},Ti.prototype.getClass=function(){return Ti};var Mi=function(){};Mi.prototype.interfaces_=function(){return[]},Mi.prototype.getClass=function(){return Mi},Mi.computeDistance=function(){if(arguments[2]instanceof Ti&&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 Ti&&arguments[0]instanceof Zt&&arguments[1]instanceof w){var a=arguments[0],u=arguments[1],l=arguments[2];Mi.computeDistance(a.getExteriorRing(),u,l);for(var c=0;c<a.getNumInteriorRing();c++)Mi.computeDistance(a.getInteriorRingN(c),u,l)}else if(arguments[2]instanceof Ti&&arguments[0]instanceof ct&&arguments[1]instanceof w){var h=arguments[0],p=arguments[1],f=arguments[2];if(h instanceof Jt)Mi.computeDistance(h,p,f);else if(h instanceof Zt)Mi.computeDistance(h,p,f);else if(h instanceof Ut)for(var g=h,d=0;d<g.getNumGeometries();d++){var y=g.getGeometryN(d);Mi.computeDistance(y,p,f)}else f.setMinimum(h.getCoordinate(),p)}else if(arguments[2]instanceof Ti&&arguments[0]instanceof dn&&arguments[1]instanceof w){var _=arguments[1],m=arguments[2],v=arguments[0].closestPoint(_);m.setMinimum(v,_)}};var Ri=function(){this._g0=null,this._g1=null,this._ptDist=new Ti,this._densifyFrac=0;var t=arguments[1];this._g0=arguments[0],this._g1=t},Di={MaxPointDistanceFilter:{configurable:!0},MaxDensifiedByFractionDistanceFilter:{configurable:!0}};Ri.prototype.getCoordinates=function(){return this._ptDist.getCoordinates()},Ri.prototype.setDensifyFraction=function(t){if(t>1||t<=0)throw new m("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t},Ri.prototype.compute=function(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist)},Ri.prototype.distance=function(){return this.compute(this._g0,this._g1),this._ptDist.getDistance()},Ri.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())}},Ri.prototype.orientedDistance=function(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance()},Ri.prototype.interfaces_=function(){return[]},Ri.prototype.getClass=function(){return Ri},Ri.distance=function(){if(2===arguments.length)return new Ri(arguments[0],arguments[1]).distance();if(3===arguments.length){var t=arguments[2],e=new Ri(arguments[0],arguments[1]);return e.setDensifyFraction(t),e.distance()}},Di.MaxPointDistanceFilter.get=function(){return Ai},Di.MaxDensifiedByFractionDistanceFilter.get=function(){return Fi},Object.defineProperties(Ri,Di);var Ai=function(){this._maxPtDist=new Ti,this._minPtDist=new Ti,this._euclideanDist=new Mi,this._geom=null,this._geom=arguments[0]};Ai.prototype.filter=function(t){this._minPtDist.initialize(),Mi.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 Ti,this._minPtDist=new Ti,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(),Mi.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[kt]},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 Ri(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 "+Q.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&&Y.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 Pi(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 "+Q.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 Bi=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},qi={VERBOSE:{configurable:!0},MAX_ENV_DIFF_FRAC:{configurable:!0}};Bi.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},Bi.prototype.checkEnvelope=function(){if(this._distance<0)return null;var t=this._distance*Bi.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")},Bi.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")},Bi.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")},Bi.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")},Bi.prototype.getErrorIndicator=function(){return this._errorIndicator},Bi.prototype.getErrorLocation=function(){return this._errorLocation},Bi.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"))},Bi.prototype.report=function(t){if(!Bi.VERBOSE)return null;Y.out.println("Check "+t+": "+(this._isValid?"passed":"FAILED"))},Bi.prototype.getErrorMessage=function(){return this._errorMsg},Bi.prototype.interfaces_=function(){return[]},Bi.prototype.getClass=function(){return Bi},Bi.isValidMsg=function(t,e,n){var i=new Bi(t,e,n);return i.isValid()?null:i.getErrorMessage()},Bi.isValid=function(t,e,n){return!!new Bi(t,e,n).isValid()},qi.VERBOSE.get=function(){return!1},qi.MAX_ENV_DIFF_FRAC.get=function(){return.012},Object.defineProperties(Bi,qi);var ki=function(){this._pts=null,this._data=null;var t=arguments[1];this._pts=arguments[0],this._data=t};ki.prototype.getCoordinates=function(){return this._pts},ki.prototype.size=function(){return this._pts.length},ki.prototype.getCoordinate=function(t){return this._pts[t]},ki.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},ki.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:hn.octant(this.getCoordinate(t),this.getCoordinate(t+1))},ki.prototype.setData=function(t){this._data=t},ki.prototype.getData=function(){return this._data},ki.prototype.toString=function(){return Q.toLineString(new ue(this._pts))},ki.prototype.interfaces_=function(){return[pn]},ki.prototype.getClass=function(){return ki};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 zi=function(){this._li=new rt,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0,this._segStrings=arguments[0]};zi.prototype.execute=function(){if(null!==this._segInt)return null;this.checkInteriorIntersections()},zi.prototype.getIntersections=function(){return this._segInt.getIntersections()},zi.prototype.isValid=function(){return this.execute(),this._isValid},zi.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},zi.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},zi.prototype.checkValid=function(){if(this.execute(),!this._isValid)throw new Le(this.getErrorMessage(),this._segInt.getInteriorIntersection())},zi.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+Q.toLineString(t[0],t[1])+" and "+Q.toLineString(t[2],t[3])},zi.prototype.interfaces_=function(){return[]},zi.prototype.getClass=function(){return zi},zi.computeIntersections=function(t){var e=new zi(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()};var Yi=function t(){this._nv=null,this._nv=new zi(t.toSegmentStrings(arguments[0]))};Yi.prototype.checkValid=function(){this._nv.checkValid()},Yi.prototype.interfaces_=function(){return[]},Yi.prototype.getClass=function(){return Yi},Yi.toSegmentStrings=function(t){for(var e=new Nt,n=t.iterator();n.hasNext();){var i=n.next();e.add(new ki(i.getCoordinates(),i))}return e},Yi.checkValid=function(t){new Yi(t).checkValid()};var Xi=function(t){this._mapOp=t};Xi.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))},Xi.prototype.interfaces_=function(){return[]},Xi.prototype.getClass=function(){return Xi},Xi.map=function(t,e){return new Xi(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 $t)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 zt)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},$i={SNAP_PRECISION_FACTOR:{configurable:!0}};Ki.prototype.snapTo=function(t,e){var n=this.extractTargetCoordinates(t);return new Qi(e,n).transform(this._srcGeom)},Ki.prototype.snapToSelf=function(t,e){var n=this.extractTargetCoordinates(this._srcGeom),i=new Qi(t,n,!0).transform(this._srcGeom),r=i;return e&&P(r,Qt)&&(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)},$i.SNAP_PRECISION_FACTOR.get=function(){return 1e-9},Object.defineProperties(Ki,$i);var Qi=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 e.__proto__=t,e.prototype=Object.create(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[kt]},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()||Y.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[I]},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 hr=function(t){function e(){t.call(this),this.events=new Nt,this.nOverlaps=null}return e.__proto__=t,e.prototype=Object.create(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&&P(arguments[0],Et)&&P(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]&&P(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),pr=function(){this._min=v.POSITIVE_INFINITY,this._max=v.NEGATIVE_INFINITY},fr={NodeComparator:{configurable:!0}};pr.prototype.getMin=function(){return this._min},pr.prototype.intersects=function(t,e){return!(this._min>e||this._max<t)},pr.prototype.getMax=function(){return this._max},pr.prototype.toString=function(){return Q.toLineString(new w(this._min,0),new w(this._max,0))},pr.prototype.interfaces_=function(){return[]},pr.prototype.getClass=function(){return pr},fr.NodeComparator.get=function(){return gr},Object.defineProperties(pr,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 e.__proto__=t,e.prototype=Object.create(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}(pr),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 e.__proto__=t,e.prototype=Object.create(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}(pr),_r=function(){this._leaves=new Nt,this._root=null,this._level=0};_r.prototype.buildTree=function(){Ze.sort(this._leaves,new pr.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){Y.out.println(Q.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(!P(t,Qt))throw new m("Argument must be Polygonal");this._index=new Er(t)},xr={SegmentVisitor:{configurable:!0},IntervalIndexedGeometry:{configurable:!0}};vr.prototype.locate=function(t){var e=new st(t),n=new Ir(e);return this._index.query(t.y,t.y,n),e.getLocation()},vr.prototype.interfaces_=function(){return[qn]},vr.prototype.getClass=function(){return vr},xr.SegmentVisitor.get=function(){return Ir},xr.IntervalIndexedGeometry.get=function(){return Er},Object.defineProperties(vr,xr);var Ir=function(){this._counter=null,this._counter=arguments[0]};Ir.prototype.visitItem=function(t){var e=t;this._counter.countSegment(e.getCoordinate(0),e.getCoordinate(1))},Ir.prototype.interfaces_=function(){return[Je]},Ir.prototype.getClass=function(){return Ir};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 pe,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 e.__proto__=t,e.prototype=Object.create(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 $t){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 Me(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 Me(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 Me(t,n):r.setLocation(t,n)},e.prototype.createEdgeSetIntersector=function(){return new hr},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 $t)this.addPoint(e);else if(e instanceof te)this.addCollection(e);else if(e instanceof zt)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 P(this._parentGeom,Qt)&&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}(Ye),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&&P(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(P(arguments[0],xt)&&P(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 Ye(new Xn),this._geomFact=e.getFactory()}return e.__proto__=t,e.prototype=Object.create(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 Me(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(),Yi.checkValid(this._edgeList.getEdges()),this._graph.addEdges(this._edgeList.getEdges()),this.computeLabelling(),this.labelIncompleteNodes(),this.findResultAreaEdges(t),this.cancelDuplicateResultEdges();var n=new Xe(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 Xi.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[qt]},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 h=new w(l-u,c+a);i.add(h)}if(this._doRight){var p=new w(l+u,c-a);i.add(p)}},Or.prototype.interfaces_=function(){return[]},Or.prototype.getClass=function(){return Or};var Pr=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)]},Tr={TOLERANCE:{configurable:!0}};Pr.prototype.reportResult=function(t,e,n){Y.out.println("Overlay result invalid - A:"+L.toLocationSymbol(e[0])+" B:"+L.toLocationSymbol(e[1])+" expected:"+(n?"i":"e")+" actual:"+L.toLocationSymbol(e[2]))},Pr.prototype.isValid=function(t){return this.addTestPts(this._geom[0]),this.addTestPts(this._geom[1]),this.checkValid(t)},Pr.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),!!Pr.hasLocation(this._location,L.BOUNDARY)||this.isValidResult(i,this._location)}},Pr.prototype.addTestPts=function(t){var e=new Or(t);this._testCoords.addAll(e.getPoints(5*this._boundaryDistanceTolerance))},Pr.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},Pr.prototype.getInvalidLocation=function(){return this._invalidLocation},Pr.prototype.interfaces_=function(){return[]},Pr.prototype.getClass=function(){return Pr},Pr.hasLocation=function(t,e){for(var n=0;n<3;n++)if(t[n]===e)return!0;return!1},Pr.computeBoundaryDistanceTolerance=function(t,e){return Math.min(Ki.computeSizeBasedSnapTolerance(t),Ki.computeSizeBasedSnapTolerance(e))},Pr.isValid=function(t,e,n,i){return new Pr(t,e,i).isValid(n)},Tr.TOLERANCE.get=function(){return 1e-6},Object.defineProperties(Pr,Tr);var Mr=function t(e){this._geomFactory=null,this._skipEmpty=!1,this._inputGeoms=null,this._geomFactory=t.extractFactory(e),this._inputGeoms=e};Mr.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)}},Mr.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)},Mr.prototype.interfaces_=function(){return[]},Mr.prototype.getClass=function(){return Mr},Mr.combine=function(){return 1===arguments.length?new Mr(arguments[0]).combine():2===arguments.length?new Mr(Mr.createList(arguments[0],arguments[1])).combine():3===arguments.length?new Mr(Mr.createList(arguments[0],arguments[1],arguments[2])).combine():void 0},Mr.extractFactory=function(t){return t.isEmpty()?null:t.iterator().next().getFactory()},Mr.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 Rr=function(){this._inputPolys=null,this._geomFactory=null,this._inputPolys=arguments[0],null===this._inputPolys&&(this._inputPolys=new Nt)},Dr={STRTREE_NODE_CAPACITY:{configurable:!0}};Rr.prototype.reduceToGeometries=function(t){for(var e=new Nt,n=t.iterator();n.hasNext();){var i=n.next(),r=null;P(i,Et)?r=this.unionTree(i):i instanceof ct&&(r=i),e.add(r)}return e},Rr.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)},Rr.prototype.unionOptimized=function(t,e){var n=t.getEnvelopeInternal(),i=e.getEnvelopeInternal();if(!n.intersects(i))return Mr.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)},Rr.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(Rr.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)},Rr.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=Rr.getGeometry(e,n);return this.unionSafe(r,null)}if(i-n==2)return this.unionSafe(Rr.getGeometry(e,n),Rr.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)}},Rr.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},Rr.prototype.unionSafe=function(t,e){return null===t&&null===e?null:null===t?e.copy():null===e?t.copy():this.unionOptimized(t,e)},Rr.prototype.unionActual=function(t,e){return Rr.restrictToPolygons(t.union(e))},Rr.prototype.unionTree=function(t){var e=this.reduceToGeometries(t);return this.binaryUnion(e)},Rr.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),Mr.combine(i)},Rr.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)}},Rr.prototype.interfaces_=function(){return[]},Rr.prototype.getClass=function(){return Rr},Rr.restrictToPolygons=function(t){if(P(t,Qt))return t;var e=Ni.getPolygons(t);return 1===e.size()?e.get(0):t.getFactory().createMultiPolygon(_e.toPolygonArray(e))},Rr.getGeometry=function(t,e){return e>=t.size()?null:t.get(e)},Rr.union=function(t){return new Rr(t).union()},Dr.STRTREE_NODE_CAPACITY.get=function(){return 4},Object.defineProperties(Rr,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})}(v.exports)),v.exports);function I(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return E(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 E(t)})),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return w(t);default:throw new Error("unknown GeoJSON type")}}function E(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=N(t.properties),e.geometry=w(t.geometry),e}function N(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})):N(i):i})),e):e}function w(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map((function(t){return w(t)})),e):(e.coordinates=C(t.coordinates),e)}function C(t){return"object"!=typeof t[0]?t.slice():t.map((function(t){return C(t)}))}function S(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?b(t):L(t):(!0!==i&&(t=I(t)),p(t,(function(t){var n="mercator"===e?b(t):L(t);t[0]=n[0],t[1]=n[1]}))),t}function b(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 L(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 O(){return new P}function P(){this.reset()}P.prototype={constructor:P,reset:function(){this.s=this.t=0},add:function(t){M(T,t,this.t),M(this,T.s,this.s),this.s?this.t+=T.t:this.s=T.t},valueOf:function(){return this.s}};var T=new P;function M(t,e,n){var i=t.s=e+n,r=i-e;t.t=e-(i-r)+(n-r)}var R=1e-6,D=Math.PI,A=D/2,F=D/4,G=2*D,V=180/D,B=D/180,q=Math.abs,k=Math.atan,U=Math.atan2,z=Math.cos,Y=Math.exp,X=Math.log,j=Math.sin,H=Math.sqrt,W=Math.tan;function J(t){return t>1?A:t<-1?-A:Math.asin(t)}function K(){}function $(t,e){t&&et.hasOwnProperty(t.type)&&et[t.type](t,e)}var Q,Z,tt={Feature:function(t,e){$(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,r=n.length;++i<r;)$(n[i].geometry,e)}},et={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){nt(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)nt(n[i],e,0)},Polygon:function(t,e){it(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,i=-1,r=n.length;++i<r;)it(n[i],e)},GeometryCollection:function(t,e){for(var n=t.geometries,i=-1,r=n.length;++i<r;)$(n[i],e)}};function nt(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 it(t,e){var n=-1,i=t.length;for(e.polygonStart();++n<i;)nt(t[n],e,1);e.polygonEnd()}function rt(t){return[U(t[1],t[0]),J(t[2])]}function ot(t){var e=t[0],n=t[1],i=z(n);return[i*z(e),i*j(e),j(n)]}function st(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function at(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 ut(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function lt(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function ct(t){var e=H(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ht(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 pt(t,e){return[t>D?t-G:t<-D?t+G:t,e]}function ft(t,e,n){return(t%=G)?e||n?ht(dt(t),yt(e,n)):dt(t):e||n?yt(e,n):pt}function gt(t){return function(e,n){return[(e+=t)>D?e-G:e<-D?e+G:e,n]}}function dt(t){var e=gt(t);return e.invert=gt(-t),e}function yt(t,e){var n=z(t),i=j(t),r=z(e),o=j(e);function s(t,e){var s=z(e),a=z(t)*s,u=j(t)*s,l=j(e),c=l*n+a*i;return[U(u*r-c*o,a*n-l*i),J(c*r+u*o)]}return s.invert=function(t,e){var s=z(e),a=z(t)*s,u=j(t)*s,l=j(e),c=l*r-u*o;return[U(u*r+l*o,a*n+c*i),J(c*n-a*i)]},s}function _t(t,e){(e=ot(e))[0]-=t,ct(e);var n=function(t){return t>1?0:t<-1?D:Math.acos(t)}(-e[1]);return((-e[2]<0?-n:n)+G-R)%G}function mt(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:K,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function vt(t,e){return q(t[0]-e[0])<R&&q(t[1]-e[1])<R}function xt(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 It(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(vt(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 xt(i,t,null,!0)),u.push(n.o=new xt(i,null,n,!1)),a.push(n=new xt(s,t,null,!1)),u.push(n.o=new xt(s,null,n,!0))}})),a.length){for(u.sort(e),Et(a),Et(u),o=0,s=u.length;o<s;++o)u[o].e=n=!n;for(var l,c,h=a[0];;){for(var p=h,f=!0;p.v;)if((p=p.n)===h)return;l=p.z,r.lineStart();do{if(p.v=p.o.v=!0,p.e){if(f)for(o=0,s=l.length;o<s;++o)r.point((c=l[o])[0],c[1]);else i(p.x,p.n.x,1,r);p=p.n}else{if(f)for(o=(l=p.p.z).length-1;o>=0;--o)r.point((c=l[o])[0],c[1]);else i(p.x,p.p.x,-1,r);p=p.p}l=(p=p.o).z,f=!f}while(!p.v);r.lineEnd()}}}function Et(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 Nt(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function wt(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}O(),O(),O(),pt.invert=pt,1===(Q=Nt).length&&(Z=Q,Q=function(t,e){return Nt(Z(t),e)});var Ct=1e9,St=-Ct;function bt(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,h=0;if(null==r||(c=s(r,a))!==(h=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)!==h);else l.point(o[0],o[1])}function s(i,r){return q(i[0]-t)<R?r>0?0:3:q(i[0]-n)<R?r>0?2:1:q(i[1]-e)<R?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,h,p,f,g,d,y,_,m,v=s,x=mt(),I={point:E,lineStart:function(){I.point=N,l&&l.push(c=[]);_=!0,y=!1,g=d=NaN},lineEnd:function(){u&&(N(h,p),f&&y&&x.rejoin(),u.push(x.result()));I.point=E,y&&v.lineEnd()},polygonStart:function(){v=x,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,h=a[0],p=h[0],f=h[1];u<c;++u)o=p,s=f,p=(h=a[u])[0],f=h[1],s<=i?f>i&&(p-o)*(i-s)>(f-s)*(t-o)&&++e:f<=i&&(p-o)*(i-s)<(f-s)*(t-o)&&--e;return e}(),n=m&&e,r=(u=wt(u)).length;(n||r)&&(s.polygonStart(),n&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),r&&It(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]),_)h=o,p=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(St,Math.min(Ct,g)),d=Math.max(St,Math.min(Ct,d))],x=[o=Math.max(St,Math.min(Ct,o)),s=Math.max(St,Math.min(Ct,s))];!function(t,e,n,i,r,o){var s,a=t[0],u=t[1],l=0,c=1,h=e[0]-a,p=e[1]-u;if(s=n-a,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=r-a,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)}if(s=i-u,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=o-u,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)}return l>0&&(t[0]=a+l*h,t[1]=u+l*p),c<1&&(e[0]=a+c*h,e[1]=u+c*p),!0}}}}}(u,x,t,e,n,i)?a&&(v.lineStart(),v.point(o,s),m=!1):(y||(v.lineStart(),v.point(u[0],u[1])),v.point(x[0],x[1]),a||v.lineEnd(),m=!1)}g=o,d=s,y=a}return I}}var Lt=O();function Ot(t){return t}O(),O(),O();var Pt=1/0,Tt=Pt,Mt=-Pt,Rt=Mt,Dt={point:function(t,e){t<Pt&&(Pt=t);t>Mt&&(Mt=t);e<Tt&&(Tt=e);e>Rt&&(Rt=e)},lineStart:K,lineEnd:K,polygonStart:K,polygonEnd:K,result:function(){var t=[[Pt,Tt],[Mt,Rt]];return Mt=Rt=-(Tt=Pt=1/0),t}};function At(t,e,n,i){return function(r,o){var s,a,u,l=e(o),c=r.invert(i[0],i[1]),h=mt(),p=e(h),f=!1,g={point:d,lineStart:_,lineEnd:m,polygonStart:function(){g.point=v,g.lineStart=x,g.lineEnd=I,a=[],s=[]},polygonEnd:function(){g.point=d,g.lineStart=_,g.lineEnd=m,a=wt(a);var t=function(t,e){var n=e[0],i=e[1],r=[j(n),-z(n),0],o=0,s=0;Lt.reset();for(var a=0,u=t.length;a<u;++a)if(c=(l=t[a]).length)for(var l,c,h=l[c-1],p=h[0],f=h[1]/2+F,g=j(f),d=z(f),y=0;y<c;++y,p=m,g=x,d=I,h=_){var _=l[y],m=_[0],v=_[1]/2+F,x=j(v),I=z(v),E=m-p,N=E>=0?1:-1,w=N*E,C=w>D,S=g*x;if(Lt.add(U(S*N*j(w),d*I+S*z(w))),o+=C?E+N*G:E,C^p>=n^m>=n){var b=at(ot(h),ot(_));ct(b);var L=at(r,b);ct(L);var O=(C^E>=0?-1:1)*J(L[2]);(i>O||i===O&&(b[0]||b[1]))&&(s+=C^E>=0?1:-1)}}return(o<-R||o<R&&Lt<-R)^1&s}(s,c);a.length?(f||(o.polygonStart(),f=!0),It(a,Gt,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);p.point(n[0],n[1])}function x(){p.lineStart(),u=[]}function I(){v(u[0][0],u[0][1]),p.lineEnd();var t,e,n,i,r=p.clean(),l=h.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(Ft))}return g}}function Ft(t){return t.length>1}function Gt(t,e){return((t=t.x)[0]<0?t[1]-A-R:A-t[1])-((e=e.x)[0]<0?e[1]-A-R:A-e[1])}O();var Vt=At((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?D:-D,u=q(o-n);q(u-D)<R?(t.point(n,i=(i+s)/2>0?A:-A),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),t.point(o,i),e=0):r!==a&&u>=D&&(q(n-r)<R&&(n-=r*R),q(o-a)<R&&(o-=a*R),i=function(t,e,n,i){var r,o,s=j(t-n);return q(s)>R?k((j(e)*(o=z(i))*j(n)-j(i)*(r=z(e))*j(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(-D,r=n*A),i.point(0,r),i.point(D,r),i.point(D,0),i.point(D,-r),i.point(0,-r),i.point(-D,-r),i.point(-D,0),i.point(-D,r);else if(q(t[0]-e[0])>R){var o=t[0]<e[0]?D:-D;i.point(-o,r=n*o/2),i.point(0,r),i.point(o,r)}else i.point(e[0],e[1])}),[-D,-A]);function Bt(t,e){var n=z(t),i=n>0,r=q(n)>R;function o(t,e){return z(t)*z(e)>n}function s(t,e,i){var r=[1,0,0],o=at(ot(t),ot(e)),s=st(o,o),a=o[0],u=s-a*a;if(!u)return!i&&t;var l=n*s/u,c=-n*a/u,h=at(r,o),p=lt(r,l);ut(p,lt(o,c));var f=h,g=st(p,f),d=st(f,f),y=g*g-d*(st(p,p)-1);if(!(y<0)){var _=H(y),m=lt(f,(-g-_)/d);if(ut(m,p),m=rt(m),!i)return m;var v,x=t[0],I=e[0],E=t[1],N=e[1];I<x&&(v=x,x=I,I=v);var w=I-x,C=q(w-D)<R;if(!C&&N<E&&(v=E,E=N,N=v),C||w<R?C?E+N>0^m[1]<(q(m[0]-x)<R?E:N):E<=m[1]&&m[1]<=N:w>D^(x<=m[0]&&m[0]<=I)){var S=lt(f,(-g+_)/d);return ut(S,p),[m,rt(S)]}}}function a(e,n){var r=i?t:D-t,o=0;return e<-r?o|=1:e>r&&(o|=2),n<-r?o|=4:n>r&&(o|=8),o}return At(o,(function(t){var e,n,u,l,c;return{lineStart:function(){l=u=!1,c=1},point:function(h,p){var f,g=[h,p],d=o(h,p),y=i?d?0:a(h,p):d?a(h+(h<0?D:-D),p):0;if(!e&&(l=u=d)&&t.lineStart(),d!==u&&(!(f=s(e,g))||vt(e,f)||vt(g,f))&&(g[0]+=R,g[1]+=R,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&&vt(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=j(e),u=i*n;null==r?(r=e+i*G,o=e-u/2):(r=_t(s,r),o=_t(s,o),(i>0?r<o:r>o)&&(r+=i*G));for(var l,c=r;i>0?c>o:c<o;c-=u)l=rt([s,-a*z(c),-a*j(c)]),t.point(l[0],l[1])}}(o,t,e,r,n,i)}),i?[0,-t]:[-D,t-D])}function qt(t){return function(e){var n=new kt;for(var i in t)n[i]=t[i];return n.stream=e,n}}function kt(){}function Ut(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&&tt.hasOwnProperty(t.type)?tt[t.type](t,e):$(t,e)}(n,t.stream(Dt));var s=Dt.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])}kt.prototype={constructor:kt,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*B);function Yt(t,e){return+e?function(t,e){function n(i,r,o,s,a,u,l,c,h,p,f,g,d,y){var _=l-i,m=c-r,v=_*_+m*m;if(v>4*e&&d--){var x=s+p,I=a+f,E=u+g,N=H(x*x+I*I+E*E),w=J(E/=N),C=q(q(E)-1)<R||q(o-h)<R?(o+h)/2:U(I,x),S=t(C,w),b=S[0],L=S[1],O=b-i,P=L-r,T=m*O-_*P;(T*T/v>e||q((_*O+m*P)/v-.5)>.3||s*p+a*f+u*g<zt)&&(n(i,r,o,s,a,u,b,L,C,x/=N,I/=N,E,d,y),y.point(b,L),n(b,L,C,x,I,E,l,c,h,p,f,g,d,y))}}return function(e){var i,r,o,s,a,u,l,c,h,p,f,g,d={point:y,lineStart:_,lineEnd:v,polygonStart:function(){e.polygonStart(),d.lineStart=x},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=ot([i,r]),s=t(i,r);n(c,h,l,p,f,g,c=s[0],h=s[1],l=i,p=o[0],f=o[1],g=o[2],16,e),e.point(c,h)}function v(){d.point=y,e.lineEnd()}function x(){_(),d.point=I,d.lineEnd=E}function I(t,e){m(i=t,e),r=c,o=h,s=p,a=f,u=g,d.point=m}function E(){n(c,h,l,p,f,g,r,o,i,s,a,u,16,e),d.lineEnd=v,v()}return d}}(t,e):function(t){return qt({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var Xt=qt({point:function(t,e){this.stream.point(t*B,e*B)}});function jt(t){return function(t){var e,n,i,r,o,s,a,u,l,c,h=150,p=480,f=250,g=0,d=0,y=0,_=0,m=0,v=null,x=Vt,I=null,E=Ot,N=.5,w=Yt(b,N);function C(t){return[(t=o(t[0]*B,t[1]*B))[0]*h+n,i-t[1]*h]}function S(t){return(t=o.invert((t[0]-n)/h,(i-t[1])/h))&&[t[0]*V,t[1]*V]}function b(t,r){return[(t=e(t,r))[0]*h+n,i-t[1]*h]}function L(){o=ht(r=ft(y,_,m),e);var t=e(g,d);return n=p-t[0]*h,i=f+t[1]*h,O()}function O(){return l=c=null,C}return C.stream=function(t){return l&&c===t?l:l=Xt(x(r,w(E(c=t))))},C.clipAngle=function(t){return arguments.length?(x=+t?Bt(v=t*B,6*B):(v=null,Vt),O()):v*V},C.clipExtent=function(t){return arguments.length?(E=null==t?(I=s=a=u=null,Ot):bt(I=+t[0][0],s=+t[0][1],a=+t[1][0],u=+t[1][1]),O()):null==I?null:[[I,s],[a,u]]},C.scale=function(t){return arguments.length?(h=+t,L()):h},C.translate=function(t){return arguments.length?(p=+t[0],f=+t[1],L()):[p,f]},C.center=function(t){return arguments.length?(g=t[0]%360*B,d=t[1]%360*B,L()):[g*V,d*V]},C.rotate=function(t){return arguments.length?(y=t[0]%360*B,_=t[1]%360*B,m=t.length>2?t[2]%360*B:0,L()):[y*V,_*V,m*V]},C.precision=function(t){return arguments.length?(w=Yt(b,N=t*t),O()):H(N)},C.fitExtent=function(t,e){return Ut(C,t,e)},C.fitSize=function(t,e){return function(t,e,n){return Ut(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 Ht(t,e){return[t,X(W((A+e)/2))]}function Wt(t){var e,n,i,r=jt(t),o=r.center,s=r.scale,a=r.translate,u=r.clipExtent,l=null;function c(){var o=D*s(),a=r(function(t){function e(e){return(e=t(e[0]*B,e[1]*B))[0]*=V,e[1]*=V,e}return t=ft(t[0]*B,t[1]*B,t.length>2?t[2]*B:0),e.invert=function(e){return(e=t.invert(e[0]*B,e[1]*B))[0]*=V,e[1]*=V,e},e}(r.rotate()).invert([0,0]));return u(null==l?[[a[0]-o,a[1]-o],[a[0]+o,a[1]+o]]:t===Ht?[[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 Jt(t,e){return[t,e]}function Kt(t,e){return[X(W((A+e)/2)),-t]}function $t(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=Qt(t,e,i);n&&s.push(n)})),o(s);case"FeatureCollection":return f(t,(function(t){var n=Qt(t,e,i);n&&f(n,(function(t){t&&s.push(t)}))})),o(s)}return Qt(t,e,i)}function Qt(t,i,r,a){var u,l=t.properties||{},c="Feature"===t.type?t.geometry:t;if("GeometryCollection"===c.type){var h=[];return g(t,(function(t){var e=Qt(t,i,r);e&&h.push(e)})),o(h)}var p=d(t),f=p[1]>50&&p[3]>50;u=f?{type:c.type,coordinates:te(c.coordinates,ne(c))}:function(t,e){return S(t,"mercator",e)}(c);var y,_=(new x.GeoJSONReader).read(u),m=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"),v=x.BufferOp.bufferOp(_,m);if(!Zt((v=(new x.GeoJSONWriter).write(v)).coordinates))return y=f?{type:v.type,coordinates:ee(v.coordinates,ne(c))}:function(t,e){return S(t,"wgs84",e)}(v),y.geometry?y:n(y,l)}function Zt(t){return Array.isArray(t[0])?Zt(t[0]):isNaN(t[0])}function te(t,e){return"object"!=typeof t[0]?e(t):t.map((function(t){return te(t,e)}))}function ee(t,e){return"object"!=typeof t[0]?e.invert(t):t.map((function(t){return ee(t,e)}))}function ne(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=Wt(Kt),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 ie(){for(var t=new x.GeoJSONReader,e=t.read(JSON.stringify(arguments[0].geometry)),n=1;n<arguments.length;n++)e=x.UnionOp.union(e,t.read(JSON.stringify(arguments[n].geometry)));return{type:"Feature",geometry:e=(new x.GeoJSONWriter).write(e),properties:arguments[0].properties}}\n/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */Ht.invert=function(t,e){return[t,2*k(Y(e))-A]},Jt.invert=Jt,Kt.invert=function(t,e){return[-e,2*k(Y(t))-A]};const re=Symbol("Comlink.proxy"),oe=Symbol("Comlink.endpoint"),se=Symbol("Comlink.releaseProxy"),ae=Symbol("Comlink.finalizer"),ue=Symbol("Comlink.thrown"),le=t=>"object"==typeof t&&null!==t||"function"==typeof t,ce={canHandle:t=>le(t)&&t[re],serialize(t){const{port1:e,port2:n}=new MessageChannel;return pe(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)}})),me(t,n,[],e)}(t))},he=new Map([["proxy",ce],["throw",{canHandle:t=>le(t)&&ue 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 pe(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(Ne);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]]=Ne(r.data.value),l=!0;break;case"APPLY":l=n.apply(e,u);break;case"CONSTRUCT":l=function(t){return Object.assign(t,{[re]:!0})}(new n(...u));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;pe(t,n),l=Ie(e,[e])}break;case"RELEASE":l=void 0;break;default:return}}catch(t){l={value:t,[ue]:0}}Promise.resolve(l).catch((t=>({value:t,[ue]:0}))).then((n=>{const[r,a]=Ee(n);e.postMessage(Object.assign(Object.assign({},r),{id:o}),a),"RELEASE"===s&&(e.removeEventListener("message",i),fe(e),ae in t&&"function"==typeof t[ae]&&t[ae]())})).catch((t=>{const[n,i]=Ee({value:new TypeError("Unserializable return value"),[ue]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),i)}))})),e.start&&e.start()}function fe(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function ge(t){if(t)throw new Error("Proxy has been released and is not useable")}function de(t){return we(t,new Map,{type:"RELEASE"}).then((()=>{fe(t)}))}const ye=new WeakMap,_e="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(ye.get(t)||0)-1;ye.set(t,e),0===e&&de(t)}));function me(t,e,n=[],i=function(){}){let r=!1;const o=new Proxy(i,{get(i,s){if(ge(r),s===se)return()=>{!function(t){_e&&_e.unregister(t)}(o),de(t),e.clear(),r=!0};if("then"===s){if(0===n.length)return{then:()=>o};const i=we(t,e,{type:"GET",path:n.map((t=>t.toString()))}).then(Ne);return i.then.bind(i)}return me(t,e,[...n,s])},set(i,o,s){ge(r);const[a,u]=Ee(s);return we(t,e,{type:"SET",path:[...n,o].map((t=>t.toString())),value:a},u).then(Ne)},apply(i,o,s){ge(r);const a=n[n.length-1];if(a===oe)return we(t,e,{type:"ENDPOINT"}).then(Ne);if("bind"===a)return me(t,e,n.slice(0,-1));const[u,l]=ve(s);return we(t,e,{type:"APPLY",path:n.map((t=>t.toString())),argumentList:u},l).then(Ne)},construct(i,o){ge(r);const[s,a]=ve(o);return we(t,e,{type:"CONSTRUCT",path:n.map((t=>t.toString())),argumentList:s},a).then(Ne)}});return function(t,e){const n=(ye.get(e)||0)+1;ye.set(e,n),_e&&_e.register(t,e,t)}(o,t),o}function ve(t){const e=t.map(Ee);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const xe=new WeakMap;function Ie(t,e){return xe.set(t,e),t}function Ee(t){for(const[e,n]of he)if(n.canHandle(t)){const[i,r]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},r]}return[{type:"RAW",value:t},xe.get(t)||[]]}function Ne(t){switch(t.type){case"HANDLER":return he.get(t.name).deserialize(t.value);case"RAW":return t.value}}function we(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 Ce=Uint8Array,Se=Uint16Array,be=Int32Array,Le=new Ce([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]),Oe=new Ce([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]),Pe=new Ce([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Te=function(t,e){for(var n=new Se(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];var r=new be(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}},Me=Te(Le,2),Re=Me.b,De=Me.r;Re[28]=258,De[258]=28;for(var Ae=Te(Oe,0).b,Fe=new Se(32768),Ge=0;Ge<32768;++Ge){var Ve=(43690&Ge)>>1|(21845&Ge)<<1;Fe[Ge]=((65280&(Ve=(61680&(Ve=(52428&Ve)>>2|(13107&Ve)<<2))>>4|(3855&Ve)<<4))>>8|(255&Ve)<<8)>>1}var Be=function(t,e,n){for(var i=t.length,r=0,o=new Se(e);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new Se(e);for(r=1;r<e;++r)a[r]=a[r-1]+o[r-1]<<1;if(n){s=new Se(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],h=a[t[r]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)s[Fe[h]>>u]=l}else for(s=new Se(i),r=0;r<i;++r)t[r]&&(s[r]=Fe[a[t[r]-1]++]>>15-t[r]);return s},qe=new Ce(288);for(Ge=0;Ge<144;++Ge)qe[Ge]=8;for(Ge=144;Ge<256;++Ge)qe[Ge]=9;for(Ge=256;Ge<280;++Ge)qe[Ge]=7;for(Ge=280;Ge<288;++Ge)qe[Ge]=8;var ke=new Ce(32);for(Ge=0;Ge<32;++Ge)ke[Ge]=5;var Ue=Be(qe,9,1),ze=Be(ke,5,1),Ye=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},Xe=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},je=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},He=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new Ce(t.subarray(e,n))},We=["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"],Je=function(t,e,n){var i=new Error(e||We[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Je),!n)throw i;return i},Ke=new Ce(0),$e=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},Ze=function(t,e){return Qe(t,e)+4294967296*Qe(t,e+4)},tn=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 Ce(32768),this.p=new Ce(0),n&&this.o.set(n)}return t.prototype.e=function(t){if(this.ondata||Je(5),this.d&&Je(4),this.p.length){if(t.length){var e=new Ce(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 Ce(0);var o=!n,s=o||2!=e.i,a=e.i;o&&(n=new Ce(3*r));var u=function(t){var e=n.length;if(t>e){var i=new Ce(Math.max(2*e,t));i.set(n),n=i}},l=e.f||0,c=e.p||0,h=e.b||0,p=e.l,f=e.d,g=e.m,d=e.n,y=8*r;do{if(!p){l=Xe(t,c,1);var _=Xe(t,c+1,3);if(c+=3,!_){var m=t[(O=4+((c+7)/8|0))-4]|t[O-3]<<8,v=O+m;if(v>r){a&&Je(0);break}s&&u(h+m),n.set(t.subarray(O,v),h),e.b=h+=m,e.p=c=8*v,e.f=l;continue}if(1==_)p=Ue,f=ze,g=9,d=5;else if(2==_){var x=Xe(t,c,31)+257,I=Xe(t,c+10,15)+4,E=x+Xe(t,c+5,31)+1;c+=14;for(var N=new Ce(E),w=new Ce(19),C=0;C<I;++C)w[Pe[C]]=Xe(t,c+3*C,7);c+=3*I;var S=Ye(w),b=(1<<S)-1,L=Be(w,S,1);for(C=0;C<E;){var O,P=L[Xe(t,c,b)];if(c+=15&P,(O=P>>4)<16)N[C++]=O;else{var T=0,M=0;for(16==O?(M=3+Xe(t,c,3),c+=2,T=N[C-1]):17==O?(M=3+Xe(t,c,7),c+=3):18==O&&(M=11+Xe(t,c,127),c+=7);M--;)N[C++]=T}}var R=N.subarray(0,x),D=N.subarray(x);g=Ye(R),d=Ye(D),p=Be(R,g,1),f=Be(D,d,1)}else Je(1);if(c>y){a&&Je(0);break}}s&&u(h+131072);for(var A=(1<<g)-1,F=(1<<d)-1,G=c;;G=c){var V=(T=p[je(t,c)&A])>>4;if((c+=15&T)>y){a&&Je(0);break}if(T||Je(2),V<256)n[h++]=V;else{if(256==V){G=c,p=null;break}var B=V-254;V>264&&(B=Xe(t,c,(1<<(U=Le[C=V-257]))-1)+Re[C],c+=U);var q=f[je(t,c)&F],k=q>>4;if(q||Je(3),c+=15&q,D=Ae[k],k>3){var U=Oe[k];D+=je(t,c)&(1<<U)-1,c+=U}if(c>y){a&&Je(0);break}s&&u(h+131072);var z=h+B;if(h<D){var Y=0-D,X=Math.min(D,z);for(Y+h<0&&Je(3);h<X;++h)n[h]=i[Y+h]}for(;h<z;++h)n[h]=n[h-D]}}e.l=p,e.p=G,e.b=h,e.f=l,p&&(l=1,e.m=g,e.d=f,e.n=d)}while(!l);return h!=n.length&&o?He(n,0,h):n.subarray(0,h)}(this.p,this.s,this.o);this.ondata(He(n,e,this.s.b),this.d),this.o=He(n,this.s.b-32768),this.s.b=this.o.length,this.p=He(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}(),en="undefined"!=typeof TextDecoder&&new TextDecoder,nn=0;try{en.decode(Ke,{stream:!0}),nn=1}catch(t){}var rn=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:He(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)}},on=function(){function t(t){this.ondata=t,nn?this.t=new TextDecoder:this.p=Ke}return t.prototype.push=function(t,e){if(this.ondata||Je(5),e=!!e,this.t)return this.ondata(this.t.decode(t,{stream:!0}),e),void(e&&(this.t.decode().length&&Je(8),this.t=null));this.p||Je(4);var n=new Ce(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var i=rn(n),r=i.s,o=i.r;e?(o.length&&Je(8),this.p=null):this.p=o,this.ondata(r,e)},t}();var sn,an,un,ln,cn,hn=function(){function t(){}return t.prototype.push=function(t,e){this.ondata(null,t,e)},t.compression=0,t}(),pn=function(){function t(){var t=this;this.i=new tn((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}(),fn=function(){function t(t){this.onfile=t,this.k=[],this.o={0:hn},this.p=Ke}return t.prototype.push=function(t,e){var n=this;if(this.onfile||Je(5),this.p||Je(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 Ce(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,h=c&&this.d,p=function(){var t,e=Qe(u,s);if(67324752==e){o=1,a=s,f.d=null,f.c=0;var i=$e(u,s+6),r=$e(u,s+8),h=2048&i,p=8&i,g=$e(u,s+26),d=$e(u,s+28);if(l>s+30+g+d){var y=[];f.k.unshift(y),o=2;var _,m=Qe(u,s+18),v=Qe(u,s+22),x=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(en)return en.decode(t);var r=rn(t),o=r.s;return(n=r.r).length&&Je(8),o}(u.subarray(s+30,s+=30+g),!h);4294967295==m?(t=p?[-2]:function(t,e){for(;1!=$e(t,e);e+=4+$e(t,e+2));return[Ze(t,e+12),Ze(t,e+4),Ze(t,e+20)]}(u,s),m=t[0],v=t[1]):p&&(m=-1),s+=d,f.c=m;var I={name:x,compression:r,start:function(){if(I.ondata||Je(5),m){var t=n.o[r];t||I.ondata(Je(14,"unknown compression type "+r,1),null,!1),(_=m<0?new t(x):new t(x,m,v)).ondata=function(t,e,n){I.ondata(t,e,n)};for(var e=0,i=y;e<i.length;e++){_.push(i[e],!1)}n.k[0]==y&&n.c?n.d=_:_.push(Ke,!0)}else I.ondata(null,Ke,!0)},terminate:function(){_&&_.terminate&&_.terminate()}};m>=0&&(I.size=m,I.originalSize=v),f.onfile(I)}return"break"}if(c){if(134695760==e)return a=s+=12+(-2==c&&8),o=3,f.c=0,"break";if(33639248==e)return a=s-=4,o=3,f.c=0,"break"}},f=this;s<l-4;++s){if("break"===p())break}if(this.p=Ke,c<0){var g=u.subarray(0,o?a-12-(-2==c&&8)-(134695760==Qe(u,a-16)&&4):s);h?h.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&&Je(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}(),gn={};function dn(){if(an)return sn;an=1,sn=function(s,u){t={},n=[],e=0,i=0,r=1,a(s),r=Math.min(r,o);for(var l=Math.ceil(Math.log(r)/Math.LN10),c=0;c<n.length;c++)u.writeStringField(1,n[c]);2!==i&&u.writeVarintField(2,i);6!==l&&u.writeVarintField(3,l);"FeatureCollection"===s.type?u.writeMessage(4,p,s):"Feature"===s.type?u.writeMessage(5,f,s):u.writeMessage(6,g,s);return t=null,u.finish()};var t,e,n,i,r,o=1e6,s={Point:0,MultiPoint:1,LineString:2,MultiLineString:3,Polygon:4,MultiPolygon:5,GeometryCollection:6};function a(t){var e,n;if("FeatureCollection"===t.type)for(e=0;e<t.features.length;e++)a(t.features[e]);else if("Feature"===t.type)for(n in null!==t.geometry&&a(t.geometry),t.properties)h(n);else if("Point"===t.type)c(t.coordinates);else if("MultiPoint"===t.type)l(t.coordinates);else if("GeometryCollection"===t.type)for(e=0;e<t.geometries.length;e++)a(t.geometries[e]);else if("LineString"===t.type)l(t.coordinates);else if("Polygon"===t.type||"MultiLineString"===t.type)u(t.coordinates);else if("MultiPolygon"===t.type)for(e=0;e<t.coordinates.length;e++)u(t.coordinates[e]);for(n in t)x(n,t.type)||h(n)}function u(t){for(var e=0;e<t.length;e++)l(t[e])}function l(t){for(var e=0;e<t.length;e++)c(t[e])}function c(t){i=Math.max(i,t.length);for(var e=0;e<t.length;e++)for(;Math.round(t[e]*r)/r!==t[e]&&r<o;)r*=10}function h(i){void 0===t[i]&&(n.push(i),t[i]=e++)}function p(t,e){for(var n=0;n<t.features.length;n++)e.writeMessage(1,f,t.features[n]);d(t,e,!0)}function f(t,e){null!==t.geometry&&e.writeMessage(1,g,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&&d(t.properties,e),d(t,e,!0)}function g(t,e){e.writeVarintField(1,s[t.type]);var n=t.coordinates;if("Point"===t.type)!function(t,e){for(var n=[],o=0;o<i;o++)n.push(Math.round(t[o]*r));e.writePackedSVarint(3,n)}(n,e);else if("MultiPoint"===t.type)_(n,e);else if("LineString"===t.type)_(n,e);else if("MultiLineString"===t.type)m(n,e);else if("Polygon"===t.type)m(n,e,!0);else if("MultiPolygon"===t.type)!function(t,e){var n,i,r=t.length;if(1!==r||1!==t[0].length){var o=[r];for(n=0;n<r;n++)for(o.push(t[n].length),i=0;i<t[n].length;i++)o.push(t[n][i].length-1);e.writePackedVarint(2,o)}var s=[];for(n=0;n<r;n++)for(i=0;i<t[n].length;i++)v(s,t[n][i],!0);e.writePackedSVarint(3,s)}(n,e);else if("GeometryCollection"===t.type)for(var o=0;o<t.geometries.length;o++)e.writeMessage(4,g,t.geometries[o]);d(t,e,!0)}function d(e,n,i){var r=[],o=0;for(var s in e)i&&x(s,e.type)||(n.writeMessage(13,y,e[s]),r.push(t[s]),r.push(o++));n.writePackedVarint(i?15:14,r)}function y(t,e){if(null!==t){var 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 _(t,e){var n=[];v(n,t),e.writePackedSVarint(3,n)}function m(t,e,n){var i,r=t.length;if(1!==r){var o=[];for(i=0;i<r;i++)o.push(t[i].length-(n?1:0));e.writePackedVarint(2,o)}var s=[];for(i=0;i<r;i++)v(s,t[i],n);e.writePackedSVarint(3,s)}function v(t,e,n){var o,s,a=e.length-(n?1:0),u=new Array(i);for(s=0;s<i;s++)u[s]=0;for(o=0;o<a;o++)for(s=0;s<i;s++){var l=Math.round(e[o][s]*r)-u[s];t.push(l),u[s]+=l}}function x(t,e){if("type"===t)return!0;if("FeatureCollection"===e){if("features"===t)return!0}else if("Feature"===e){if("id"===t||"properties"===t||"geometry"===t)return!0}else if("GeometryCollection"===e){if("geometries"===t)return!0}else if("coordinates"===t)return!0;return!1}return sn}function yn(){if(ln)return un;var t,e,n,i,r;ln=1;var o=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon","GeometryCollection"];function s(e,n,o){1===e?t.push(o.readString()):2===e?i=o.readVarint():3===e?r=Math.pow(10,o.readVarint()):4===e?function(t,e){e.type="FeatureCollection",e.features=[],t.readMessage(l,e)}(o,n):5===e?a(o,n):6===e&&u(o,n)}function a(t,e){e.type="Feature";var n=t.readMessage(c,e);return"geometry"in n||(n.geometry=null),n}function u(t,e){return e.type="Point",t.readMessage(h,e)}function l(t,n,i){1===t?n.features.push(a(i,{})):13===t?e.push(p(i)):15===t&&f(i,n)}function c(t,n,i){1===t?n.geometry=u(i,{}):11===t?n.id=i.readString():12===t?n.id=i.readSVarint():13===t?e.push(p(i)):14===t?n.properties=f(i,{}):15===t&&f(i,n)}function h(t,i,s){1===t?i.type=o[s.readVarint()]:2===t?n=s.readPackedVarint():3===t?function(t,e,i){"Point"===i?t.coordinates=function(t){var e=t.readVarint()+t.pos,n=[];for(;t.pos<e;)n.push(t.readSVarint()/r);return n}(e):"MultiPoint"===i||"LineString"===i?t.coordinates=d(e):"MultiLineString"===i?t.coordinates=y(e):"Polygon"===i?t.coordinates=y(e,!0):"MultiPolygon"===i&&(t.coordinates=function(t){var e=t.readVarint()+t.pos;if(!n)return[[g(t,e,null,!0)]];for(var i=[],r=1,o=0;o<n[0];o++){for(var s=[],a=0;a<n[r];a++)s.push(g(t,e,n[r+1+a],!0));r+=n[r]+1,i.push(s)}return n=null,i}(e))}(i,s,i.type):4===t?(i.geometries=i.geometries||[],i.geometries.push(u(s,{}))):13===t?e.push(p(s)):15===t&&f(s,i)}function p(t){for(var e=t.readVarint()+t.pos,n=null;t.pos<e;){var i=t.readVarint()>>3;1===i?n=t.readString():2===i?n=t.readDouble():3===i?n=t.readVarint():4===i?n=-t.readVarint():5===i?n=t.readBoolean():6===i&&(n=JSON.parse(t.readString()))}return n}function f(n,i){for(var r=n.readVarint()+n.pos;n.pos<r;)i[t[n.readVarint()]]=e[n.readVarint()];return e=[],i}function g(t,e,n,o){var s,a,u=0,l=[],c=[];for(a=0;a<i;a++)c[a]=0;for(;n?u<n:t.pos<e;){for(s=[],a=0;a<i;a++)c[a]+=t.readSVarint(),s[a]=c[a]/r;l.push(s),u++}return o&&l.push(l[0]),l}function d(t){return g(t,t.readVarint()+t.pos)}function y(t,e){var i=t.readVarint()+t.pos;if(!n)return[g(t,i,null,e)];for(var r=[],o=0;o<n.length;o++)r.push(g(t,i,n[o],e));return n=null,r}return un=function(o){i=2,r=Math.pow(10,6),n=null,t=[],e=[];var a=o.readFields(s,{});return t=null,a}}var _n=y((cn||(cn=1,gn.encode=dn(),gn.decode=yn()),gn));const mn=4294967296,vn=1/mn,xn="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class In{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,n=this.length){for(;this.pos<n;){const n=this.readVarint(),i=n>>3,r=this.pos;this.type=7&n,t(i,e,this),this.pos===r&&this.skip(n)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*mn;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*mn;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let n,i;return i=e[this.pos++],n=127&i,i<128?n:(i=e[this.pos++],n|=(127&i)<<7,i<128?n:(i=e[this.pos++],n|=(127&i)<<14,i<128?n:(i=e[this.pos++],n|=(127&i)<<21,i<128?n:(i=e[this.pos],n|=(15&i)<<28,function(t,e,n){const i=n.buf;let r,o;if(o=i[n.pos++],r=(112&o)>>4,o<128)return En(t,r,e);if(o=i[n.pos++],r|=(127&o)<<3,o<128)return En(t,r,e);if(o=i[n.pos++],r|=(127&o)<<10,o<128)return En(t,r,e);if(o=i[n.pos++],r|=(127&o)<<17,o<128)return En(t,r,e);if(o=i[n.pos++],r|=(127&o)<<24,o<128)return En(t,r,e);if(o=i[n.pos++],r|=(1&o)<<31,o<128)return En(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(n,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&xn?xn.decode(this.buf.subarray(e,t)):function(t,e,n){let i="",r=e;for(;r<n;){const e=t[r];let o,s,a,u=null,l=e>239?4:e>223?3:e>191?2:1;if(r+l>n)break;1===l?e<128&&(u=e):2===l?(o=t[r+1],128==(192&o)&&(u=(31&e)<<6|63&o,u<=127&&(u=null))):3===l?(o=t[r+1],s=t[r+2],128==(192&o)&&128==(192&s)&&(u=(15&e)<<12|(63&o)<<6|63&s,(u<=2047||u>=55296&&u<=57343)&&(u=null))):4===l&&(o=t[r+1],s=t[r+2],a=t[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&e)<<18|(63&o)<<12|(63&s)<<6|63&a,(u<=65535||u>=1114112)&&(u=null))),null===u?(u=65533,l=1):u>65535&&(u-=65536,i+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),i+=String.fromCharCode(u),r+=l}return i}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(t){const e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}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*vn),!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*vn),!0),this.pos+=8}writeVarint(t){(t=+t||0)>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&&Nn(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);for(let n=0;n<e;n++)this.buf[this.pos++]=t[n]}writeRawMessage(t,e){this.pos++;const n=this.pos;t(e,this);const i=this.pos-n;i>=128&&Nn(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,wn,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,Cn,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,Ln,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,Sn,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,bn,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,On,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Pn,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,Tn,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Mn,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 En(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Nn(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);for(let e=n.pos-1;e>=t;e--)n.buf[e+i]=n.buf[e]}function wn(t,e){for(let n=0;n<t.length;n++)e.writeVarint(t[n])}function Cn(t,e){for(let n=0;n<t.length;n++)e.writeSVarint(t[n])}function Sn(t,e){for(let n=0;n<t.length;n++)e.writeFloat(t[n])}function bn(t,e){for(let n=0;n<t.length;n++)e.writeDouble(t[n])}function Ln(t,e){for(let n=0;n<t.length;n++)e.writeBoolean(t[n])}function On(t,e){for(let n=0;n<t.length;n++)e.writeFixed32(t[n])}function Pn(t,e){for(let n=0;n<t.length;n++)e.writeSFixed32(t[n])}function Tn(t,e){for(let n=0;n<t.length;n++)e.writeFixed64(t[n])}function Mn(t,e){for(let n=0;n<t.length;n++)e.writeSFixed64(t[n])}var Rn,Dn,An,Fn={exports:{}},Gn=Fn.exports;var Vn=function(){if(An)return Dn;An=1;var t,e=(Rn||(Rn=1,t=Fn,function(){var e,n,i,r,o,s,a,u,l,c,h,p,f,g,d,y,_,m,v,x,I,E,N,w,C;_=function(t,e,n,i,r,o,s,a){var u;return(u=new Date(2e3,0,1)).setTime(t.getTime()+1e3*(60*(60*(24*(null!=i?i:0)+(null!=r?r:0))+(null!=o?o:0))+(null!=s?s:0))+(null!=a?a:0)),u.setFullYear(u.getFullYear()+(null!=e?e:0)+Math.floor((u.getMonth()+(null!=n?n:0))/12)),u.setMonth(((u.getMonth()+(null!=n?n:0))%12+12)%12),u},w=function(t){return _(t,0,0,0,9)},f=function(t){return _(t,0,0,0,-9)},C=function(t,e,n){return new Date(Date.UTC(t,e,n))},g=function(t,e,n){return f(C(t,e,n))},o=function(t){return w(t).getUTCDay()},r=function(t){return w(t).getUTCDate()},l=function(t){return w(t).getUTCMonth()},s=function(t){return w(t).getUTCFullYear()},a=function(t){return w(t).getUTCHours()},u=function(t){return w(t).getUTCMinutes()},c=function(t,e){return function(n){var i;return i=g(n,t-1,1),_(i,0,0,(7-(o(i)-1))%7+7*(e-1))}},I=function(t){return new Date(31556940400*(t-1949)-6558667e5)},x=function(t){var e;return e=I(t),g(t,l(e),r(e))},v=function(t){var e;return(e={1603:23,2074:23,2355:23,2384:22}[t])?g(t,8,e):new Date(3155691e4*(t-1948)-67131691e4)},m=function(t){var e;return e=v(t),g(t,l(e),r(e))},e=[["元日",(E=function(t,e){return function(n){return g(n,t-1,e)}})(1,1),1949],["成人の日",E(1,15),1949,1999],["成人の日",c(1,2),2e3],["建国記念の日",E(2,11),1967],["天皇誕生日",E(2,23),2020],["昭和天皇の大喪の礼",E(2,24),1989,1989],["春分の日",x,1949],["皇太子明仁親王の結婚の儀",E(4,10),1959,1959],["天皇誕生日",E(4,29),1949,1988],["みどりの日",E(4,29),1989,2006],["昭和の日",E(4,29),2007],["即位の日",E(5,1),2019,2019],["憲法記念日",E(5,3),1949],["みどりの日",E(5,4),2007],["こどもの日",E(5,5),1949],["皇太子徳仁親王の結婚の儀",E(6,9),1993,1993],["海の日",E(7,20),1996,2002],["海の日",c(7,3),2003,2019],["海の日",E(7,23),2020,2020],["海の日",E(7,22),2021,2021],["海の日",c(7,3),2022],["山の日",E(8,11),2016,2019],["山の日",E(8,10),2020,2020],["山の日",E(8,8),2021,2021],["山の日",E(8,11),2022],["敬老の日",E(9,15),1966,2002],["敬老の日",c(9,3),2003],["秋分の日",m,1948],["体育の日",E(10,10),1966,1999],["体育の日",c(10,2),2e3,2019],["スポーツの日",E(7,24),2020,2020],["スポーツの日",E(7,23),2021,2021],["スポーツの日",c(10,2),2022],["即位礼正殿の儀",E(10,22),2019,2019],["文化の日",E(11,3),1948],["即位礼正殿の儀",E(11,12),1990,1990],["勤労感謝の日",E(11,23),1948],["天皇誕生日",E(12,23),1989,2018]],n=function(t){var e;if(t<g(1973,3,29)||0!==o(t))return null;if(e=_(t,0,0,1),!p(e,!1))return e;if(t<g(2007,0,1))return null;for(;;)if(e=_(e,0,0,1),!p(e,!1))return e},d=function(t){var e;return s(t)<1988?null:p(_(t,0,0,2),!1)?(e=_(t,0,0,1),p(e,!1)||0===o(e)||1===o(e)?null:e):null},h={true:{},false:{}},i=function(t,i){var o,s,a,u,c,p,f,y,_,m,v,x,I;if(null!=(o=h[i=!(null!=i&&!i)][t]))return o;for(I={},c=0,y=e.length;c<y;c++)null!=(a=e[c])[2]&&t<a[2]||null!=a[3]&&a[3]<t||null!=(u=a[1](t))&&(I[[m=l(u)+1,s=r(u)]]=a[0]);for(v in h[!1][t]=I,f=[],I)v=v.split(","),null!=(u=d(g(t,v[0]-1,v[1])))&&(m=l(u)+1,s=r(u),f.push([m,s]));for(p=0,_=f.length;p<_;p++)I[u=f[p]]="国民の休日";for(v in x={},I)x[v]=I[v],v=v.split(","),null!=(u=n(g(t,v[0]-1,v[1])))&&(x[[m=l(u)+1,s=r(u)]]="振替休日");return h[!0][t]=x,h[i][t]},(N=null!=(y=null!==t?t.exports:void 0)?y:this.JapaneseHolidays={}).getHolidaysOf=function(t,e){var n,r,o,s;for(n in s=[],o=i(t,e))r=o[n],s.push({month:parseInt(n.split(",")[0]),date:parseInt(n.split(",")[1]),name:r});return s.sort((function(t,e){return t.month-e.month||t.date-e.date})),s},p=function(t,e){return i(s(t),e)[[l(t)+1,r(t)]]},N.isHoliday=function(t,e){return i(t.getFullYear(),e)[[t.getMonth()+1,t.getDate()]]},N.isHolidayAt=p,N.shiftDate=_,N.u2j=w,N.j2u=f,N.jDate=g,N.uDate=C,N.getJDay=o,N.getJDate=r,N.getJMonth=l,N.getJFullYear=s,N.getJHours=a,N.getJMinutes=u,N.__forTest={shunbunWithTime:I,shubunWithTime:v}}.call(Gn)),Fn.exports);return Dn=e}(),Bn=y(Vn);const qn={standingDuration:6e4,minStandingDuration:3e4,trainRefreshInterval:6e4,refreshTimeout:1e4,realtimeCheckInterval:15e3,maxSpeedKMPH:80,accelerationKMPHPS:3,get maxSpeed(){return qn.maxSpeedKMPH/36e5},get acceleration(){return qn.accelerationKMPHPS/36e8},get maxAccelerationTime(){return qn.maxSpeed/qn.acceleration},get maxAccDistance(){return qn.maxAccelerationTime*qn.maxSpeed/2},maxFlightSpeedKMPH:500,flightAccelerationKMPHPS:12,get maxFlightSpeed(){return qn.maxFlightSpeedKMPH/36e5},get flightAcceleration(){return qn.flightAccelerationKMPHPS/36e8},maxBusSpeedKMPH:30,busAccelerationKMPHPS:3,get maxBusSpeed(){return qn.maxBusSpeedKMPH/36e5},get busAcceleration(){return qn.busAccelerationKMPHPS/36e8},get maxBusAccelerationTime(){return qn.maxBusSpeed/qn.busAcceleration},get maxBusAccDistance(){return qn.maxBusAccelerationTime*qn.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",defaultEcoMode:"normal",apiUrl:{odpt:"https://api.odpt.org/api/v4/",challenge2024:"https://api-challenge2024.odpt.org/api/v4/"},tidUrl:"https://mini-tokyo.appspot.com/tid",trainInfoUrl:"https://mini-tokyo.appspot.com/traininfo",atisUrl:"https://mini-tokyo.appspot.com/atisinfo",flightUrl:"https://mini-tokyo.appspot.com/flight",dataUrl:"https://minitokyo3d.com/data",dataSources:[],searchUrl:"https://search.minitokyo3d.com/api/v1/routes",lastStaticUpdate:"2024-11-25 15:00:00",customAttribution:\'<a href="https://github.com/nagix/mini-tokyo-3d">© Akihiko Kusanagi</a>\',copyright:"© 2019-2025 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"]};function kn(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 Un(...t){const e=new Map;for(const n of t)for(const[t,i]of n)e.set(t,i);return e}function zn(t){return kn(qn.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}"undefined"!=typeof window&&window.addEventListener("touchstart",(()=>{}),{once:!0});class Yn{constructor(t,e){const n=this;n.reset(),n.setDate(t),n.setSpeed(e)}reset(){const t=this;t.baseTime=0,t.baseHighResTime=0,t.speed=1}setSpeed(t){if(isNaN(t))return;const e=this;e.baseTime=e.getTime()-Date.now()*t,e.baseHighResTime=e.getHighResTime()-performance.now()*t,e.speed=t}setDate(t){if(!(t instanceof Date))return;const e=this,n=e.baseTime,i=-e.getTimezoneOffset(),r=e.baseTime=t.getTime()+i-Date.now()*e.speed;e.baseHighResTime+=r-n}getJSTDate(t){const e=this.getTimezoneOffset();return new Date((n=t,i=this.getTime(),(void 0===n?i:n)+e));var n,i}getTime(t){const e=this;if(!t)return e.baseTime+Date.now()*e.speed;const n=e.getJSTDate(),i=t.split(":"),r=+i[0],o=+i[1],s=-e.getTimezoneOffset()+864e5*((n.getHours()<3?-1:0)+(r<3?1:0));return n.setHours(r,o,0,0)+s+qn.minDelay}getString(t){const e=this.getJSTDate(t);return`${e.getFullYear()}-${`0${e.getMonth()+1}`.slice(-2)}-${`0${e.getDate()}`.slice(-2)} ${`0${e.getHours()}`.slice(-2)}:${`0${e.getMinutes()}`.slice(-2)}:${`0${e.getSeconds()}`.slice(-2)}`}getTimeString(t){const e=this.getJSTDate(t);return`${`0${e.getHours()}`.slice(-2)}:${`0${e.getMinutes()}`.slice(-2)}`}getTimeOffset(){return this.getTime()-this.getTime("03:00")}getHighResTime(){return this.baseHighResTime+performance.now()*this.speed}getTimezoneOffset(){return 6e4*((new Date).getTimezoneOffset()+540)}getCalendar(){const t=this.getJSTDate(),e=t.getHours();e<3&&t.setHours(e-24);const n=t.getDay(),i=t.getFullYear(),r=t.getMonth(),o=t.getDate();return 0===n||Bn.isHoliday(t)||2022===i&&11===r&&o>=30||2023===i&&0===r&&o<=3?"Holiday":6===n?"Saturday":"Weekday"}}function Xn(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=Xn(t),r=Xn(e),o=a(i[0]),s=a(r[0]),u=a(i[1]),c=a(r[1]),h=Math.sin(s-o)*Math.cos(c),p=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(h,p))}var Hn,Wn={exports:{}},Jn={exports:{}};function Kn(){return Hn||(Hn=1,Jn.exports=function(){function t(t,i,r,o,s){!function t(n,i,r,o,s){for(;o>r;){if(o-r>600){var a=o-r+1,u=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(a-c)/a)*(u-a/2<0?-1:1);t(n,i,Math.max(r,Math.floor(i-u*c/a+h)),Math.min(o,Math.floor(i+(a-u)*c/a+h)),s)}var p=n[i],f=r,g=o;for(e(n,r,i),s(n[o],p)>0&&e(n,r,o);f<g;){for(e(n,f,g),f++,g--;s(n[f],p)<0;)f++;for(;s(n[g],p)>0;)g--}0===s(n[r],p)?e(n,r,g):e(n,++g,o),g<=i&&(r=g+1),i<=g&&(o=g-1)}}(t,i,r||0,o||t.length-1,s||n)}function e(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function n(t,e){return t<e?-1:t>e?1:0}var i=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(t,e,n){if(!n)return e.indexOf(t);for(var i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function o(t,e){s(t,0,t.children.length,e,t)}function s(t,e,n,i,r){r||(r=g(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var o=e;o<n;o++){var s=t.children[o];a(r,t.leaf?i(s):s)}return r}function a(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function u(t,e){return t.minX-e.minX}function l(t,e){return t.minY-e.minY}function c(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function h(t){return t.maxX-t.minX+(t.maxY-t.minY)}function p(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function f(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function d(e,n,i,r,o){for(var s=[n,i];s.length;)if(!((i=s.pop())-(n=s.pop())<=r)){var a=n+Math.ceil((i-n)/r/2)*r;t(e,a,n,i,o),s.push(n,a,a,i)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(t){var e=this.data,n=[];if(!f(t,e))return n;for(var i=this.toBBox,r=[];e;){for(var o=0;o<e.children.length;o++){var s=e.children[o],a=e.leaf?i(s):s;f(t,a)&&(e.leaf?n.push(s):p(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n},i.prototype.collides=function(t){var e=this.data;if(!f(t,e))return!1;for(var n=[];e;){for(var i=0;i<e.children.length;i++){var r=e.children[i],o=e.leaf?this.toBBox(r):r;if(f(t,o)){if(e.leaf||p(t,o))return!0;n.push(r)}}e=n.pop()}return!1},i.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.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 i=this.data;this.data=n,n=i}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},i.prototype.clear=function(){return this.data=g([]),this},i.prototype.remove=function(t,e){if(!t)return this;for(var n,i,o,s=this.data,a=this.toBBox(t),u=[],l=[];s||u.length;){if(s||(s=u.pop(),i=u[u.length-1],n=l.pop(),o=!0),s.leaf){var c=r(t,s.children,e);if(-1!==c)return s.children.splice(c,1),u.push(s),this._condense(u),this}o||s.leaf||!p(s,a)?i?(n++,s=i.children[n],o=!1):s=null:(u.push(s),l.push(n),n=0,i=s,s=s.children[0])}return this},i.prototype.toBBox=function(t){return t},i.prototype.compareMinX=function(t,e){return t.minX-e.minX},i.prototype.compareMinY=function(t,e){return t.minY-e.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(t){return this.data=t,this},i.prototype._all=function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},i.prototype._build=function(t,e,n,i){var r,s=n-e+1,a=this._maxEntries;if(s<=a)return o(r=g(t.slice(e,n+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(s)/Math.log(a)),a=Math.ceil(s/Math.pow(a,i-1))),(r=g([])).leaf=!1,r.height=i;var u=Math.ceil(s/a),l=u*Math.ceil(Math.sqrt(a));d(t,e,n,l,this.compareMinX);for(var c=e;c<=n;c+=l){var h=Math.min(c+l-1,n);d(t,c,h,u,this.compareMinY);for(var p=c;p<=h;p+=u){var f=Math.min(p+u-1,h);r.children.push(this._build(t,p,f,i-1))}}return o(r,this.toBBox),r},i.prototype._chooseSubtree=function(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){for(var r=1/0,o=1/0,s=void 0,a=0;a<e.children.length;a++){var u=e.children[a],l=c(u),h=(p=t,f=u,(Math.max(f.maxX,p.maxX)-Math.min(f.minX,p.minX))*(Math.max(f.maxY,p.maxY)-Math.min(f.minY,p.minY))-l);h<o?(o=h,r=l<r?l:r,s=u):h===o&&l<r&&(r=l,s=u)}e=s||e.children[0]}var p,f;return e},i.prototype._insert=function(t,e,n){var i=n?t:this.toBBox(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),a(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)},i.prototype._split=function(t,e){var n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var s=this._chooseSplitIndex(n,r,i),a=g(n.children.splice(s,n.children.length-s));a.height=n.height,a.leaf=n.leaf,o(n,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)},i.prototype._splitRoot=function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(t,e,n){for(var i,r,o,a,u,l,h,p=1/0,f=1/0,g=e;g<=n-e;g++){var d=s(t,0,g,this.toBBox),y=s(t,g,n,this.toBBox),_=(r=d,o=y,a=void 0,u=void 0,l=void 0,h=void 0,a=Math.max(r.minX,o.minX),u=Math.max(r.minY,o.minY),l=Math.min(r.maxX,o.maxX),h=Math.min(r.maxY,o.maxY),Math.max(0,l-a)*Math.max(0,h-u)),m=c(d)+c(y);_<p?(p=_,i=g,f=m<f?m:f):_===p&&m<f&&(f=m,i=g)}return i||n-e},i.prototype._chooseSplitAxis=function(t,e,n){var i=t.leaf?this.compareMinX:u,r=t.leaf?this.compareMinY:l;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)},i.prototype._allDistMargin=function(t,e,n,i){t.children.sort(i);for(var r=this.toBBox,o=s(t,0,e,r),u=s(t,n-e,n,r),l=h(o)+h(u),c=e;c<n-e;c++){var p=t.children[c];a(o,t.leaf?r(p):p),l+=h(o)}for(var f=n-e-1;f>=e;f--){var g=t.children[f];a(u,t.leaf?r(g):g),l+=h(u)}return l},i.prototype._adjustParentBBoxes=function(t,e,n){for(var i=n;i>=0;i--)a(e[i],t)},i.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():o(t[e],this.toBBox)},i}()),Jn.exports}function $n(t,e){return t<e?-1:t>e?1:0}var Qn,Zn,ti,ei,ni,ii=Object.freeze({__proto__:null,default:class{constructor(t=[],e=$n){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(n(i,o)>=0)break;e[t]=o,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1),o=e[i];const s=i+1;if(s<this.length&&n(e[s],o)<0&&(i=s,o=e[s]),n(o,r)>=0)break;e[t]=o,t=i}e[t]=r}}}),ri=_(ii),oi={exports:{}};function si(){if(ni)return oi.exports;ni=1;var t=(Zn||(Zn=1,Qn=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],h=e[n+2*u+1],p=e[n+2*l+1];h>o!=p>o&&r<(e[n+2*l+0]-c)*(o-h)/(p-h)+c&&(s=!s)}return s}),Qn),e=(ei||(ei=1,ti=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],h=e[u+n][1],p=e[l+n][1];h>o!=p>o&&r<(e[l+n][0]-c)*(o-h)/(p-h)+c&&(s=!s)}return s}),ti);return oi.exports=function(n,i,r,o){return i.length>0&&Array.isArray(i[0])?e(n,i,r,o):t(n,i,r,o)},oi.exports.nested=e,oi.exports.flat=t,oi.exports}var ai,ui,li={exports:{}};function ci(){return ai||(ai=1,function(t){const e=134217729,n=33306690738754706e-32;function i(t,e,n,i,r){let o,s,a,u,l=e[0],c=i[0],h=0,p=0;c>l==c>-l?(o=l,l=e[++h]):(o=c,c=i[++p]);let f=0;if(h<t&&p<n)for(c>l==c>-l?(a=o-((s=l+o)-l),l=e[++h]):(a=o-((s=c+o)-c),c=i[++p]),o=s,0!==a&&(r[f++]=a);h<t&&p<n;)c>l==c>-l?(a=o-((s=o+l)-(u=s-o))+(l-u),l=e[++h]):(a=o-((s=o+c)-(u=s-o))+(c-u),c=i[++p]),o=s,0!==a&&(r[f++]=a);for(;h<t;)a=o-((s=o+l)-(u=s-o))+(l-u),l=e[++h],o=s,0!==a&&(r[f++]=a);for(;p<n;)a=o-((s=o+c)-(u=s-o))+(c-u),c=i[++p],o=s,0!==a&&(r[f++]=a);return 0===o&&0!==f||(r[f++]=o),f}function r(t){return new Float64Array(t)}const o=33306690738754716e-32,s=22204460492503146e-32,a=11093356479670487e-47,u=r(4),l=r(8),c=r(12),h=r(16),p=r(4);t.orient2d=function(t,r,f,g,d,y){const _=(r-y)*(f-d),m=(t-d)*(g-y),v=_-m;if(0===_||0===m||_>0!=m>0)return v;const x=Math.abs(_+m);return Math.abs(v)>=o*x?v:-function(t,r,o,f,g,d,y){let _,m,v,x,I,E,N,w,C,S,b,L,O,P,T,M,R,D;const A=t-g,F=o-g,G=r-d,V=f-d;I=(T=(w=A-(N=(E=e*A)-(E-A)))*(S=V-(C=(E=e*V)-(E-V)))-((P=A*V)-N*C-w*C-N*S))-(b=T-(R=(w=G-(N=(E=e*G)-(E-G)))*(S=F-(C=(E=e*F)-(E-F)))-((M=G*F)-N*C-w*C-N*S))),u[0]=T-(b+I)+(I-R),I=(O=P-((L=P+b)-(I=L-P))+(b-I))-(b=O-M),u[1]=O-(b+I)+(I-M),I=(D=L+b)-L,u[2]=L-(D-I)+(b-I),u[3]=D;let B=function(t,e){let n=e[0];for(let i=1;i<t;i++)n+=e[i];return n}(4,u),q=s*y;if(B>=q||-B>=q)return B;if(_=t-(A+(I=t-A))+(I-g),v=o-(F+(I=o-F))+(I-g),m=r-(G+(I=r-G))+(I-d),x=f-(V+(I=f-V))+(I-d),0===_&&0===m&&0===v&&0===x)return B;if(q=a*y+n*Math.abs(B),(B+=A*x+V*_-(G*v+F*m))>=q||-B>=q)return B;I=(T=(w=_-(N=(E=e*_)-(E-_)))*(S=V-(C=(E=e*V)-(E-V)))-((P=_*V)-N*C-w*C-N*S))-(b=T-(R=(w=m-(N=(E=e*m)-(E-m)))*(S=F-(C=(E=e*F)-(E-F)))-((M=m*F)-N*C-w*C-N*S))),p[0]=T-(b+I)+(I-R),I=(O=P-((L=P+b)-(I=L-P))+(b-I))-(b=O-M),p[1]=O-(b+I)+(I-M),I=(D=L+b)-L,p[2]=L-(D-I)+(b-I),p[3]=D;const k=i(4,u,4,p,l);I=(T=(w=A-(N=(E=e*A)-(E-A)))*(S=x-(C=(E=e*x)-(E-x)))-((P=A*x)-N*C-w*C-N*S))-(b=T-(R=(w=G-(N=(E=e*G)-(E-G)))*(S=v-(C=(E=e*v)-(E-v)))-((M=G*v)-N*C-w*C-N*S))),p[0]=T-(b+I)+(I-R),I=(O=P-((L=P+b)-(I=L-P))+(b-I))-(b=O-M),p[1]=O-(b+I)+(I-M),I=(D=L+b)-L,p[2]=L-(D-I)+(b-I),p[3]=D;const U=i(k,l,4,p,c);I=(T=(w=_-(N=(E=e*_)-(E-_)))*(S=x-(C=(E=e*x)-(E-x)))-((P=_*x)-N*C-w*C-N*S))-(b=T-(R=(w=m-(N=(E=e*m)-(E-m)))*(S=v-(C=(E=e*v)-(E-v)))-((M=m*v)-N*C-w*C-N*S))),p[0]=T-(b+I)+(I-R),I=(O=P-((L=P+b)-(I=L-P))+(b-I))-(b=O-M),p[1]=O-(b+I)+(I-M),I=(D=L+b)-L,p[2]=L-(D-I)+(b-I),p[3]=D;const z=i(U,c,4,p,h);return h[z-1]}(t,r,f,g,d,y,x)},t.orient2dfast=function(t,e,n,i,r,o){return(e-o)*(n-r)-(t-r)*(i-o)},Object.defineProperty(t,"__esModule",{value:!0})}(li.exports)),li.exports}function hi(t,e,n){if(!l(n=n||{}))throw new Error("options is invalid");var i=n.units,r=Xn(t),o=Xn(e),u=a(o[1]-r[1]),c=a(o[0]-r[0]),h=a(r[1]),p=a(o[1]),f=Math.pow(Math.sin(u/2),2)+Math.pow(Math.sin(c/2),2)*Math.cos(h)*Math.cos(p);return s(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),i)}function pi(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=hi(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 fi(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.trips)e.writeMessage(3,((t,e)=>{e.writeStringField(1,t.id),e.writeStringField(2,t.shortName),e.writeStringField(3,t.color),e.writeStringField(4,t.textColor),e.writeStringField(5,t.shape);for(const n of t.stops)e.writeStringField(6,n);e.writePackedVarint(7,t.stopSequences);for(const n of t.headsigns)e.writeStringField(8,n)}),n);return e.writeStringField(4,t.version),e.finish()}!function(){if(ui)return Wn.exports;ui=1;var t=Kn(),e=ri,n=si(),i=ci().orient2d;function r(e,i,r){i=Math.max(0,void 0===i?2:i),r=r||0;var s=function(t){for(var e=t[0],i=t[0],r=t[0],o=t[0],s=0;s<t.length;s++){var a=t[s];a[0]<e[0]&&(e=a),a[0]>r[0]&&(r=a),a[1]<i[1]&&(i=a),a[1]>o[1]&&(o=a)}var u=[e,i,r,o],l=u.slice();for(s=0;s<t.length;s++)n(t[s],u)||l.push(t[s]);return function(t){t.sort(y);for(var e=[],n=0;n<t.length;n++){for(;e.length>=2&&c(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var i=[],r=t.length-1;r>=0;r--){for(;i.length>=2&&c(i[i.length-2],i[i.length-1],t[r])<=0;)i.pop();i.push(t[r])}return i.pop(),e.pop(),e.concat(i)}(l)}(e),a=new t(16);a.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},a.compareMinX=function(t,e){return t[0]-e[0]},a.compareMinY=function(t,e){return t[1]-e[1]},a.load(e);for(var u,l=[],g=0;g<s.length;g++){var d=s[g];a.remove(d),u=p(d,u),l.push(u)}var _=new t(16);for(g=0;g<l.length;g++)_.insert(h(l[g]));for(var m=i*i,v=r*r;l.length;){var x=l.shift(),I=x.p,E=x.next.p,N=f(I,E);if(!(N<v)){var w=N/m;(d=o(a,x.prev.p,I,E,x.next.next.p,w,_))&&Math.min(f(d,I),f(d,E))<=w&&(l.push(x),l.push(p(d,x)),a.remove(d),_.remove(x),_.insert(h(x)),_.insert(h(x.next)))}}x=u;var C=[];do{C.push(x.p),x=x.next}while(x!==u);return C.push(x.p),C}function o(t,n,i,r,o,u,c){for(var h=new e([],s),p=t.data;p;){for(var f=0;f<p.children.length;f++){var d=p.children[f],y=p.leaf?g(d,i,r):a(i,r,d);y>u||h.push({node:d,dist:y})}for(;h.length&&!h.peek().node.children;){var _=h.pop(),m=_.node,v=g(m,n,i),x=g(m,r,o);if(_.dist<v&&_.dist<x&&l(i,m,c)&&l(r,m,c))return m}(p=h.pop())&&(p=p.node)}return null}function s(t,e){return t.dist-e.dist}function a(t,e,n){if(u(t,n)||u(e,n))return 0;var i=d(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;var r=d(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;var o=d(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===o)return 0;var s=d(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===s?0:Math.min(i,r,o,s)}function u(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function l(t,e,n){for(var i,r,o,s,a=Math.min(t[0],e[0]),u=Math.min(t[1],e[1]),l=Math.max(t[0],e[0]),h=Math.max(t[1],e[1]),p=n.search({minX:a,minY:u,maxX:l,maxY:h}),f=0;f<p.length;f++)if(r=p[f].next.p,o=t,(i=p[f].p)!==(s=e)&&r!==o&&c(i,r,o)>0!=c(i,r,s)>0&&c(o,s,i)>0!=c(o,s,r)>0)return!1;return!0}function c(t,e,n){return i(t[0],t[1],e[0],e[1],n[0],n[1])}function h(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function p(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function f(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function g(t,e,n){var i=e[0],r=e[1],o=n[0]-i,s=n[1]-r;if(0!==o||0!==s){var a=((t[0]-i)*o+(t[1]-r)*s)/(o*o+s*s);a>1?(i=n[0],r=n[1]):a>0&&(i+=o*a,r+=s*a)}return(o=t[0]-i)*o+(s=t[1]-r)*s}function d(t,e,n,i,r,o,s,a){var u,l,c,h,p=n-t,f=i-e,g=s-r,d=a-o,y=t-r,_=e-o,m=p*p+f*f,v=p*g+f*d,x=g*g+d*d,I=p*y+f*_,E=g*y+d*_,N=m*x-v*v,w=N,C=N;0===N?(l=0,w=1,h=E,C=x):(h=m*E-v*I,(l=v*E-x*I)<0?(l=0,h=E,C=x):l>w&&(l=w,h=E+v,C=x)),h<0?(h=0,-I<0?l=0:-I>m?l=w:(l=-I,w=m)):h>C&&(h=C,-I+v<0?l=0:-I+v>m?l=w:(l=-I+v,w=m));var S=(1-(c=0===h?0:h/C))*r+c*s-((1-(u=0===l?0:l/w))*t+u*n),b=(1-c)*o+c*a-((1-u)*e+u*i);return S*S+b*b}function y(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}e.default&&(e=e.default),Wn.exports=r,Wn.exports.default=r}();const gi={agency:class{read(t){const e=this,n=t.split(",");void 0===e.agencyNameIndex?e.agencyNameIndex=n.indexOf("agency_name"):e.agencyName=n[e.agencyNameIndex]}get result(){return this.agencyName}},calendar:class{constructor(){const t=this,e=(new Yn).getJSTDate(),n=e.getHours();n<3&&e.setHours(n-24);const i=e.getDay(),r=e.getFullYear(),o=`0${e.getMonth()+1}`.slice(-2),s=`0${e.getDate()}`.slice(-2);t.dayOfWeek=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"][i],t.date=`${r}${o}${s}`,t.services=new Set}read(t){const e=this,n=t.split(",");void 0===e.serviceIdIndex?(e.serviceIdIndex=n.indexOf("service_id"),e.dayIndex=n.indexOf(e.dayOfWeek),e.startDateIndex=n.indexOf("start_date"),e.endDateIndex=n.indexOf("end_date")):e.date>=n[e.startDateIndex]&&e.date<=n[e.endDateIndex]&&"1"===n[e.dayIndex]&&e.services.add(n[e.serviceIdIndex])}get result(){return this.services}},calendar_dates:class{constructor(){const t=this,e=(new Yn).getJSTDate(),n=e.getHours();n<3&&e.setHours(n-24);const i=e.getFullYear(),r=`0${e.getMonth()+1}`.slice(-2),o=`0${e.getDate()}`.slice(-2);t.date=`${i}${r}${o}`,t.additions=new Set,t.deletions=new Set}read(t){const e=this,n=t.split(",");if(void 0===e.serviceIdIndex)e.serviceIdIndex=n.indexOf("service_id"),e.dateIndex=n.indexOf("date"),e.exceptionTypeIndex=n.indexOf("exception_type");else{const t=n[e.serviceIdIndex];e.date===n[e.dateIndex]&&("1"===n[e.exceptionTypeIndex]?e.additions.add(t):e.deletions.add(t))}}get result(){return[this.additions,this.deletions]}},feed_info:class{constructor({lang:t}){this.lang=t}read(t){const e=this,n=t.split(",");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:zn(t.feedLang)!==t.lang,version:t.feedVersion}}},routes:class{constructor(){this.lookup=new Map}read(t){const e=this,n=t.split(",");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")):e.lookup.set(n[e.routeIdIndex],{shortName:n[e.routeShortNameIndex]||n[e.routeLongNameIndex],color:`#${n[e.routeColorIndex]}`,textColor:`#${n[e.routeTextColorIndex]}`})}get result(){return this.lookup}},shapes:class{constructor({color:t}){this.color=t,this.features=[]}read(t){const e=this,n=t.split(",");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");else{const t=n[e.shapeIdIndex];let i=e.coords;if(e.id!==t){if(i){const t=r(i,{id:e.id,type:0,color:e.color,width:2});pi(t),e.features.push(t)}e.id=t,i=e.coords=[]}i.push([+n[e.shapePtLonIdIndex],+n[e.shapePtLatIdIndex]])}}get result(){return this.features}},stops:class{constructor(){this.array=[]}read(t){const e=this,n=t.split(",");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=t.split(","),i=e.lookup;if(void 0===e.tripIdIndex)e.tripIdIndex=n.indexOf("trip_id"),e.stopIdIndex=n.indexOf("stop_id"),e.stopSequenceIndex=n.indexOf("stop_sequence"),e.stopHeadsignIndex=n.indexOf("stop_headsign");else{const t=n[e.tripIdIndex];let r,o,s;i.has(t)?({stops:r,stopSequences:o,stopHeadsigns:s}=i.get(t)):(r=[],o=[],s=[],i.set(t,{stops:r,stopSequences:o,stopHeadsigns:s})),r.push(n[e.stopIdIndex]),o.push(+n[e.stopSequenceIndex]),s.push(n[e.stopHeadsignIndex])}}get result(){return this.lookup}},translations:class{constructor({lang:t}){this.lang=t,this.lookup=new Map}read(t){const e=this,n=t.split(",");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 i;e.lookup.has(t)?i=e.lookup.get(t):(i=new Map,e.lookup.set(t,i)),i.set(`${n[e.tableNameIndex]}.${n[e.fieldNameIndex]}.${n[e.recordIdIndex]||n[e.fieldValueIndex]}`,n[e.translationIndex])}}get result(){const t=this,e=t.lookup.get("en")||new Map;if("en"===t.lang)return e;if(t.lookup.has(t.lang))return Un(e,t.lookup.get(t.lang));for(const[n,i]of t.lookup){const r=zn(n);if(r===t.lang||"zh-Hans"===r&&"zh-Hant"===t.lang)return Un(e,i)}return e}},trips:class{constructor(){this.array=[]}read(t){const e=this,n=t.split(",");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}}},di=Object.keys(gi);function yi(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=ie(...n.map((t=>$t(i(t),e/4))));o.properties={type:1,outlineColor:"#000000",width:2,color:"#FFFFFF",zoom:t},r.push(o)}}return o(r)}function _i(t,e,n,i,r,o){const s=e.union(n[0]).difference(n[1]),a=[];for(const{id:e,service:n,route:u,shape:l,headsign:c}of t)if(s.has(n)){const{shortName:t,color:n,textColor:s}=i.get(u),{stops:h,stopSequences:p,stopHeadsigns:f}=r.get(e),g=new Set(f).size>1,d=[];if(c&&!g)d.push(o&&(o.get(`trips.trip_headsign.${e}`)||o.get(`trips.trip_headsign.${c}`))||c);else for(const t of g?f:[f[0]])d.push(o&&o.get(`stop_times.stop_headsign.${t}`)||t);a.push({id:e,shortName:o&&(o.get(`routes.route_short_name.${u}`)||o.get(`routes.route_short_name.${t}`)||o.get(`routes.route_long_name.${u}`)||o.get(`routes.route_long_name.${t}`))||t,color:n,textColor:s,shape:l,stops:h,stopSequences:p,headsigns:d})}return a}function mi(t,e){return new Promise(((n,i)=>fetch(t.gtfsUrl).then((r=>{const o={},s=r.body.getReader(),a=new fn((r=>{const s=r.name.split(".")[0];if(kn(di,s)){let a="";const u=new gi[s]({lang:e,color:t.color}),l=new on((async(t,e)=>{const i=t.split(/\\r?\\n/);u.read(a+i[0]);for(let t=1;t<i.length-1;t++)u.read(i[t]);if(a=i[i.length-1],e&&(a&&u.read(a),o[s]=u.result,Object.keys(o).length===di.length)){const t=yi(o.shapes,o.stops,o.feed_info.needTranslation&&o.translations),e={agency:o.agency,version:o.feed_info.version,stops:(r=o.stops,l=o.feed_info.needTranslation&&o.translations,r.map((({id:t,name:e,coord:n})=>({id:t,name:l&&(l.get(`stops.stop_name.${t}`)||l.get(`stops.stop_name.${e}`))||e,coord:n})))),trips:_i(o.trips,o.calendar,o.calendar_dates,o.routes,o.stop_times,o.feed_info.needTranslation&&o.translations)};n([_n.encode(t,new In),fi(e,new In)])}var r,l}));r.ondata=(t,e,n)=>{if(t)i(t);else try{l.push(e,n)}catch(t){i(t)}},r.start()}}));return a.register(pn),s.read().then((function t({done:e,value:n}){e?a.push(new Uint8Array(0),!0):(a.push(n),s.read().then(t))}))}))))}pe({load:(t,e,n)=>Promise.all(t.map((t=>mi(t,e)))).then((t=>n(Ie(t,[].concat(...t.map((t=>t.map((({buffer:t})=>t)))))))))})}));\n'],{type:"text/javascript"})),i=new Worker(n),r=wrap(i);return new Promise((n=>r.load(t,e,proxy((e=>{const o=e.map(((e,n)=>({featureCollection:geobuf.decode(new Pbf(e[0])),...decode(new Pbf(e[1])),vehiclePositionUrl:t[n].vehiclePositionUrl,color:t[n].color})));r[releaseProxy](),i.terminate(),n(o)})))))}function loadDynamicBusData(t){return Promise.all(t.map((t=>fetch(t.vehiclePositionUrl).then((t=>t.arrayBuffer())).then((e=>({gtfs:t,vehiclePosition:GtfsRealtimeBindings.transit_realtime.FeedMessage.decode(new Uint8Array(e))}))))))}function updateOdptUrl(t,e){return t.startsWith("https://api.odpt.org/")&&!t.match(/acl:consumerKey/)?`${t}${t.match(/\?/)?"&":"?"}acl:consumerKey=${e.odpt}`:t.startsWith("https://api-challenge2024.odpt.org/")&&!t.match(/acl:consumerKey/)?`${t}${t.match(/\?/)?"&":"?"}acl:consumerKey=${e.challenge2024}`:t}const isWindows=includes(navigator.userAgent,"Windows");class Panel{constructor(t){this._options=Object.assign({modal:!1},t)}setTitle(t){const e=this,n=e._container;return e._title=t,n&&(n.querySelector("#panel-title").innerHTML=t),e}setHTML(t){const e=this,n=e._container;return e._html=t,n&&(n.querySelector("#panel-content").innerHTML=t),e}setButtons(t){const e=this,n=e._container;if(e._buttons=t,n){const e=n.querySelector("#panel-button-group"),i=e.children;for(let t=i.length-1;t>0;t--)e.removeChild(i[t]);for(const n of t||[])e.appendChild(n)}return e}addTo(t){const e=this,n=e._options;if(e._map=t,n.modal){(e._background=createElement$1("div",{className:"modal-panel-background closed"},t.container)).addEventListener("click",(()=>{e.remove()}))}const i=e._container=createElement$1("div",{className:`panel closed ${n.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="${n.modal?"close-button":"slide-button"}"></div>`,"</div>","</div>",`<div id="panel-body"${isWindows?' class="windows"':""}>`,'<div id="panel-content"></div>',"</div>"].join("")},t.container);return e._title&&e.setTitle(e._title),e._html&&e.setHTML(e._html),e._buttons&&e.setButtons(e._buttons),n.modal?i.querySelector("#panel-button").addEventListener("click",(()=>{e.remove()})):(i.querySelector("#panel-header").addEventListener("click",(()=>{const t=i.classList;t.contains("collapsed")?t.remove("collapsed"):t.add("collapsed")})),i.querySelector("#panel-header").style.cursor="pointer"),requestAnimationFrame((()=>{n.modal&&(e._background.classList.remove("closed"),i.style.height=`min(calc(100% - 10px), ${i.querySelector("#panel-content").offsetHeight+50}px)`),i.classList.remove("closed")})),e}remove(){const t=this,e=t._options,n=t._background,i=t._container;return e.modal&&n.classList.add("closed"),i.style.removeProperty("height"),i.classList.add("closed"),setTimeout((()=>{e.modal&&(n.parentNode.removeChild(n),delete t._background),i.parentNode.removeChild(i),delete t._container,delete t._map}),300),t}isOpen(){return!!this._map}}class AboutPanel extends Panel{constructor(t){super(Object.assign({className:"about-panel",modal:!0},t))}addTo(t){return super.addTo(t).setTitle(t.dict.about).updateContent()}updateContent(){const t=this;if(t.isOpen()){const{dict:e,gtfs:n,lastDynamicUpdate:i}=t._map,r=[...n.values()];t.setHTML([e.description.replace(/<h3>.*<\/h3>/,""),`<p>${configs.copyright}</p>`,`<div class="card-title">${e["static-update"]}</div>`,`<div class="card-body">${configs.lastStaticUpdate}</div>`,`<div class="card-title">${e["dynamic-update"]}</div>`,'<div class="card-body">',i.Toei||"N/A",` (${e.toei})<br>`,i["HND-JAT"]||"N/A",` (${e["hnd-jat"]})<br>`,i["HND-TIAT"]||"N/A",` (${e["hnd-tiat"]})<br>`,i.NAA||"N/A",` (${e.naa})<br>`,r.map((({date:t,agency:e})=>`${t} (${e})`)).join("<br>"),"</div>",r.length>0?[`<div class="card-title">${e["gtfs-feed-version"]}</div>`,'<div class="card-body">',r.map((({version:t,agency:e})=>`${t} (${e})`)).join("<br>"),"</div>"].join(""):""].join(""))}return t}}class BusPanel extends Panel{constructor(t){super(Object.assign({className:"bus-panel"},t))}addTo(t){const e=this,n=[],i=[],r=e._options.object,o=t.gtfs.get(r.gtfsId),s=o.stopLookup;for(const t of r.trip.stops){const e=s.get(t);n.push(['<div class="busstop-row">',`<div class="busstop-title-box">${e.name}</div>`,'<div class="busstop-time-box"></div>',"</div>"].join(""))}super.addTo(t),e.updateHeader(),e.setHTML(['<div id="timetable-content">',...n,"</div>",'<svg id="busroute-mark"></svg>','<svg id="bus-mark"></svg>'].join(""));const a=e._container,l=a.querySelector("#panel-body");for(const t of a.querySelector("#timetable-content").children)i.push(t.offsetTop+t.getBoundingClientRect().height/2);return a.querySelector("#busroute-mark").innerHTML=[`<line stroke="${o.color}" stroke-width="10" x1="12" y1="${i[0]}" x2="12" y2="${i[i.length-1]}" stroke-linecap="round" />`].concat(i.map((t=>`<circle cx="12" cy="${t}" r="3" fill="#ffffff" />`))).join(""),function t(){const n=l.getBoundingClientRect().height,o=r.sectionIndex,s=lerp$5(i[o],i[Math.min(o+1,i.length-1)],r._t),c=performance.now()%1500/1500;a.querySelector("#bus-mark").innerHTML=`<circle cx="22" cy="${s}" r="${7+15*c}" fill="#ffffff" opacity="${1-c}" /><circle cx="22" cy="${s}" r="7" fill="#ffffff" />`,void 0!==e._scrollTop&&e._scrollTop!==l.scrollTop||(e._scrollTop=l.scrollTop=Math.round(s-n/2+4)),e._container&&requestAnimationFrame(t)}(),e}updateHeader(){const t=this._options.object,e=this._map.gtfs.get(t.gtfsId),n=t.trip,{shortName:i,headsigns:r}=n;this.setTitle(['<div class="desc-header">',`<div style="background-color: ${e.color};"></div>`,'<div><div class="desc-first-row">',e.agency,'</div><div class="desc-second-row">',i?` <span class="bus-route-label" style="color: ${n.textColor}; background-color: ${n.color};">${i}</span> `:"",r[1===r.length?0:t.sectionIndex],"</div></div></div>"].join(""))}reset(){delete this._scrollTop}}class LayerPanel extends Panel{constructor(t){super(Object.assign({className:"layer-panel",modal:!0},t))}addTo(t){const e=this,n=e._options.layers;super.addTo(t).setTitle(t.dict.layers).setHTML(n.map((e=>[`<div id="${e.getId()}-layer" class="layer-row">`,'<div class="layer-icon"></div>',`<div>${e.getName(t.lang)}</div>`,"</div>"].join(""))).join(""));for(const t of n){const n=e._container.querySelector(`#${t.getId()}-layer .layer-icon`),i=n.classList;Object.assign(n.style,t.getIconStyle()),t.isEnabled()&&i.add("layer-icon-enabled"),n.addEventListener("click",(()=>{t.isEnabled()?(i.remove("layer-icon-enabled"),t.disable()):(i.add("layer-icon-enabled"),t.enable())}))}return e}}class SharePanel{constructor(t){this._object=t.object}addTo(t){const e=this,n=t.dict,i=e._object,r=i instanceof Train?"train":"flight",o=e._container=createElement$1("div",{className:"share-panel"},t.container);return(e._button=createElement$1("button",{className:"share-button",innerHTML:n["share-this"].replace("$1",n[r])},o)).onclick=()=>{window.navigator.share({title:n.my.replace("$1",n[r]),text:n["on-this"].replace("$1",n[r]),url:`${configs.shareUrl}?selection=${i.id}`}).then((()=>{showNotification(t.container,n.shared)})).catch((()=>{}))},e._map=t,e}remove(){const t=this,e=t._container;return e.parentNode.removeChild(e),delete t._container,delete t._map,t}}function isObject$1(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function extend$2(t,e){void 0===t&&(t={}),void 0===e&&(e={}),Object.keys(e).forEach((n=>{void 0===t[n]?t[n]=e[n]:isObject$1(e[n])&&isObject$1(t[n])&&Object.keys(e[n]).length>0&&extend$2(t[n],e[n])}))}const ssrDocument={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 getDocument(){const t="undefined"!=typeof document?document:{};return extend$2(t,ssrDocument),t}const ssrWindow={document:ssrDocument,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:t=>"undefined"==typeof setTimeout?(t(),null):setTimeout(t,0),cancelAnimationFrame(t){"undefined"!=typeof setTimeout&&clearTimeout(t)}};function getWindow(){const t="undefined"!=typeof window?window:{};return extend$2(t,ssrWindow),t}function classesToTokens(t){return void 0===t&&(t=""),t.trim().split(" ").filter((t=>!!t.trim()))}function deleteProps(t){const e=t;Object.keys(e).forEach((t=>{try{e[t]=null}catch(t){}try{delete e[t]}catch(t){}}))}function nextTick(t,e){return void 0===e&&(e=0),setTimeout(t,e)}function now(){return Date.now()}function getComputedStyle$1(t){const e=getWindow();let n;return e.getComputedStyle&&(n=e.getComputedStyle(t,null)),!n&&t.currentStyle&&(n=t.currentStyle),n||(n=t.style),n}function getTranslate(t,e){void 0===e&&(e="x");const n=getWindow();let i,r,o;const s=getComputedStyle$1(t);return n.WebKitCSSMatrix?(r=s.transform||s.webkitTransform,r.split(",").length>6&&(r=r.split(", ").map((t=>t.replace(",","."))).join(", ")),o=new n.WebKitCSSMatrix("none"===r?"":r)):(o=s.MozTransform||s.OTransform||s.MsTransform||s.msTransform||s.transform||s.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=o.toString().split(",")),"x"===e&&(r=n.WebKitCSSMatrix?o.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===e&&(r=n.WebKitCSSMatrix?o.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),r||0}function isObject(t){return"object"==typeof t&&null!==t&&t.constructor&&"Object"===Object.prototype.toString.call(t).slice(8,-1)}function isNode(t){return"undefined"!=typeof window&&void 0!==window.HTMLElement?t instanceof HTMLElement:t&&(1===t.nodeType||11===t.nodeType)}function extend$1(){const t=Object(arguments.length<=0?void 0:arguments[0]),e=["__proto__","constructor","prototype"];for(let n=1;n<arguments.length;n+=1){const i=n<0||arguments.length<=n?void 0:arguments[n];if(null!=i&&!isNode(i)){const n=Object.keys(Object(i)).filter((t=>e.indexOf(t)<0));for(let e=0,r=n.length;e<r;e+=1){const r=n[e],o=Object.getOwnPropertyDescriptor(i,r);void 0!==o&&o.enumerable&&(isObject(t[r])&&isObject(i[r])?i[r].__swiper__?t[r]=i[r]:extend$1(t[r],i[r]):!isObject(t[r])&&isObject(i[r])?(t[r]={},i[r].__swiper__?t[r]=i[r]:extend$1(t[r],i[r])):t[r]=i[r])}}}return t}function setCSSProperty(t,e,n){t.style.setProperty(e,n)}function animateCSSModeScroll(t){let{swiper:e,targetPosition:n,side:i}=t;const r=getWindow(),o=-e.translate;let s,a=null;const l=e.params.speed;e.wrapperEl.style.scrollSnapType="none",r.cancelAnimationFrame(e.cssModeFrameID);const c=n>o?"next":"prev",u=(t,e)=>"next"===c&&t>=e||"prev"===c&&t<=e,h=()=>{s=(new Date).getTime(),null===a&&(a=s);const t=Math.max(Math.min((s-a)/l,1),0),c=.5-Math.cos(t*Math.PI)/2;let d=o+c*(n-o);if(u(d,n)&&(d=n),e.wrapperEl.scrollTo({[i]:d}),u(d,n))return e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout((()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[i]:d})})),void r.cancelAnimationFrame(e.cssModeFrameID);e.cssModeFrameID=r.requestAnimationFrame(h)};h()}function elementChildren(t,e){void 0===e&&(e="");const n=[...t.children];return t instanceof HTMLSlotElement&&n.push(...t.assignedElements()),e?n.filter((t=>t.matches(e))):n}function elementIsChildOfSlot(t,e){const n=[e];for(;n.length>0;){const e=n.shift();if(t===e)return!0;n.push(...e.children,...e.shadowRoot?.children||[],...e.assignedElements?.()||[])}}function elementIsChildOf(t,e){let n=e.contains(t);if(!n&&e instanceof HTMLSlotElement){n=[...e.assignedElements()].includes(t),n||(n=elementIsChildOfSlot(t,e))}return n}function showWarning(t){try{return void console.warn(t)}catch(t){}}function createElement(t,e){void 0===e&&(e=[]);const n=document.createElement(t);return n.classList.add(...Array.isArray(e)?e:classesToTokens(e)),n}function elementPrevAll(t,e){const n=[];for(;t.previousElementSibling;){const i=t.previousElementSibling;e?i.matches(e)&&n.push(i):n.push(i),t=i}return n}function elementNextAll(t,e){const n=[];for(;t.nextElementSibling;){const i=t.nextElementSibling;e?i.matches(e)&&n.push(i):n.push(i),t=i}return n}function elementStyle(t,e){return getWindow().getComputedStyle(t,null).getPropertyValue(e)}function elementIndex(t){let e,n=t;if(n){for(e=0;null!==(n=n.previousSibling);)1===n.nodeType&&(e+=1);return e}}function elementParents(t,e){const n=[];let i=t.parentElement;for(;i;)e?i.matches(e)&&n.push(i):n.push(i),i=i.parentElement;return n}function elementOuterSize(t,e,n){const i=getWindow();return t["width"===e?"offsetWidth":"offsetHeight"]+parseFloat(i.getComputedStyle(t,null).getPropertyValue("width"===e?"margin-right":"margin-top"))+parseFloat(i.getComputedStyle(t,null).getPropertyValue("width"===e?"margin-left":"margin-bottom"))}function makeElementsArray(t){return(Array.isArray(t)?t:[t]).filter((t=>!!t))}let support,deviceCached,browser;function calcSupport(){const t=getWindow(),e=getDocument();return{smoothScroll:e.documentElement&&e.documentElement.style&&"scrollBehavior"in e.documentElement.style,touch:!!("ontouchstart"in t||t.DocumentTouch&&e instanceof t.DocumentTouch)}}function getSupport(){return support||(support=calcSupport()),support}function calcDevice(t){let{userAgent:e}=void 0===t?{}:t;const n=getSupport(),i=getWindow(),r=i.navigator.platform,o=e||i.navigator.userAgent,s={ios:!1,android:!1},a=i.screen.width,l=i.screen.height,c=o.match(/(Android);?[\s\/]+([\d.]+)?/);let u=o.match(/(iPad).*OS\s([\d_]+)/);const h=o.match(/(iPod)(.*OS\s([\d_]+))?/),d=!u&&o.match(/(iPhone\sOS|iOS)\s([\d_]+)/),p="Win32"===r;let f="MacIntel"===r;return!u&&f&&n.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${a}x${l}`)>=0&&(u=o.match(/(Version)\/([\d.]+)/),u||(u=[0,1,"13_0_0"]),f=!1),c&&!p&&(s.os="android",s.android=!0),(u||d||h)&&(s.os="ios",s.ios=!0),s}function getDevice(t){return void 0===t&&(t={}),deviceCached||(deviceCached=calcDevice(t)),deviceCached}function calcBrowser(){const t=getWindow(),e=getDevice();let n=!1;function i(){const e=t.navigator.userAgent.toLowerCase();return e.indexOf("safari")>=0&&e.indexOf("chrome")<0&&e.indexOf("android")<0}if(i()){const e=String(t.navigator.userAgent);if(e.includes("Version/")){const[t,i]=e.split("Version/")[1].split(" ")[0].split(".").map((t=>Number(t)));n=t<16||16===t&&i<2}}const r=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(t.navigator.userAgent),o=i();return{isSafari:n||o,needPerspectiveFix:n,need3dFix:o||r&&e.ios,isWebView:r}}function getBrowser(){return browser||(browser=calcBrowser()),browser}function Resize(t){let{swiper:e,on:n,emit:i}=t;const r=getWindow();let o=null,s=null;const a=()=>{e&&!e.destroyed&&e.initialized&&(i("beforeResize"),i("resize"))},l=()=>{e&&!e.destroyed&&e.initialized&&i("orientationchange")};n("init",(()=>{e.params.resizeObserver&&void 0!==r.ResizeObserver?e&&!e.destroyed&&e.initialized&&(o=new ResizeObserver((t=>{s=r.requestAnimationFrame((()=>{const{width:n,height:i}=e;let r=n,o=i;t.forEach((t=>{let{contentBoxSize:n,contentRect:i,target:s}=t;s&&s!==e.el||(r=i?i.width:(n[0]||n).inlineSize,o=i?i.height:(n[0]||n).blockSize)})),r===n&&o===i||a()}))})),o.observe(e.el)):(r.addEventListener("resize",a),r.addEventListener("orientationchange",l))})),n("destroy",(()=>{s&&r.cancelAnimationFrame(s),o&&o.unobserve&&e.el&&(o.unobserve(e.el),o=null),r.removeEventListener("resize",a),r.removeEventListener("orientationchange",l)}))}function Observer(t){let{swiper:e,extendParams:n,on:i,emit:r}=t;const o=[],s=getWindow(),a=function(t,n){void 0===n&&(n={});const i=new(s.MutationObserver||s.WebkitMutationObserver)((t=>{if(e.__preventObserver__)return;if(1===t.length)return void r("observerUpdate",t[0]);const n=function(){r("observerUpdate",t[0])};s.requestAnimationFrame?s.requestAnimationFrame(n):s.setTimeout(n,0)}));i.observe(t,{attributes:void 0===n.attributes||n.attributes,childList:e.isElement||(void 0===n.childList||n).childList,characterData:void 0===n.characterData||n.characterData}),o.push(i)};n({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",(()=>{if(e.params.observer){if(e.params.observeParents){const t=elementParents(e.hostEl);for(let e=0;e<t.length;e+=1)a(t[e])}a(e.hostEl,{childList:e.params.observeSlideChildren}),a(e.wrapperEl,{attributes:!1})}})),i("destroy",(()=>{o.forEach((t=>{t.disconnect()})),o.splice(0,o.length)}))}var eventsEmitter={on(t,e,n){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof e)return i;const r=n?"unshift":"push";return t.split(" ").forEach((t=>{i.eventsListeners[t]||(i.eventsListeners[t]=[]),i.eventsListeners[t][r](e)})),i},once(t,e,n){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof e)return i;function r(){i.off(t,r),r.__emitterProxy&&delete r.__emitterProxy;for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];e.apply(i,o)}return r.__emitterProxy=e,i.on(t,r,n)},onAny(t,e){const n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;const i=e?"unshift":"push";return n.eventsAnyListeners.indexOf(t)<0&&n.eventsAnyListeners[i](t),n},offAny(t){const e=this;if(!e.eventsListeners||e.destroyed)return e;if(!e.eventsAnyListeners)return e;const n=e.eventsAnyListeners.indexOf(t);return n>=0&&e.eventsAnyListeners.splice(n,1),e},off(t,e){const n=this;return!n.eventsListeners||n.destroyed?n:n.eventsListeners?(t.split(" ").forEach((t=>{void 0===e?n.eventsListeners[t]=[]:n.eventsListeners[t]&&n.eventsListeners[t].forEach(((i,r)=>{(i===e||i.__emitterProxy&&i.__emitterProxy===e)&&n.eventsListeners[t].splice(r,1)}))})),n):n},emit(){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsListeners)return t;let e,n,i;for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];"string"==typeof o[0]||Array.isArray(o[0])?(e=o[0],n=o.slice(1,o.length),i=t):(e=o[0].events,n=o[0].data,i=o[0].context||t),n.unshift(i);return(Array.isArray(e)?e:e.split(" ")).forEach((e=>{t.eventsAnyListeners&&t.eventsAnyListeners.length&&t.eventsAnyListeners.forEach((t=>{t.apply(i,[e,...n])})),t.eventsListeners&&t.eventsListeners[e]&&t.eventsListeners[e].forEach((t=>{t.apply(i,n)}))})),t}};function updateSize(){const t=this;let e,n;const i=t.el;e=null!=t.params.width?t.params.width:i.clientWidth,n=null!=t.params.height?t.params.height:i.clientHeight,0===e&&t.isHorizontal()||0===n&&t.isVertical()||(e=e-parseInt(elementStyle(i,"padding-left")||0,10)-parseInt(elementStyle(i,"padding-right")||0,10),n=n-parseInt(elementStyle(i,"padding-top")||0,10)-parseInt(elementStyle(i,"padding-bottom")||0,10),Number.isNaN(e)&&(e=0),Number.isNaN(n)&&(n=0),Object.assign(t,{width:e,height:n,size:t.isHorizontal()?e:n}))}function updateSlides(){const t=this;function e(e,n){return parseFloat(e.getPropertyValue(t.getDirectionLabel(n))||0)}const n=t.params,{wrapperEl:i,slidesEl:r,size:o,rtlTranslate:s,wrongRTL:a}=t,l=t.virtual&&n.virtual.enabled,c=l?t.virtual.slides.length:t.slides.length,u=elementChildren(r,`.${t.params.slideClass}, swiper-slide`),h=l?t.virtual.slides.length:u.length;let d=[];const p=[],f=[];let m=n.slidesOffsetBefore;"function"==typeof m&&(m=n.slidesOffsetBefore.call(t));let g=n.slidesOffsetAfter;"function"==typeof g&&(g=n.slidesOffsetAfter.call(t));const _=t.snapGrid.length,y=t.slidesGrid.length;let v=n.spaceBetween,x=-m,b=0,T=0;if(void 0===o)return;"string"==typeof v&&v.indexOf("%")>=0?v=parseFloat(v.replace("%",""))/100*o:"string"==typeof v&&(v=parseFloat(v)),t.virtualSize=-v,u.forEach((t=>{s?t.style.marginLeft="":t.style.marginRight="",t.style.marginBottom="",t.style.marginTop=""})),n.centeredSlides&&n.cssMode&&(setCSSProperty(i,"--swiper-centered-offset-before",""),setCSSProperty(i,"--swiper-centered-offset-after",""));const E=n.grid&&n.grid.rows>1&&t.grid;let S;E?t.grid.initSlides(u):t.grid&&t.grid.unsetSlides();const w="auto"===n.slidesPerView&&n.breakpoints&&Object.keys(n.breakpoints).filter((t=>void 0!==n.breakpoints[t].slidesPerView)).length>0;for(let i=0;i<h;i+=1){let r;if(S=0,u[i]&&(r=u[i]),E&&t.grid.updateSlide(i,r,u),!u[i]||"none"!==elementStyle(r,"display")){if("auto"===n.slidesPerView){w&&(u[i].style[t.getDirectionLabel("width")]="");const o=getComputedStyle(r),s=r.style.transform,a=r.style.webkitTransform;if(s&&(r.style.transform="none"),a&&(r.style.webkitTransform="none"),n.roundLengths)S=t.isHorizontal()?elementOuterSize(r,"width"):elementOuterSize(r,"height");else{const t=e(o,"width"),n=e(o,"padding-left"),i=e(o,"padding-right"),s=e(o,"margin-left"),a=e(o,"margin-right"),l=o.getPropertyValue("box-sizing");if(l&&"border-box"===l)S=t+s+a;else{const{clientWidth:e,offsetWidth:o}=r;S=t+n+i+s+a+(o-e)}}s&&(r.style.transform=s),a&&(r.style.webkitTransform=a),n.roundLengths&&(S=Math.floor(S))}else S=(o-(n.slidesPerView-1)*v)/n.slidesPerView,n.roundLengths&&(S=Math.floor(S)),u[i]&&(u[i].style[t.getDirectionLabel("width")]=`${S}px`);u[i]&&(u[i].swiperSlideSize=S),f.push(S),n.centeredSlides?(x=x+S/2+b/2+v,0===b&&0!==i&&(x=x-o/2-v),0===i&&(x=x-o/2-v),Math.abs(x)<.001&&(x=0),n.roundLengths&&(x=Math.floor(x)),T%n.slidesPerGroup==0&&d.push(x),p.push(x)):(n.roundLengths&&(x=Math.floor(x)),(T-Math.min(t.params.slidesPerGroupSkip,T))%t.params.slidesPerGroup==0&&d.push(x),p.push(x),x=x+S+v),t.virtualSize+=S+v,b=S,T+=1}}if(t.virtualSize=Math.max(t.virtualSize,o)+g,s&&a&&("slide"===n.effect||"coverflow"===n.effect)&&(i.style.width=`${t.virtualSize+v}px`),n.setWrapperSize&&(i.style[t.getDirectionLabel("width")]=`${t.virtualSize+v}px`),E&&t.grid.updateWrapperSize(S,d),!n.centeredSlides){const e=[];for(let i=0;i<d.length;i+=1){let r=d[i];n.roundLengths&&(r=Math.floor(r)),d[i]<=t.virtualSize-o&&e.push(r)}d=e,Math.floor(t.virtualSize-o)-Math.floor(d[d.length-1])>1&&d.push(t.virtualSize-o)}if(l&&n.loop){const e=f[0]+v;if(n.slidesPerGroup>1){const i=Math.ceil((t.virtual.slidesBefore+t.virtual.slidesAfter)/n.slidesPerGroup),r=e*n.slidesPerGroup;for(let t=0;t<i;t+=1)d.push(d[d.length-1]+r)}for(let i=0;i<t.virtual.slidesBefore+t.virtual.slidesAfter;i+=1)1===n.slidesPerGroup&&d.push(d[d.length-1]+e),p.push(p[p.length-1]+e),t.virtualSize+=e}if(0===d.length&&(d=[0]),0!==v){const e=t.isHorizontal()&&s?"marginLeft":t.getDirectionLabel("marginRight");u.filter(((t,e)=>!(n.cssMode&&!n.loop)||e!==u.length-1)).forEach((t=>{t.style[e]=`${v}px`}))}if(n.centeredSlides&&n.centeredSlidesBounds){let t=0;f.forEach((e=>{t+=e+(v||0)})),t-=v;const e=t>o?t-o:0;d=d.map((t=>t<=0?-m:t>e?e+g:t))}if(n.centerInsufficientSlides){let t=0;f.forEach((e=>{t+=e+(v||0)})),t-=v;const e=(n.slidesOffsetBefore||0)+(n.slidesOffsetAfter||0);if(t+e<o){const n=(o-t-e)/2;d.forEach(((t,e)=>{d[e]=t-n})),p.forEach(((t,e)=>{p[e]=t+n}))}}if(Object.assign(t,{slides:u,snapGrid:d,slidesGrid:p,slidesSizesGrid:f}),n.centeredSlides&&n.cssMode&&!n.centeredSlidesBounds){setCSSProperty(i,"--swiper-centered-offset-before",-d[0]+"px"),setCSSProperty(i,"--swiper-centered-offset-after",t.size/2-f[f.length-1]/2+"px");const e=-t.snapGrid[0],n=-t.slidesGrid[0];t.snapGrid=t.snapGrid.map((t=>t+e)),t.slidesGrid=t.slidesGrid.map((t=>t+n))}if(h!==c&&t.emit("slidesLengthChange"),d.length!==_&&(t.params.watchOverflow&&t.checkOverflow(),t.emit("snapGridLengthChange")),p.length!==y&&t.emit("slidesGridLengthChange"),n.watchSlidesProgress&&t.updateSlidesOffset(),t.emit("slidesUpdated"),!(l||n.cssMode||"slide"!==n.effect&&"fade"!==n.effect)){const e=`${n.containerModifierClass}backface-hidden`,i=t.el.classList.contains(e);h<=n.maxBackfaceHiddenSlides?i||t.el.classList.add(e):i&&t.el.classList.remove(e)}}function updateAutoHeight(t){const e=this,n=[],i=e.virtual&&e.params.virtual.enabled;let r,o=0;"number"==typeof t?e.setTransition(t):!0===t&&e.setTransition(e.params.speed);const s=t=>i?e.slides[e.getSlideIndexByData(t)]:e.slides[t];if("auto"!==e.params.slidesPerView&&e.params.slidesPerView>1)if(e.params.centeredSlides)(e.visibleSlides||[]).forEach((t=>{n.push(t)}));else for(r=0;r<Math.ceil(e.params.slidesPerView);r+=1){const t=e.activeIndex+r;if(t>e.slides.length&&!i)break;n.push(s(t))}else n.push(s(e.activeIndex));for(r=0;r<n.length;r+=1)if(void 0!==n[r]){const t=n[r].offsetHeight;o=t>o?t:o}(o||0===o)&&(e.wrapperEl.style.height=`${o}px`)}function updateSlidesOffset(){const t=this,e=t.slides,n=t.isElement?t.isHorizontal()?t.wrapperEl.offsetLeft:t.wrapperEl.offsetTop:0;for(let i=0;i<e.length;i+=1)e[i].swiperSlideOffset=(t.isHorizontal()?e[i].offsetLeft:e[i].offsetTop)-n-t.cssOverflowAdjustment()}const toggleSlideClasses$1=(t,e,n)=>{e&&!t.classList.contains(n)?t.classList.add(n):!e&&t.classList.contains(n)&&t.classList.remove(n)};function updateSlidesProgress(t){void 0===t&&(t=this&&this.translate||0);const e=this,n=e.params,{slides:i,rtlTranslate:r,snapGrid:o}=e;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&e.updateSlidesOffset();let s=-t;r&&(s=t),e.visibleSlidesIndexes=[],e.visibleSlides=[];let a=n.spaceBetween;"string"==typeof a&&a.indexOf("%")>=0?a=parseFloat(a.replace("%",""))/100*e.size:"string"==typeof a&&(a=parseFloat(a));for(let t=0;t<i.length;t+=1){const l=i[t];let c=l.swiperSlideOffset;n.cssMode&&n.centeredSlides&&(c-=i[0].swiperSlideOffset);const u=(s+(n.centeredSlides?e.minTranslate():0)-c)/(l.swiperSlideSize+a),h=(s-o[0]+(n.centeredSlides?e.minTranslate():0)-c)/(l.swiperSlideSize+a),d=-(s-c),p=d+e.slidesSizesGrid[t],f=d>=0&&d<=e.size-e.slidesSizesGrid[t],m=d>=0&&d<e.size-1||p>1&&p<=e.size||d<=0&&p>=e.size;m&&(e.visibleSlides.push(l),e.visibleSlidesIndexes.push(t)),toggleSlideClasses$1(l,m,n.slideVisibleClass),toggleSlideClasses$1(l,f,n.slideFullyVisibleClass),l.progress=r?-u:u,l.originalProgress=r?-h:h}}function updateProgress(t){const e=this;if(void 0===t){t=e&&e.translate&&e.translate*(e.rtlTranslate?-1:1)||0}const n=e.params,i=e.maxTranslate()-e.minTranslate();let{progress:r,isBeginning:o,isEnd:s,progressLoop:a}=e;const l=o,c=s;if(0===i)r=0,o=!0,s=!0;else{r=(t-e.minTranslate())/i;const n=Math.abs(t-e.minTranslate())<1,a=Math.abs(t-e.maxTranslate())<1;o=n||r<=0,s=a||r>=1,n&&(r=0),a&&(r=1)}if(n.loop){const n=e.getSlideIndexByData(0),i=e.getSlideIndexByData(e.slides.length-1),r=e.slidesGrid[n],o=e.slidesGrid[i],s=e.slidesGrid[e.slidesGrid.length-1],l=Math.abs(t);a=l>=r?(l-r)/s:(l+s-o)/s,a>1&&(a-=1)}Object.assign(e,{progress:r,progressLoop:a,isBeginning:o,isEnd:s}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&e.updateSlidesProgress(t),o&&!l&&e.emit("reachBeginning toEdge"),s&&!c&&e.emit("reachEnd toEdge"),(l&&!o||c&&!s)&&e.emit("fromEdge"),e.emit("progress",r)}const toggleSlideClasses=(t,e,n)=>{e&&!t.classList.contains(n)?t.classList.add(n):!e&&t.classList.contains(n)&&t.classList.remove(n)};function updateSlidesClasses(){const t=this,{slides:e,params:n,slidesEl:i,activeIndex:r}=t,o=t.grid&&n.grid&&n.grid.rows>1,s=t=>elementChildren(i,`.${n.slideClass}${t}, swiper-slide${t}`)[0];let a,l,c;if(t.virtual&&n.virtual.enabled)if(n.loop){let e=r-t.virtual.slidesBefore;e<0&&(e=t.virtual.slides.length+e),e>=t.virtual.slides.length&&(e-=t.virtual.slides.length),a=s(`[data-swiper-slide-index="${e}"]`)}else a=s(`[data-swiper-slide-index="${r}"]`);else o?(a=e.find((t=>t.column===r)),c=e.find((t=>t.column===r+1)),l=e.find((t=>t.column===r-1))):a=e[r];a&&(o||(c=elementNextAll(a,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!c&&(c=e[0]),l=elementPrevAll(a,`.${n.slideClass}, swiper-slide`)[0],n.loop&&0===!l&&(l=e[e.length-1]))),e.forEach((t=>{toggleSlideClasses(t,t===a,n.slideActiveClass),toggleSlideClasses(t,t===c,n.slideNextClass),toggleSlideClasses(t,t===l,n.slidePrevClass)})),t.emitSlidesClasses()}const processLazyPreloader=(t,e)=>{if(!t||t.destroyed||!t.params)return;const n=e.closest(t.isElement?"swiper-slide":`.${t.params.slideClass}`);if(n){let e=n.querySelector(`.${t.params.lazyPreloaderClass}`);!e&&t.isElement&&(n.shadowRoot?e=n.shadowRoot.querySelector(`.${t.params.lazyPreloaderClass}`):requestAnimationFrame((()=>{n.shadowRoot&&(e=n.shadowRoot.querySelector(`.${t.params.lazyPreloaderClass}`),e&&e.remove())}))),e&&e.remove()}},unlazy=(t,e)=>{if(!t.slides[e])return;const n=t.slides[e].querySelector('[loading="lazy"]');n&&n.removeAttribute("loading")},preload=t=>{if(!t||t.destroyed||!t.params)return;let e=t.params.lazyPreloadPrevNext;const n=t.slides.length;if(!n||!e||e<0)return;e=Math.min(e,n);const i="auto"===t.params.slidesPerView?t.slidesPerViewDynamic():Math.ceil(t.params.slidesPerView),r=t.activeIndex;if(t.params.grid&&t.params.grid.rows>1){const n=r,o=[n-e];return o.push(...Array.from({length:e}).map(((t,e)=>n+i+e))),void t.slides.forEach(((e,n)=>{o.includes(e.column)&&unlazy(t,n)}))}const o=r+i-1;if(t.params.rewind||t.params.loop)for(let i=r-e;i<=o+e;i+=1){const e=(i%n+n)%n;(e<r||e>o)&&unlazy(t,e)}else for(let i=Math.max(r-e,0);i<=Math.min(o+e,n-1);i+=1)i!==r&&(i>o||i<r)&&unlazy(t,i)};function getActiveIndexByTranslate(t){const{slidesGrid:e,params:n}=t,i=t.rtlTranslate?t.translate:-t.translate;let r;for(let t=0;t<e.length;t+=1)void 0!==e[t+1]?i>=e[t]&&i<e[t+1]-(e[t+1]-e[t])/2?r=t:i>=e[t]&&i<e[t+1]&&(r=t+1):i>=e[t]&&(r=t);return n.normalizeSlideIndex&&(r<0||void 0===r)&&(r=0),r}function updateActiveIndex(t){const e=this,n=e.rtlTranslate?e.translate:-e.translate,{snapGrid:i,params:r,activeIndex:o,realIndex:s,snapIndex:a}=e;let l,c=t;const u=t=>{let n=t-e.virtual.slidesBefore;return n<0&&(n=e.virtual.slides.length+n),n>=e.virtual.slides.length&&(n-=e.virtual.slides.length),n};if(void 0===c&&(c=getActiveIndexByTranslate(e)),i.indexOf(n)>=0)l=i.indexOf(n);else{const t=Math.min(r.slidesPerGroupSkip,c);l=t+Math.floor((c-t)/r.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),c===o&&!e.params.loop)return void(l!==a&&(e.snapIndex=l,e.emit("snapIndexChange")));if(c===o&&e.params.loop&&e.virtual&&e.params.virtual.enabled)return void(e.realIndex=u(c));const h=e.grid&&r.grid&&r.grid.rows>1;let d;if(e.virtual&&r.virtual.enabled&&r.loop)d=u(c);else if(h){const t=e.slides.find((t=>t.column===c));let n=parseInt(t.getAttribute("data-swiper-slide-index"),10);Number.isNaN(n)&&(n=Math.max(e.slides.indexOf(t),0)),d=Math.floor(n/r.grid.rows)}else if(e.slides[c]){const t=e.slides[c].getAttribute("data-swiper-slide-index");d=t?parseInt(t,10):c}else d=c;Object.assign(e,{previousSnapIndex:a,snapIndex:l,previousRealIndex:s,realIndex:d,previousIndex:o,activeIndex:c}),e.initialized&&preload(e),e.emit("activeIndexChange"),e.emit("snapIndexChange"),(e.initialized||e.params.runCallbacksOnInit)&&(s!==d&&e.emit("realIndexChange"),e.emit("slideChange"))}function updateClickedSlide(t,e){const n=this,i=n.params;let r=t.closest(`.${i.slideClass}, swiper-slide`);!r&&n.isElement&&e&&e.length>1&&e.includes(t)&&[...e.slice(e.indexOf(t)+1,e.length)].forEach((t=>{!r&&t.matches&&t.matches(`.${i.slideClass}, swiper-slide`)&&(r=t)}));let o,s=!1;if(r)for(let t=0;t<n.slides.length;t+=1)if(n.slides[t]===r){s=!0,o=t;break}if(!r||!s)return n.clickedSlide=void 0,void(n.clickedIndex=void 0);n.clickedSlide=r,n.clickedIndex=n.virtual&&n.params.virtual.enabled?parseInt(r.getAttribute("data-swiper-slide-index"),10):o,i.slideToClickedSlide&&void 0!==n.clickedIndex&&n.clickedIndex!==n.activeIndex&&n.slideToClickedSlide()}var update={updateSize:updateSize,updateSlides:updateSlides,updateAutoHeight:updateAutoHeight,updateSlidesOffset:updateSlidesOffset,updateSlidesProgress:updateSlidesProgress,updateProgress:updateProgress,updateSlidesClasses:updateSlidesClasses,updateActiveIndex:updateActiveIndex,updateClickedSlide:updateClickedSlide};function getSwiperTranslate(t){void 0===t&&(t=this.isHorizontal()?"x":"y");const{params:e,rtlTranslate:n,translate:i,wrapperEl:r}=this;if(e.virtualTranslate)return n?-i:i;if(e.cssMode)return i;let o=getTranslate(r,t);return o+=this.cssOverflowAdjustment(),n&&(o=-o),o||0}function setTranslate(t,e){const n=this,{rtlTranslate:i,params:r,wrapperEl:o,progress:s}=n;let a=0,l=0;let c;n.isHorizontal()?a=i?-t:t:l=t,r.roundLengths&&(a=Math.floor(a),l=Math.floor(l)),n.previousTranslate=n.translate,n.translate=n.isHorizontal()?a:l,r.cssMode?o[n.isHorizontal()?"scrollLeft":"scrollTop"]=n.isHorizontal()?-a:-l:r.virtualTranslate||(n.isHorizontal()?a-=n.cssOverflowAdjustment():l-=n.cssOverflowAdjustment(),o.style.transform=`translate3d(${a}px, ${l}px, 0px)`);const u=n.maxTranslate()-n.minTranslate();c=0===u?0:(t-n.minTranslate())/u,c!==s&&n.updateProgress(t),n.emit("setTranslate",n.translate,e)}function minTranslate(){return-this.snapGrid[0]}function maxTranslate(){return-this.snapGrid[this.snapGrid.length-1]}function translateTo(t,e,n,i,r){void 0===t&&(t=0),void 0===e&&(e=this.params.speed),void 0===n&&(n=!0),void 0===i&&(i=!0);const o=this,{params:s,wrapperEl:a}=o;if(o.animating&&s.preventInteractionOnTransition)return!1;const l=o.minTranslate(),c=o.maxTranslate();let u;if(u=i&&t>l?l:i&&t<c?c:t,o.updateProgress(u),s.cssMode){const t=o.isHorizontal();if(0===e)a[t?"scrollLeft":"scrollTop"]=-u;else{if(!o.support.smoothScroll)return animateCSSModeScroll({swiper:o,targetPosition:-u,side:t?"left":"top"}),!0;a.scrollTo({[t?"left":"top"]:-u,behavior:"smooth"})}return!0}return 0===e?(o.setTransition(0),o.setTranslate(u),n&&(o.emit("beforeTransitionStart",e,r),o.emit("transitionEnd"))):(o.setTransition(e),o.setTranslate(u),n&&(o.emit("beforeTransitionStart",e,r),o.emit("transitionStart")),o.animating||(o.animating=!0,o.onTranslateToWrapperTransitionEnd||(o.onTranslateToWrapperTransitionEnd=function(t){o&&!o.destroyed&&t.target===this&&(o.wrapperEl.removeEventListener("transitionend",o.onTranslateToWrapperTransitionEnd),o.onTranslateToWrapperTransitionEnd=null,delete o.onTranslateToWrapperTransitionEnd,o.animating=!1,n&&o.emit("transitionEnd"))}),o.wrapperEl.addEventListener("transitionend",o.onTranslateToWrapperTransitionEnd))),!0}var translate={getTranslate:getSwiperTranslate,setTranslate:setTranslate,minTranslate:minTranslate,maxTranslate:maxTranslate,translateTo:translateTo};function setTransition(t,e){const n=this;n.params.cssMode||(n.wrapperEl.style.transitionDuration=`${t}ms`,n.wrapperEl.style.transitionDelay=0===t?"0ms":""),n.emit("setTransition",t,e)}function transitionEmit(t){let{swiper:e,runCallbacks:n,direction:i,step:r}=t;const{activeIndex:o,previousIndex:s}=e;let a=i;if(a||(a=o>s?"next":o<s?"prev":"reset"),e.emit(`transition${r}`),n&&o!==s){if("reset"===a)return void e.emit(`slideResetTransition${r}`);e.emit(`slideChangeTransition${r}`),e.emit("next"===a?`slideNextTransition${r}`:`slidePrevTransition${r}`)}}function transitionStart(t,e){void 0===t&&(t=!0);const n=this,{params:i}=n;i.cssMode||(i.autoHeight&&n.updateAutoHeight(),transitionEmit({swiper:n,runCallbacks:t,direction:e,step:"Start"}))}function transitionEnd(t,e){void 0===t&&(t=!0);const n=this,{params:i}=n;n.animating=!1,i.cssMode||(n.setTransition(0),transitionEmit({swiper:n,runCallbacks:t,direction:e,step:"End"}))}var transition={setTransition:setTransition,transitionStart:transitionStart,transitionEnd:transitionEnd};function slideTo(t,e,n,i,r){void 0===t&&(t=0),void 0===n&&(n=!0),"string"==typeof t&&(t=parseInt(t,10));const o=this;let s=t;s<0&&(s=0);const{params:a,snapGrid:l,slidesGrid:c,previousIndex:u,activeIndex:h,rtlTranslate:d,wrapperEl:p,enabled:f}=o;if(!f&&!i&&!r||o.destroyed||o.animating&&a.preventInteractionOnTransition)return!1;void 0===e&&(e=o.params.speed);const m=Math.min(o.params.slidesPerGroupSkip,s);let g=m+Math.floor((s-m)/o.params.slidesPerGroup);g>=l.length&&(g=l.length-1);const _=-l[g];if(a.normalizeSlideIndex)for(let t=0;t<c.length;t+=1){const e=-Math.floor(100*_),n=Math.floor(100*c[t]),i=Math.floor(100*c[t+1]);void 0!==c[t+1]?e>=n&&e<i-(i-n)/2?s=t:e>=n&&e<i&&(s=t+1):e>=n&&(s=t)}if(o.initialized&&s!==h){if(!o.allowSlideNext&&(d?_>o.translate&&_>o.minTranslate():_<o.translate&&_<o.minTranslate()))return!1;if(!o.allowSlidePrev&&_>o.translate&&_>o.maxTranslate()&&(h||0)!==s)return!1}let y;s!==(u||0)&&n&&o.emit("beforeSlideChangeStart"),o.updateProgress(_),y=s>h?"next":s<h?"prev":"reset";const v=o.virtual&&o.params.virtual.enabled;if(!(v&&r)&&(d&&-_===o.translate||!d&&_===o.translate))return o.updateActiveIndex(s),a.autoHeight&&o.updateAutoHeight(),o.updateSlidesClasses(),"slide"!==a.effect&&o.setTranslate(_),"reset"!==y&&(o.transitionStart(n,y),o.transitionEnd(n,y)),!1;if(a.cssMode){const t=o.isHorizontal(),n=d?_:-_;if(0===e)v&&(o.wrapperEl.style.scrollSnapType="none",o._immediateVirtual=!0),v&&!o._cssModeVirtualInitialSet&&o.params.initialSlide>0?(o._cssModeVirtualInitialSet=!0,requestAnimationFrame((()=>{p[t?"scrollLeft":"scrollTop"]=n}))):p[t?"scrollLeft":"scrollTop"]=n,v&&requestAnimationFrame((()=>{o.wrapperEl.style.scrollSnapType="",o._immediateVirtual=!1}));else{if(!o.support.smoothScroll)return animateCSSModeScroll({swiper:o,targetPosition:n,side:t?"left":"top"}),!0;p.scrollTo({[t?"left":"top"]:n,behavior:"smooth"})}return!0}return o.setTransition(e),o.setTranslate(_),o.updateActiveIndex(s),o.updateSlidesClasses(),o.emit("beforeTransitionStart",e,i),o.transitionStart(n,y),0===e?o.transitionEnd(n,y):o.animating||(o.animating=!0,o.onSlideToWrapperTransitionEnd||(o.onSlideToWrapperTransitionEnd=function(t){o&&!o.destroyed&&t.target===this&&(o.wrapperEl.removeEventListener("transitionend",o.onSlideToWrapperTransitionEnd),o.onSlideToWrapperTransitionEnd=null,delete o.onSlideToWrapperTransitionEnd,o.transitionEnd(n,y))}),o.wrapperEl.addEventListener("transitionend",o.onSlideToWrapperTransitionEnd)),!0}function slideToLoop(t,e,n,i){if(void 0===t&&(t=0),void 0===n&&(n=!0),"string"==typeof t){t=parseInt(t,10)}const r=this;if(r.destroyed)return;void 0===e&&(e=r.params.speed);const o=r.grid&&r.params.grid&&r.params.grid.rows>1;let s=t;if(r.params.loop)if(r.virtual&&r.params.virtual.enabled)s+=r.virtual.slidesBefore;else{let t;if(o){const e=s*r.params.grid.rows;t=r.slides.find((t=>1*t.getAttribute("data-swiper-slide-index")===e)).column}else t=r.getSlideIndexByData(s);const e=o?Math.ceil(r.slides.length/r.params.grid.rows):r.slides.length,{centeredSlides:n}=r.params;let a=r.params.slidesPerView;"auto"===a?a=r.slidesPerViewDynamic():(a=Math.ceil(parseFloat(r.params.slidesPerView,10)),n&&a%2==0&&(a+=1));let l=e-t<a;if(n&&(l=l||t<Math.ceil(a/2)),i&&n&&"auto"!==r.params.slidesPerView&&!o&&(l=!1),l){const i=n?t<r.activeIndex?"prev":"next":t-r.activeIndex-1<r.params.slidesPerView?"next":"prev";r.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?t+1:t-e+1,slideRealIndex:"next"===i?r.realIndex:void 0})}if(o){const t=s*r.params.grid.rows;s=r.slides.find((e=>1*e.getAttribute("data-swiper-slide-index")===t)).column}else s=r.getSlideIndexByData(s)}return requestAnimationFrame((()=>{r.slideTo(s,e,n,i)})),r}function slideNext(t,e,n){void 0===e&&(e=!0);const i=this,{enabled:r,params:o,animating:s}=i;if(!r||i.destroyed)return i;void 0===t&&(t=i.params.speed);let a=o.slidesPerGroup;"auto"===o.slidesPerView&&1===o.slidesPerGroup&&o.slidesPerGroupAuto&&(a=Math.max(i.slidesPerViewDynamic("current",!0),1));const l=i.activeIndex<o.slidesPerGroupSkip?1:a;if(o.loop){if(s&&!(i.virtual&&o.virtual.enabled)&&o.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&o.cssMode)return requestAnimationFrame((()=>{i.slideTo(i.activeIndex+l,t,e,n)})),!0}return i.slideTo(o.rewind&&i.isEnd?0:i.activeIndex+l,t,e,n)}function slidePrev(t,e,n){void 0===e&&(e=!0);const i=this,{params:r,snapGrid:o,slidesGrid:s,rtlTranslate:a,enabled:l,animating:c}=i;if(!l||i.destroyed)return i;void 0===t&&(t=i.params.speed);if(r.loop){if(c&&!(i.virtual&&r.virtual.enabled)&&r.loopPreventsSliding)return!1;i.loopFix({direction:"prev"}),i._clientLeft=i.wrapperEl.clientLeft}function u(t){return t<0?-Math.floor(Math.abs(t)):Math.floor(t)}const h=u(a?i.translate:-i.translate),d=o.map((t=>u(t)));let p=o[d.indexOf(h)-1];if(void 0===p&&r.cssMode){let t;o.forEach(((e,n)=>{h>=e&&(t=n)})),void 0!==t&&(p=o[t>0?t-1:t])}let f=0;if(void 0!==p&&(f=s.indexOf(p),f<0&&(f=i.activeIndex-1),"auto"===r.slidesPerView&&1===r.slidesPerGroup&&r.slidesPerGroupAuto&&(f=f-i.slidesPerViewDynamic("previous",!0)+1,f=Math.max(f,0))),r.rewind&&i.isBeginning){return i.slideTo(i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1,t,e,n)}return r.loop&&0===i.activeIndex&&r.cssMode?(requestAnimationFrame((()=>{i.slideTo(f,t,e,n)})),!0):i.slideTo(f,t,e,n)}function slideReset(t,e,n){void 0===e&&(e=!0);const i=this;if(!i.destroyed)return void 0===t&&(t=i.params.speed),i.slideTo(i.activeIndex,t,e,n)}function slideToClosest(t,e,n,i){void 0===e&&(e=!0),void 0===i&&(i=.5);const r=this;if(r.destroyed)return;void 0===t&&(t=r.params.speed);let o=r.activeIndex;const s=Math.min(r.params.slidesPerGroupSkip,o),a=s+Math.floor((o-s)/r.params.slidesPerGroup),l=r.rtlTranslate?r.translate:-r.translate;if(l>=r.snapGrid[a]){const t=r.snapGrid[a];l-t>(r.snapGrid[a+1]-t)*i&&(o+=r.params.slidesPerGroup)}else{const t=r.snapGrid[a-1];l-t<=(r.snapGrid[a]-t)*i&&(o-=r.params.slidesPerGroup)}return o=Math.max(o,0),o=Math.min(o,r.slidesGrid.length-1),r.slideTo(o,t,e,n)}function slideToClickedSlide(){const t=this;if(t.destroyed)return;const{params:e,slidesEl:n}=t,i="auto"===e.slidesPerView?t.slidesPerViewDynamic():e.slidesPerView;let r,o=t.clickedIndex;const s=t.isElement?"swiper-slide":`.${e.slideClass}`;if(e.loop){if(t.animating)return;r=parseInt(t.clickedSlide.getAttribute("data-swiper-slide-index"),10),e.centeredSlides?o<t.loopedSlides-i/2||o>t.slides.length-t.loopedSlides+i/2?(t.loopFix(),o=t.getSlideIndex(elementChildren(n,`${s}[data-swiper-slide-index="${r}"]`)[0]),nextTick((()=>{t.slideTo(o)}))):t.slideTo(o):o>t.slides.length-i?(t.loopFix(),o=t.getSlideIndex(elementChildren(n,`${s}[data-swiper-slide-index="${r}"]`)[0]),nextTick((()=>{t.slideTo(o)}))):t.slideTo(o)}else t.slideTo(o)}var slide={slideTo:slideTo,slideToLoop:slideToLoop,slideNext:slideNext,slidePrev:slidePrev,slideReset:slideReset,slideToClosest:slideToClosest,slideToClickedSlide:slideToClickedSlide};function loopCreate(t){const e=this,{params:n,slidesEl:i}=e;if(!n.loop||e.virtual&&e.params.virtual.enabled)return;const r=()=>{elementChildren(i,`.${n.slideClass}, swiper-slide`).forEach(((t,e)=>{t.setAttribute("data-swiper-slide-index",e)}))},o=e.grid&&n.grid&&n.grid.rows>1,s=n.slidesPerGroup*(o?n.grid.rows:1),a=o&&e.slides.length%n.grid.rows!=0,l=t=>{for(let i=0;i<t;i+=1){const t=e.isElement?createElement("swiper-slide",[n.slideBlankClass]):createElement("div",[n.slideClass,n.slideBlankClass]);e.slidesEl.append(t)}};if(e.slides.length%s!=0){if(n.loopAddBlankSlides){l(s-e.slides.length%s),e.recalcSlides(),e.updateSlides()}else showWarning("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)");r()}else if(a){if(n.loopAddBlankSlides){l(n.grid.rows-e.slides.length%n.grid.rows),e.recalcSlides(),e.updateSlides()}else showWarning("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)");r()}else r();e.loopFix({slideRealIndex:t,direction:n.centeredSlides?void 0:"next"})}function loopFix(t){let{slideRealIndex:e,slideTo:n=!0,direction:i,setTranslate:r,activeSlideIndex:o,byController:s,byMousewheel:a}=void 0===t?{}:t;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}=p;if(l.allowSlidePrev=!0,l.allowSlideNext=!0,l.virtual&&p.virtual.enabled)return n&&(p.centeredSlides||0!==l.snapIndex?p.centeredSlides&&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 m=p.slidesPerView;"auto"===m?m=l.slidesPerViewDynamic():(m=Math.ceil(parseFloat(p.slidesPerView,10)),f&&m%2==0&&(m+=1));const g=p.slidesPerGroupAuto?m:p.slidesPerGroup;let _=g;_%g!=0&&(_+=g-_%g),_+=p.loopAdditionalSlides,l.loopedSlides=_;const y=l.grid&&p.grid&&p.grid.rows>1;c.length<m+_?showWarning("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):y&&"row"===p.grid.fill&&showWarning("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const v=[],x=[];let b=l.activeIndex;void 0===o?o=l.getSlideIndex(c.find((t=>t.classList.contains(p.slideActiveClass)))):b=o;const T="next"===i||!i,E="prev"===i||!i;let S=0,w=0;const A=y?Math.ceil(c.length/p.grid.rows):c.length,M=(y?c[o].column:o)+(f&&void 0===r?-m/2+.5:0);if(M<_){S=Math.max(_-M,g);for(let t=0;t<_-M;t+=1){const e=t-Math.floor(t/A)*A;if(y){const t=A-e-1;for(let e=c.length-1;e>=0;e-=1)c[e].column===t&&v.push(e)}else v.push(A-e-1)}}else if(M+m>A-_){w=Math.max(M-(A-2*_),g);for(let t=0;t<w;t+=1){const e=t-Math.floor(t/A)*A;y?c.forEach(((t,n)=>{t.column===e&&x.push(n)})):x.push(e)}}if(l.__preventObserver__=!0,requestAnimationFrame((()=>{l.__preventObserver__=!1})),E&&v.forEach((t=>{c[t].swiperLoopMoveDOM=!0,d.prepend(c[t]),c[t].swiperLoopMoveDOM=!1})),T&&x.forEach((t=>{c[t].swiperLoopMoveDOM=!0,d.append(c[t]),c[t].swiperLoopMoveDOM=!1})),l.recalcSlides(),"auto"===p.slidesPerView?l.updateSlides():y&&(v.length>0&&E||x.length>0&&T)&&l.slides.forEach(((t,e)=>{l.grid.updateSlide(e,t,l.slides)})),p.watchSlidesProgress&&l.updateSlidesOffset(),n)if(v.length>0&&E){if(void 0===e){const t=l.slidesGrid[b+S]-l.slidesGrid[b];a?l.setTranslate(l.translate-t):(l.slideTo(b+Math.ceil(S),0,!1,!0),r&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else if(r){l.slideTo(l.activeIndex+(y?v.length/p.grid.rows:v.length),0,!1,!0),l.touchEventsData.currentTranslate=l.translate}}else if(x.length>0&&T)if(void 0===e){const t=l.slidesGrid[b-w]-l.slidesGrid[b];a?l.setTranslate(l.translate-t):(l.slideTo(b-w,0,!1,!0),r&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else{l.slideTo(l.activeIndex-(y?x.length/p.grid.rows:x.length),0,!1,!0)}if(l.allowSlidePrev=u,l.allowSlideNext=h,l.controller&&l.controller.control&&!s){const t={slideRealIndex:e,direction:i,setTranslate:r,activeSlideIndex:o,byController:!0};Array.isArray(l.controller.control)?l.controller.control.forEach((e=>{!e.destroyed&&e.params.loop&&e.loopFix({...t,slideTo:e.params.slidesPerView===p.slidesPerView&&n})})):l.controller.control instanceof l.constructor&&l.controller.control.params.loop&&l.controller.control.loopFix({...t,slideTo:l.controller.control.params.slidesPerView===p.slidesPerView&&n})}l.emit("loopFix")}function loopDestroy(){const t=this,{params:e,slidesEl:n}=t;if(!e.loop||t.virtual&&t.params.virtual.enabled)return;t.recalcSlides();const i=[];t.slides.forEach((t=>{const e=void 0===t.swiperSlideIndex?1*t.getAttribute("data-swiper-slide-index"):t.swiperSlideIndex;i[e]=t})),t.slides.forEach((t=>{t.removeAttribute("data-swiper-slide-index")})),i.forEach((t=>{n.append(t)})),t.recalcSlides(),t.slideTo(t.realIndex,0)}var loop={loopCreate:loopCreate,loopFix:loopFix,loopDestroy:loopDestroy};function setGrabCursor(t){const e=this;if(!e.params.simulateTouch||e.params.watchOverflow&&e.isLocked||e.params.cssMode)return;const n="container"===e.params.touchEventsTarget?e.el:e.wrapperEl;e.isElement&&(e.__preventObserver__=!0),n.style.cursor="move",n.style.cursor=t?"grabbing":"grab",e.isElement&&requestAnimationFrame((()=>{e.__preventObserver__=!1}))}function unsetGrabCursor(){const t=this;t.params.watchOverflow&&t.isLocked||t.params.cssMode||(t.isElement&&(t.__preventObserver__=!0),t["container"===t.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",t.isElement&&requestAnimationFrame((()=>{t.__preventObserver__=!1})))}var grabCursor={setGrabCursor:setGrabCursor,unsetGrabCursor:unsetGrabCursor};function closestElement(t,e){return void 0===e&&(e=this),function e(n){if(!n||n===getDocument()||n===getWindow())return null;n.assignedSlot&&(n=n.assignedSlot);const i=n.closest(t);return i||n.getRootNode?i||e(n.getRootNode().host):null}(e)}function preventEdgeSwipe(t,e,n){const i=getWindow(),{params:r}=t,o=r.edgeSwipeDetection,s=r.edgeSwipeThreshold;return!o||!(n<=s||n>=i.innerWidth-s)||"prevent"===o&&(e.preventDefault(),!0)}function onTouchStart(t){const e=this,n=getDocument();let i=t;i.originalEvent&&(i=i.originalEvent);const r=e.touchEventsData;if("pointerdown"===i.type){if(null!==r.pointerId&&r.pointerId!==i.pointerId)return;r.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(r.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void preventEdgeSwipe(e,i,i.targetTouches[0].pageX);const{params:o,touches:s,enabled:a}=e;if(!a)return;if(!o.simulateTouch&&"mouse"===i.pointerType)return;if(e.animating&&o.preventInteractionOnTransition)return;!e.animating&&o.cssMode&&o.loop&&e.loopFix();let l=i.target;if("wrapper"===o.touchEventsTarget&&!elementIsChildOf(l,e.wrapperEl))return;if("which"in i&&3===i.which)return;if("button"in i&&i.button>0)return;if(r.isTouched&&r.isMoved)return;const c=!!o.noSwipingClass&&""!==o.noSwipingClass,u=i.composedPath?i.composedPath():i.path;c&&i.target&&i.target.shadowRoot&&u&&(l=u[0]);const h=o.noSwipingSelector?o.noSwipingSelector:`.${o.noSwipingClass}`;if(o.noSwiping&&(!(!i.target||!i.target.shadowRoot)?closestElement(h,l):l.closest(h)))return void(e.allowClick=!0);if(o.swipeHandler&&!l.closest(o.swipeHandler))return;s.currentX=i.pageX,s.currentY=i.pageY;const d=s.currentX,p=s.currentY;if(!preventEdgeSwipe(e,i,d))return;Object.assign(r,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),s.startX=d,s.startY=p,r.touchStartTime=now(),e.allowClick=!0,e.updateSize(),e.swipeDirection=void 0,o.threshold>0&&(r.allowThresholdMove=!1);let f=!0;l.matches(r.focusableElements)&&(f=!1,"SELECT"===l.nodeName&&(r.isTouched=!1)),n.activeElement&&n.activeElement.matches(r.focusableElements)&&n.activeElement!==l&&("mouse"===i.pointerType||"mouse"!==i.pointerType&&!l.matches(r.focusableElements))&&n.activeElement.blur();!o.touchStartForcePreventDefault&&!(f&&e.allowTouchMove&&o.touchStartPreventDefault)||l.isContentEditable||i.preventDefault(),o.freeMode&&o.freeMode.enabled&&e.freeMode&&e.animating&&!o.cssMode&&e.freeMode.onTouchStart(),e.emit("touchStart",i)}function onTouchMove(t){const e=getDocument(),n=this,i=n.touchEventsData,{params:r,touches:o,rtlTranslate:s,enabled:a}=n;if(!a)return;if(!r.simulateTouch&&"mouse"===t.pointerType)return;let l,c=t;if(c.originalEvent&&(c=c.originalEvent),"pointermove"===c.type){if(null!==i.touchId)return;if(c.pointerId!==i.pointerId)return}if("touchmove"===c.type){if(l=[...c.changedTouches].find((t=>t.identifier===i.touchId)),!l||l.identifier!==i.touchId)return}else l=c;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&n.emit("touchMoveOpposite",c));const u=l.pageX,h=l.pageY;if(c.preventedByNestedSwiper)return o.startX=u,void(o.startY=h);if(!n.allowTouchMove)return c.target.matches(i.focusableElements)||(n.allowClick=!1),void(i.isTouched&&(Object.assign(o,{startX:u,startY:h,currentX:u,currentY:h}),i.touchStartTime=now()));if(r.touchReleaseOnEdges&&!r.loop)if(n.isVertical()){if(h<o.startY&&n.translate<=n.maxTranslate()||h>o.startY&&n.translate>=n.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(u<o.startX&&n.translate<=n.maxTranslate()||u>o.startX&&n.translate>=n.minTranslate())return;if(e.activeElement&&e.activeElement.matches(i.focusableElements)&&e.activeElement!==c.target&&"mouse"!==c.pointerType&&e.activeElement.blur(),e.activeElement&&c.target===e.activeElement&&c.target.matches(i.focusableElements))return i.isMoved=!0,void(n.allowClick=!1);i.allowTouchCallbacks&&n.emit("touchMove",c),o.previousX=o.currentX,o.previousY=o.currentY,o.currentX=u,o.currentY=h;const d=o.currentX-o.startX,p=o.currentY-o.startY;if(n.params.threshold&&Math.sqrt(d**2+p**2)<n.params.threshold)return;if(void 0===i.isScrolling){let t;n.isHorizontal()&&o.currentY===o.startY||n.isVertical()&&o.currentX===o.startX?i.isScrolling=!1:d*d+p*p>=25&&(t=180*Math.atan2(Math.abs(p),Math.abs(d))/Math.PI,i.isScrolling=n.isHorizontal()?t>r.touchAngle:90-t>r.touchAngle)}if(i.isScrolling&&n.emit("touchMoveOpposite",c),void 0===i.startMoving&&(o.currentX===o.startX&&o.currentY===o.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===c.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;n.allowClick=!1,!r.cssMode&&c.cancelable&&c.preventDefault(),r.touchMoveStopPropagation&&!r.nested&&c.stopPropagation();let f=n.isHorizontal()?d:p,m=n.isHorizontal()?o.currentX-o.previousX:o.currentY-o.previousY;r.oneWayMovement&&(f=Math.abs(f)*(s?1:-1),m=Math.abs(m)*(s?1:-1)),o.diff=f,f*=r.touchRatio,s&&(f=-f,m=-m);const g=n.touchesDirection;n.swipeDirection=f>0?"prev":"next",n.touchesDirection=m>0?"prev":"next";const _=n.params.loop&&!r.cssMode,y="next"===n.touchesDirection&&n.allowSlideNext||"prev"===n.touchesDirection&&n.allowSlidePrev;if(!i.isMoved){if(_&&y&&n.loopFix({direction:n.swipeDirection}),i.startTranslate=n.getTranslate(),n.setTransition(0),n.animating){const t=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});n.wrapperEl.dispatchEvent(t)}i.allowMomentumBounce=!1,!r.grabCursor||!0!==n.allowSlideNext&&!0!==n.allowSlidePrev||n.setGrabCursor(!0),n.emit("sliderFirstMove",c)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==n.touchesDirection&&_&&y&&Math.abs(f)>=1)return Object.assign(o,{startX:u,startY:h,currentX:u,currentY:h,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);n.emit("sliderMove",c),i.isMoved=!0,i.currentTranslate=f+i.startTranslate;let v=!0,x=r.resistanceRatio;if(r.touchReleaseOnEdges&&(x=0),f>0?(_&&y&&i.allowThresholdMove&&i.currentTranslate>(r.centeredSlides?n.minTranslate()-n.slidesSizesGrid[n.activeIndex+1]-("auto"!==r.slidesPerView&&n.slides.length-r.slidesPerView>=2?n.slidesSizesGrid[n.activeIndex+1]+n.params.spaceBetween:0)-n.params.spaceBetween:n.minTranslate())&&n.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),i.currentTranslate>n.minTranslate()&&(v=!1,r.resistance&&(i.currentTranslate=n.minTranslate()-1+(-n.minTranslate()+i.startTranslate+f)**x))):f<0&&(_&&y&&i.allowThresholdMove&&i.currentTranslate<(r.centeredSlides?n.maxTranslate()+n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween+("auto"!==r.slidesPerView&&n.slides.length-r.slidesPerView>=2?n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween:0):n.maxTranslate())&&n.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:n.slides.length-("auto"===r.slidesPerView?n.slidesPerViewDynamic():Math.ceil(parseFloat(r.slidesPerView,10)))}),i.currentTranslate<n.maxTranslate()&&(v=!1,r.resistance&&(i.currentTranslate=n.maxTranslate()+1-(n.maxTranslate()-i.startTranslate-f)**x))),v&&(c.preventedByNestedSwiper=!0),!n.allowSlideNext&&"next"===n.swipeDirection&&i.currentTranslate<i.startTranslate&&(i.currentTranslate=i.startTranslate),!n.allowSlidePrev&&"prev"===n.swipeDirection&&i.currentTranslate>i.startTranslate&&(i.currentTranslate=i.startTranslate),n.allowSlidePrev||n.allowSlideNext||(i.currentTranslate=i.startTranslate),r.threshold>0){if(!(Math.abs(f)>r.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,o.startX=o.currentX,o.startY=o.currentY,i.currentTranslate=i.startTranslate,void(o.diff=n.isHorizontal()?o.currentX-o.startX:o.currentY-o.startY)}r.followFinger&&!r.cssMode&&((r.freeMode&&r.freeMode.enabled&&n.freeMode||r.watchSlidesProgress)&&(n.updateActiveIndex(),n.updateSlidesClasses()),r.freeMode&&r.freeMode.enabled&&n.freeMode&&n.freeMode.onTouchMove(),n.updateProgress(i.currentTranslate),n.setTranslate(i.currentTranslate))}function onTouchEnd(t){const e=this,n=e.touchEventsData;let i,r=t;r.originalEvent&&(r=r.originalEvent);if("touchend"===r.type||"touchcancel"===r.type){if(i=[...r.changedTouches].find((t=>t.identifier===n.touchId)),!i||i.identifier!==n.touchId)return}else{if(null!==n.touchId)return;if(r.pointerId!==n.pointerId)return;i=r}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(r.type)){if(!(["pointercancel","contextmenu"].includes(r.type)&&(e.browser.isSafari||e.browser.isWebView)))return}n.pointerId=null,n.touchId=null;const{params:o,touches:s,rtlTranslate:a,slidesGrid:l,enabled:c}=e;if(!c)return;if(!o.simulateTouch&&"mouse"===r.pointerType)return;if(n.allowTouchCallbacks&&e.emit("touchEnd",r),n.allowTouchCallbacks=!1,!n.isTouched)return n.isMoved&&o.grabCursor&&e.setGrabCursor(!1),n.isMoved=!1,void(n.startMoving=!1);o.grabCursor&&n.isMoved&&n.isTouched&&(!0===e.allowSlideNext||!0===e.allowSlidePrev)&&e.setGrabCursor(!1);const u=now(),h=u-n.touchStartTime;if(e.allowClick){const t=r.path||r.composedPath&&r.composedPath();e.updateClickedSlide(t&&t[0]||r.target,t),e.emit("tap click",r),h<300&&u-n.lastClickTime<300&&e.emit("doubleTap doubleClick",r)}if(n.lastClickTime=now(),nextTick((()=>{e.destroyed||(e.allowClick=!0)})),!n.isTouched||!n.isMoved||!e.swipeDirection||0===s.diff&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset)return n.isTouched=!1,n.isMoved=!1,void(n.startMoving=!1);let d;if(n.isTouched=!1,n.isMoved=!1,n.startMoving=!1,d=o.followFinger?a?e.translate:-e.translate:-n.currentTranslate,o.cssMode)return;if(o.freeMode&&o.freeMode.enabled)return void e.freeMode.onTouchEnd({currentPos:d});const p=d>=-e.maxTranslate()&&!e.params.loop;let f=0,m=e.slidesSizesGrid[0];for(let t=0;t<l.length;t+=t<o.slidesPerGroupSkip?1:o.slidesPerGroup){const e=t<o.slidesPerGroupSkip-1?1:o.slidesPerGroup;void 0!==l[t+e]?(p||d>=l[t]&&d<l[t+e])&&(f=t,m=l[t+e]-l[t]):(p||d>=l[t])&&(f=t,m=l[l.length-1]-l[l.length-2])}let g=null,_=null;o.rewind&&(e.isBeginning?_=o.virtual&&o.virtual.enabled&&e.virtual?e.virtual.slides.length-1:e.slides.length-1:e.isEnd&&(g=0));const y=(d-l[f])/m,v=f<o.slidesPerGroupSkip-1?1:o.slidesPerGroup;if(h>o.longSwipesMs){if(!o.longSwipes)return void e.slideTo(e.activeIndex);"next"===e.swipeDirection&&e.slideTo(y>=o.longSwipesRatio?o.rewind&&e.isEnd?g:f+v:f),"prev"===e.swipeDirection&&(y>1-o.longSwipesRatio?e.slideTo(f+v):null!==_&&y<0&&Math.abs(y)>o.longSwipesRatio?e.slideTo(_):e.slideTo(f))}else{if(!o.shortSwipes)return void e.slideTo(e.activeIndex);e.navigation&&(r.target===e.navigation.nextEl||r.target===e.navigation.prevEl)?e.slideTo(r.target===e.navigation.nextEl?f+v:f):("next"===e.swipeDirection&&e.slideTo(null!==g?g:f+v),"prev"===e.swipeDirection&&e.slideTo(null!==_?_:f))}}function onResize(){const t=this,{params:e,el:n}=t;if(n&&0===n.offsetWidth)return;e.breakpoints&&t.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:r,snapGrid:o}=t,s=t.virtual&&t.params.virtual.enabled;t.allowSlideNext=!0,t.allowSlidePrev=!0,t.updateSize(),t.updateSlides(),t.updateSlidesClasses();!("auto"===e.slidesPerView||e.slidesPerView>1)||!t.isEnd||t.isBeginning||t.params.centeredSlides||s&&e.loop?t.params.loop&&!s?t.slideToLoop(t.realIndex,0,!1,!0):t.slideTo(t.activeIndex,0,!1,!0):t.slideTo(t.slides.length-1,0,!1,!0),t.autoplay&&t.autoplay.running&&t.autoplay.paused&&(clearTimeout(t.autoplay.resizeTimeout),t.autoplay.resizeTimeout=setTimeout((()=>{t.autoplay&&t.autoplay.running&&t.autoplay.paused&&t.autoplay.resume()}),500)),t.allowSlidePrev=r,t.allowSlideNext=i,t.params.watchOverflow&&o!==t.snapGrid&&t.checkOverflow()}function onClick(t){const e=this;e.enabled&&(e.allowClick||(e.params.preventClicks&&t.preventDefault(),e.params.preventClicksPropagation&&e.animating&&(t.stopPropagation(),t.stopImmediatePropagation())))}function onScroll(){const t=this,{wrapperEl:e,rtlTranslate:n,enabled:i}=t;if(!i)return;let r;t.previousTranslate=t.translate,t.translate=t.isHorizontal()?-e.scrollLeft:-e.scrollTop,0===t.translate&&(t.translate=0),t.updateActiveIndex(),t.updateSlidesClasses();const o=t.maxTranslate()-t.minTranslate();r=0===o?0:(t.translate-t.minTranslate())/o,r!==t.progress&&t.updateProgress(n?-t.translate:t.translate),t.emit("setTranslate",t.translate,!1)}function onLoad(t){const e=this;processLazyPreloader(e,t.target),e.params.cssMode||"auto"!==e.params.slidesPerView&&!e.params.autoHeight||e.update()}function onDocumentTouchStart(){const t=this;t.documentTouchHandlerProceeded||(t.documentTouchHandlerProceeded=!0,t.params.touchReleaseOnEdges&&(t.el.style.touchAction="auto"))}const events=(t,e)=>{const n=getDocument(),{params:i,el:r,wrapperEl:o,device:s}=t,a=!!i.nested,l="on"===e?"addEventListener":"removeEventListener",c=e;r&&"string"!=typeof r&&(n[l]("touchstart",t.onDocumentTouchStart,{passive:!1,capture:a}),r[l]("touchstart",t.onTouchStart,{passive:!1}),r[l]("pointerdown",t.onTouchStart,{passive:!1}),n[l]("touchmove",t.onTouchMove,{passive:!1,capture:a}),n[l]("pointermove",t.onTouchMove,{passive:!1,capture:a}),n[l]("touchend",t.onTouchEnd,{passive:!0}),n[l]("pointerup",t.onTouchEnd,{passive:!0}),n[l]("pointercancel",t.onTouchEnd,{passive:!0}),n[l]("touchcancel",t.onTouchEnd,{passive:!0}),n[l]("pointerout",t.onTouchEnd,{passive:!0}),n[l]("pointerleave",t.onTouchEnd,{passive:!0}),n[l]("contextmenu",t.onTouchEnd,{passive:!0}),(i.preventClicks||i.preventClicksPropagation)&&r[l]("click",t.onClick,!0),i.cssMode&&o[l]("scroll",t.onScroll),t[c](i.updateOnWindowResize?s.ios||s.android?"resize orientationchange observerUpdate":"resize observerUpdate":"observerUpdate",onResize,!0),r[l]("load",t.onLoad,{capture:!0}))};function attachEvents(){const t=this,{params:e}=t;t.onTouchStart=onTouchStart.bind(t),t.onTouchMove=onTouchMove.bind(t),t.onTouchEnd=onTouchEnd.bind(t),t.onDocumentTouchStart=onDocumentTouchStart.bind(t),e.cssMode&&(t.onScroll=onScroll.bind(t)),t.onClick=onClick.bind(t),t.onLoad=onLoad.bind(t),events(t,"on")}function detachEvents(){events(this,"off")}var events$1={attachEvents:attachEvents,detachEvents:detachEvents};const isGridEnabled=(t,e)=>t.grid&&e.grid&&e.grid.rows>1;function setBreakpoint(){const t=this,{realIndex:e,initialized:n,params:i,el:r}=t,o=i.breakpoints;if(!o||o&&0===Object.keys(o).length)return;const s=getDocument(),a="window"!==i.breakpointsBase&&i.breakpointsBase?"container":i.breakpointsBase,l=["window","container"].includes(i.breakpointsBase)||!i.breakpointsBase?t.el:s.querySelector(i.breakpointsBase),c=t.getBreakpoint(o,a,l);if(!c||t.currentBreakpoint===c)return;const u=(c in o?o[c]:void 0)||t.originalParams,h=isGridEnabled(t,i),d=isGridEnabled(t,u),p=t.params.grabCursor,f=u.grabCursor,m=i.enabled;h&&!d?(r.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),t.emitContainerClasses()):!h&&d&&(r.classList.add(`${i.containerModifierClass}grid`),(u.grid.fill&&"column"===u.grid.fill||!u.grid.fill&&"column"===i.grid.fill)&&r.classList.add(`${i.containerModifierClass}grid-column`),t.emitContainerClasses()),p&&!f?t.unsetGrabCursor():!p&&f&&t.setGrabCursor(),["navigation","pagination","scrollbar"].forEach((e=>{if(void 0===u[e])return;const n=i[e]&&i[e].enabled,r=u[e]&&u[e].enabled;n&&!r&&t[e].disable(),!n&&r&&t[e].enable()}));const g=u.direction&&u.direction!==i.direction,_=i.loop&&(u.slidesPerView!==i.slidesPerView||g),y=i.loop;g&&n&&t.changeDirection(),extend$1(t.params,u);const v=t.params.enabled,x=t.params.loop;Object.assign(t,{allowTouchMove:t.params.allowTouchMove,allowSlideNext:t.params.allowSlideNext,allowSlidePrev:t.params.allowSlidePrev}),m&&!v?t.disable():!m&&v&&t.enable(),t.currentBreakpoint=c,t.emit("_beforeBreakpoint",u),n&&(_?(t.loopDestroy(),t.loopCreate(e),t.updateSlides()):!y&&x?(t.loopCreate(e),t.updateSlides()):y&&!x&&t.loopDestroy()),t.emit("breakpoint",u)}function getBreakpoint(t,e,n){if(void 0===e&&(e="window"),!t||"container"===e&&!n)return;let i=!1;const r=getWindow(),o="window"===e?r.innerHeight:n.clientHeight,s=Object.keys(t).map((t=>{if("string"==typeof t&&0===t.indexOf("@")){const e=parseFloat(t.substr(1));return{value:o*e,point:t}}return{value:t,point:t}}));s.sort(((t,e)=>parseInt(t.value,10)-parseInt(e.value,10)));for(let t=0;t<s.length;t+=1){const{point:o,value:a}=s[t];"window"===e?r.matchMedia(`(min-width: ${a}px)`).matches&&(i=o):a<=n.clientWidth&&(i=o)}return i||"max"}var breakpoints={setBreakpoint:setBreakpoint,getBreakpoint:getBreakpoint};function prepareClasses(t,e){const n=[];return t.forEach((t=>{"object"==typeof t?Object.keys(t).forEach((i=>{t[i]&&n.push(e+i)})):"string"==typeof t&&n.push(e+t)})),n}function addClasses(){const t=this,{classNames:e,params:n,rtl:i,el:r,device:o}=t,s=prepareClasses(["initialized",n.direction,{"free-mode":t.params.freeMode&&n.freeMode.enabled},{autoheight:n.autoHeight},{rtl:i},{grid:n.grid&&n.grid.rows>1},{"grid-column":n.grid&&n.grid.rows>1&&"column"===n.grid.fill},{android:o.android},{ios:o.ios},{"css-mode":n.cssMode},{centered:n.cssMode&&n.centeredSlides},{"watch-progress":n.watchSlidesProgress}],n.containerModifierClass);e.push(...s),r.classList.add(...e),t.emitContainerClasses()}function removeClasses(){const{el:t,classNames:e}=this;t&&"string"!=typeof t&&(t.classList.remove(...e),this.emitContainerClasses())}var classes={addClasses:addClasses,removeClasses:removeClasses};function checkOverflow(){const t=this,{isLocked:e,params:n}=t,{slidesOffsetBefore:i}=n;if(i){const e=t.slides.length-1;t.isLocked=t.size>t.slidesGrid[e]+t.slidesSizesGrid[e]+2*i}else t.isLocked=1===t.snapGrid.length;!0===n.allowSlideNext&&(t.allowSlideNext=!t.isLocked),!0===n.allowSlidePrev&&(t.allowSlidePrev=!t.isLocked),e&&e!==t.isLocked&&(t.isEnd=!1),e!==t.isLocked&&t.emit(t.isLocked?"lock":"unlock")}var checkOverflow$1={checkOverflow:checkOverflow},defaults={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,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 moduleExtendParams(t,e){return function(n){void 0===n&&(n={});const i=Object.keys(n)[0],r=n[i];"object"==typeof r&&null!==r?(!0===t[i]&&(t[i]={enabled:!0}),"navigation"===i&&t[i]&&t[i].enabled&&!t[i].prevEl&&!t[i].nextEl&&(t[i].auto=!0),["pagination","scrollbar"].indexOf(i)>=0&&t[i]&&t[i].enabled&&!t[i].el&&(t[i].auto=!0),i in t&&"enabled"in r?("object"!=typeof t[i]||"enabled"in t[i]||(t[i].enabled=!0),t[i]||(t[i]={enabled:!1}),extend$1(e,n)):extend$1(e,n)):extend$1(e,n)}}const prototypes={eventsEmitter:eventsEmitter,update:update,translate:translate,transition:transition,slide:slide,loop:loop,grabCursor:grabCursor,events:events$1,breakpoints:breakpoints,checkOverflow:checkOverflow$1,classes:classes},extendedDefaults={};class Swiper{constructor(){let t,e;for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];1===i.length&&i[0].constructor&&"Object"===Object.prototype.toString.call(i[0]).slice(8,-1)?e=i[0]:[t,e]=i,e||(e={}),e=extend$1({},e),t&&!e.el&&(e.el=t);const o=getDocument();if(e.el&&"string"==typeof e.el&&o.querySelectorAll(e.el).length>1){const t=[];return o.querySelectorAll(e.el).forEach((n=>{const i=extend$1({},e,{el:n});t.push(new Swiper(i))})),t}const s=this;s.__swiper__=!0,s.support=getSupport(),s.device=getDevice({userAgent:e.userAgent}),s.browser=getBrowser(),s.eventsListeners={},s.eventsAnyListeners=[],s.modules=[...s.__modules__],e.modules&&Array.isArray(e.modules)&&s.modules.push(...e.modules);const a={};s.modules.forEach((t=>{t({params:e,swiper:s,extendParams:moduleExtendParams(e,a),on:s.on.bind(s),once:s.once.bind(s),off:s.off.bind(s),emit:s.emit.bind(s)})}));const l=extend$1({},defaults,a);return s.params=extend$1({},l,extendedDefaults,e),s.originalParams=extend$1({},s.params),s.passedParams=extend$1({},e),s.params&&s.params.on&&Object.keys(s.params.on).forEach((t=>{s.on(t,s.params.on[t])})),s.params&&s.params.onAny&&s.onAny(s.params.onAny),Object.assign(s,{enabled:s.params.enabled,el:t,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===s.params.direction,isVertical:()=>"vertical"===s.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:s.params.allowSlideNext,allowSlidePrev:s.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:s.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:s.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),s.emit("_swiper"),s.params.init&&s.init(),s}getDirectionLabel(t){return this.isHorizontal()?t:{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"}[t]}getSlideIndex(t){const{slidesEl:e,params:n}=this,i=elementIndex(elementChildren(e,`.${n.slideClass}, swiper-slide`)[0]);return elementIndex(t)-i}getSlideIndexByData(t){return this.getSlideIndex(this.slides.find((e=>1*e.getAttribute("data-swiper-slide-index")===t)))}recalcSlides(){const{slidesEl:t,params:e}=this;this.slides=elementChildren(t,`.${e.slideClass}, swiper-slide`)}enable(){const t=this;t.enabled||(t.enabled=!0,t.params.grabCursor&&t.setGrabCursor(),t.emit("enable"))}disable(){const t=this;t.enabled&&(t.enabled=!1,t.params.grabCursor&&t.unsetGrabCursor(),t.emit("disable"))}setProgress(t,e){const n=this;t=Math.min(Math.max(t,0),1);const i=n.minTranslate(),r=n.maxTranslate();n.translateTo((r-i)*t+i,void 0===e?0:e),n.updateActiveIndex(),n.updateSlidesClasses()}emitContainerClasses(){const t=this;if(!t.params._emitClasses||!t.el)return;const e=t.el.className.split(" ").filter((e=>0===e.indexOf("swiper")||0===e.indexOf(t.params.containerModifierClass)));t.emit("_containerClasses",e.join(" "))}getSlideClasses(t){const e=this;return e.destroyed?"":t.className.split(" ").filter((t=>0===t.indexOf("swiper-slide")||0===t.indexOf(e.params.slideClass))).join(" ")}emitSlidesClasses(){const t=this;if(!t.params._emitClasses||!t.el)return;const e=[];t.slides.forEach((n=>{const i=t.getSlideClasses(n);e.push({slideEl:n,classNames:i}),t.emit("_slideClass",n,i)})),t.emit("_slideClasses",e)}slidesPerViewDynamic(t,e){void 0===t&&(t="current"),void 0===e&&(e=!1);const{params:n,slides:i,slidesGrid:r,slidesSizesGrid:o,size:s,activeIndex:a}=this;let l=1;if("number"==typeof n.slidesPerView)return n.slidesPerView;if(n.centeredSlides){let t,e=i[a]?Math.ceil(i[a].swiperSlideSize):0;for(let n=a+1;n<i.length;n+=1)i[n]&&!t&&(e+=Math.ceil(i[n].swiperSlideSize),l+=1,e>s&&(t=!0));for(let n=a-1;n>=0;n-=1)i[n]&&!t&&(e+=i[n].swiperSlideSize,l+=1,e>s&&(t=!0))}else if("current"===t)for(let t=a+1;t<i.length;t+=1){(e?r[t]+o[t]-r[a]<s:r[t]-r[a]<s)&&(l+=1)}else for(let t=a-1;t>=0;t-=1){r[a]-r[t]<s&&(l+=1)}return l}update(){const t=this;if(!t||t.destroyed)return;const{snapGrid:e,params:n}=t;function i(){const e=Math.min(Math.max(t.rtlTranslate?-1*t.translate:t.translate,t.maxTranslate()),t.minTranslate());t.setTranslate(e),t.updateActiveIndex(),t.updateSlidesClasses()}let r;if(n.breakpoints&&t.setBreakpoint(),[...t.el.querySelectorAll('[loading="lazy"]')].forEach((e=>{e.complete&&processLazyPreloader(t,e)})),t.updateSize(),t.updateSlides(),t.updateProgress(),t.updateSlidesClasses(),n.freeMode&&n.freeMode.enabled&&!n.cssMode)i(),n.autoHeight&&t.updateAutoHeight();else{if(("auto"===n.slidesPerView||n.slidesPerView>1)&&t.isEnd&&!n.centeredSlides){r=t.slideTo((t.virtual&&n.virtual.enabled?t.virtual.slides:t.slides).length-1,0,!1,!0)}else r=t.slideTo(t.activeIndex,0,!1,!0);r||i()}n.watchOverflow&&e!==t.snapGrid&&t.checkOverflow(),t.emit("update")}changeDirection(t,e){void 0===e&&(e=!0);const n=this,i=n.params.direction;return t||(t="horizontal"===i?"vertical":"horizontal"),t===i||"horizontal"!==t&&"vertical"!==t||(n.el.classList.remove(`${n.params.containerModifierClass}${i}`),n.el.classList.add(`${n.params.containerModifierClass}${t}`),n.emitContainerClasses(),n.params.direction=t,n.slides.forEach((e=>{"vertical"===t?e.style.width="":e.style.height=""})),n.emit("changeDirection"),e&&n.update()),n}changeLanguageDirection(t){const e=this;e.rtl&&"rtl"===t||!e.rtl&&"ltr"===t||(e.rtl="rtl"===t,e.rtlTranslate="horizontal"===e.params.direction&&e.rtl,e.rtl?(e.el.classList.add(`${e.params.containerModifierClass}rtl`),e.el.dir="rtl"):(e.el.classList.remove(`${e.params.containerModifierClass}rtl`),e.el.dir="ltr"),e.update())}mount(t){const e=this;if(e.mounted)return!0;let n=t||e.params.el;if("string"==typeof n&&(n=document.querySelector(n)),!n)return!1;n.swiper=e,n.parentNode&&n.parentNode.host&&n.parentNode.host.nodeName===e.params.swiperElementNodeName.toUpperCase()&&(e.isElement=!0);const i=()=>`.${(e.params.wrapperClass||"").trim().split(" ").join(".")}`;let r=(()=>{if(n&&n.shadowRoot&&n.shadowRoot.querySelector){return n.shadowRoot.querySelector(i())}return elementChildren(n,i())[0]})();return!r&&e.params.createElements&&(r=createElement("div",e.params.wrapperClass),n.append(r),elementChildren(n,`.${e.params.slideClass}`).forEach((t=>{r.append(t)}))),Object.assign(e,{el:n,wrapperEl:r,slidesEl:e.isElement&&!n.parentNode.host.slideSlots?n.parentNode.host:r,hostEl:e.isElement?n.parentNode.host:n,mounted:!0,rtl:"rtl"===n.dir.toLowerCase()||"rtl"===elementStyle(n,"direction"),rtlTranslate:"horizontal"===e.params.direction&&("rtl"===n.dir.toLowerCase()||"rtl"===elementStyle(n,"direction")),wrongRTL:"-webkit-box"===elementStyle(r,"display")}),!0}init(t){const e=this;if(e.initialized)return e;if(!1===e.mount(t))return e;e.emit("beforeInit"),e.params.breakpoints&&e.setBreakpoint(),e.addClasses(),e.updateSize(),e.updateSlides(),e.params.watchOverflow&&e.checkOverflow(),e.params.grabCursor&&e.enabled&&e.setGrabCursor(),e.slideTo(e.params.loop&&e.virtual&&e.params.virtual.enabled?e.params.initialSlide+e.virtual.slidesBefore:e.params.initialSlide,0,e.params.runCallbacksOnInit,!1,!0),e.params.loop&&e.loopCreate(),e.attachEvents();const n=[...e.el.querySelectorAll('[loading="lazy"]')];return e.isElement&&n.push(...e.hostEl.querySelectorAll('[loading="lazy"]')),n.forEach((t=>{t.complete?processLazyPreloader(e,t):t.addEventListener("load",(t=>{processLazyPreloader(e,t.target)}))})),preload(e),e.initialized=!0,preload(e),e.emit("init"),e.emit("afterInit"),e}destroy(t,e){void 0===t&&(t=!0),void 0===e&&(e=!0);const n=this,{params:i,el:r,wrapperEl:o,slides:s}=n;return void 0===n.params||n.destroyed||(n.emit("beforeDestroy"),n.initialized=!1,n.detachEvents(),i.loop&&n.loopDestroy(),e&&(n.removeClasses(),r&&"string"!=typeof r&&r.removeAttribute("style"),o&&o.removeAttribute("style"),s&&s.length&&s.forEach((t=>{t.classList.remove(i.slideVisibleClass,i.slideFullyVisibleClass,i.slideActiveClass,i.slideNextClass,i.slidePrevClass),t.removeAttribute("style"),t.removeAttribute("data-swiper-slide-index")}))),n.emit("destroy"),Object.keys(n.eventsListeners).forEach((t=>{n.off(t)})),!1!==t&&(n.el&&"string"!=typeof n.el&&(n.el.swiper=null),deleteProps(n)),n.destroyed=!0),null}static extendDefaults(t){extend$1(extendedDefaults,t)}static get extendedDefaults(){return extendedDefaults}static get defaults(){return defaults}static installModule(t){Swiper.prototype.__modules__||(Swiper.prototype.__modules__=[]);const e=Swiper.prototype.__modules__;"function"==typeof t&&e.indexOf(t)<0&&e.push(t)}static use(t){return Array.isArray(t)?(t.forEach((t=>Swiper.installModule(t))),Swiper):(Swiper.installModule(t),Swiper)}}function createElementIfNotDefined(t,e,n,i){return t.params.createElements&&Object.keys(i).forEach((r=>{if(!n[r]&&!0===n.auto){let o=elementChildren(t.el,`.${i[r]}`)[0];o||(o=createElement("div",i[r]),o.className=i[r],t.el.append(o)),n[r]=o,e[r]=o}})),n}function classesToSelector(t){return void 0===t&&(t=""),`.${t.trim().replace(/([\.:!+\/])/g,"\\$1").replace(/ /g,".")}`}function Pagination(t){let{swiper:e,extendParams:n,on:i,emit:r}=t;const o="swiper-pagination";let s;n({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:t=>t,formatFractionTotal:t=>t,bulletClass:`${o}-bullet`,bulletActiveClass:`${o}-bullet-active`,modifierClass:`${o}-`,currentClass:`${o}-current`,totalClass:`${o}-total`,hiddenClass:`${o}-hidden`,progressbarFillClass:`${o}-progressbar-fill`,progressbarOppositeClass:`${o}-progressbar-opposite`,clickableClass:`${o}-clickable`,lockClass:`${o}-lock`,horizontalClass:`${o}-horizontal`,verticalClass:`${o}-vertical`,paginationDisabledClass:`${o}-disabled`}}),e.pagination={el:null,bullets:[]};let a=0;function l(){return!e.params.pagination.el||!e.pagination.el||Array.isArray(e.pagination.el)&&0===e.pagination.el.length}function c(t,n){const{bulletActiveClass:i}=e.params.pagination;t&&(t=t[("prev"===n?"previous":"next")+"ElementSibling"])&&(t.classList.add(`${i}-${n}`),(t=t[("prev"===n?"previous":"next")+"ElementSibling"])&&t.classList.add(`${i}-${n}-${n}`))}function u(t){const n=t.target.closest(classesToSelector(e.params.pagination.bulletClass));if(!n)return;t.preventDefault();const i=elementIndex(n)*e.params.slidesPerGroup;if(e.params.loop){if(e.realIndex===i)return;const t=function(t,e,n){return(e%=n)==1+(t%=n)?"next":e===t-1?"previous":void 0}(e.realIndex,i,e.slides.length);"next"===t?e.slideNext():"previous"===t?e.slidePrev():e.slideToLoop(i)}else e.slideTo(i)}function h(){const t=e.rtl,n=e.params.pagination;if(l())return;let i,o,u=e.pagination.el;u=makeElementsArray(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?(o=e.previousRealIndex||0,i=e.params.slidesPerGroup>1?Math.floor(e.realIndex/e.params.slidesPerGroup):e.realIndex):void 0!==e.snapIndex?(i=e.snapIndex,o=e.previousSnapIndex):(o=e.previousIndex||0,i=e.activeIndex||0),"bullets"===n.type&&e.pagination.bullets&&e.pagination.bullets.length>0){const r=e.pagination.bullets;let l,h,d;if(n.dynamicBullets&&(s=elementOuterSize(r[0],e.isHorizontal()?"width":"height"),u.forEach((t=>{t.style[e.isHorizontal()?"width":"height"]=s*(n.dynamicMainBullets+4)+"px"})),n.dynamicMainBullets>1&&void 0!==o&&(a+=i-(o||0),a>n.dynamicMainBullets-1?a=n.dynamicMainBullets-1:a<0&&(a=0)),l=Math.max(i-a,0),h=l+(Math.min(r.length,n.dynamicMainBullets)-1),d=(h+l)/2),r.forEach((t=>{const e=[...["","-next","-next-next","-prev","-prev-prev","-main"].map((t=>`${n.bulletActiveClass}${t}`))].map((t=>"string"==typeof t&&t.includes(" ")?t.split(" "):t)).flat();t.classList.remove(...e)})),u.length>1)r.forEach((t=>{const r=elementIndex(t);r===i?t.classList.add(...n.bulletActiveClass.split(" ")):e.isElement&&t.setAttribute("part","bullet"),n.dynamicBullets&&(r>=l&&r<=h&&t.classList.add(...`${n.bulletActiveClass}-main`.split(" ")),r===l&&c(t,"prev"),r===h&&c(t,"next"))}));else{const t=r[i];if(t&&t.classList.add(...n.bulletActiveClass.split(" ")),e.isElement&&r.forEach(((t,e)=>{t.setAttribute("part",e===i?"bullet-active":"bullet")})),n.dynamicBullets){const t=r[l],e=r[h];for(let t=l;t<=h;t+=1)r[t]&&r[t].classList.add(...`${n.bulletActiveClass}-main`.split(" "));c(t,"prev"),c(e,"next")}}if(n.dynamicBullets){const i=Math.min(r.length,n.dynamicMainBullets+4),o=(s*i-s)/2-d*s,a=t?"right":"left";r.forEach((t=>{t.style[e.isHorizontal()?a:"top"]=`${o}px`}))}}u.forEach(((t,o)=>{if("fraction"===n.type&&(t.querySelectorAll(classesToSelector(n.currentClass)).forEach((t=>{t.textContent=n.formatFractionCurrent(i+1)})),t.querySelectorAll(classesToSelector(n.totalClass)).forEach((t=>{t.textContent=n.formatFractionTotal(h)}))),"progressbar"===n.type){let r;r=n.progressbarOpposite?e.isHorizontal()?"vertical":"horizontal":e.isHorizontal()?"horizontal":"vertical";const o=(i+1)/h;let s=1,a=1;"horizontal"===r?s=o:a=o,t.querySelectorAll(classesToSelector(n.progressbarFillClass)).forEach((t=>{t.style.transform=`translate3d(0,0,0) scaleX(${s}) scaleY(${a})`,t.style.transitionDuration=`${e.params.speed}ms`}))}"custom"===n.type&&n.renderCustom?(t.innerHTML=n.renderCustom(e,i+1,h),0===o&&r("paginationRender",t)):(0===o&&r("paginationRender",t),r("paginationUpdate",t)),e.params.watchOverflow&&e.enabled&&t.classList[e.isLocked?"add":"remove"](n.lockClass)}))}function d(){const t=e.params.pagination;if(l())return;const n=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 i=e.pagination.el;i=makeElementsArray(i);let o="";if("bullets"===t.type){let i=e.params.loop?Math.ceil(n/e.params.slidesPerGroup):e.snapGrid.length;e.params.freeMode&&e.params.freeMode.enabled&&i>n&&(i=n);for(let n=0;n<i;n+=1)o+=t.renderBullet?t.renderBullet.call(e,n,t.bulletClass):`<${t.bulletElement} ${e.isElement?'part="bullet"':""} class="${t.bulletClass}"></${t.bulletElement}>`}"fraction"===t.type&&(o=t.renderFraction?t.renderFraction.call(e,t.currentClass,t.totalClass):`<span class="${t.currentClass}"></span> / <span class="${t.totalClass}"></span>`),"progressbar"===t.type&&(o=t.renderProgressbar?t.renderProgressbar.call(e,t.progressbarFillClass):`<span class="${t.progressbarFillClass}"></span>`),e.pagination.bullets=[],i.forEach((n=>{"custom"!==t.type&&(n.innerHTML=o||""),"bullets"===t.type&&e.pagination.bullets.push(...n.querySelectorAll(classesToSelector(t.bulletClass)))})),"custom"!==t.type&&r("paginationRender",i[0])}function p(){e.params.pagination=createElementIfNotDefined(e,e.originalParams.pagination,e.params.pagination,{el:"swiper-pagination"});const t=e.params.pagination;if(!t.el)return;let n;"string"==typeof t.el&&e.isElement&&(n=e.el.querySelector(t.el)),n||"string"!=typeof t.el||(n=[...document.querySelectorAll(t.el)]),n||(n=t.el),n&&0!==n.length&&(e.params.uniqueNavElements&&"string"==typeof t.el&&Array.isArray(n)&&n.length>1&&(n=[...e.el.querySelectorAll(t.el)],n.length>1&&(n=n.find((t=>elementParents(t,".swiper")[0]===e.el)))),Array.isArray(n)&&1===n.length&&(n=n[0]),Object.assign(e.pagination,{el:n}),n=makeElementsArray(n),n.forEach((n=>{"bullets"===t.type&&t.clickable&&n.classList.add(...(t.clickableClass||"").split(" ")),n.classList.add(t.modifierClass+t.type),n.classList.add(e.isHorizontal()?t.horizontalClass:t.verticalClass),"bullets"===t.type&&t.dynamicBullets&&(n.classList.add(`${t.modifierClass}${t.type}-dynamic`),a=0,t.dynamicMainBullets<1&&(t.dynamicMainBullets=1)),"progressbar"===t.type&&t.progressbarOpposite&&n.classList.add(t.progressbarOppositeClass),t.clickable&&n.addEventListener("click",u),e.enabled||n.classList.add(t.lockClass)})))}function f(){const t=e.params.pagination;if(l())return;let n=e.pagination.el;n&&(n=makeElementsArray(n),n.forEach((n=>{n.classList.remove(t.hiddenClass),n.classList.remove(t.modifierClass+t.type),n.classList.remove(e.isHorizontal()?t.horizontalClass:t.verticalClass),t.clickable&&(n.classList.remove(...(t.clickableClass||"").split(" ")),n.removeEventListener("click",u))}))),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:n}=e.pagination;n=makeElementsArray(n),n.forEach((n=>{n.classList.remove(t.horizontalClass,t.verticalClass),n.classList.add(e.isHorizontal()?t.horizontalClass:t.verticalClass)}))})),i("init",(()=>{!1===e.params.pagination.enabled?m():(p(),d(),h())})),i("activeIndexChange",(()=>{void 0===e.snapIndex&&h()})),i("snapIndexChange",(()=>{h()})),i("snapGridLengthChange",(()=>{d(),h()})),i("destroy",(()=>{f()})),i("enable disable",(()=>{let{el:t}=e.pagination;t&&(t=makeElementsArray(t),t.forEach((t=>t.classList[e.enabled?"remove":"add"](e.params.pagination.lockClass))))})),i("lock unlock",(()=>{h()})),i("click",((t,n)=>{const i=n.target,o=makeElementsArray(e.pagination.el);if(e.params.pagination.el&&e.params.pagination.hideOnClick&&o&&o.length>0&&!i.classList.contains(e.params.pagination.bulletClass)){if(e.navigation&&(e.navigation.nextEl&&i===e.navigation.nextEl||e.navigation.prevEl&&i===e.navigation.prevEl))return;const t=o[0].classList.contains(e.params.pagination.hiddenClass);r(!0===t?"paginationShow":"paginationHide"),o.forEach((t=>t.classList.toggle(e.params.pagination.hiddenClass)))}}));const m=()=>{e.el.classList.add(e.params.pagination.paginationDisabledClass);let{el:t}=e.pagination;t&&(t=makeElementsArray(t),t.forEach((t=>t.classList.add(e.params.pagination.paginationDisabledClass)))),f()};Object.assign(e.pagination,{enable:()=>{e.el.classList.remove(e.params.pagination.paginationDisabledClass);let{el:t}=e.pagination;t&&(t=makeElementsArray(t),t.forEach((t=>t.classList.remove(e.params.pagination.paginationDisabledClass)))),p(),d(),h()},disable:m,render:d,update:h,init:p,destroy:f})}Object.keys(prototypes).forEach((t=>{Object.keys(prototypes[t]).forEach((e=>{Swiper.prototype[e]=prototypes[t][e]}))})),Swiper.use([Resize,Observer]);const MODE_CLASSES=["station-departure","station-to","station-from","station-exits","station-searching","station-routes","station-noroute"];class StationPanel extends Panel{constructor(t){super(Object.assign({className:"station-panel"},t))}addTo(t){const e=this,n=e._options,i=n.object,r=[],o={},s=n.mode||"departure",a=e._departures=[],l=e._exits=[].concat(...i.map((t=>t.exit||[]))),c=t.getPitch(),{lang:u,dict:h,clock:d}=t,p=d.getJSTDate(),f=p.getMonth()+1,m=p.getDate(),g=p.getHours(),_=p.getMinutes();for(const e of i){const n=t.getLocalizedStationTitle(e),i=e.railway.id;includes(r,n)||r.push(n),o[i]||(o[i]=[]),includes(o[i],n)||o[i].push(n)}for(const e of i){const{railway:n,alternate:i,ascending:r,descending:s}=e,{stations:l,ascending:c,descending:u,color:h}=n;for(const{direction:d,altDirection:p}of[{direction:c,altDirection:r},{direction:u,altDirection:s}])if(null!==p)if(i){for(const{railways:t}of a)if(t[0].station===i&&t[0].direction===p){t.push({railway:n,station:e,direction:d});break}}else{let i;if(l[0]!==l[l.length-1])for(let t=0,e=l.length;t<e;t++){const n=l[d===c?e-1-t:t];if(!n.alternate){i=n;break}}e!==i&&a.push({railways:[{railway:n,station:e,direction:d}],color:h,label:[t.getLocalizedRailwayTitle(n),o[n.id].length>1?`(${t.getLocalizedStationTitle(e)})`:"",t.getLocalizedRailDirectionTitle(p||d)].join(" ")})}}super.addTo(t).setTitle(['<div id="station-title-name">',`<div>${r.join(h.and)}</div>`,'<div class="station-content-selector">',"<span>",'<input id="station-departure-button" type="radio" name="station">',`<label for="station-departure-button">${h.departures}</label>`,"</span>","<span>",'<input id="station-to-button" type="radio" name="station">',`<label for="station-to-button">${h["to-here"]}</label>`,"</span>","<span>",'<input id="station-from-button" type="radio" name="station">',`<label for="station-from-button">${h["from-here"]}</label>`,"</span>",l.length?["<span>",'<input id="station-exits-button" type="radio" name="station">',`<label for="station-exits-button">${h.exits}</label>`,"</span>"].join(""):"","</div>","</div>",`<div id="station-title-searching">${h["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">${h["from-station"]} <input id="origin" class="search-input search-focus" type="text" list="stations" placeholder="${h["enter-station-name"]}"></div>`,'<div class="search-form-element">','<select id="to-type" class="search-select">',`<option value="departure" selected>${h["depart-at"]}</option>`,"</select>",'<select id="to-month" class="search-select">',`<option value="${f}" selected>${p.toLocaleDateString(u,{month:"short"})}</option>`,"</select>",'<select id="to-date" class="search-select">',`<option value="${m}" selected>${p.toLocaleDateString(u,{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>${h["search-route"]}</button></div>`,"</div>",'<div id="station-from">',`<div class="search-form-element">${h["to-station"]} <input id="destination" class="search-input search-focus" type="text" list="stations" placeholder="${h["enter-station-name"]}"></div>`,'<div class="search-form-element">','<select id="from-type" class="search-select">',`<option value="departure" selected>${h["depart-at"]}</option>`,"</select>",'<select id="from-month" class="search-select">',`<option value="${f}" selected>${p.toLocaleDateString(u,{month:"short"})}</option>`,"</select>",'<select id="from-date" class="search-select">',`<option value="${m}" selected>${p.toLocaleDateString(u,{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>${h["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">${h["cannot-find-train"]}</div>`].join(""));const y=e._container,v=y.querySelector("#origin"),x=y.querySelector("#destination");y.classList.add(`station-${s}`),y.querySelector(`#station-${s}-button`).checked=!0;for(const e of["station-departure","station-to","station-from","station-exits"]){const n=y.querySelector(`#${e}-button`);n&&n.addEventListener("click",(()=>{const n=y.classList;n.contains(e)||(n.remove(...MODE_CLASSES),n.add(e),"station-to"===e?v.focus():"station-from"===e&&x.focus(),"station-exits"!==e?(t.hideStationExits(),t.map.flyTo({center:t.lastCameraParams.center,zoom:15.5,pitch:c})):t.showStationExits(i),t._setSearchMode(includes(["station-to","station-from"],e)?"edit":"none"))}))}e.updateContent();for(const n of["to","from"]){const r=y.querySelector(`#${n}-hours`),o=y.querySelector(`#${n}-minutes`),s="to"===n?v:x,a=y.querySelector(`#${n}-search-button`);for(let t=0;t<24;t++)p.setHours(t),createElement$1("option",{value:t,text:p.toLocaleTimeString(u,{hour:"numeric"}),selected:t===g},r);for(let t=0;t<60;t++)p.setMinutes(t),createElement$1("option",{value:t,text:`${p.toLocaleTimeString(u,{minute:"numeric"})}${h.minute}`,selected:t===_},o);s.addEventListener("input",(()=>{const e=t.stationTitleLookup.get(s.value.toUpperCase());a.disabled=!e||includes(i,e)})),a.addEventListener("click",(()=>{const s=y.classList,a=t.stationTitleLookup,l="to"===n?a.get(v.value.toUpperCase()):i[0],c="from"===n?a.get(x.value.toUpperCase()):i[0],u=y.querySelector(`#${n}-type`).value,h=y.querySelector(`#${n}-month`).value,d=y.querySelector(`#${n}-date`).value,p=r.value,f=o.value;s.remove(...MODE_CLASSES),s.add("station-searching"),e.setButtons([e._backButton]),loadJSON(`${configs.searchUrl}?origin=${l.id}&destination=${c.id}&type=${u}&month=${h}&date=${d}&hours=${p}&minutes=${f}`).then((t=>{const n=y.classList;n.contains("station-searching")&&(n.remove(...MODE_CLASSES),e.showResult(t))}))}))}e.popups=[];const b=e._backButton=createElement$1("div",{innerHTML:['<button id="back-button" class="back-button">','<span class="back-icon"></span>',"</button>"].join("")});return b.addEventListener("click",(t=>{t.stopPropagation()})),b.querySelector("#back-button").addEventListener("click",(()=>{const n=e._swiper,i=y.classList;n&&(n.destroy(),delete e._swiper,e.hideRoute()),i.remove(...MODE_CLASSES),y.querySelector("#station-to-button").checked?(i.add("station-to"),v.focus()):(i.add("station-from"),x.focus()),e.setButtons(),t.map.flyTo({center:t.lastCameraParams.center,zoom:15.5}),t._setSearchMode("edit")})),e}reset(){const t=this,{_map:e,_container:n,_swiper:i}=t,r=t._container.classList;i&&(i.destroy(),delete t._swiper,t.hideRoute()),r.remove(...MODE_CLASSES),r.add("station-departure"),n.querySelector(":checked").checked=!1,n.querySelector("#station-departure-button").checked=!0,t.setButtons(),e.hideStationExits(),e.map.flyTo({center:e.lastCameraParams.center,zoom:15.5}),e._setSearchMode("none")}updateContent(){const t=this,{_map:e,_container:n,_exits:i}=t,{dict:r,clock:o,container:s}=e,a=o.getTimeOffset(),l=o.getCalendar(),c=n.querySelector("#station-exits");if(t.isOpen()){for(const n of t._departures){const t=[];for(const{railway:i,station:r,direction:o}of n.railways)for(const n of e.timetables.getByDirectionId(i.id,o.id)){const i=e.activeTrainLookup.get(n.t)||e.standbyTrainLookup.get(n.id),o=i&&i.delay||0,s=n.stations;if(!(n.end+o<=a))for(let e=0,l=s.length-1;e<l;e++)if(s[e]===r){const r=n.departureTimes[e]+o;r>a&&(0===t.length||r<t[0].time?(t.unshift({train:i||n,time:r}),t.splice(2,1)):(1===t.length||r<t[1].time)&&t.splice(1,1,{train:i||n,time:r}));break}}n.trains=t}n.querySelector("#station-departure").innerHTML=t._departures.map((({color:t,label:n,trains:i})=>['<div class="direction-row">',`<div class="line-strip" style="background-color: ${t};"></div>`,`<div class="direction-label">${n}</div>`,"</div>",'<div class="trains-row">',i.length?i.map((({train:t,time:n})=>['<div class="train-row">',`<div class="train-time-box${t.delay>=6e4?" desc-caution":""}">${getTimeString(n)}</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),t.delay>=6e4?` <span class="desc-caution">${r.delay.replace("$1",Math.floor(t.delay/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(((t,e)=>!e.calendar||includes(e.calendar,l)?e:t),{}),o=createElement$1("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?` (${getTimeString(r.open)}-${getTimeString(r.close)})`:"","</div>",(n.facilities||[]).map((t=>`<div class="exit-${t}-icon"></div>`)).join(""),'<div class="exit-share-button"></div>'].join("")},c);o.addEventListener("click",(()=>{e.map.flyTo({center:n.coord,zoom:19,pitch:30})})),o.addEventListener("mouseenter",(()=>{const e=s.querySelector(`#exit-${t}`);e&&e.classList.add("highlighted")})),o.addEventListener("mouseleave",(()=>{const e=s.querySelector(`#exit-${t}`);e&&e.classList.remove("highlighted")}))}}}fillStationName(t){const e=this._container,n=e.classList;if(n.contains("station-to")){const n=e.querySelector("#origin");n.value=t,n.dispatchEvent(new Event("input")),n.focus()}else if(n.contains("station-from")){const n=e.querySelector("#destination");n.value=t,n.dispatchEvent(new Event("input")),n.focus()}}showResult(t){const e=this,{_map:n,_container:i,_backButton:r}=e,o=n.dict,s=i.classList,a=createElement$1("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=i.querySelector(".swiper-wrapper"),c=t.routes;if(e._result=t,n._setSearchMode("route"),a.addEventListener("click",(t=>{t.stopPropagation()})),a.querySelector("#previous-button").addEventListener("click",(()=>{e._swiper.slidePrev()})),a.querySelector("#next-button").addEventListener("click",(()=>{e._swiper.slideNext()})),l.innerHTML="",c){s.add("station-routes"),e.setButtons([r,a]);for(const t of c){const e=createElement$1("div",{className:"swiper-slide",innerHTML:['<div class="swiper-slide-content">','<div id="search-routes"></div>','<svg id="railway-mark"></svg>',"</div>"].join("")},l),i=e.querySelector("#search-routes"),r=e.querySelector("#railway-mark"),s=[],a=[],c=[];let u;for(const{r:e,y:i,ds:r,d:l,tt:c,nm:h,transfer:d,delay:p}of t.trains){const t=c[0],f=c[c.length-1],m=n.getLocalizedTrainNameOrRailwayTitle(h,n.railways.get(e)),g=n.getLocalizedTrainTypeTitle(n.trainTypes.get(i)),_=n.getLocalizedDestinationTitle(r?r.map((t=>n.stations.get(t))):void 0,n.railDirections.get(l)),y={};if(y.start=a.length,a.push(['<div class="station-row">',`<div class="station-title-box">${n.getLocalizedStationTitle(n.stations.get(t.s))}</div>`,`<div class="station-time-box${p?" desc-caution":""}">`,void 0!==u?`${getTimeString(u+6e4*p)}<br>`:"",getTimeString(getTimeOffset(t.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">${o.delay.replace("$1",p)}</span>`:"","</div></div>"].join("")),y.end=a.length,y.color=n.railways.get(e).color,s.push(y),0===d)u=getTimeOffset(f.a);else{if(a.push(['<div class="station-row">',`<div class="station-title-box">${n.getLocalizedStationTitle(n.stations.get(f.s))}</div>`,`<div class="station-time-box${p?" desc-caution":""}">`,getTimeString(getTimeOffset(f.a||f.d)+6e4*p),"</div></div>"].join("")),d>0){const t={};t.start=a.length-1,a.push(['<div class="station-row">',`<div class="train-title-box">${o["transfer-and-wait"].replace("$1",d)}</div>`,"</div>"].join("")),t.end=a.length,s.push(t)}u=void 0}}i.innerHTML=a.join("");for(const t of i.children)c.push(t.offsetTop+t.getBoundingClientRect().height/2);r.innerHTML=s.map((({color:t,start:e,end:n})=>t?`<line stroke="${t}" stroke-width="10" x1="12" y1="${c[e]}" x2="12" y2="${c[n]}" stroke-linecap="round" />`:`<line stroke="#7f7f7f" stroke-width="4" x1="12" y1="${c[e]}" x2="12" y2="${c[n]}" stroke-dasharray="4 4" />`)).concat(c.map(((t,e)=>e%2==0?`<circle cx="12" cy="${t}" r="3" fill="#ffffff" />`:""))).join("")}e._swiper=new Swiper(".swiper",{modules:[Pagination],pagination:{el:".swiper-pagination",clickable:!0}}),e._swiper.on("slideChange",(()=>{e.hideRoute()})),e._swiper.on("slideChangeTransitionEnd",(()=>{e.switchRoute()})),e.switchRoute()}else s.add("station-noroute"),e.setButtons([r]),l.innerHTML=['<div class="swiper-slide">','<div class="swiper-slide-content">',o["cannot-find-train"],"</div></div>"].join("")}switchRoute(){const t=this,{_map:e,_container:n,_swiper:i}=t,{dict:r,map:o,featureCollection:s}=e,a=i.activeIndex,l=t._result.routes[a],c=l.trains,u=[],h=[],d=[];n.querySelector("#station-title-routes").innerHTML=[`${r.route}${a+1} `,r.transfers.replace("$1",l.numTransfers)].join(""),n.querySelector("#previous-button").disabled=i.isBeginning,n.querySelector("#next-button").disabled=i.isEnd;for(const{r:t,tt:n,d:i}of c){const{stations:r,ascending:o}=e.railways.get(t),s=r.map((({id:t})=>t)),a=n[0].s,l=n[n.length-1].s;for(const t of n){const n=e.stations.get(t.s);h.push(n.group),d.push(n.coord)}if(i===o.id){const e=s.indexOf(a),n=s.indexOf(l,e);for(let i=e;i<n;i++)u.push(`${t}.${i+1}`)}else{const e=s.lastIndexOf(a),n=s.lastIndexOf(l,e);for(let i=e;i>n;i--)u.push(`${t}.${i}`)}}for(const t of[13,14,15,16,17,18])o.getLayer(`railways-routeug-${t}`).implementation.setProps({data:featureFilter(s,(e=>e.zoom===t&&e.altitude<0&&includes(u,e.section)))}),o.getLayer(`stations-routeug-${t}`).implementation.setProps({data:featureFilter(s,(e=>e.zoom===t&&e.altitude<0&&includes(h,e.group)))}),o.getLayer(`railways-routeog-${t}`).implementation.setProps({data:featureFilter(s,(e=>e.zoom===t&&0===e.altitude&&includes(u,e.section)))}),o.getLayer(`stations-routeog-${t}`).implementation.setProps({data:featureFilter(s,(e=>e.zoom===t&&0===e.altitude&&includes(h,e.group)))});o.fitBounds(getBounds$1(d),{bearing:o.getBearing(),pitch:o.getPitch(),offset:[0,-o.transform.height/12],padding:{top:20,bottom:20,left:10,right:50},linear:!0,maxZoom:18}),e.refreshMap();const p=[c[0].tt[0].s];for(const t of c)(t.transfer>0||t===c[c.length-1])&&p.push(t.tt[t.tt.length-1].s);t.popups=p.map(((n,i)=>setTimeout((()=>{const s=new Popup$1({className:"popup-route",closeButton:!1,closeOnClick:!1});s.setLngLat(e.stations.get(n).coord).setHTML(0===i?r["from-station"]:i===p.length-1?r["to-station"]:`${r.transfer}${i}`).addTo(o),t.popups[i]=s}),i/p.length*1e3+500)))}hideRoute(){const t=this,e=t._map.map;for(const t of[13,14,15,16,17,18])for(const n of["routeug","routeog"])for(const i of["railways","stations"])setLayerProps(e,`${i}-${n}-${t}`,{data:emptyFeatureCollection()});for(const e of t.popups)e instanceof Popup$1?e.remove():clearTimeout(e)}remove(){return this.hideRoute(),super.remove()}}const trackingModes=["position","back","topback","front","topfront","helicopter","drone","bird"];class TrackingModePanel extends Panel{constructor(t){super(Object.assign({className:"tracking-mode-panel",modal:!0},t));const e=this;e._onModeChanged=t=>{const n=e._container,i=t.mode.replace("heading","topback");n.querySelector(".tracking-mode-icon-enabled").classList.remove("tracking-mode-icon-enabled"),n.querySelector(`#${i}-tracking-mode .tracking-mode-icon`).classList.add("tracking-mode-icon-enabled")}}addTo(t){const e=this,n=t.dict,i=t.getTrackingMode();super.addTo(t).setTitle(n["tracking-modes"]).setHTML(trackingModes.map((t=>[`<div id="${t}-tracking-mode" class="tracking-mode-row">`,'<div class="tracking-mode-icon"></div>',`<div>${n[t]}</div>`,"</div>"].join(""))).join(""));for(const n of trackingModes){const r=e._container.querySelector(`#${n}-tracking-mode .tracking-mode-icon`);(n===i||"topback"===n&&"heading"===i)&&r.classList.add("tracking-mode-icon-enabled"),r.addEventListener("click",(()=>{t.getTrackingMode()!==n&&t.setTrackingMode(n)}))}return t.on("trackingmode",e._onModeChanged),e}remove(){return this._map.off("trackingmode",this._onModeChanged),super.remove()}}class TrainPanel extends Panel{constructor(t){super(Object.assign({className:"train-panel"},t))}addTo(t){const e=this,n=[],i=[],r=[],o=[],s=e._options.object,{r:a,timetable:l}=s,c=(s.v||a).color,u=s.delay||0;let h;for(let t=l;t;t=t.pt&&t.pt[0])n.unshift(t);for(let t=l.nt&&l.nt[0];t;t=t.nt&&t.nt[0])n.push(t);for(const e of n){const n={},o=e.stations;n.start=Math.max(r.length-1,0);for(let n=0,i=o.length;n<i;n++)if(n>0||!e.pt){const i=e.arrivalTimes[n],s=e.departureTimes[n];r.push(['<div class="station-row">',`<div class="station-title-box">${t.getLocalizedStationTitle(o[n])}</div>`,'<div class="station-time-box',u>=6e4?" desc-caution":"",'">',void 0!==i?getTimeString(i+u):"",void 0!==i&&void 0!==s?"<br>":"",void 0!==s?getTimeString(s+u):"","</div></div>"].join(""))}n.end=r.length-1,n.color=e.r.color,i.push(n),e===l&&(h=n)}super.addTo(t).setTitle(['<div class="desc-header">',Array.isArray(c)?["<div>",...c.slice(0,3).map((t=>`<div class="line-strip-long" style="background-color: ${t};"></div>`)),"</div>"].join(""):`<div style="background-color: ${c};"></div>`,'<div><div class="desc-first-row">',t.getLocalizedTrainNameOrRailwayTitle(s.nm,a),'</div><div class="desc-second-row">',`<span class="train-type-label">${t.getLocalizedTrainTypeTitle(s.y)}</span> `,t.getLocalizedDestinationTitle(s.ds,s.d),"</div></div></div>"].join("")).setHTML(['<div id="timetable-content">',...r,"</div>",'<svg id="railway-mark"></svg>','<svg id="train-mark"></svg>'].join(""));const d=e._container,p=d.querySelector("#panel-body");for(const t of d.querySelector("#timetable-content").children)o.push(t.offsetTop+t.getBoundingClientRect().height/2);d.querySelector("#railway-mark").innerHTML=i.map((({color:t,start:e,end:n})=>`<line stroke="${t}" stroke-width="10" x1="12" y1="${o[e]}" x2="12" y2="${o[n]}" stroke-linecap="round" />`)).concat(o.map((t=>`<circle cx="12" cy="${t}" r="3" fill="#ffffff" />`))).join("");const f=o.slice(h.start,h.end+1);return function t(){const n=p.getBoundingClientRect().height,i=s.timetableIndex,r=f[i],o=lerp$5(r,s.arrivalStation?f[i+1]:r,s._t),a=performance.now()%1500/1500;d.querySelector("#train-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!==e._scrollTop&&e._scrollTop!==p.scrollTop||(e._scrollTop=p.scrollTop=Math.round(o-n/2+4)),e._container&&requestAnimationFrame(t)}(),e}reset(){delete this._scrollTop}}class Plugin{constructor(t){const e=this;e.implementation=t,e.enabled=!1,e.clockModes=t.clockModes||["realtime","playback"],e.viewModes=t.viewModes||["ground","underground"],e.searchModes=t.searchModes||["none"],e._onModeChanged=()=>{e.setVisibility(!0)}}addTo(t){const e=this,n=e.implementation;return e.map=t,n.onAdd&&n.onAdd(t),valueOrDefault(n.enabled,!0)&&e.enable(),e}remove(){const t=this,e=t.implementation;return t.disable(),e.onRemove&&e.onRemove(t.map),delete t.map,t}enable(){const t=this,{map:e,_onModeChanged:n,implementation:i}=t;return t.enabled||(t.enabled=!0,e.on("clockmode",n),e.on("viewmode",n),i.onEnabled&&i.onEnabled(),t.setVisibility(!0)),t}disable(){const t=this,{map:e,_onModeChanged:n,implementation:i}=t;return t.enabled&&(t.enabled=!1,e.off("clockmode",n),e.off("viewmode",n),t.setVisibility(!1),i.onDisabled&&i.onDisabled()),t}setVisibility(t){const e=this,{map:n,implementation:i}=e;i.onVisibilityChanged&&i.onVisibilityChanged(t&&e.enabled&&includes(e.clockModes,n.getClockMode())&&includes(e.viewModes,n.getViewMode())&&includes(e.searchModes,n.searchMode))}getId(){return this.implementation.id}getName(t){const e=this.implementation.name;return e[t]||e.en}getIconStyle(){return this.implementation.iconStyle}isEnabled(){return this.enabled}}function destination(t,e,n,i){if(!isObject$5(i=i||{}))throw new Error("options is invalid");var r=i.units,o=i.properties,s=getCoord(t),a=degreesToRadians(s[0]),l=degreesToRadians(s[1]),c=degreesToRadians(n),u=lengthToRadians(e,r),h=Math.asin(Math.sin(l)*Math.cos(u)+Math.cos(l)*Math.sin(u)*Math.cos(c));return point([radiansToDegrees(a+Math.atan2(Math.sin(c)*Math.sin(u)*Math.cos(l),Math.cos(u)-Math.sin(l)*Math.sin(h))),radiansToDegrees(h)],o)}function quickselect(t,e,n,i,r){quickselectStep(t,e,n||0,i||t.length-1,r||defaultCompare)}function quickselectStep(t,e,n,i,r){for(;i>n;){if(i-n>600){var o=i-n+1,s=e-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);quickselectStep(t,e,Math.max(n,Math.floor(e-s*l/o+c)),Math.min(i,Math.floor(e+(o-s)*l/o+c)),r)}var u=t[e],h=n,d=i;for(swap(t,n,e),r(t[i],u)>0&&swap(t,n,i);h<d;){for(swap(t,h,d),h++,d--;r(t[h],u)<0;)h++;for(;r(t[d],u)>0;)d--}0===r(t[n],u)?swap(t,n,d):swap(t,++d,i),d<=e&&(n=d+1),e<=d&&(i=d-1)}}function swap(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function defaultCompare(t,e){return t<e?-1:t>e?1:0}function rbush(t,e){if(!(this instanceof rbush))return new rbush(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function findItem(t,e,n){if(!n)return e.indexOf(t);for(var i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function calcBBox(t,e){distBBox(t,0,t.children.length,e,t)}function distBBox(t,e,n,i,r){r||(r=createNode(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var o,s=e;s<n;s++)o=t.children[s],extend(r,t.leaf?i(o):o);return r}function extend(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function compareNodeMinX(t,e){return t.minX-e.minX}function compareNodeMinY(t,e){return t.minY-e.minY}function bboxArea(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function bboxMargin(t){return t.maxX-t.minX+(t.maxY-t.minY)}function enlargedArea(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function intersectionArea(t,e){var n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,o-i)}function contains(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function intersects$1(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function createNode(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function multiSelect(t,e,n,i,r){for(var o,s=[e,n];s.length;)(n=s.pop())-(e=s.pop())<=i||(quickselect(t,o=e+Math.ceil((n-e)/i/2)*i,e,n,r),s.push(e,o,o,n))}function geojsonRbush(t){var e=rbush(t);return e.insert=function(t){if(Array.isArray(t)){var e=t;(t=bboxPolygon(e)).bbox=e}else t.bbox=t.bbox?t.bbox:turfBBox(t);return rbush.prototype.insert.call(this,t)},e.load=function(t){var e=[];return Array.isArray(t)?t.forEach((function(t){var n=bboxPolygon(t);n.bbox=t,e.push(n)})):featureEach(t,(function(t){t.bbox=t.bbox?t.bbox:turfBBox(t),e.push(t)})),rbush.prototype.load.call(this,e)},e.remove=function(t){if(Array.isArray(t)){var e=t;(t=bboxPolygon(e)).bbox=e}return rbush.prototype.remove.call(this,t)},e.clear=function(){return rbush.prototype.clear.call(this)},e.search=function(t){return{type:"FeatureCollection",features:rbush.prototype.search.call(this,this.toBBox(t))}},e.collides=function(t){return rbush.prototype.collides.call(this,this.toBBox(t))},e.all=function(){return{type:"FeatureCollection",features:rbush.prototype.all.call(this)}},e.toJSON=function(){return rbush.prototype.toJSON.call(this)},e.fromJSON=function(t){return rbush.prototype.fromJSON.call(this,t)},e.toBBox=function(t){var e;return{minX:(e=t.bbox?t.bbox:Array.isArray(t)&&4===t.length?t:turfBBox(t))[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}function bboxPolygon(t){var e=[t[0],t[1]];return{type:"Feature",bbox:t,properties:{},geometry:{type:"Polygon",coordinates:[[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]]}}}function turfBBox(t){var e=[1/0,1/0,-1/0,-1/0];return coordEach(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}function lineSegment(t){if(!t)throw new Error("geojson is required");var e=[];return flattenEach(t,(function(t){lineSegmentFeature(t,e)})),featureCollection(e)}function lineSegmentFeature(t,e){var n=[],i=t.geometry;switch(i.type){case"Polygon":n=getCoords(i);break;case"LineString":n=[getCoords(i)]}n.forEach((function(n){createSegments(n,t.properties).forEach((function(t){t.id=e.length,e.push(t)}))}))}function createSegments(t,e){var n=[];return t.reduce((function(t,i){var r=lineString([t,i],e);return r.bbox=bbox(t,i),n.push(r),i})),n}function bbox(t,e){var n=t[0],i=t[1],r=e[0],o=e[1];return[n<r?n:r,i<o?i:o,n>r?n:r,i>o?i:o]}function lineIntersect(t,e){var n={},i=[];if("LineString"===t.type&&(t=feature(t)),"LineString"===e.type&&(e=feature(e)),"Feature"===t.type&&"Feature"===e.type&&"LineString"===t.geometry.type&&"LineString"===e.geometry.type&&2===t.geometry.coordinates.length&&2===e.geometry.coordinates.length){var r=intersects(t,e);return r&&i.push(r),featureCollection(i)}var o=geojsonRbush();return o.load(lineSegment(e)),featureEach(lineSegment(t),(function(t){featureEach(o.search(t),(function(e){var r=intersects(t,e);if(r){var o=getCoords(r).join(",");n[o]||(n[o]=!0,i.push(r))}}))})),featureCollection(i)}function intersects(t,e){var n=getCoords(t),i=getCoords(e);if(2!==n.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==i.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var r=n[0][0],o=n[0][1],s=n[1][0],a=n[1][1],l=i[0][0],c=i[0][1],u=i[1][0],h=i[1][1],d=(h-c)*(s-r)-(u-l)*(a-o),p=(u-l)*(o-c)-(h-c)*(r-l),f=(s-r)*(o-c)-(a-o)*(r-l);if(0===d)return null;var m=p/d,g=f/d;return m>=0&&m<=1&&g>=0&&g<=1?point([r+m*(s-r),o+m*(a-o)]):null}function nearestCloserPointOnLine(t,e,n,i){if(!isObject$5(i=i||{}))throw new Error("options is invalid");const r=t.geometry?t.geometry.type:t.type;if("LineString"!==r&&"MultiLineString"!==r)throw new Error("lines must be LineString or MultiLineString");let o=point([1/0,1/0],{dist:1/0,score:1/0}),s=0;return flattenEach(t,(t=>{const r=getCoords(t);for(let t=0;t<r.length-1;t++){const a=point(r[t]);a.properties.dist=distance$1(e,a,i),a.properties.score=a.properties.dist+Math.abs(s-n)/100;const l=point(r[t+1]);l.properties.dist=distance$1(e,l,i);const c=distance$1(a,l,i);l.properties.score=l.properties.dist+Math.abs(s+c-n)/100;const u=Math.max(a.properties.dist,l.properties.dist),h=bearing(a,l),d=destination(e,u,h+90,i),p=destination(e,u,h-90,i),f=lineIntersect(lineString([d.geometry.coordinates,p.geometry.coordinates]),lineString([a.geometry.coordinates,l.geometry.coordinates]));let m=null;f.features.length>0&&(m=f.features[0],m.properties.dist=distance$1(e,m,i),m.properties.location=s+distance$1(a,m,i),m.properties.score=m.properties.dist+Math.abs(m.properties.location-n)/100),a.properties.score<o.properties.score&&(o=a,o.properties.index=t,o.properties.location=s),l.properties.score<o.properties.score&&(o=l,o.properties.index=t+1,o.properties.location=s+c),m&&m.properties.score<o.properties.score&&(o=m,o.properties.index=t),s+=c}})),o}rbush.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,n=[],i=this.toBBox;if(!intersects$1(t,e))return n;for(var r,o,s,a,l=[];e;){for(r=0,o=e.children.length;r<o;r++)s=e.children[r],intersects$1(t,a=e.leaf?i(s):s)&&(e.leaf?n.push(s):contains(t,a)?this._all(s,n):l.push(s));e=l.pop()}return n},collides:function(t){var e=this.data,n=this.toBBox;if(!intersects$1(t,e))return!1;for(var i,r,o,s,a=[];e;){for(i=0,r=e.children.length;i<r;i++)if(o=e.children[i],intersects$1(t,s=e.leaf?n(o):o)){if(e.leaf||contains(t,s))return!0;a.push(o)}e=a.pop()}return!1},load:function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0,n=t.length;e<n;e++)this.insert(t[e]);return this}var i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var r=this.data;this.data=i,i=r}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},insert:function(t){return t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=createNode([]),this},remove:function(t,e){if(!t)return this;for(var n,i,r,o,s=this.data,a=this.toBBox(t),l=[],c=[];s||l.length;){if(s||(s=l.pop(),i=l[l.length-1],n=c.pop(),o=!0),s.leaf&&-1!==(r=findItem(t,s.children,e)))return s.children.splice(r,1),l.push(s),this._condense(l),this;o||s.leaf||!contains(s,a)?i?(n++,s=i.children[n],o=!1):s=null:(l.push(s),c.push(n),n=0,i=s,s=s.children[0])}return this},toBBox:function(t){return t},compareMinX:compareNodeMinX,compareMinY:compareNodeMinY,toJSON:function(){return this.data},fromJSON:function(t){return this.data=t,this},_all:function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},_build:function(t,e,n,i){var r,o=n-e+1,s=this._maxEntries;if(o<=s)return calcBBox(r=createNode(t.slice(e,n+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,i-1))),(r=createNode([])).leaf=!1,r.height=i;var a,l,c,u,h=Math.ceil(o/s),d=h*Math.ceil(Math.sqrt(s));for(multiSelect(t,e,n,d,this.compareMinX),a=e;a<=n;a+=d)for(multiSelect(t,a,c=Math.min(a+d-1,n),h,this.compareMinY),l=a;l<=c;l+=h)u=Math.min(l+h-1,c),r.children.push(this._build(t,l,u,i-1));return calcBBox(r,this.toBBox),r},_chooseSubtree:function(t,e,n,i){for(var r,o,s,a,l,c,u,h;i.push(e),!e.leaf&&i.length-1!==n;){for(u=h=1/0,r=0,o=e.children.length;r<o;r++)l=bboxArea(s=e.children[r]),(c=enlargedArea(t,s)-l)<h?(h=c,u=l<u?l:u,a=s):c===h&&l<u&&(u=l,a=s);e=a||e.children[0]}return e},_insert:function(t,e,n){var i=n?t:(0,this.toBBox)(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),extend(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)},_split:function(t,e){var n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var o=this._chooseSplitIndex(n,r,i),s=createNode(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,calcBBox(n,this.toBBox),calcBBox(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},_splitRoot:function(t,e){this.data=createNode([t,e]),this.data.height=t.height+1,this.data.leaf=!1,calcBBox(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var i,r,o,s,a,l,c,u;for(l=c=1/0,i=e;i<=n-e;i++)s=intersectionArea(r=distBBox(t,0,i,this.toBBox),o=distBBox(t,i,n,this.toBBox)),a=bboxArea(r)+bboxArea(o),s<l?(l=s,u=i,c=a<c?a:c):s===l&&a<c&&(c=a,u=i);return u},_chooseSplitAxis:function(t,e,n){var i=t.leaf?this.compareMinX:compareNodeMinX,r=t.leaf?this.compareMinY:compareNodeMinY;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)},_allDistMargin:function(t,e,n,i){t.children.sort(i);var r,o,s=this.toBBox,a=distBBox(t,0,e,s),l=distBBox(t,n-e,n,s),c=bboxMargin(a)+bboxMargin(l);for(r=e;r<n-e;r++)o=t.children[r],extend(a,t.leaf?s(o):o),c+=bboxMargin(a);for(r=n-e-1;r>=e;r--)o=t.children[r],extend(l,t.leaf?s(o):o),c+=bboxMargin(l);return c},_adjustParentBBoxes:function(t,e,n){for(var i=n;i>=0;i--)extend(e[i],t)},_condense:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():calcBBox(t[n],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}};const RAILWAY_NAMBOKU="TokyoMetro.Namboku",RAILWAY_MITA="Toei.Mita",RAILWAY_ARAKAWA="Toei.Arakawa",AIRLINES_FOR_ANA_CODE_SHARE=["ADO","SFJ","SNJ"],DEGREE_TO_RADIAN=Math.PI/180,_updateZoomButtons=mapboxGlExports.NavigationControl.prototype._updateZoomButtons;mapboxGlExports.NavigationControl.prototype._updateZoomButtons=function(){const{_disabled:t,_zoomInButton:e,_zoomOutButton:n,_compass:i}=this;_updateZoomButtons.apply(this),t&&(e.disabled=n.disabled=!0,e.setAttribute("aria-disabled","true"),n.setAttribute("aria-disabled","true")),i.disabled=!!t,i.setAttribute("aria-disabled",(!!t).toString())},mapboxGlExports.NavigationControl.prototype.enable=function(){delete this._disabled,this._updateZoomButtons()},mapboxGlExports.NavigationControl.prototype.disable=function(){this._disabled=!0,this._updateZoomButtons()};const modelOrigin=mapboxGlExports.MercatorCoordinate.fromLngLat(configs.defaultCenter),modelScale=modelOrigin.meterInMercatorCoordinateUnits();class Map$1 extends mapboxGlExports.Evented{constructor(t){super();const e=this;t=extend$3({hash:!1,useWebGL2:!0,center:configs.defaultCenter,zoom:configs.defaultZoom,bearing:configs.defaultBearing,pitch:configs.defaultPitch,dataUrl:configs.dataUrl,dataSources:configs.dataSources,clockControl:!0,searchControl:!0,navigationControl:!0,fullscreenControl:!0,modeControl:!0,configControl:!0,trackingMode:configs.defaultTrackingMode,ecoMode:configs.defaultEcoMode,ecoFrameRate:configs.defaultEcoFrameRate},t),e.lang=getLang(t.lang),e.dataUrl=t.dataUrl,e.dataSources=t.dataSources.map((({gtfsUrl:e,vehiclePositionUrl:n,color:i})=>({gtfsUrl:updateOdptUrl(e,t.secrets),vehiclePositionUrl:updateOdptUrl(n,t.secrets),color:i}))),e.container="string"==typeof t.container?document.getElementById(t.container):t.container,e.secrets=t.secrets,e.exitPopups=[],e.clockControl=t.clockControl,e.searchControl=t.searchControl,e.navigationControl=t.navigationControl,e.fullscreenControl=t.fullscreenControl,e.modeControl=t.modeControl,e.configControl=t.configControl,e.clock=new Clock$1,e.plugins=(t.plugins||[]).map((t=>new Plugin(t))),e.searchMode="none",e.viewMode=configs.defaultViewMode,e.trackingMode=t.trackingMode,e.trackingParams={zoom:{},bearing:{},pitch:{}},e.lastCameraParams={},e.initialSelection=t.selection,e.clockMode=configs.defaultClockMode,e.isEditingTime=!1,e.ecoMode=t.ecoMode,e.ecoFrameRate=t.ecoFrameRate,e.lastDynamicUpdate={},e.lastRepaint=0,e.frameRateFactor=1,t.container=initContainer(e.container),t.style=`${t.dataUrl}/osm-liberty.json`,t.configControl||(t.customAttribution=flat$1([t.customAttribution,configs.customAttribution])),e.map=new mapboxGlExports.Map(t);for(const t of configs.events)e.map.on(t,e.fire.bind(e));e.map.once("idle",(()=>{measureFrameRate().then((t=>{e.frameRateFactor=Math.min(60/t,2)}))})),Promise.all([loadStaticData(e.dataUrl,e.lang,e.clock).then(e.initData.bind(e)).catch((t=>{throw showErrorMessage(e.container),t})),new Promise((t=>{e.map.once("styledata",t)}))]).then(e.initialize.bind(e)),e.refreshBusData()}getMapboxMap(){return this.map}getCenter(){return this.map.getCenter()}setCenter(t){const e=this;return e.trackObject(),e.map.setCenter(t),e}getZoom(){return this.map.getZoom()}setZoom(t){return this.map.setZoom(t),this}getBearing(){return this.map.getBearing()}setBearing(t){const e=this;return e.trackObject(),e.map.setBearing(t),e}getPitch(){return this.map.getPitch()}setPitch(t){return this.map.setPitch(t),this}easeTo(t){const e=this;return void 0===t.center&&void 0===t.bearing||e.trackObject(),e.map.easeTo(t),e}flyTo(t){const e=this;return void 0===t.center&&void 0===t.bearing||e.trackObject(),e.map.flyTo(t),e}jumpTo(t){const e=this;return void 0===t.center&&void 0===t.bearing||e.trackObject(),e.map.jumpTo(t),e}getViewMode(){return this.viewMode}setViewMode(t){const e=this;return e.initialized&&e._setViewMode(t),e}getTrackingMode(){return this.trackingMode}setTrackingMode(t){return this._setTrackingMode(t),this}getSelection(){const t=this.trackedObject;return isVehicle(t)?t.object.id:isStation(t)?t.stations:void 0}setSelection(t){const e=this,n=removePrefix(t),i=e.stations.get(n);if(i)e.trackObject(e.stationGroupLookup.get(i.group)),delete e.initialSelection;else if(n.match(/NRT|HND/))if(e.flightLoaded){const t=e.activeFlightLookup.get(n);t?t.aircraft?e.trackObject(t.aircraft):e.selection=t.id:showNotification(e.container,e.dict["flight-terminated"]),delete e.initialSelection}else e.initialSelection=n;else if(e.trainLoaded){let t;for(const i of e.timetables.getConnectingTrainIds(n))if(t=e.activeTrainLookup.get(i))break;t?t.cars[0]?e.trackObject(t.cars[0]):e.selection=t.id:showNotification(e.container,e.dict["train-terminated"]),delete e.initialSelection}else e.initialSelection=n;return e}getClockMode(){return this.clockMode}setClockMode(t){const e=this;return e.initialized&&e._setClockMode(t),e}getEcoMode(){return this.ecoMode}setEcoMode(t){return this._setEcoMode(t),this}addLayer(t,e){const n=this;return"three"===t.type?new ThreeLayer(t).onAdd(n,e):"geojson"===t.type?new GeoJsonLayer(t).onAdd(n,e):"tile-3d"===t.type?new Tile3DLayer(t).onAdd(n,e):n.map.addLayer(t,e||"poi"),n}removeLayer(t){return this.map.removeLayer(t),this}setLayerVisibility(t,e){return this.map.setLayoutProperty(t,"visibility",e),this}getModelOrigin(){return modelOrigin}getModelScale(){return modelScale}getModelPosition(t,e){const n=mapboxGlExports.MercatorCoordinate.fromLngLat(t,e);return{x:n.x-modelOrigin.x,y:-(n.y-modelOrigin.y),z:n.z-modelOrigin.z}}hasDarkBackground(){return hasDarkBackground(this.map)}initData(t){const e=this,n=e.featureLookup=new Map,i=e.stationGroupLookup=new Map;e.dict=t.dict,e.featureCollection=t.featureCollection,e.stations=new Dataset(Station),e.railDirections=new Dataset(RailDirection,t.railDirectionData),e.railways=new Dataset(Railway,t.railwayData,{stations:e.stations,railDirections:e.railDirections}),e.pois=new Dataset(POI,t.poiData),e.stations.load(t.stationData,{stations:e.stations,railways:e.railways,railDirections:e.railDirections,pois:e.pois}),featureEach(e.featureCollection,(t=>{const r=t.properties,{group:o,altitude:s}=r;1===r.type?(n.set(`${o}.${r.zoom}`,t),i.has(o)||i.set(o,{id:o,type:"station",stations:r.ids.map((t=>e.stations.get(t))),layer:0===s?"ground":"underground"})):s<=0||(n.set(r.id,t),updateDistances(t))}));for(const t of e.stations.getAll())if(t.alternate)for(const e of["og","ug"]){const n=t.group.replace(/.g$/,e),r=i.get(n);r&&(r.hidden||(r.hidden=[]),r.hidden.push(t))}e.trainTypes=new Dataset(TrainType,t.trainTypeData),e.trainVehicleTypes=new Dataset(TrainVehicleType,t.trainVehicleData),e.lastTimetableRefresh=e.clock.getTime("03:00"),e.dataReferences={railways:e.railways,stations:e.stations,railDirections:e.railDirections,trainTypes:e.trainTypes,trainVehicleTypes:e.trainVehicleTypes},e.timetables=new TrainTimetables(t.timetableData,e.dataReferences),e.operators=new Dataset(Operator,t.operatorData),e.airports=new Dataset(Airport,t.airportData),e.flightStatuses=new Dataset(FlightStatus,t.flightStatusData),e.activeTrainLookup=new Map,e.standbyTrainLookup=new Map,e.realtimeTrains=new Set,e.activeFlightLookup=new Map,e.flightLookup=new Map,e.gtfs=new Map}initialize(){const t=this,{lang:e,dict:n,clock:i,map:r,container:o,featureCollection:s}=t,a=r.getZoom(),l=t.layerZoom=getLayerZoom(a);r.loaded()?hideLoader(o):r.once("load",(()=>{hideLoader(o)})),t.trafficLayer=new TrafficLayer({id:"traffic"}),r.setLight({intensity:.35,anchor:"map"}),r.addLayer({id:"sky",type:"sky",paint:{"sky-opacity":["interpolate",["linear"],["zoom"],0,0,5,.3,8,1],"sky-type":"atmosphere","sky-atmosphere-sun-intensity":20}},"background"),r.addLayer({id:"background-underground",type:"background",paint:{"background-color":"rgba(16,16,16,1)","background-opacity":0},metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":0,"mt3d:opacity-underground":1}},"natural_earth"),r.addLayer({id:"building-underground-underground",type:"fill",source:"mapbox","source-layer":"building",minzoom:14.5,filter:["all",["match",["get","type"],["underground_mall","subway"],!0,!1],["==",["get","underground"],"true"],["==",["geometry-type"],"Polygon"]],layout:{},paint:{"fill-outline-color":"hsl(35, 8%, 80%)","fill-opacity":["interpolate",["linear"],["zoom"],14.5,0,15,0],"fill-color":"hsla(268, 67%, 67%, 0.5)"},metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":0,"mt3d:opacity-underground":1,"mt3d:opacity-underground-route":.1}},"building"),r.setLayoutProperty("poi","text-field",["coalesce",["get",`name_${e}`],["get","name_en"],["get","name"]]);for(const e of[13,14,15,16,17,18]){const n={type:"geojson",lineWidthUnits:"pixels",lineWidthScale:13===e?clamp$3(Math.pow(2,a-12),.125,1):18===e?clamp$3(Math.pow(2,a-19),1,8):1,parameters:{depthTest:!1},minzoom:e<=13?0:e,maxzoom:e>=18?24:e+1};for(const i of["marked","selected"])t.addLayer(Object.assign({},n,{id:`stations-${i}-${e}`,getLineWidth:12,getLineColor:[255,255,255],getFillColor:[255,255,255],visible:!1}),"building-3d");for(const i of["ug","routeug","routeog"])for(const r of["railways","stations"]){const o="railways"===r?0:1;t.addLayer(Object.assign({},n,{id:`${r}-${i}-${e}`,data:"ug"===i?featureFilter(s,(t=>t.zoom===e&&t.type===o&&t.altitude<0)):emptyFeatureCollection(),transitions:{opacity:configs.transitionDuration}},{railways:{filled:!1,getLineWidth:t=>t.properties.width,getLineColor:t=>colorToRGBArray(t.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,metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":.125,"mt3d:opacity-underground":1}},routeog:{metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":1,"mt3d:opacity-underground":.25}}}[i]),"building-3d")}}r.__deck.props.getCursor=()=>r.getCanvas().style.cursor,r.addSource("odpt",{type:"geojson",data:featureFilter(s,(t=>0===t.altitude))});for(const t of[13,14,15,16,17,18]){const e=["interpolate",["exponential",2],["zoom"]],n=["get","width"],i=["get","color"],o=13===t?[...e,9,["/",n,8],12,n]:18===t?[...e,19,n,22,["*",n,8]]:n;for(const e of["railways","stations","stations-outline"])r.addLayer({id:`${e}-og-${t}`,type:"stations"===e?"fill":"line",source:"odpt",filter:["all",["==",["get","zoom"],t],["==",["get","type"],"railways"===e?0:1]],layout:{visibility:t===l?"visible":"none"},paint:{railways:{"line-color":i,"line-width":o},stations:{"fill-color":i,"fill-opacity":.7},"stations-outline":{"line-color":["get","outlineColor"],"line-width":o}}[e],metadata:{"mt3d:opacity-effect":!0,"mt3d:opacity":1,"mt3d:opacity-route":.1,"mt3d:opacity-underground":.25,"mt3d:opacity-underground-route":.1}},"building-3d")}t.addLayer(t.trafficLayer,"building-3d"),t.styleColors=getStyleColors(r,"mt3d:color-effect"),t.styleOpacities=getStyleOpacities(r,"mt3d:opacity-effect");const c=createElement$1("datalist",{id:"stations"},document.body),u=t.stationTitleLookup=new Map;for(const n of[e,"en"])for(const e of t.railways.getAll())for(const t of e.stations){const{title:e,utitle:i}=t,r=i&&i[n]||normalize$5(e[n]||e.en),o=r.toUpperCase();u.has(o)||(createElement$1("option",{value:r},c),u.set(o,t))}if(t.searchControl){const e=new SearchControl({title:t.dict.search,placeholder:t.dict["station-name"],list:"stations",eventHandler:({value:e})=>{const n=t.stationTitleLookup.get(e.toUpperCase());if(n&&n.coord)return t.markObject(),t.trackObject(t.stationGroupLookup.get(n.group)),!0}});r.addControl(e)}if(t.navigationControl){const e=t.navControl=new mapboxGlExports.NavigationControl;e._setButtonTitle=function(t){const{_zoomInButton:e,_zoomOutButton:i,_compass:r}=this,o=t===e?n["zoom-in"]:t===i?n["zoom-out"]:t===r?n.compass:"";t.title=o,t.setAttribute("aria-label",o)},r.addControl(e)}if(t.fullscreenControl){const t=new mapboxGlExports.FullscreenControl({container:o});t._updateTitle=function(){const t=this._fullscreenButton,e=n[this._isFullscreen()?"exit-fullscreen":"enter-fullscreen"];t.title=e,t.setAttribute("aria-label",e)},r.addControl(t)}if(t.modeControl){const e=new MapboxGLButtonControl([{className:"mapboxgl-ctrl-underground",title:n["enter-underground"],eventHandler(){t._setViewMode("ground"===t.viewMode?"underground":"ground")}},{className:"mapboxgl-ctrl-playback",title:n["enter-playback"],eventHandler(){t._setClockMode("realtime"===t.clockMode?"playback":"realtime")}},{className:"mapboxgl-ctrl-eco",title:n["enter-eco"],eventHandler(){t._setEcoMode("eco"===t.ecoMode?"normal":"eco")}}]);r.addControl(e)}if(t.layerPanel=new LayerPanel({layers:t.plugins}),t.trackingModePanel=new TrackingModePanel,t.aboutPanel=new AboutPanel,t.configControl&&r.addControl(new MapboxGLButtonControl([{className:"mapboxgl-ctrl-layers",title:n["select-layers"],eventHandler(){t.layerPanel.addTo(t)}},{className:"mapboxgl-ctrl-tracking-mode",title:n["select-tracking-mode"],eventHandler(){t.trackingModePanel.addTo(t)}},{className:"mapboxgl-ctrl-about",title:n.about,eventHandler(){t.aboutPanel.addTo(t)}}])),t.clockControl){const o=t.clockCtrl=new ClockControl({lang:e,dict:n,clock:i});o.on("change",t.onClockChange.bind(t)),r.addControl(o)}r.on("mousemove",(e=>{t.markObject(t.pickObject(e.point))})),r.on("mouseout",(()=>{t.markObject()})),r.on("click",(e=>{const n=t.pickObject(e.point);t.markObject(n),t.trackObject(n)})),r.on("zoom",(e=>{e.tracking||t.updateBaseZoom();const n=r.getZoom(),i=t.layerZoom,o=t.layerZoom=getLayerZoom(n);if(n<13){const t=clamp$3(Math.pow(2,n-12),.125,1);for(const e 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"])setLayerProps(r,e,{lineWidthScale:t})}else if(n>19){const t=clamp$3(Math.pow(2,n-19),1,8);for(const e 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"])setLayerProps(r,e,{lineWidthScale:t})}if(i!==o){for(const e of["railways","stations","stations-outline"])t.setLayerVisibility(`${e}-og-${i}`,"none"),t.setLayerVisibility(`${e}-og-${o}`,"visible");for(const{id:e}of t.gtfs.values())for(const n of["busstops","busstops-outline"])i>=14&&t.setLayerVisibility(`${n}-${e}-og-${i}`,"none"),o>=14&&t.setLayerVisibility(`${n}-${e}-og-${o}`,"visible");e.tracking?t.prevLayerZoom=i:delete t.prevLayerZoom;for(const e of t.activeTrainLookup.values())t.updateTrainProps(e),t.updateTrainShape(e);for(const e of t.activeFlightLookup.values())t.updateFlightShape(e)}})),r.on("render",(()=>{t.markedObject&&t.updatePopup()}));for(const e of t.plugins.slice().reverse())e.addTo(t);animation.init(),animation.start({callback:()=>{const e=t.clock,n=e.getTime(),{minDelay:i,realtimeCheckInterval:o}=configs;n-t.lastTimetableRefresh>=864e5&&(t.refreshTrainTimetableData(),t.refreshBusData(),t.lastTimetableRefresh=e.getTime("03:00")),Date.now()-t.lastFrameRefresh>=configs.refreshTimeout&&t.stopAll(),t.lastFrameRefresh=Date.now(),t.updateVisibleArea(),Math.floor((n-i)/o)!==Math.floor(t.lastTrainRefresh/o)&&(setStyleColors(r,t.styleColors,t.getLightColor()),setSunlight(r,n),"none"===t.searchMode&&("realtime"===t.clockMode?(t.refreshRealtimeTrainData(),t.refreshRealtimeFlightData(),t.refreshRealtimeBusData()):(t.refreshTrains(),t.refreshFlights()),isStation(t.trackedObject)&&t.detailPanel.updateContent()),t.lastTrainRefresh=n-i),!isVehicle(t.trackedObject)&&("normal"===t.ecoMode&&r._loaded||Date.now()-t.lastRepaint>=1e3/t.ecoFrameRate)&&(t.trackedObject&&t.refreshStationOutline(),r.triggerRepaint(),t.lastRepaint=Date.now())}}),t.initialized=!0,t.fire({type:"initialized"})}_jumpTo(t){const e=this,{map:n,trackingMode:i,trackingParams:r,frameRateFactor:o}=e,s=performance.now(),a=n.getZoom(),l=n.getBearing(),c=n.getPitch(),u=n.scrollZoom._active;let h,d,{center:p,altitude:f,bearing:m,easeOutFactor:g,easeInFactor:_,bearingFactor:y}=t;"position"===i?(h=e.baseZoom,m=l,d=c):"helicopter"===i?(h=15,m=r.bearing.fn(s),d=60):"drone"===i?(h=17,m=r.bearing.fn(s),d=75):"bird"===i?(e.updateTrackingParams(),h=r.zoom.fn(s),m=r.bearing.fn(s),d=r.pitch.fn(s)):("front"!==i&&"topfront"!==i||(m=(m+360)%360-180),y>=0&&(m=l+((m-l+540)%360-180)*y*o),"back"===i||"front"===i?(h=18.5,d=85):(h=15,d=60));const v=n.getFreeCameraOptions().position.z/Math.cos(c*DEGREE_TO_RADIAN)*Math.pow(2,a-h),x=e.getModelPosition(p,f).z/Math.cos(d*DEGREE_TO_RADIAN);if(h=Math.min(h-Math.log2(Math.max(v+x,0)/v),22),p=e.adjustCoord(p,f,m),g>=0){const t=n.getCenter();p=new mapboxGlExports.LngLat(lerp$5(t.lng,p.lng,g*o),lerp$5(t.lat,p.lat,g*o))}_>=0&&(h=lerp$5(a,h,_*o),d=lerp$5(c,d,_*o)),Math.floor(h+1)-h<1e-6&&(h=Math.floor(h+1)),e.prevLayerZoom===getLayerZoom(h)?h=a:delete e.prevLayerZoom,n.jumpTo({center:p,zoom:h,bearing:m,pitch:d},{tracking:!0}),u&&(n.scrollZoom._active=!0)}updateVisibleArea(){const t=this,e=t.map,{width:n,height:i}=e.transform,r=t.getModelPosition(e.unproject([0,0])),o=t.getModelPosition(e.unproject([n,0])),s=t.getModelPosition(e.unproject([0,i])),a=t.getModelPosition(e.unproject([n,i]));t.visibleArea=bufferTrapezoid([[r.x,r.y],[o.x,o.y],[a.x,a.y],[s.x,s.y]],Math.max(14e-6,5e-5*Math.sin(e.getPitch()*DEGREE_TO_RADIAN)))}updateTrainProps(t){const e=(t.railwayFeature=this.featureLookup.get(`${t.r.id}.${this.layerZoom}`)).properties["station-offsets"],n=t.sectionIndex,i=t.offset=e[n];t.interval=e[n+t.sectionLength]-i}updateTrainShape(t,e){const n=this,{map:i,trafficLayer:r}=n,{railwayFeature:o,direction:s,cars:a,animationID:l}=t,c=a.length;let u,h,d;if(void 0!==e&&(t._t=e),void 0===t._t)return;if(0===c){const{markedObject:e,trackedObject:i}=n,r=t.id;a.push({type:"train",object:t,index:0,color:(t.v||t.r).color,delay:0}),e&&"train"===e.type&&e.object.id===r&&(u=a[e.index]),i&&"train"===i.type&&i.object.id===r&&(h=a[i.index]),n.selection===r&&(h=a[0],delete n.selection)}a[0].delay=t.delay?1:0;const p=getCoordAndBearing(o,t.offset+t._t*t.interval,1,0);for(let t=0,e=a.length;t<e;t++){const e=a[t],{coord:o,altitude:c,bearing:f,pitch:m}=p[t];if(e.altitude<0&&c>=0?d="ground":e.altitude>=0&&c<0&&(d="underground"),e.coord=o,e.altitude=c,e.bearing=f+(s<0?180:0),e.pitch=m*s,u===e&&n.markObject(e),h===e&&n.trackObject(e),e.outline=n.markedObject===e?1:n.trackedObject===e?blink():0,n.trackedObject!==e||n.viewAnimationID||i._zooming||i._rotating||i._pitching||n._jumpTo({center:o,altitude:c,bearing:e.bearing,bearingFactor:.02}),animation.isActive(l)){const{x:t,y:e}=n.getModelPosition(o),r=pointInTrapezoid([t,e],n.visibleArea)?"normal"===n.ecoMode&&i._loaded?0:n.ecoFrameRate:1;animation.setFrameRate(l,r)}void 0===e.meshIndex?r.addObject(e):r.updateObject(e),d&&n.trackedObject===e&&n._setViewMode(d),n.trackedObject===e&&n.markedObject===e&&n.updatePopup()}}updateFlightShape(t,e){const n=this,{map:i,trafficLayer:r}=n,{feature:o,animationID:s}=t;let a,l=t.aircraft;if(void 0!==e&&(t._t=e),void 0===t._t)return;if(!l){const e=t.a;l=t.aircraft={type:"flight",object:t,color:[e.color||"#FFFFFF",e.tailcolor||"#FFFFFF"]},n.selection===t.id&&(a=l,delete n.selection)}const{coord:c,altitude:u,bearing:h,pitch:d}=getCoordAndBearing(o,t._t*o.properties.length,1,0)[0];if(l.coord=c,l.altitude=u,l.bearing=h,l.pitch=d,a===l&&n.trackObject(l),l.outline=n.markedObject===l?1:n.trackedObject===l?blink():0,n.trackedObject!==l||n.viewAnimationID||i._zooming||i._rotating||i._pitching||n._jumpTo({center:c,altitude:u,bearing:h,bearingFactor:.02}),animation.isActive(s)){const{x:t,y:e}=n.getModelPosition(c),r=pointInTrapezoid([t,e],n.visibleArea)||n.trackedObject===l?"normal"===n.ecoMode&&i._loaded?0:n.ecoFrameRate:1;animation.setFrameRate(s,r)}void 0===l.meshIndex?r.addObject(l):r.updateObject(l),n.trackedObject===l&&n.markedObject===l&&n.updatePopup()}updateBusProps(t){const e=t.sectionIndex,n=t.offsets,i=t.offset=n[e];t.interval=n[e+t.sectionLength]-i}updateBusShape(t,e){const n=this,{map:i,trafficLayer:r}=n,o=t.animationID;let s=t.car;if(void 0!==e&&(t._t=e),void 0===t._t)return;void 0===s&&(s=t.car={type:"bus",object:t,color:n.gtfs.get(t.gtfsId).color});const{coord:a,altitude:l,bearing:c,pitch:u}=getCoordAndBearing(t.feature,t.offset+t._t*t.interval,1,0)[0];if(s.coord=a,s.altitude=l,s.bearing=c,s.pitch=u,s.outline=n.markedObject===s?1:n.trackedObject===s?blink():0,n.trackedObject!==s||n.viewAnimationID||i._zooming||i._rotating||i._pitching||n._jumpTo({center:a,altitude:l,bearing:s.bearing,bearingFactor:.02}),animation.isActive(o)){const{x:t,y:e}=n.getModelPosition(a),r=pointInTrapezoid([t,e],n.visibleArea)||n.trackedObject===s?"normal"===n.ecoMode&&i._loaded?0:n.ecoFrameRate:1;animation.setFrameRate(o,r)}void 0===s.meshIndex?r.addObject(s):r.updateObject(s),n.trackedObject===s&&n.markedObject===s&&n.updatePopup()}refreshTrains(){const t=this,e=t.initialSelection,n=t.clock.getTimeOffset();for(const e of t.timetables.getAll())e.start<=n&&n<=e.end&&!t.standbyTrainLookup.has(e.id)&&t.trainStart(new Train(e));t.trafficLayer.refreshDelayMarkers(),t.trainLoaded=!0,e&&t.setSelection(e)}trainStart(t,e){const n=this,{r:i,timetable:r}=t,o=n.clock.getTimeOffset();if(n.checkActiveTrains(t)||i.status&&i.dynamic&&!n.realtimeTrains.has(t.id)||i.suspended)return void n.deactivateTrain(t);if(!n.setSectionData(t,e))return void n.deactivateTrain(t);n.activeTrainLookup.set(t.id,t),t.cars=[],n.updateTrainProps(t);const s=t.departureTime+(t.delay||0);r||0===t.sectionLength?r&&o>=s?n.trainRepeat(t,o-s):n.trainStand(t):n.trainRepeat(t)}trainStand(t,e){const n=this,i=t.timetable;if(i||(e=!n.setSectionData(t,void 0,!n.realtimeTrains.has(t.id))),!e&&t.arrivalStation&&(n.updateTrainProps(t),n.updateTrainShape(t,0)),i||0===t.sectionLength){const r=n.markedObject,o=n.clock,s=t.departureTime+(t.delay||0),a=configs.minStandingDuration;t.standing=!0,r&&r.object===t&&n.updatePopup({setHTML:!0}),t.animationID=animation.start({callback:()=>{const e=n.trackedObject;e&&e.object===t&&n.updateTrainShape(t)},complete:()=>{const r=n.clock;e?n.stopTrain(t):i?n.trainRepeat(t,1===r.speed?void 0:r.getTimeOffset()-s):n.trainStand(t)},duration:i?Math.max(s-o.getTimeOffset(),1===o.speed?a:0):e?a:configs.realtimeCheckInterval,clock:o})}else n.trainRepeat(t)}trainRepeat(t,e){const n=this,{clock:i,markedObject:r}=n,o=i.getTimeOffset(),s=t.delay||0,a=configs.minDelay,{arrivalTime:l,nextDepartureTime:c}=t;let u,h;void 0!==c&&(h=c+s-o+(e||0)-a+6e4-configs.minStandingDuration),void 0!==l&&(u=l+s-o+(e||0)-a,h<u+6e4||(h=u+6e4)),t.standing=!1,r&&r.object===t&&n.updatePopup({setHTML:!0}),t.animationID=startTrainAnimation((e=>{t.cars&&!isNaN(e)?n.updateTrainShape(t,e):n.stopTrain(t)}),(()=>{const e=n.activeTrainLookup,{timetable:i,timetableIndex:r}=t;if(!t.cars||i&&r+1>=i.stations.length)n.stopTrain(t);else if(n.setSectionData(t,r+1))n.trainStand(t);else{const r=i&&i.nt;if(r){let i=!1;for(const{t:t}of r[0].pt){const n=e.get(t);n&&n.arrivalStation&&(i=!0)}if(i)n.trainStand(t);else{const{markedObject:t,trackedObject:i}=n;let o=!1,s=!1;for(const{t:a}of r[0].pt){const r=e.get(a);t&&t.object===r&&(o=!0),i&&i.object===r&&(s=!0),r&&n.stopTrain(r,o||s)}r.forEach(((e,r)=>{const a=n.standbyTrainLookup.get(e.id)||new Train(e);0===r&&(o&&(t.object=a),s&&(i.object=a)),n.trainStart(a,0)}))}return}n.trainStand(t,!0)}}),Math.abs(t.interval),u,h,e,i)}refreshFlights(){const t=this,{clock:e,activeFlightLookup:n,markedObject:i,initialSelection:r}=t,o=e.getTimeOffset();for(const r of t.flightLookup.values()){const{id:s,start:a}=r;r.entry<=o&&o<=r.end&&!n.has(s)&&(n.set(s,r),o>=a?t.flightRepeat(r,o-a):(t.updateFlightShape(r,0),r.standing=!0,i&&i.object===r&&t.updatePopup({setHTML:!0}),r.animationID=animation.start({callback:()=>{const e=t.trackedObject;e&&e.object===r&&t.updateFlightShape(r)},complete:()=>{t.flightRepeat(r)},duration:a-o,clock:e})))}t.flightLoaded=!0,r&&t.setSelection(r)}flightRepeat(t,e){const n=this,{clock:i,markedObject:r}=n;t.standing=!1,r&&r.object===t&&n.updatePopup({setHTML:!0}),t.animationID=startFlightAnimation((e=>{n.updateFlightShape(t,e)}),(()=>{const e=n.markedObject;t.standing=!0,e&&e.object===t&&n.updatePopup({setHTML:!0}),t.animationID=animation.start({callback:()=>{const e=n.trackedObject;e&&e.object===t&&n.updateFlightShape(t)},complete:()=>{n.stopFlight(t)},duration:Math.max(t.end-i.getTimeOffset(),0),clock:i})}),t.feature.properties.length,t.maxSpeed,t.acceleration,e,i)}busStart(t){const e=this;e.setBusSectionData(t)&&(e.gtfs.get(t.gtfsId).activeBusLookup.set(t.trip.id,t),e.updateBusProps(t),t.sectionLength>0&&t.interval>0?e.busRepeat(t):e.busStand(t))}busStand(t){const e=this;let n=!1;if(e.setBusSectionData(t,!e.gtfs.get(t.gtfsId).realtimeBuses.has(t.trip.id))?(e.updateBusProps(t),e.updateBusShape(t,0)):n=!0,t.sectionLength>0&&t.interval>0)e.busRepeat(t);else{const{markedObject:i,trackedObject:r}=e;i&&i.object===t&&e.updatePopup({setHTML:!0}),r&&r.object===t&&e.detailPanel&&e.detailPanel.updateHeader(),t.animationID=animation.start({callback:()=>{const n=e.trackedObject;n&&n.object===t&&e.updateBusShape(t)},complete:()=>{n?e.stopBus(t):e.busStand(t)},duration:configs.realtimeCheckInterval,clock:e.clock})}}busRepeat(t){const e=this,{markedObject:n,trackedObject:i}=e;n&&n.object===t&&e.updatePopup({setHTML:!0}),i&&i.object===t&&e.detailPanel&&e.detailPanel.updateHeader(),t.animationID=startBusAnimation((n=>{e.updateBusShape(t,n)}),(()=>{e.busStand(t)}),Math.abs(t.interval),0,e.clock)}updateTrackingParams(t){const e=this,{map:n,trackingMode:i,trackingParams:r}=e,o=performance.now();if("bird"===i){const{zoom:i,bearing:s,pitch:a}=r;if(!i.time||t){const t=i.time=[0,o,0,0],n=i.value=[0,e.baseZoom,0,0];for(const[e,i]of[[0,1],[2,1],[3,2]])t[e]=t[i]+Math.sign(e-i)*(1e4*Math.random()+3e4),n[e]=5*Math.random()+15;i.fn=createInterpolant(t,n)}else o>=i.time[2]&&(i.time=i.time.slice(1).concat(i.time[3]+1e4*Math.random()+3e4),i.value=i.value.slice(1).concat(5*Math.random()+15),i.fn=createInterpolant(i.time,i.value));if(!s.time||t){const t=s.time=[0,o,0,0],e=s.value=[0,n.getBearing(),0,0];for(const[n,i]of[[0,1],[2,1],[3,2]])t[n]=t[i]+Math.sign(n-i)*(1e4*Math.random()+4e4),e[n]=360*Math.random()-180;s.fn=createInterpolant(t,e)}else o>=s.time[2]&&(s.time=s.time.slice(1).concat(s.time[3]+1e4*Math.random()+4e4),s.value=s.value.slice(1).concat(360*Math.random()-180),s.fn=createInterpolant(s.time,s.value));if(!a.time||t){const t=a.time=[0,o,0,0],e=a.value=[0,n.getPitch(),0,0];for(const[n,i]of[[0,1],[2,1],[3,2]])t[n]=t[i]+Math.sign(n-i)*(1e4*Math.random()+2e4),e[n]=30*Math.random()+45;a.fn=createInterpolant(t,e)}else o>=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=createInterpolant(a.time,a.value))}else if(delete r.zoom.time,delete r.bearing.time,delete r.pitch.time,"drone"===i){const t=n.getBearing();r.bearing.fn=e=>(t-(e-o)/200)%360}else if("helicopter"===i){const t=n.getBearing();r.bearing.fn=e=>(t+(e-o)/400)%360}}updateHandlersAndControls(){const t=this,{map:e,trackedObject:n,trackingMode:i}=t,r=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];if(isVehicle(n)&&"position"!==i){for(const t of r)e[t].disable();t.navControl.disable()}else{for(const t of r)e[t].enable();isVehicle(n)&&"position"===i&&e.dragPan.disable(),t.navControl.enable()}}startViewAnimation(){const t=this;let e=0,n=0;t.viewAnimationID=animation.start({callback:(i,r)=>{const o=t.trackedObject,s=easeOutQuart(i/r),a=1-(1-s)/(1-e),l=easeInQuad(i/r);t._jumpTo({center:o.coord,altitude:o.altitude,bearing:o.bearing,easeOutFactor:a,easeInFactor:1-(1-l)/(1-n),bearingFactor:a}),e=s,n=l},complete:()=>{delete t.viewAnimationID},duration:1e3})}stopViewAnimation(){const t=this;t.viewAnimationID&&(animation.stop(t.viewAnimationID),delete t.viewAnimationID)}adjustCoord(t,e,n){if(!e)return mapboxGlExports.LngLat.convert(t);const{map:i,trafficLayer:r}=this;if(!isNaN(n)){const r=mapboxGlExports.MercatorCoordinate.fromLngLat(t,e),o=r.z*Math.tan(i.getPitch()*DEGREE_TO_RADIAN),s=r.x+o*Math.sin(n*DEGREE_TO_RADIAN),a=r.y-o*Math.cos(n*DEGREE_TO_RADIAN);return new mapboxGlExports.MercatorCoordinate(s,a,0).toLngLat()}return i.unproject(r.project(t,e))}getLocalizedRailwayTitle(t){const e=(t||{}).title||{};return e[this.lang]||e.en}getLocalizedTrainNameOrRailwayTitle(t,e){const n=this;return t?t.map((t=>t[n.lang]||t.en)).join(n.dict.and):n.getLocalizedRailwayTitle(e)}getLocalizedTrainTypeTitle(t){const e=(t||{}).title||{};return e[this.lang]||e.en}getLocalizedStationTitle(t){const e=this;return(Array.isArray(t)?t:[t]).map((t=>{const n=(t||{}).title||{};return n[e.lang]||n.en})).join(e.dict.and)}getLocalizedRailDirectionTitle(t){const e=(t||{}).title||{};return e[this.lang]||e.en}getLocalizedDestinationTitle(t,e){const n=this;return t?n.dict.for.replace("$1",n.getLocalizedStationTitle(t)):n.getLocalizedRailDirectionTitle(e)}getLocalizedOperatorTitle(t){const e=(t||{}).title||{};return e[this.lang]||e.en}getLocalizedAirportTitle(t){const e=(t||{}).title||{};return e[this.lang]||e.en}getLocalizedFlightStatusTitle(t){const e=(t||{}).title||{};return e[this.lang]||e.en}getLocalizedPOITitle(t){const e=(t||{}).title||{};return e[this.lang]||e.en}getLocalizedPOIDescription(t){const e=(t||{}).description||{};return e[this.lang]||e.en}getTrainDescription(t){const e=this,{lang:n,dict:i}=e,{r:r,departureTime:o,arrivalStation:s}=t,a=(t.v||r).color,l=t.delay||0,c=valueOrDefault(t.arrivalTime,t.nextDepartureTime),u=r.status;return['<div class="desc-header">',Array.isArray(a)?["<div>",...a.slice(0,3).map((t=>`<div class="line-strip" style="background-color: ${t};"></div>`)),"</div>"].join(""):`<div style="background-color: ${a};"></div>`,"<div><strong>",e.getLocalizedTrainNameOrRailwayTitle(t.nm,r),"</strong>",`<br> <span class="train-type-label">${e.getLocalizedTrainTypeTitle(t.y)}</span> `,e.getLocalizedDestinationTitle(t.ds,t.d),"</div></div>",`<strong>${i["train-number"]}:</strong> ${t.n}`,t.timetable?"":` <span class="desc-caution">${i.special}</span>`,"<br>",l>=6e4?'<span class="desc-caution">':"","<strong>",i[t.standing?"standing-at":"previous-stop"],":</strong> ",e.getLocalizedStationTitle(t.departureStation),void 0!==o?` ${getTimeString(o+l)}`:"",s?[`<br><strong>${i["next-stop"]}:</strong> `,e.getLocalizedStationTitle(s),void 0!==c?` ${getTimeString(c+l)}`:""].join(""):"",l>=6e4?`<br>${i.delay.replace("$1",Math.floor(l/6e4))}</span>`:"",u&&"ja"===n?`<br><span class="desc-caution"><strong>${u}:</strong> ${r.text}</span>`:""].join("")}getFlightDescription(t){const e=this,n=e.dict,{a:i,n:r,ds:o}=t,s=i.tailcolor||"#FFFFFF",a=valueOrDefault(t.sdt,t.sat),l=valueOrDefault(t.edt,t.eat),c=valueOrDefault(t.adt,t.aat),u=(void 0!==l||void 0!==c)&&a!==valueOrDefault(l,c);return['<div class="desc-header">',`<div style="background-color: ${s};"></div>`,`<div><strong>${e.getLocalizedOperatorTitle(i)}</strong>`,`<br>${r[0]} `,n[o?"to":"from"].replace("$1",e.getLocalizedAirportTitle(o||t.or)),"</div></div>",`<strong>${n.status}:</strong> ${e.getLocalizedFlightStatusTitle(t.s)}`,"<br><strong>",n[o?"scheduled-departure-time":"scheduled-arrival-time"],`:</strong> ${getTimeString(a)}`,u?'<span class="desc-caution">':"",void 0!==l?["<br><strong>",n[o?"estimated-departure-time":"estimated-arrival-time"],`:</strong> ${getTimeString(l)}`].join(""):void 0!==c?["<br><strong>",n[o?"actual-departure-time":"actual-arrival-time"],`:</strong> ${getTimeString(c)}`].join(""):"",u?"</span>":"",r.length>1?`<br><strong>${n["code-share"]}:</strong> ${r.slice(1).join(" ")}`:""].join("")}getBusDescription(t){const e=this.dict,n=this.gtfs.get(t.gtfsId),i=n.stopLookup,r=t.trip,{shortName:o,headsigns:s,stops:a}=r,l=t.sectionIndex+t.sectionLength,c=i.get(a[l]).name,u=Math.max(0,l-1),h=i.get(a[u]).name;return['<div class="desc-header">',`<div style="background-color: ${n.color};"></div>`,`<div><strong>${n.agency}</strong><br>`,o?` <span class="bus-route-label" style="color: ${r.textColor}; background-color: ${r.color};">${o}</span> `:"",s[1===s.length?0:u],"</div></div>",`<strong>${e["vehicle-number"]}:</strong> ${t.id}`,`<br><strong>${e["previous-busstop"]}:</strong> ${h}`,`<br><strong>${e["next-busstop"]}:</strong> ${c}`].join("")}checkActiveTrains(t){const e=this;function n(t,i){const r=e.activeTrainLookup.get(t.t);if(r&&t.id===r.timetable.id)return!0;const o=t[i];if(o)for(const t of o)if(n(t,i))return!0;return!1}return!!t.timetable&&(n(t.timetable,"pt")||n(t.timetable,"nt"))}stopTrain(t,e){const n=this,i=t.cars;if(animation.stop(t.animationID),i)for(const t of i)n.trafficLayer.removeObject(t),t!==n.markedObject||e||n.markObject(),t!==n.trackedObject||e||n.trackObject();delete t.cars,n.activeTrainLookup.delete(t.id)}deactivateTrain(t){const e=this,{markedObject:n,trackedObject:i}=e;n&&n.object===t&&e.markObject(),i&&i.object===t&&e.trackObject()}stopFlight(t){const e=this,n=t.aircraft;animation.stop(t.animationID),e.trafficLayer.removeObject(n),n===e.markedObject&&e.markObject(),n===e.trackedObject&&e.trackObject(),delete t.aircraft,e.activeFlightLookup.delete(t.id)}stopBus(t){const e=this,n=t.car;animation.stop(t.animationID),e.trafficLayer.removeObject(n),n===e.markedObject&&e.markObject(),n===e.trackedObject&&e.trackObject(),delete t.car,e.gtfs.get(t.gtfsId).activeBusLookup.delete(t.trip.id)}stopAll(){const t=this;for(const e of t.activeTrainLookup.values())t.stopTrain(e);for(const e of t.activeFlightLookup.values())t.stopFlight(e);t.standbyTrainLookup.clear(),t.realtimeTrains.clear();for(const{activeBusLookup:e,realtimeBuses:n}of t.gtfs.values()){for(const n of e.values())t.stopBus(n);n.clear()}delete t.lastTrainRefresh}resetRailwayStatus(){for(const t of this.railways.getAll())delete t.status,delete t.text,delete t.suspended}refreshTrainTimetableData(){const t=this;showLoader(t.container),t.timetables.clear(),loadTimetableData(t.dataUrl,t.clock).then((e=>{t.timetables=new TrainTimetables(e,t.dataReferences),delete t.lastTrainRefresh,hideLoader(t.container)}))}refreshBusData(){const t=this;loadBusData(t.dataSources,t.lang).then((e=>new Promise((n=>t.initialized?n(e):t.once("initialized",(()=>n(e))))))).then((e=>{const n=t.map;for(const{id:e,activeBusLookup:i,layerIds:r}of t.gtfs.values()){for(const e of i.values())t.stopBus(e);for(const e of r){t.removeLayer(e);for(let n=0,i=t.styleOpacities.length;n<i;n++)if(t.styleOpacities[n].id===e){t.styleOpacities.splice(n,1);break}}n.removeSource(`gtfs-${e}`),t.gtfs.delete(e)}for(const i of e){const{agency:e,featureCollection:r,version:o}=i,s=`${e}.${o}`,a=new Map,l=new Map,c=new Map,u=new Set,h=`gtfs-${s}`;featureEach(r,(t=>{const e=t.properties;0===e.type&&a.set(e.id,t)}));for(const t of i.stops)l.set(t.id,t);for(const t of i.trips)c.set(t.id,t);t.gtfs.set(s,{id:s,agency:e,version:o,featureLookup:a,stopLookup:l,tripLookup:c,layerIds:u,activeBusLookup:new Map,realtimeBuses:new Set,vehiclePositionUrl:i.vehiclePositionUrl,color:i.color}),n.addSource(h,{type:"geojson",data:r}),t.addLayer({id:`busroute-${s}-og-`,type:"line",source:h,filter:["==",["get","type"],0],paint:{"line-color":["get","color"],"line-width":["interpolate",["exponential",2],["zoom"],11,["/",["get","width"],2],12,["get","width"],19,["get","width"],22,["*",["get","width"],8]]},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(`busroute-${s}-og-`);for(const e of[14,15,16,17,18]){const n=["get","width"],i=18===e?[...["interpolate",["exponential",2],["zoom"]],19,n,22,["*",n,8]]:n;for(const n of["busstops","busstops-outline"])t.addLayer({id:`${n}-${s}-og-${e}`,type:"busstops"===n?"fill":"line",source:h,filter:["all",["==",["get","zoom"],e],["==",["get","type"],1]],layout:{visibility:e===t.layerZoom?"visible":"none"},paint:{busstops:{"fill-color":["get","color"],"fill-opacity":.7},"busstops-outline":{"line-color":["get","outlineColor"],"line-width":i}}[n],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(`${n}-${s}-og-${e}`)}t.addLayer({id:`busstops-poi-${s}`,type:"symbol",source:h,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-${s}`)}const i=new Set(t.styleOpacities.map((({id:t})=>t)));for(const e of getStyleOpacities(n,"mt3d:opacity-effect"))i.has(e.id)||t.styleOpacities.push(e);t.refreshMap(),"realtime"===t.clockMode&&t.refreshRealtimeBusData()}))}refreshRealtimeTrainData(){const t=this;loadDynamicTrainData(t.secrets).then((({trainData:e,trainInfoData:n})=>{const{activeTrainLookup:i,standbyTrainLookup:r,realtimeTrains:o,dataReferences:s}=t,a=t.clock.getTimeOffset();t.resetRailwayStatus();for(const e of n){const n=t.railways.get(e.railway),i=e.status;n&&i&&i.ja&&(n.status=i.ja,n.text=e.text.ja),e.suspended&&(n.suspended=!0)}r.clear(),o.clear();for(const n of e){const{id:e,r:l,n:c,y:u,d:h,os:d,ds:p,ts:f,fs:m,v:g,delay:_,carComposition:y}=n,v=e.replace(".Marunouchi.",".MarunouchiBranch.");t.lastDynamicUpdate[n.o]=n.date,o.add(n.id);const x=i.get(e)||i.get(v);if(x){if(!(u&&u!==x.y.id||d&&x.os&&d[0]!==x.os[0].id||p&&x.ds&&p[0]!==x.ds[0].id||g&&g!==x.v.id||!isNaN(y)&&y!==x.carComposition||!isNaN(_)&&_!==x.delay)){x.timetable||x.update({ts:f,fs:m},s);continue}t.stopTrain(x,!0)}let b=t.timetables.getByTrainId(e);if(0===b.length&&(b=t.timetables.getByTrainId(v)),0===b.length)l&&(l===RAILWAY_NAMBOKU&&(d[0].startsWith(RAILWAY_MITA)||p[0].startsWith(RAILWAY_MITA))||l!==RAILWAY_ARAKAWA&&t.trainStart(new Train({id:e,r:l,n:c,y:u,d:h,os:d,ds:p,ts:f,fs:m,delay:_,carComposition:y},s)));else for(const e of b){const n=new Train(e);n.update({y:u,os:d,ds:p,v:g,delay:_,carComposition:y},s),e.start+(_||0)<=a&&a<=e.end+(_||0)?t.trainStart(n):(t.deactivateTrain(n),r.set(e.id,n))}}for(const e of i.values()){const n=e.r;((n.status&&n.dynamic||!e.timetable)&&!o.has(e.id)||n.suspended)&&t.stopTrain(e)}t.refreshTrains(),t.aboutPanel.updateContent()})).catch((e=>{t.refreshTrains()}))}refreshRealtimeFlightData(){const t=this;loadDynamicFlightData(t.secrets).then((({atisData:e,flightData:n})=>{const i=t.flightLookup,{landing:r,departure:o}=e,s=[r.join("/"),o.join("/")].join(" "),a={},l={};let c={},u={},h=!0;if(t.flightPattern!==s){t.flightPattern=s,t.lastFlightPatternChanged=Date.now();for(const e of t.activeFlightLookup.values())t.stopFlight(e)}includes(r,["R16L","R16R"])?(c={S:"R16L",N:"R16R"},u={S:"22",N:"16R"},h=!1):includes(r,["L22","L23"])?(c={S:"L23",N:"L22"},u={S:"O16R",N:"16L"},h=!1):includes(r,["I16L","I16R"])?(c={S:"I16L",N:"I16R"},u={S:"22",N:"16R"},h=!1):includes(r,["I22","I23"])?(c={S:"I23",N:"I22"},u={S:"16R",N:"16L"},h=!1):includes(r,["I34L","H34R"])?(c={S:"IX34L",N:"H34R"},u={S:"05",N:"34R"},h=!0):includes(r,["I34L","I34R"])?(c={S:"IZ34L",N:"H34R"},u={S:"05",N:"34R"},h=!0):1!==r.length||(includes(r,"I23")?(c={S:"IY23",N:"IY23"},h=!1):includes(r,"L23")?(c={S:"LY23",N:"LY23"},h=!1):includes(r,"I34L")?(c={S:"IX34L",N:"IX34L"},h=!0):includes(r,"I34R")?(c={S:"IY34R",N:"IY34R"},h=!0):includes(r,"L22")&&(c={S:"L22",N:"L22"},h=!1),includes(o,"16L")?u={S:"N16L",N:"N16L"}:includes(o,"05")?u={S:"N05",N:"N05"}:includes(o,"16R")&&(u={S:"16R",N:"16R"}));for(const t of n)if(includes(AIRLINES_FOR_ANA_CODE_SHARE,t.a)){const{dp:e,ds:n,sdt:i,or:r,ar:o,sat:s}=t;a[`${e||r}.${n||o}.${i||s}`]=t}for(const e of n){const{id:n,n:r,dp:o,ds:s,sdt:d,or:p,ar:f,sat:m}=e;let g=i.get(n),_=e.s,{maxFlightSpeed:y,flightAcceleration:v}=configs;if(n.match(/NH\d{4}$/)){const t=a[`${o||p}.${s||f}.${d||m}`];if(t){t.n.push(...r);continue}}if(!g){if(includes(["Cancelled","PostponedTomorrow"],_))continue;const a=t.airports.get(s||p),l=a?a.direction:"S",d="NRT"===o?`NRT.${h?"34L":"16R"}.Dep`:"NRT"===f?`NRT.${h?"34R":"16L"}.Arr`:"HND"===o?`HND.${u[l]}.Dep`:"HND"===f?`HND.${c[l]}.Arr`:void 0,m=t.featureLookup.get(d);if(!m)continue;g=new Flight({id:n,n:r,a:e.a,dp:o,ar:f,ds:s,or:p},{airports:t.airports,operators:t.operators}),g.runway=d.replace(/^([^.]+\.)[A-Z]*([^.]+).+/,"$1$2"),g.feature=m,i.set(g.id,g)}g.update({edt:e.edt,adt:e.adt,sdt:d,eat:e.eat,aat:e.aat,sat:m});const x=valueOrDefault(g.edt,valueOrDefault(g.adt,g.sdt)),b=valueOrDefault(g.eat,valueOrDefault(g.aat,g.sat));void 0===b||_?void 0===x||_&&"CheckIn"!==_&&"NowBoarding"!==_&&"FinalCall"!==_&&"BoardingComplete"!==_&&"Departed"!==_||(x<g.sdt?_="NewTime":x>g.sdt?_="Delayed":x===g.sdt&&(_="OnTime")):b<g.sat?_="NewTime":b>g.sat?_="Delayed":b===g.sat&&(_="OnTime"),g.update({s:_},{flightStatuses:t.flightStatuses}),void 0!==b&&(y/=2,v/=-2);const T=y/Math.abs(v)/2+g.feature.properties.length/y,E=configs.standingDuration;x?(g.start=g.base=x,g.entry=g.start-E,g.end=g.start+T):(g.start=g.entry=b-T,g.base=g.start+T-E,g.end=g.start+T+E),g.maxSpeed=y,g.acceleration=v;(l[g.runway]=l[g.runway]||[]).push(g),t.lastDynamicUpdate[e.o]=e.date}for(const t of Object.keys(l)){const e=l[t];let n=0;e.sort(((t,e)=>t.base-e.base));for(const t of e){const e=t.base,i=Math.max(e,n+configs.minFlightInterval)-e;i&&(t.start+=i,t.base+=i,t.entry+=i,t.end+=i),n=t.base}}t.refreshFlights(),t.aboutPanel.updateContent()})).catch((e=>{t.refreshFlights()}))}refreshRealtimeBusData(){const t=this;loadDynamicBusData([...t.gtfs.values()]).then((e=>{for(const{gtfs:n,vehiclePosition:i}of e){const{id:e,featureLookup:r,stopLookup:o,tripLookup:s,activeBusLookup:a,realtimeBuses:l}=n;l.clear(),n.date=t.clock.getString(1e3*i.header.timestamp);for(const{id:n,vehicle:c}of i.entity){const i=c.vehicle,u=c.currentStopSequence,h=c.position,d=c.trip&&c.trip.tripId;if(!u&&!h||!d)continue;const p=s.get(d),f=p&&r.get(p.shape);if(!p||!f)continue;const m=a.has(d);let g;if(m)g=a.get(d);else{let t=0;const r=p.stops.map((e=>t=nearestCloserPointOnLine(f,o.get(e).coord,t).properties.location));g={id:i?i.license_plate||i.id:n,gtfsId:e,trip:p,feature:f,offsets:r,offset:0}}if(u)g.stop=u;else{const t=g.offsets,e=nearestCloserPointOnLine(f,[h.longitude,h.latitude],g.offset).properties.location;g.stop=p.stopSequences[t.reduce(((n,i,r)=>i<e?Math.min(r+1,t.length-1):n),0)]}m||t.busStart(g),l.add(d)}}t.aboutPanel.updateContent()})).catch((t=>{}))}updateUndergroundButton(t){const{container:e,dict:n}=this,i=e.querySelector(".mapboxgl-ctrl-underground");if(i){const e=i.classList;"underground"===t?(i.title=n["exit-underground"],e.add("mapboxgl-ctrl-underground-visible")):(i.title=n["enter-underground"],e.remove("mapboxgl-ctrl-underground-visible"))}}updatePlaybackButton(t){const{container:e,dict:n}=this,i=e.querySelector(".mapboxgl-ctrl-playback");if(i){const e=i.classList;"playback"===t?(i.title=n["exit-playback"],e.add("mapboxgl-ctrl-playback-active")):(i.title=n["enter-playback"],e.remove("mapboxgl-ctrl-playback-active"))}}updateEcoButton(t){const{container:e,dict:n}=this,i=e.querySelector(".mapboxgl-ctrl-eco");if(i){const e=i.classList;"eco"===t?(i.title=n["exit-eco"],e.add("mapboxgl-ctrl-eco-active")):(i.title=n["enter-eco"],e.remove("mapboxgl-ctrl-eco-active"))}}refreshMap(){const t=this,{viewMode:e,searchMode:n}=t,i="mt3d:opacity"+("underground"===e?"-underground":"");setStyleOpacities(t.map,t.styleOpacities,"none"===n||"edit"===n?i:[`${i}-route`,i]),t.trafficLayer.setMode(e,n)}_setSearchMode(t){const e=this;if(e.searchMode!==t){e.searchMode=t,e.stopAll();for(const n of e.plugins)n.setVisibility("none"===t);e.refreshMap()}}_setViewMode(t){const e=this;e.viewMode!==t&&(e.updateUndergroundButton(t),e.viewMode=t,e.refreshMap(),e.fire({type:"viewmode",mode:t}))}_setTrackingMode(t){const e=this;e.trackingMode!==t&&(e.trackingMode=t,isVehicle(e.trackedObject)&&(e.updateBaseZoom(),e.updateTrackingParams(!0),e.updateHandlersAndControls(),e.startViewAnimation()),e.fire({type:"trackingmode",mode:t}))}_setClockMode(t){const e=this;e.clockMode!==t&&(e.updatePlaybackButton(t),e.clockMode=t,e.clock.reset(),e.onClockChange(),e.clockControl&&e.clockCtrl.setMode(t),"playback"===t&&e.resetRailwayStatus(),e.fire({type:"clockmode",mode:t}))}_setEcoMode(t){const e=this;e.ecoMode!==t&&(e.updateEcoButton(t),e.ecoMode=t,e.fire({type:"ecomode",mode:t}))}onClockChange(){const t=this,e=t.clock.getTime("03:00");t.stopAll(),t.markObject(),t.trackObject(),t.lastTimetableRefresh!==e&&(t.refreshTrainTimetableData(),t.lastTimetableRefresh=e)}getLightColor(){return getSunlightColor(this.map,this.clock.getTime())}pickObject(t){const e=this,{map:n,layerZoom:i}=e,r=["ground","underground"];let o;"underground"===e.viewMode&&r.reverse();for(const s of r){if(o=e.trafficLayer.pickObject(s,t),o)return o;if(o="ground"===s?n.queryRenderedFeatures(t,{layers:[`stations-og-${i}`]})[0]:pickObject(n,`stations-ug-${i}`,t),o)return e.stationGroupLookup.get(o.properties.group)}}markObject(t){const e=this,{markedObject:n,trafficLayer:i,map:r,popup:o}=e;isEqualObject(n,t)||(n&&(isVehicle(n)?(n.outline=0,i.updateObject(n)):e.removeStationOutline("stations-marked"),delete e.markedObject,o&&o.isOpen()&&(r.getCanvas().style.cursor="",o.remove())),t&&!t.removing&&(e.markedObject=t,r.getCanvas().style.cursor="pointer",e.popup=new Popup$1({className:isTouchDevice()?"popup-object popup-touch":"popup-object",closeButton:!1,closeOnClick:!1,maxWidth:"300px",offset:{top:[0,10],bottom:[0,-30]},openingAnimation:{duration:300,easing:"easeOutBack"}}),e.updatePopup({setHTML:!0,addToMap:!0}),isVehicle(t)?(t.outline=1,i.updateObject(t)):e.addStationOutline(t,"stations-marked")))}trackObject(t){const e=this,{searchMode:n,lang:i,map:r,trackedObject:o,lastCameraParams:s,sharePanel:a,detailPanel:l}=e;if("edit"===n&&l&&isStation(t)){const{title:e,utitle:n}=t.stations[0],r=n&&n[i]||normalize$5(e[i]||e.en);l.fillStationName(r)}else if(isEqualObject(o,t))(isVehicle(t)||isStation(t))&&e.detailPanel&&e.detailPanel.reset();else{if(!o&&t?(s.viewMode=e.getViewMode(),delete s.center,s.zoom=r.getZoom(),s.bearing=r.getBearing(),s.pitch=r.getPitch()):o&&!t&&(e._setViewMode(s.viewMode),r.flyTo({center:s.center||r.getCenter(),zoom:s.zoom,bearing:s.bearing,pitch:s.pitch})),o){if(isVehicle(o)){const t=o.object;o.outline=0,e.trafficLayer.updateObject(o),e.fire({type:"deselection",deselection:t.id})}else isStation(o)?(e.removeStationOutline("stations-selected"),e.fire({type:"deselection",deselection:o.stations.map((({id:t})=>t))}),e._setSearchMode("none"),e.hideStationExits()):e.fire(Object.assign({type:"deselection"},o));delete e.trackedObject,e.updateHandlersAndControls(),e.stopViewAnimation(),a&&(a.remove(),delete e.sharePanel),l&&(l.remove(),delete e.detailPanel)}if(t&&!t.removing)if(e.trackedObject=t,isVehicle(t)){const n=t.object;e.updateBaseZoom(),e.updateTrackingParams(!0),e.updateHandlersAndControls(),e.startViewAnimation(),e._setViewMode(t.altitude<0?"underground":"ground"),includes(["train","flight"],t.type)&&"realtime"===e.clockMode&&navigator.share&&(e.sharePanel=new SharePanel({object:n}),e.sharePanel.addTo(e)),n.timetable?(e.detailPanel=new TrainPanel({object:n}),e.detailPanel.addTo(e)):n.trip&&(e.detailPanel=new BusPanel({object:n}),e.detailPanel.addTo(e)),t.outline=1,e.trafficLayer.updateObject(t),e.fire({type:"selection",selection:n.id})}else if(isStation(t)){const n=t.stations.concat(t.hidden||[]),i=n.map((t=>t.coord)),o=s.center=getBounds$1(i).getCenter();if("ground"===t.layer)e._setViewMode("ground");else if(r.getCenter().distanceTo(o)){let t=r.getZoom();const n=t,i=()=>{const i=r.getZoom();i<t&&i<n-.5?e._setViewMode("ground"):i>t&&i>15&&e._setViewMode("underground"),t=i};r.on("zoom",i),r.once("zoomend",(()=>{e._setViewMode("underground"),r.off("zoom",i)}))}else e._setViewMode("underground");r.flyTo({center:o,zoom:15.5}),e.detailPanel=new StationPanel({object:n}),e.detailPanel.addTo(e),e.addStationOutline(t,"stations-selected"),e.fire({type:"selection",selection:t.stations.map((({id:t})=>t))})}else e.fire(Object.assign({type:"selection"},t))}}showStationExits(t){const e=this,n=e.map,i=[].concat(...t.map((t=>t.exit||[])));if(i.length>0){const t=[];e.exitPopups=i.map(((r,o)=>{const{coord:s,facilities:a=[]}=r,l=a.map((t=>`<span class="exit-${t}-small-icon"></span>`)).join(""),c=()=>{e.exitPopups[o]=setTimeout((()=>{const t=new Popup$1({className:"popup-exit",closeButton:!1,closeOnClick:!1});t.setLngLat(s).setHTML(l+e.getLocalizedPOITitle(r)).addTo(n).getElement().id=`exit-${o}`,e.exitPopups[o]=t}),o/i.length*1e3)};return n.once("moveend",c),t.push(s),c})),n.fitBounds(getBounds$1(t),{bearing:n.getBearing(),pitch:n.getPitch(),offset:[0,-n.transform.height/12],padding:{top:20,bottom:20,left:10,right:50},maxZoom:18})}}hideStationExits(){const t=this;for(const e of t.exitPopups)e instanceof Popup$1?e.remove():"function"==typeof e?t.map.off("moveend",e):clearTimeout(e);t.exitPopups=[]}updateBaseZoom(){const t=this,{map:e,trackedObject:n}=t;if(isVehicle(n)){const i=t.getModelPosition(n.coord,n.altitude).z,r=e.getFreeCameraOptions().position.z;t.baseZoom=e.getZoom()+Math.log2(r/Math.abs(r-i))}}updatePopup(t){const e=this,{markedObject:n,map:i,popup:r}=e,{setHTML:o,addToMap:s}=t||{};if(isVehicle(n)){const t=n===e.trackedObject?i.getBearing():void 0;r.setLngLat(e.adjustCoord(n.coord,n.altitude,t)),o&&r.setHTML("train"===n.type?e.getTrainDescription(n.object):"flight"===n.type?e.getFlightDescription(n.object):e.getBusDescription(n.object))}else{const t=e.featureLookup.get(`${n.id}.${e.layerZoom}`),i=getCenterCoord(t),s=getAltitude(t);if(r.setLngLat(e.adjustCoord(i,s)),o){const t=n.stations,i={};for(const n of t){const t=e.getLocalizedStationTitle(n),r=n.railway;(i[t]=i[t]||{})[e.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('${t[0].thumbnail}');"></div>`,"</div>",'<div class="railway-list">',Object.keys(i).map((t=>{const e=Object.keys(i[t]).map((e=>`<div class="line-strip" style="background-color: ${i[t][e]};"></div><span>${e}</span>`)).join("<br>");return`<strong>${t}</strong><br>${e}`})).join("<br>"),"</div>"].join(""))}}s&&r.addTo(i)}addStationOutline(t,e){const n=this,i=t.stations[0].id;for(const t of[13,14,15,16,17,18])setLayerProps(n.map,`${e}-${t}`,{data:featureFilter(n.featureCollection,(e=>e.zoom===t&&e.ids&&e.ids[0]===i)),opacity:1,visible:!0})}removeStationOutline(t){for(const e of[13,14,15,16,17,18])setLayerProps(this.map,`${t}-${e}`,{visible:!1})}refreshStationOutline(){const t=performance.now()%1500/1500*2;for(const e of[13,14,15,16,17,18])setLayerProps(this.map,`stations-selected-${e}`,{opacity:t<1?t:2-t,visible:!0})}setSectionData(t,e,n){const i=t.r.stations,{direction:r,timetable:o}=t,s=(t.ds||[])[0],a=t.delay||0,l=this.clock.getTimeOffset();let c,u,h,d,p,f,m,g;if(o){const t=o.stations;c=o.arrivalTimes,u=o.departureTimes,h=valueOrDefault(e,u.reduce(((t,e,n)=>void 0!==e&&e+a<=l?n:t),0)),d=t[h],p=t[h+1]}else d=t.fs||t.ts,p=t.ts||t.fs;if(r>0?(f=i.indexOf(d),m=i.indexOf(p,f),g=i.indexOf(s,f),-1===g&&(g=i.length-1)):(f=i.lastIndexOf(d),m=i.lastIndexOf(p,f),g=i.lastIndexOf(s,f),-1===g&&(g=0)),o){if(t.timetableIndex=h,t.departureStation=d,t.departureTime=valueOrDefault(u[h],c[h]),f>=0&&m>=0)return t.sectionIndex=f,t.sectionLength=m-f,t.arrivalStation=p,t.arrivalTime=c[h+1],t.nextDepartureTime=u[h+1],!0}else{const e=numberOrDefault(t.sectionIndex+t.sectionLength,f);if(t.departureStation=d,e>=0&&e!==g&&(!n&&m>=0||n&&g>=0))return t.sectionIndex=e,t.sectionLength=(n?g:m)-e,t.arrivalStation=p===d?i[e+r]:p,!0}t.arrivalStation=t.arrivalTime=t.nextDepartureTime=void 0}setBusSectionData(t,e){const n=t.trip.stopSequences,i=n.indexOf(t.stop),r=n.length-1,o=Math.min(i+1,r),s=numberOrDefault(t.sectionIndex+t.sectionLength,i);return t.sectionIndex=s,t.sectionLength=o-s,!e&&s!==r}}function initContainer(t){const e=createElement$1("div",{id:"map"},t);return createElement$1("div",{id:"loader",className:"loader-inner ball-pulse",innerHTML:"<div></div><div></div><div></div>"},t),createElement$1("div",{id:"loading-error"},t),t.classList.add("mini-tokyo-3d"),e}function showLoader(t){const e=t.querySelector("#loader");e.style.opacity=1,e.style.display="block"}function hideLoader(t){const e=t.querySelector("#loader");e.style.opacity=0,setTimeout((()=>{e.style.display="none"}),1e3)}function showErrorMessage(t){const e=t.querySelector("#loader"),n=t.querySelector("#loading-error");e.style.display="none",n.innerHTML="Loading failed. Please reload the page.",n.style.display="block"}function startTrainAnimation(t,e,n,i,r,o,s){let a,l,{maxSpeed:c,acceleration:u,maxAccelerationTime:h,maxAccDistance:d}=configs;return n<=2*d?(a=2*Math.sqrt(n/u),l=a/2):(a=2*h+(n-2*d)/c,r>0&&(a=clamp$3(a,i||0,r),d=u*a*a/8,n>=2*d?(c=2*n/a,u=2*c/a):c=u*a/2-Math.sqrt(u*(2*d-n))),l=c/u),animation.start({callback:e=>{const i=a-e;let r;r=e<=l?u/2*e*e:i<=l?n-u/2*i*i:c*(e-l/2),t(r/n)},complete:e,duration:a,start:o>0?s.getHighResTime()-o:void 0,clock:s})}function startFlightAnimation(t,e,n,i,r,o,s){const a=i/Math.abs(r),l=a/2+n/i;return animation.start({callback:e=>{const o=l-e;let s;s=r>0?e<=a?r/2*e*e:i*(e-a/2):o<=a?n+r/2*o*o:i*e,t(s/n)},complete:e,duration:l,start:o>0?s.getHighResTime()-o:void 0,clock:s})}function startBusAnimation(t,e,n,i,r){const{maxBusSpeed:o,busAcceleration:s,maxBusAccelerationTime:a,maxBusAccDistance:l}=configs,c=n<2*l?2*Math.sqrt(n/s):2*a+(n-2*l)/o,u=Math.min(a,c/2);return animation.start({callback:e=>{const i=c-e;let r;r=e<=u?s/2*e*e:i<=u?n-s/2*i*i:o*(e-u/2),t(r/n)},complete:e,duration:c,start:void 0,clock:r})}function easeInQuad(t){return t*t}function easeOutQuart(t){return-((t-=1)*t*t*t-1)}function createInterpolant(t,e){const n=t.length,i=[],r=[];for(let o=0;o<n-1;o++){const n=t[o+1]-t[o],s=e[o+1]-e[o];i.push(n),r.push(s/n)}const o=[r[0]];for(let t=0;t<i.length-1;t++){const e=r[t],n=r[t+1];if(e*n<=0)o.push(0);else{const r=i[t],s=i[t+1],a=r+s;o.push(3*a/((a+s)/e+(a+r)/n))}}o.push(r[r.length-1]);const s=[],a=[];for(let t=0;t<o.length-1;t++){const e=o[t],n=r[t],l=1/i[t],c=e+o[t+1]-n-n;s.push((n-e-c)*l),a.push(c*l*l)}return n=>{let i=t.length-1;if(n===t[i])return e[i];let r,l=0,c=a.length-1;for(;l<=c;){r=Math.floor(.5*(l+c));const i=t[r];if(i<n)l=r+1;else{if(!(i>n))return e[r];c=r-1}}i=Math.max(0,c);const u=n-t[i],h=u*u;return e[i]+o[i]*u+s[i]*h+a[i]*u*h}}function getLayerZoom(t){return clamp$3(Math.floor(t),13,18)}function isVehicle(t){return t&&includes(["train","flight","bus"],t.type)}function isStation(t){return t&&"station"===t.type}function isEqualObject(t,e){return t===e||!!(t&&t.properties&&e&&e.properties&&t.properties.ids===e.properties.ids)}class Popup{constructor(){this._popup=new Popup$1({className:isTouchDevice()?"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(t){return this._popup.addTo(t.map),this}remove(){return this._popup.remove(),this}setLngLat(t){return this._popup.setLngLat(t),this}setHTML(t){return this._popup.setHTML(t),this}}class GLTFLoader extends Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new GLTFMaterialsClearcoatExtension(t)})),this.register((function(t){return new GLTFMaterialsDispersionExtension(t)})),this.register((function(t){return new GLTFTextureBasisUExtension(t)})),this.register((function(t){return new GLTFTextureWebPExtension(t)})),this.register((function(t){return new GLTFTextureAVIFExtension(t)})),this.register((function(t){return new GLTFMaterialsSheenExtension(t)})),this.register((function(t){return new GLTFMaterialsTransmissionExtension(t)})),this.register((function(t){return new GLTFMaterialsVolumeExtension(t)})),this.register((function(t){return new GLTFMaterialsIorExtension(t)})),this.register((function(t){return new GLTFMaterialsEmissiveStrengthExtension(t)})),this.register((function(t){return new GLTFMaterialsSpecularExtension(t)})),this.register((function(t){return new GLTFMaterialsIridescenceExtension(t)})),this.register((function(t){return new GLTFMaterialsAnisotropyExtension(t)})),this.register((function(t){return new GLTFMaterialsBumpExtension(t)})),this.register((function(t){return new GLTFLightsExtension(t)})),this.register((function(t){return new GLTFMeshoptCompression(t)})),this.register((function(t){return new GLTFMeshGpuInstancing(t)}))}load(t,e,n,i){const r=this;let o;if(""!==this.resourcePath)o=this.resourcePath;else if(""!==this.path){const e=LoaderUtils.extractUrlBase(t);o=LoaderUtils.resolveURL(e,this.path)}else o=LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const s=function(e){i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)},a=new FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,(function(n){try{r.parse(n,o,(function(n){e(n),r.manager.itemEnd(t)}),s)}catch(t){s(t)}}),n,s)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r;const o={},s={},a=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(a.decode(new Uint8Array(t,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{o[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(t)}catch(t){return void(i&&i(t))}r=JSON.parse(o[EXTENSIONS.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new GLTFParser(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](l);s[e.name]=e,o[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],n=r.extensionsRequired||[];switch(e){case EXTENSIONS.KHR_MATERIALS_UNLIT:o[e]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:o[e]=new GLTFDracoMeshCompressionExtension(r,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:o[e]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:o[e]=new GLTFMeshQuantizationExtension;break;default:n.indexOf(e)}}l.setExtensions(o),l.setPlugins(s),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise((function(i,r){n.parse(t,e,i,r)}))}}function GLTFRegistry(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const EXTENSIONS={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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let i=e.cache.get(n);if(i)return i;const r=e.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let s;const a=new Color(16777215);void 0!==o.color&&a.setRGB(o.color[0],o.color[1],o.color[2],LinearSRGBColorSpace);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":s=new DirectionalLight(a),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new PointLight(a),s.distance=l;break;case"spot":s=new SpotLight(a),s.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,s.angle=o.spot.outerConeAngle,s.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return s.position.set(0,0,0),s.decay=2,assignExtrasToUserData(s,o),void 0!==o.intensity&&(s.intensity=o.intensity),s.name=e.createUniqueName(o.name||"light_"+t),i=Promise.resolve(s),e.cache.add(n,i),i}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,i=n.json.nodes[t],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(t){return n._getNodeRef(e.cache,r,t)}))}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return MeshBasicMaterial}extendParams(t,e,n){const i=[];t.color=new Color(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.setRGB(e[0],e[1],e[2],LinearSRGBColorSpace),t.opacity=e[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(t,"map",r.baseColorTexture,SRGBColorSpace))}return Promise.all(i)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(e.emissiveIntensity=i),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];if(void 0!==o.clearcoatFactor&&(e.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&r.push(n.assignTexture(e,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(e.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&r.push(n.assignTexture(e,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(r.push(n.assignTexture(e,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const t=o.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new Vector2(t,t)}return Promise.all(r)}}class GLTFMaterialsDispersionExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_DISPERSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}class GLTFMaterialsIridescenceExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return void 0!==o.iridescenceFactor&&(e.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&r.push(n.assignTexture(e,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(e.iridescenceIOR=o.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&r.push(n.assignTexture(e,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class GLTFMaterialsSheenExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const o=i.extensions[this.name];if(void 0!==o.sheenColorFactor){const t=o.sheenColorFactor;e.sheenColor.setRGB(t[0],t[1],t[2],LinearSRGBColorSpace)}return void 0!==o.sheenRoughnessFactor&&(e.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&r.push(n.assignTexture(e,"sheenColorMap",o.sheenColorTexture,SRGBColorSpace)),void 0!==o.sheenRoughnessTexture&&r.push(n.assignTexture(e,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}}class GLTFMaterialsTransmissionExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return void 0!==o.transmissionFactor&&(e.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&r.push(n.assignTexture(e,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class GLTFMaterialsVolumeExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];e.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&r.push(n.assignTexture(e,"thicknessMap",o.thicknessTexture)),e.attenuationDistance=o.attenuationDistance||1/0;const s=o.attenuationColor||[1,1,1];return e.attenuationColor=(new Color).setRGB(s[0],s[1],s[2],LinearSRGBColorSpace),Promise.all(r)}}class GLTFMaterialsIorExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];e.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&r.push(n.assignTexture(e,"specularIntensityMap",o.specularTexture));const s=o.specularColorFactor||[1,1,1];return e.specularColor=(new Color).setRGB(s[0],s[1],s[2],LinearSRGBColorSpace),void 0!==o.specularColorTexture&&r.push(n.assignTexture(e,"specularColorMap",o.specularColorTexture,SRGBColorSpace)),Promise.all(r)}}class GLTFMaterialsBumpExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return e.bumpScale=void 0!==o.bumpFactor?o.bumpFactor:1,void 0!==o.bumpTexture&&r.push(n.assignTexture(e,"bumpMap",o.bumpTexture)),Promise.all(r)}}class GLTFMaterialsAnisotropyExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return void 0!==o.anisotropyStrength&&(e.anisotropy=o.anisotropyStrength),void 0!==o.anisotropyRotation&&(e.anisotropyRotation=o.anisotropyRotation),void 0!==o.anisotropyTexture&&r.push(n.assignTexture(e,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}}class GLTFTextureBasisUExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],o=e.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,o)}}class GLTFTextureWebPExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const o=r.extensions[e],s=i.images[o.source];let a=n.textureLoader;if(s.uri){const t=n.options.manager.getHandler(s.uri);null!==t&&(a=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,o.source,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class GLTFTextureAVIFExtension{constructor(t){this.parser=t,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const o=r.extensions[e],s=i.images[o.source];let a=n.textureLoader;if(s.uri){const t=n.options.manager.getHandler(s.uri);null!==t&&(a=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,o.source,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class GLTFMeshoptCompression{constructor(t){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(e){const n=t.count,i=t.byteStride,o=new Uint8Array(e,t.byteOffset||0,t.byteLength||0);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(n,i,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(n*i);return r.decodeGltfBuffer(new Uint8Array(e),n,i,o,t.mode,t.filter),e}))}))}return null}}class GLTFMeshGpuInstancing{constructor(t){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=e.meshes[n.mesh];for(const t of i.primitives)if(t.mode!==WEBGL_CONSTANTS.TRIANGLES&&t.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&t.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=n.extensions[this.name].attributes,o=[],s={};for(const t in r)o.push(this.parser.getDependency("accessor",r[t]).then((e=>(s[t]=e,s[t]))));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then((t=>{const e=t.pop(),n=e.isGroup?e.children:[e],i=t[0].count,r=[];for(const t of n){const e=new Matrix4,n=new Vector3,o=new Quaternion,a=new Vector3(1,1,1),l=new InstancedMesh(t.geometry,t.material,i);for(let t=0;t<i;t++)s.TRANSLATION&&n.fromBufferAttribute(s.TRANSLATION,t),s.ROTATION&&o.fromBufferAttribute(s.ROTATION,t),s.SCALE&&a.fromBufferAttribute(s.SCALE,t),l.setMatrixAt(t,e.compose(n,o,a));for(const e in s)if("_COLOR_0"===e){const t=s[e];l.instanceColor=new InstancedBufferAttribute(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,s[e]);Object3D.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),r.push(l)}return e.isGroup?(e.clear(),e.add(...r),e):r[0]})))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(t){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,BINARY_EXTENSION_HEADER_LENGTH),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,r=new DataView(t,BINARY_EXTENSION_HEADER_LENGTH);let o=0;for(;o<i;){const e=r.getUint32(o,!0);o+=4;const i=r.getUint32(o,!0);if(o+=4,i===BINARY_EXTENSION_CHUNK_TYPES.JSON){const i=new Uint8Array(t,BINARY_EXTENSION_HEADER_LENGTH+o,e);this.content=n.decode(i)}else if(i===BINARY_EXTENSION_CHUNK_TYPES.BIN){const n=BINARY_EXTENSION_HEADER_LENGTH+o;this.body=t.slice(n,n+e)}o+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,s={},a={},l={};for(const t in o){const e=ATTRIBUTES[t]||t.toLowerCase();s[e]=o[t]}for(const e in t.attributes){const i=ATTRIBUTES[e]||e.toLowerCase();if(void 0!==o[e]){const r=n.accessors[t.attributes[e]];l[i]=WEBGL_COMPONENT_TYPES[r.componentType].name,a[i]=!0===r.normalized}}return e.getDependency("bufferView",r).then((function(t){return new Promise((function(e,n){i.decodeDracoFile(t,(function(t){for(const e in t.attributes){const n=a[e];void 0!==n&&(t.attributes[e].normalized=n)}e(t)}),s,l,LinearSRGBColorSpace,n)}))}))}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends Interpolant{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let t=0;t!==i;t++)e[t]=n[r+t];return e}interpolate_(t,e,n,i){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=2*s,l=3*s,c=i-e,u=(n-e)/c,h=u*u,d=h*u,p=t*l,f=p-l,m=-2*d+3*h,g=d-h,_=1-m,y=g-h+u;for(let t=0;t!==s;t++){r[t]=_*o[f+t+s]+y*(o[f+t+a]*c)+m*o[p+t+s]+g*(o[p+t]*c)}return r}}const _q=new Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(t,e,n,i){const r=super.interpolate_(t,e,n,i);return _q.fromArray(r).normalize().toArray(r),r}}const WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:NearestFilter,9729:LinearFilter,9984:NearestMipmapNearestFilter,9985:LinearMipmapNearestFilter,9986:NearestMipmapLinearFilter,9987:LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:ClampToEdgeWrapping,33648:MirroredRepeatWrapping,10497:RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={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"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:InterpolateLinear,STEP:InterpolateDiscrete},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function createDefaultMaterial(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:FrontSide})),t.DefaultMaterial}function addUnknownExtensionsToUserData(t,e,n){for(const i in n.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function assignExtrasToUserData(t,e){void 0!==e.extras&&"object"==typeof e.extras&&Object.assign(t.userData,e.extras)}function addMorphTargets(t,e,n){let i=!1,r=!1,o=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(o=!0),i&&r&&o)break}if(!i&&!r&&!o)return Promise.resolve(t);const s=[],a=[],l=[];for(let c=0,u=e.length;c<u;c++){const u=e[c];if(i){const e=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):t.attributes.position;s.push(e)}if(r){const e=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):t.attributes.normal;a.push(e)}if(o){const e=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):t.attributes.color;l.push(e)}}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(l)]).then((function(e){const n=e[1],s=e[2];return i&&(t.morphAttributes.position=e[0]),r&&(t.morphAttributes.normal=n),o&&(t.morphAttributes.color=s),t.morphTargetsRelative=!0,t}))}function updateMorphTargets(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,i=e.weights.length;n<i;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,i=n.length;e<i;e++)t.morphTargetDictionary[n[e]]=e}}}function createPrimitiveKey(t){let e;const n=t.extensions&&t.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(e=n?"draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):t.indices+":"+createAttributesKey(t.attributes)+":"+t.mode,void 0!==t.targets)for(let n=0,i=t.targets.length;n<i;n++)e+=":"+createAttributesKey(t.targets[n]);return e}function createAttributesKey(t){let e="";const n=Object.keys(t).sort();for(let i=0,r=n.length;i<r;i++)e+=n[i]+":"+t[n[i]]+";";return e}function getNormalizedComponentScale(t){switch(t){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.")}}function getImageURIMimeType(t){return t.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"}const _identityMatrix=new Matrix4;class GLTFParser{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new GLTFRegistry,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 n=!1,i=-1,r=!1,o=-1;if("undefined"!=typeof navigator){const t=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);i=n&&e?parseInt(e[1],10):-1,r=t.indexOf("Firefox")>-1,o=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}this.textureLoader="undefined"==typeof createImageBitmap||n&&i<17||r&&o<98?new TextureLoader(this.options.manager):new ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const o={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return addUnknownExtensionsToUserData(r,o,i),assignExtrasToUserData(o,i),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(o)}))).then((function(){for(const t of o.scenes)t.updateMatrixWorld();t(o)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n].joints;for(let e=0,n=i.length;e<n;e++)t[i[e]].isBone=!0}for(let e=0,i=t.length;e<i;e++){const i=t[e];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone(),r=(t,e)=>{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne((function(t){return t.loadNode&&t.loadNode(e)}));break;case"mesh":i=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":i=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne((function(t){return t.loadAnimation&&t.loadAnimation(e)}));break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(t,e)})),!i)throw new Error("Unknown type: "+t)}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this;e=Promise.all((this.json[t+("mesh"===t?"es":"s")]||[]).map((function(e,i){return n.getDependency(t,i)}))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(t,r){n.load(LoaderUtils.resolveURL(e.uri,i.path),t,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const n=e.byteOffset||0;return t.slice(n,n+(e.byteLength||0))}))}loadAccessor(t){const e=this,n=this.json,i=this.json.accessors[t];if(void 0===i.bufferView&&void 0===i.sparse){const t=WEBGL_TYPE_SIZES[i.type],e=!0===i.normalized,n=new(0,WEBGL_COMPONENT_TYPES[i.componentType])(i.count*t);return Promise.resolve(new BufferAttribute(n,t,e))}const r=[];return r.push(void 0!==i.bufferView?this.getDependency("bufferView",i.bufferView):null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(t){const r=t[0],o=WEBGL_TYPE_SIZES[i.type],s=WEBGL_COMPONENT_TYPES[i.componentType],a=s.BYTES_PER_ELEMENT,l=i.byteOffset||0,c=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,u=!0===i.normalized;let h,d;if(c&&c!==a*o){const t=Math.floor(l/c),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+t+":"+i.count;let p=e.cache.get(n);p||(h=new s(r,t*c,i.count*c/a),p=new InterleavedBuffer(h,c/a),e.cache.add(n,p)),d=new InterleavedBufferAttribute(p,o,l%c/a,u)}else h=null===r?new s(i.count*o):new s(r,l,i.count*o),d=new BufferAttribute(h,o,u);if(void 0!==i.sparse){const e=i.sparse.values.byteOffset||0,n=new(0,WEBGL_COMPONENT_TYPES[i.sparse.indices.componentType])(t[1],i.sparse.indices.byteOffset||0,i.sparse.count*WEBGL_TYPE_SIZES.SCALAR),a=new s(t[2],e,i.sparse.count*o);null!==r&&(d=new BufferAttribute(d.array.slice(),d.itemSize,d.normalized)),d.normalized=!1;for(let t=0,e=n.length;t<e;t++){const e=n[t];if(d.setX(e,a[t*o]),o>=2&&d.setY(e,a[t*o+1]),o>=3&&d.setZ(e,a[t*o+2]),o>=4&&d.setW(e,a[t*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}d.normalized=u}return d}))}loadTexture(t){const e=this.json,n=e.textures[t].source,i=e.images[n];let r=this.textureLoader;if(i.uri){const t=this.options.manager.getHandler(i.uri);null!==t&&(r=t)}return this.loadTextureImage(t,n,r)}loadTextureImage(t,e,n){const i=this,r=this.json,o=r.textures[t],s=r.images[e],a=(s.uri||s.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(e,n).then((function(e){e.flipY=!1,e.name=o.name||s.name||"",""===e.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(e.name=s.uri);const n=(r.samplers||{})[o.sampler]||{};return e.magFilter=WEBGL_FILTERS[n.magFilter]||LinearFilter,e.minFilter=WEBGL_FILTERS[n.minFilter]||LinearMipmapLinearFilter,e.wrapS=WEBGL_WRAPPINGS[n.wrapS]||RepeatWrapping,e.wrapT=WEBGL_WRAPPINGS[n.wrapT]||RepeatWrapping,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter,i.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[a]=l,l}loadImageSource(t,e){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const o=i.images[t],s=self.URL||self.webkitURL;let a=o.uri||"",l=!1;if(void 0!==o.bufferView)a=n.getDependency("bufferView",o.bufferView).then((function(t){l=!0;const e=new Blob([t],{type:o.mimeType});return a=s.createObjectURL(e),a}));else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const c=Promise.resolve(a).then((function(t){return new Promise((function(n,i){let o=n;!0===e.isImageBitmapLoader&&(o=function(t){const e=new Texture(t);e.needsUpdate=!0,n(e)}),e.load(LoaderUtils.resolveURL(t,r.path),o,void 0,i)}))})).then((function(t){return!0===l&&s.revokeObjectURL(a),assignExtrasToUserData(t,o),t.userData.mimeType=o.mimeType||getImageURIMimeType(o.uri),t})).catch((function(t){throw t}));return this.sourceCache[t]=c,c}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then((function(o){if(!o)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((o=o.clone()).channel=n.texCoord),r.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(o);o=r.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(o,t),r.associations.set(o,e)}}return void 0!==i&&(o.colorSpace=i),t[e]=o,o}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,o=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new PointsMaterial,Material.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new LineBasicMaterial,Material.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,this.cache.add(t,e)),n=e}if(i||r||o){let t="ClonedMaterial:"+n.uuid+":";i&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),o&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),r&&(e.vertexColors=!0),o&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}t.material=n}getMaterialType(){return MeshStandardMaterial}loadMaterial(t){const e=this,n=this.extensions,i=this.json.materials[t];let r;const o={},s=[];if((i.extensions||{})[EXTENSIONS.KHR_MATERIALS_UNLIT]){const t=n[EXTENSIONS.KHR_MATERIALS_UNLIT];r=t.getMaterialType(),s.push(t.extendParams(o,i,e))}else{const n=i.pbrMetallicRoughness||{};if(o.color=new Color(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;o.color.setRGB(t[0],t[1],t[2],LinearSRGBColorSpace),o.opacity=t[3]}void 0!==n.baseColorTexture&&s.push(e.assignTexture(o,"map",n.baseColorTexture,SRGBColorSpace)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(s.push(e.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),s.push(e.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),r=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),s.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,o)}))))}!0===i.doubleSided&&(o.side=DoubleSide);const a=i.alphaMode||ALPHA_MODES.OPAQUE;if(a===ALPHA_MODES.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,a===ALPHA_MODES.MASK&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&r!==MeshBasicMaterial&&(s.push(e.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new Vector2(1,1),void 0!==i.normalTexture.scale)){const t=i.normalTexture.scale;o.normalScale.set(t,t)}if(void 0!==i.occlusionTexture&&r!==MeshBasicMaterial&&(s.push(e.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&r!==MeshBasicMaterial){const t=i.emissiveFactor;o.emissive=(new Color).setRGB(t[0],t[1],t[2],LinearSRGBColorSpace)}return void 0!==i.emissiveTexture&&r!==MeshBasicMaterial&&s.push(e.assignTexture(o,"emissiveMap",i.emissiveTexture,SRGBColorSpace)),Promise.all(s).then((function(){const s=new r(o);return i.name&&(s.name=i.name),assignExtrasToUserData(s,i),e.associations.set(s,{materials:t}),i.extensions&&addUnknownExtensionsToUserData(n,s,i),s}))}createUniqueName(t){const e=PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return addPrimitiveAttributes(n,t,e)}))}const o=[];for(let n=0,s=t.length;n<s;n++){const s=t[n],a=createPrimitiveKey(s),l=i[a];if(l)o.push(l.promise);else{let t;t=s.extensions&&s.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?r(s):addPrimitiveAttributes(new BufferGeometry,s,e),i[a]={primitive:s,promise:t},o.push(t)}}return Promise.all(o)}loadMesh(t){const e=this,n=this.extensions,i=this.json.meshes[t],r=i.primitives,o=[];for(let t=0,e=r.length;t<e;t++){const e=void 0===r[t].material?createDefaultMaterial(this.cache):this.getDependency("material",r[t].material);o.push(e)}return o.push(e.loadGeometries(r)),Promise.all(o).then((function(o){const s=o.slice(0,o.length-1),a=o[o.length-1],l=[];for(let o=0,c=a.length;o<c;o++){const c=a[o],u=r[o];let h;const d=s[o];if(u.mode===WEBGL_CONSTANTS.TRIANGLES||u.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||u.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||void 0===u.mode)h=!0===i.isSkinnedMesh?new SkinnedMesh(c,d):new Mesh(c,d),!0===h.isSkinnedMesh&&h.normalizeSkinWeights(),u.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?h.geometry=toTrianglesDrawMode(h.geometry,TriangleStripDrawMode):u.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(h.geometry=toTrianglesDrawMode(h.geometry,TriangleFanDrawMode));else if(u.mode===WEBGL_CONSTANTS.LINES)h=new LineSegments(c,d);else if(u.mode===WEBGL_CONSTANTS.LINE_STRIP)h=new Line(c,d);else if(u.mode===WEBGL_CONSTANTS.LINE_LOOP)h=new LineLoop(c,d);else{if(u.mode!==WEBGL_CONSTANTS.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new Points(c,d)}Object.keys(h.geometry.morphAttributes).length>0&&updateMorphTargets(h,i),h.name=e.createUniqueName(i.name||"mesh_"+t),assignExtrasToUserData(h,i),u.extensions&&addUnknownExtensionsToUserData(n,h,u),e.assignFinalMaterial(h),l.push(h)}for(let n=0,i=l.length;n<i;n++)e.associations.set(l[n],{meshes:t,primitives:n});if(1===l.length)return i.extensions&&addUnknownExtensionsToUserData(n,l[0],i),l[0];const c=new Group;i.extensions&&addUnknownExtensionsToUserData(n,c,i),e.associations.set(c,{meshes:t});for(let t=0,e=l.length;t<e;t++)c.add(l[t]);return c}))}loadCamera(t){let e;const n=this.json.cameras[t],i=n[n.type];if(i)return"perspective"===n.type?e=new PerspectiveCamera(MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(e=new OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),assignExtrasToUserData(e,n),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],n=[];for(let t=0,i=e.joints.length;t<i;t++)n.push(this._loadNodeShallow(e.joints[t]));return n.push(void 0!==e.inverseBindMatrices?this.getDependency("accessor",e.inverseBindMatrices):null),Promise.all(n).then((function(t){const e=t.pop(),n=t,i=[],r=[];for(let t=0,o=n.length;t<o;t++){const o=n[t];if(o){i.push(o);const n=new Matrix4;null!==e&&n.fromArray(e.array,16*t),r.push(n)}}return new Skeleton(i,r)}))}loadAnimation(t){const e=this,n=this.json.animations[t],i=n.name?n.name:"animation_"+t,r=[],o=[],s=[],a=[],l=[];for(let t=0,e=n.channels.length;t<e;t++){const e=n.channels[t],i=n.samplers[e.sampler],c=e.target,u=void 0!==n.parameters?n.parameters[i.input]:i.input,h=void 0!==n.parameters?n.parameters[i.output]:i.output;void 0!==c.node&&(r.push(this.getDependency("node",c.node)),o.push(this.getDependency("accessor",u)),s.push(this.getDependency("accessor",h)),a.push(i),l.push(c))}return Promise.all([Promise.all(r),Promise.all(o),Promise.all(s),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=[];for(let t=0,i=n.length;t<i;t++){const i=n[t],c=r[t],u=o[t],h=s[t],d=a[t];if(void 0===i)continue;i.updateMatrix&&i.updateMatrix();const p=e._createAnimationTracks(i,c,u,h,d);if(p)for(let t=0;t<p.length;t++)l.push(p[t])}return new AnimationClip(i,void 0,l)}))}createNodeMesh(t){const e=this,n=this.json.nodes[t];return void 0===n.mesh?null:e.getDependency("mesh",n.mesh).then((function(t){const i=e._getNodeRef(e.meshCache,n.mesh,t);return void 0!==n.weights&&i.traverse((function(t){if(t.isMesh)for(let e=0,i=n.weights.length;e<i;e++)t.morphTargetInfluences[e]=n.weights[e]})),i}))}loadNode(t){const e=this,n=this.json.nodes[t],i=e._loadNodeShallow(t),r=[],o=n.children||[];for(let t=0,n=o.length;t<n;t++)r.push(e.getDependency("node",o[t]));const s=void 0===n.skin?Promise.resolve(null):e.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),s]).then((function(t){const e=t[0],n=t[1],i=t[2];null!==i&&e.traverse((function(t){t.isSkinnedMesh&&t.bind(i,_identityMatrix)}));for(let t=0,i=n.length;t<i;t++)e.add(n[t]);return e}))}_loadNodeShallow(t){const e=this.extensions,n=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const i=this.json.nodes[t],r=i.name?n.createUniqueName(i.name):"",o=[],s=n._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return s&&o.push(s),void 0!==i.camera&&o.push(n.getDependency("camera",i.camera).then((function(t){return n._getNodeRef(n.cameraCache,i.camera,t)}))),n._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){o.push(t)})),this.nodeCache[t]=Promise.all(o).then((function(o){let s;if(s=!0===i.isBone?new Bone:o.length>1?new Group:1===o.length?o[0]:new Object3D,s!==o[0])for(let t=0,e=o.length;t<e;t++)s.add(o[t]);if(i.name&&(s.userData.name=i.name,s.name=r),assignExtrasToUserData(s,i),i.extensions&&addUnknownExtensionsToUserData(e,s,i),void 0!==i.matrix){const t=new Matrix4;t.fromArray(i.matrix),s.applyMatrix4(t)}else void 0!==i.translation&&s.position.fromArray(i.translation),void 0!==i.rotation&&s.quaternion.fromArray(i.rotation),void 0!==i.scale&&s.scale.fromArray(i.scale);return n.associations.has(s)||n.associations.set(s,{}),n.associations.get(s).nodes=t,s})),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],i=this,r=new Group;n.name&&(r.name=i.createUniqueName(n.name)),assignExtrasToUserData(r,n),n.extensions&&addUnknownExtensionsToUserData(e,r,n);const o=n.nodes||[],s=[];for(let t=0,e=o.length;t<e;t++)s.push(i.getDependency("node",o[t]));return Promise.all(s).then((function(t){for(let e=0,n=t.length;e<n;e++)r.add(t[e]);return i.associations=(t=>{const e=new Map;for(const[t,n]of i.associations)(t instanceof Material||t instanceof Texture)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(r),r}))}_createAnimationTracks(t,e,n,i,r){const o=[],s=t.name?t.name:t.uuid,a=[];let l;switch(PATH_PROPERTIES[r.path]===PATH_PROPERTIES.weights?t.traverse((function(t){t.morphTargetInfluences&&a.push(t.name?t.name:t.uuid)})):a.push(s),PATH_PROPERTIES[r.path]){case PATH_PROPERTIES.weights:l=NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:l=QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:l=VectorKeyframeTrack;break;default:if(1===n.itemSize)l=NumberKeyframeTrack;else l=VectorKeyframeTrack}const c=void 0!==i.interpolation?INTERPOLATION[i.interpolation]:InterpolateLinear,u=this._getArrayFromAccessor(n);for(let t=0,n=a.length;t<n;t++){const n=new l(a[t]+"."+PATH_PROPERTIES[r.path],e.array,u,c);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(n),o.push(n)}return o}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const t=getNormalizedComponentScale(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*t;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(t,e,n){const i=e.attributes,r=new Box3;if(void 0===i.POSITION)return;{const t=n.json.accessors[i.POSITION],e=t.min,o=t.max;if(void 0===e||void 0===o)return;if(r.set(new Vector3(e[0],e[1],e[2]),new Vector3(o[0],o[1],o[2])),t.normalized){const e=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[t.componentType]);r.min.multiplyScalar(e),r.max.multiplyScalar(e)}}const o=e.targets;if(void 0!==o){const t=new Vector3,e=new Vector3;for(let i=0,r=o.length;i<r;i++){const r=o[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],o=i.min,s=i.max;if(void 0!==o&&void 0!==s){if(e.setX(Math.max(Math.abs(o[0]),Math.abs(s[0]))),e.setY(Math.max(Math.abs(o[1]),Math.abs(s[1]))),e.setZ(Math.max(Math.abs(o[2]),Math.abs(s[2]))),i.normalized){const t=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[i.componentType]);e.multiplyScalar(t)}t.max(e)}}}r.expandByVector(t)}t.boundingBox=r;const s=new Sphere;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=s}function addPrimitiveAttributes(t,e,n){const i=e.attributes,r=[];function o(e,i){return n.getDependency("accessor",e).then((function(e){t.setAttribute(i,e)}))}for(const e in i){const n=ATTRIBUTES[e]||e.toLowerCase();n in t.attributes||r.push(o(i[e],n))}if(void 0!==e.indices&&!t.index){const i=n.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));r.push(i)}return assignExtrasToUserData(t,e),computeBounds(t,e,n),Promise.all(r).then((function(){return void 0!==e.targets?addMorphTargets(t,e.targets,n):t}))}const THREE=Object.assign({GLTFLoader:GLTFLoader},three);var index={mapboxgl:mapboxgl,Marker:Marker,Map:Map$1,Panel:Panel,Popup:Popup,THREE:THREE};return index}));
//# sourceMappingURL=mini-tokyo-3d.min.js.map
