!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).mapboxgl=t()}(this,(function(){"use strict";var e,t,i;function n(n,r){if(e)if(t){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 = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",s={};e(s);i=r(s);"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else t=r;else e=r}n(0,(function(e){var t="undefined"!=typeof self?self:{},i=n;function n(e,t,i,n){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=n,this.p2x=i,this.p2y=n}n.prototype.sampleCurveX=function(e){return((this.ax*e+this.bx)*e+this.cx)*e},n.prototype.sampleCurveY=function(e){return((this.ay*e+this.by)*e+this.cy)*e},n.prototype.sampleCurveDerivativeX=function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},n.prototype.solveCurveX=function(e,t){var i,n,r,o,s;for(void 0===t&&(t=1e-6),r=e,s=0;s<8;s++){if(o=this.sampleCurveX(r)-e,Math.abs(o)(n=1))return n;for(;io?i=r:n=r,r=.5*(n-i)+i}return r},n.prototype.solve=function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))};var r=o;function o(e,t){this.x=e,this.y=t}o.prototype={clone:function(){return new o(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),i=Math.sin(e),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround:function(e,t){var i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(e){return e instanceof o?e:Array.isArray(e)?new o(e[0],e[1]):e};const s=Math.PI/180,a=180/Math.PI;function l(e){return e*s}function c(e){return e*a}const u=[[0,0],[1,0],[1,1],[0,1]];function h(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function p(e,t,n,r){const o=new i(e,t,n,r);return function(e){return o.solve(e)}}const d=p(.25,.1,.25,1);function f(e,t,i){return Math.min(i,Math.max(t,e))}function m(e,t,i){return(i=f((i-e)/(t-e),0,1))*i*(3-2*i)}function g(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function _(e,t,i){if(!e.length)return i(null,[]);let n=e.length;const r=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),r[s]=t,0==--n&&i(o,r)}))}))}function y(e){const t=[];for(const i in e)t.push(e[i]);return t}function v(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let x=1;function b(){return x++}function w(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function M(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function T(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function S(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function E(e,t){return-1!==e.indexOf(t,e.length-t.length)}function A(e,t,i){const n={};for(const r in e)n[r]=t.call(i||this,e[r],r,e);return n}function C(e,t,i){const n={};for(const r in e)t.call(i||this,e[r],r,e)&&(n[r]=e[r]);return n}function L(e){return Array.isArray(e)?e.map(L):"object"==typeof e&&e?A(e,L):e}const I={};function P(e){I[e]||("undefined"!=typeof console&&console.warn(e),I[e]=!0)}function R(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function k(e){let t=0;for(let i,n,r=0,o=e.length,s=o-1;r@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,n,r)=>{const o=n||r;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let O=null;function F(e){if(null==O){const t=e.navigator?e.navigator.userAgent:null;O=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return O}function B(e){try{const i=t[e];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function N(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const U=t.performance;function j(e){const t=e?e.url.toString():void 0;return U.getEntriesByName(t)}var V="2.9.1";let G,H,W,q;const $={now:()=>void 0!==W?W:t.performance.now(),setNow(e){W=e},restoreNow(){W=void 0},frame(e){const i=t.requestAnimationFrame(e);return{cancel:()=>t.cancelAnimationFrame(i)}},getImageData(e,i=0){const{width:n,height:r}=e;q||(q=t.document.createElement("canvas"));const o=q.getContext("2d");if(!o)throw new Error("failed to create canvas 2d context");return(n>q.width||r>q.height)&&(q.width=n,q.height=r),o.clearRect(-i,-i,n+2*i,r+2*i),o.drawImage(e,0,0,n,r),o.getImageData(-i,-i,n+2*i,r+2*i)},resolveURL:e=>(G||(G=t.document.createElement("a")),G.href=e,G.href),get devicePixelRatio(){return t.devicePixelRatio},get prefersReducedMotion(){return!!t.matchMedia&&(null==H&&(H=t.matchMedia("(prefers-reduced-motion: reduce)")),H.matches)}};let Z;const X={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==Z){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Z=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e}catch(t){Z=e}}return Z},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null: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},Y={supported:!1,testSupport:function(e){!K&&Q&&(ee?te(e):J=e)}};let J,Q,K=!1,ee=!1;function te(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,Q),e.isContextLost())return;Y.supported=!0}catch(e){}e.deleteTexture(t),K=!0}t.document&&(Q=t.document.createElement("img"),Q.onload=function(){J&&te(J),J=null,ee=!0},Q.onerror=function(){K=!0,J=null},Q.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const ie="01",ne="NO_ACCESS_TOKEN";function re(e){return 0===e.indexOf("mapbox:")}function oe(e){return X.API_URL_REGEX.test(e)}const se=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ae(e){const t=e.match(se);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function le(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}function ce(e){if(!e)return null;const i=e.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(t.atob(i[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class ue{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const i=ce(X.ACCESS_TOKEN);let n="";return n=i&&i.u?t.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):X.ACCESS_TOKEN||"",e?`mapbox.eventData.${e}:${n}`:`mapbox.eventData:${n}`}fetchEventData(){const e=B("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{const e=t.localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const r=t.localStorage.getItem(n);r&&(this.anonId=r)}catch(e){P("Unable to read from LocalStorage")}}saveEventData(){const e=B("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{t.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&t.localStorage.setItem(i,JSON.stringify(this.eventData))}catch(e){P("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,n){if(!X.EVENTS_URL)return;const r=ae(X.EVENTS_URL);r.params.push(`access_token=${n||X.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(e).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:V,skuId:ie,userId:this.anonId},s=t?v(o,t):o,a={url:le(r),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=Re(a,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(n)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const he=new class extends ue{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){X.EVENTS_URL&&X.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>re(e)||oe(e)))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=ce(X.ACCESS_TOKEN),i=t?t.u:X.ACCESS_TOKEN;let n=i!==this.eventData.tokenU;T(this.anonId)||(this.anonId=w(),n=!0);const r=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(r),i=(r-this.eventData.lastSuccess)/864e5;n=n||i>=1||i<-1||e.getDate()!==t.getDate()}else n=!0;n?this.postEvent(r,{"enabled.telemetry":!1},(e=>{e||(this.eventData.lastSuccess=r,this.eventData.tokenU=i)}),e):this.processRequests()}},pe=he.postTurnstileEvent.bind(he),de=new class extends ue{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,n){this.skuToken=t,this.errorCb=n,X.EVENTS_URL&&(i||X.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(ne)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),T(this.anonId)||(this.anonId=w()),this.postEvent(i,{skuToken:this.skuToken},(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e))}},fe=de.postMapLoadEvent.bind(de),me=new class extends ue{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,n){if(!X.API_URL||!X.SESSION_PATH)return;const r=ae(X.API_URL+X.SESSION_PATH);r.params.push(`sku=${t||""}`),r.params.push(`access_token=${n||X.ACCESS_TOKEN||""}`);const o={url:le(r),headers:{"Content-Type":"text/plain"}};this.pendingRequest=ke(o,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(n)}))}getSessionAPI(e,t,i,n){this.skuToken=t,this.errorCb=n,X.SESSION_PATH&&X.API_URL&&(i||X.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(ne)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e)}},ge=me.getSessionAPI.bind(me),_e=new Set;let ye,ve=500,xe=50,be={};function we(e){const t=Te(e);let i,n;t&&t.forEach((e=>{const t=e.split("=");"language"===t[0]?i=t[1]:"worldview"===t[0]&&(n=t[1])}));let r="mapbox-tiles";return i&&(r+=`-${i}`),n&&(r+=`-${n}`),r}function Me(e){t.caches&&!be[e]&&(be[e]=t.caches.open(e))}function Te(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}function Se(e){const t=e.indexOf("?");if(t<0)return e;const i=Te(e).filter((e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]}));return i.length?`${e.slice(0,t)}?${i.join("&")}`:e.slice(0,t)}let Ee=1/0;const Ae={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Ae);class Ce extends Error{constructor(e,t,i){401===t&&oe(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Le=z()?()=>self.worker&&self.worker.referrer:()=>("blob:"===t.location.protocol?t.parent:t).location.href,Ie=function(e,i){if(!(/^file:/.test(n=e.url)||/^file:/.test(Le())&&!/^\w+:/.test(n))){if(t.fetch&&t.Request&&t.AbortController&&t.Request.prototype.hasOwnProperty("signal"))return function(e,i){const n=new t.AbortController,r=new t.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Le(),signal:n.signal});let o=!1,s=!1;const a=(l=r.url).indexOf("sku=")>0&&oe(l);var l;"json"===e.type&&r.headers.set("Accept","application/json");const c=(n,o,l)=>{if(s)return;if(n&&"SecurityError"!==n.message&&P(n),o&&l)return u(o);const c=Date.now();t.fetch(r).then((t=>{if(t.ok){const e=a?t.clone():null;return u(t,e,c)}return i(new Ce(t.statusText,t.status,e.url))})).catch((e=>{20!==e.code&&i(new Error(e.message))}))},u=(n,a,l)=>{("arrayBuffer"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text()).then((e=>{s||(a&&l&&function(e,i,n){const r=we(e.url);if(Me(r),!be[r])return;const o={status:i.status,statusText:i.statusText,headers:new t.Headers};i.headers.forEach(((e,t)=>o.headers.set(t,e)));const s=D(i.headers.get("Cache-Control")||"");if(s["no-store"])return;s["max-age"]&&o.headers.set("Expires",new Date(n+1e3*s["max-age"]).toUTCString());const a=o.headers.get("Expires");a&&(new Date(a).getTime()-n<42e4||function(e,t){if(void 0===ye)try{new Response(new ReadableStream),ye=!0}catch(e){ye=!1}ye?t(e.body):e.blob().then(t)}(i,(i=>{const n=new t.Response(i,o);Me(r),be[r]&&be[r].then((t=>t.put(Se(e.url),n))).catch((e=>P(e.message)))})))}(r,a,l),o=!0,i(null,e,n.headers.get("Cache-Control"),n.headers.get("Expires")))})).catch((e=>{s||i(new Error(e.message))}))};return a?function(e,t){const i=we(e.url);if(Me(i),!be[i])return t(null);const n=Se(e.url);be[i].then((e=>{e.match(n).then((i=>{const r=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=D(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(i);e.delete(n),r&&e.put(n,i.clone()),t(null,i,r)})).catch(t)})).catch(t)}(r,c):c(null,null),{cancel:()=>{s=!0,o||n.abort()}}}(e,i);if(z()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,i,void 0,!0)}var n;return function(e,i){const n=new t.XMLHttpRequest;n.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(n.responseType="arraybuffer");for(const t in e.headers)n.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===e.credentials,n.onerror=()=>{i(new Error(n.statusText))},n.onload=()=>{if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){let t=n.response;if("json"===e.type)try{t=JSON.parse(n.response)}catch(e){return i(e)}i(null,t,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else i(new Ce(n.statusText,n.status,e.url))},n.send(e.body),{cancel:()=>n.abort()}}(e,i)},Pe=function(e,t){return Ie(v(e,{type:"arrayBuffer"}),t)},Re=function(e,t){return Ie(v(e,{method:"POST"}),t)},ke=function(e,t){return Ie(v(e,{method:"GET"}),t)};function ze(e){const i=t.document.createElement("a");return i.href=e,i.protocol===t.document.location.protocol&&i.host===t.document.location.host}const De="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Oe,Fe;Oe=[],Fe=0;const Be=function(e,i){if(Y.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Fe>=X.MAX_PARALLEL_IMAGE_REQUESTS){const t={requestParameters:e,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return Oe.push(t),t}Fe++;let n=!1;const r=()=>{if(!n)for(n=!0,Fe--;Oe.length&&Fe{r(),e?i(e):n&&(t.createImageBitmap?function(e,i){const n=new t.Blob([new Uint8Array(e)],{type:"image/png"});t.createImageBitmap(n).then((e=>{i(null,e)})).catch((e=>{i(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(n,((e,t)=>i(e,t,o,s))):function(e,i){const n=new t.Image,r=t.URL;n.onload=()=>{i(null,n),r.revokeObjectURL(n.src),n.onload=null,t.requestAnimationFrame((()=>{n.src=De}))},n.onerror=()=>i(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 t.Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?r.createObjectURL(o):De}(n,((e,t)=>i(e,t,o,s))))}));return{cancel:()=>{o.cancel(),r()}}};function Ne(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function Ue(e,t,i){if(i&&i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class je{constructor(e,t={}){v(this,t),this.type=e}}class Ve extends je{constructor(e,t={}){super("error",v({error:e},t))}}class Ge{on(e,t){return this._listeners=this._listeners||{},Ne(e,t,this._listeners),this}off(e,t){return Ue(e,t,this._listeners),Ue(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ne(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new je(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const n=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of n)Ue(i,t,this._oneTimeListeners),t.call(this,e);const r=this._eventedParent;r&&(v(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(e))}else e instanceof Ve&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var He=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"}},"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":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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"}},"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":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"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"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function We(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function qe(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function $e(e){if(Array.isArray(e))return e.map($e);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=$e(e[i]);return t}return qe(e)}class Ze extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var Xe=Ze;class Ye{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Ye(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var Je=Ye;const Qe={kind:"null"},Ke={kind:"number"},et={kind:"string"},tt={kind:"boolean"},it={kind:"color"},nt={kind:"object"},rt={kind:"value"},ot={kind:"collator"},st={kind:"formatted"},at={kind:"resolvedImage"};function lt(e,t){return{kind:"array",itemType:e,N:t}}function ct(e){if("array"===e.kind){const t=ct(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const ut=[Qe,Ke,et,tt,it,st,nt,lt(rt),at];function ht(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!ht(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of ut)if(!ht(e,t))return null}return`Expected ${ct(e)} but found ${ct(t)} instead.`}function pt(e,t){return t.some((t=>t.kind===e.kind))}function dt(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}function ft(e){var t={exports:{}};return e(t,t.exports),t.exports}var mt=ft((function(e,t){var i={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 n(e){return(e=Math.round(e))<0?0:e>255?255:e}function r(e){return n("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function o(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function s(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{t.parseCSSColor=function(e){var t,a=e.replace(/ /g,"").toLowerCase();if(a in i)return i[a].slice();if("#"===a[0])return 4===a.length?(t=parseInt(a.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===a.length&&(t=parseInt(a.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,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(","),p=1;switch(u){case"rgba":if(4!==h.length)return null;p=o(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),p];case"hsla":if(4!==h.length)return null;p=o(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=o(h[1]),m=o(h[2]),g=m<=.5?m*(f+1):m+f-m*f,_=2*m-g;return[n(255*s(_,g,d+1/3)),n(255*s(_,g,d)),n(255*s(_,g,d-1/3)),p];default:return null}}return null}}catch(e){}}));class gt{constructor(e,t,i,n=1){this.r=e,this.g=t,this.b=i,this.a=n}static parse(e){if(!e)return;if(e instanceof gt)return e;if("string"!=typeof e)return;const t=mt.parseCSSColor(e);return t?new gt(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,i,n]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${n})`}toArray(){const{r:e,g:t,b:i,a:n}=this;return 0===n?[0,0,0,0]:[255*e/n,255*t/n,255*i/n,n]}toArray01(){const{r:e,g:t,b:i,a:n}=this;return 0===n?[0,0,0,0]:[e/n,t/n,i/n,n]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:n}=this;return[e,t,i,n]}}gt.black=new gt(0,0,0,1),gt.white=new gt(1,1,1,1),gt.transparent=new gt(0,0,0,0),gt.red=new gt(1,0,0,1),gt.blue=new gt(0,0,1,1);var _t=gt;class yt{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class vt{constructor(e,t,i,n,r){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r}}class xt{constructor(e){this.sections=e}static fromString(e){return new xt([new vt(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof xt?e:xt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i)}return e}}class bt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new bt({name:e,available:!1}):null}serialize(){return["image",this.name]}}function wt(e,t,i,n){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Mt(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof _t)return!0;if(e instanceof yt)return!0;if(e instanceof xt)return!0;if(e instanceof bt)return!0;if(Array.isArray(e)){for(const t of e)if(!Mt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Mt(e[t]))return!1;return!0}return!1}function Tt(e){if(null===e)return Qe;if("string"==typeof e)return et;if("boolean"==typeof e)return tt;if("number"==typeof e)return Ke;if(e instanceof _t)return it;if(e instanceof yt)return ot;if(e instanceof xt)return st;if(e instanceof bt)return at;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Tt(t);if(i){if(i===e)continue;i=rt;break}i=e}return lt(i||rt,t)}return nt}function St(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof _t||e instanceof xt||e instanceof bt?e.toString():JSON.stringify(e)}class Et{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Mt(e[1]))return t.error("invalid value");const i=e[1];let n=Tt(i);const r=t.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Et(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof _t?["rgba"].concat(this.value.toArray()):this.value instanceof xt?this.value.serialize():this.value}}var At=Et,Ct=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const Lt={string:et,number:Ke,boolean:tt,object:nt};class It{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Lt)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Lt[i],n++}else r=rt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],n++}i=lt(r,o)}else i=Lt[r];const o=[];for(;ne.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n)}}return t.concat(this.args.map((e=>e.serialize())))}}var Pt=It;class Rt{constructor(e){this.type=st,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,Ke),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,lt(et)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,it),!s))return null;const a=n[n.length-1];a.scale=e,a.font=i,a.textColor=s}else{const o=t.parse(e[i],1,rt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null})}}return new Rt(n)}evaluate(e){return new xt(this.sections.map((t=>{const i=t.content.evaluate(e);return Tt(i)===at?new vt("",i,null,null,null):new vt(St(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class kt{constructor(e){this.type=at,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,et);return i?new kt(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=bt.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const zt={"to-boolean":tt,"to-color":it,"to-number":Ke,"to-string":et};class Dt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=zt[i],r=[];for(let i=1;i4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:wt(t[0],t[1],t[2],t[3]),!i))return new _t(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ct(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Ct(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?xt.fromString(St(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?bt.fromString(St(this.args[0].evaluate(e))):St(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Rt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new kt(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Ot=Dt;const Ft=["Unknown","Point","LineString","Polygon"];var Bt=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&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ft[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 e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=_t.parse(e)),t}};class Nt{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const i=e[0],n=Nt.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let a=null;for(const[n,o]of s){a=new pi(t.registry,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(ct).join(", ")})`:`(${ct(t.type)}...)`;var t})).join(" | "),n=[];for(let i=1;i=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Wt(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Vt),Math.round(n*r*Vt)]}function qt(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function $t(e,t){let i=!1;for(let s=0,a=t.length;s(n=e)[1]!=(o=a[t+1])[1]>n[1]&&n[0]<(o[0]-r[0])*(n[1]-r[1])/(o[1]-r[1])+r[0]&&(i=!i)}}var n,r,o;return i}function Zt(e,t){for(let i=0;i0&&a<0||s<0&&a>0}function Yt(e,t,i){for(const c of i)for(let i=0;ii[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}Gt(t,e)}function ii(e,t,i,n){const r=Math.pow(2,n.z)*Vt,o=[n.x*Vt,n.y*Vt],s=[];if(!e)return s;for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];ti(n,t,i,r),s.push(n)}return s}function ni(e,t,i,n){const r=Math.pow(2,n.z)*Vt,o=[n.x*Vt,n.y*Vt],s=[];if(!e)return s;for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Gt(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)ti(n,t,i,r)}var a;return s}class ri{constructor(e,t){this.type=tt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Mt(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e{t&&!si(e)&&(t=!1)})),t}function ai(e){if(e instanceof Ut&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!ai(e)&&(t=!1)})),t}function li(e,t){if(e instanceof Ut&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild((e=>{i&&!li(e,t)&&(i=!1)})),i}class ci{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new ci(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var ui=ci;class hi{constructor(e,t=[],i,n=new Je,r=[]){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new Pt(t,[e]):"coerce"===i?new Ot(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof At)&&"resolvedImage"!==n.type.kind&&di(n)){const t=new Bt;try{n=new At(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new hi(this.registry,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Xe(i,e))}checkSubtype(e,t){const i=ht(e,t);return i&&this.error(i),i}}var pi=hi;function di(e){if(e instanceof ui)return di(e.boundExpression);if(e instanceof Ut&&"error"===e.name)return!1;if(e instanceof jt)return!1;if(e instanceof oi)return!1;const t=e instanceof Ot||e instanceof Pt;let i=!0;return e.eachChild((e=>{i=t?i&&di(e):i&&e instanceof At})),!!i&&si(e)&&li(e,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function fi(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new Ct("Input is not a number.");s=a-1}return 0}class mi{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Ke);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new mi(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[fi(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var gi=mi;function _i(e,t,i){return e*(1-i)+t*i}var yi=Object.freeze({__proto__:null,number:_i,color:function(e,t,i){return new _t(_i(e.r,t.r,i),_i(e.g,t.g,i),_i(e.b,t.b,i),_i(e.a,t.a,i))},array:function(e,t,i){return e.map(((e,n)=>_i(e,t[n],i)))}});const vi=.95047,xi=1.08883,bi=4/29,wi=6/29,Mi=3*wi*wi,Ti=Math.PI/180,Si=180/Math.PI;function Ei(e){return e>.008856451679035631?Math.pow(e,1/3):e/Mi+bi}function Ai(e){return e>wi?e*e*e:Mi*(e-bi)}function Ci(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Li(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ii(e){const t=Li(e.r),i=Li(e.g),n=Li(e.b),r=Ei((.4124564*t+.3575761*i+.1804375*n)/vi),o=Ei((.2126729*t+.7151522*i+.072175*n)/1);return{l:116*o-16,a:500*(r-o),b:200*(o-Ei((.0193339*t+.119192*i+.9503041*n)/xi)),alpha:e.a}}function Pi(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,n=isNaN(e.b)?t:t-e.b/200;return t=1*Ai(t),i=vi*Ai(i),n=xi*Ai(n),new _t(Ci(3.2404542*i-1.5371385*t-.4985314*n),Ci(-.969266*i+1.8760108*t+.041556*n),Ci(.0556434*i-.2040259*t+1.0572252*n),e.alpha)}function Ri(e,t,i){const n=t-e;return e+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const ki={forward:Ii,reverse:Pi,interpolate:function(e,t,i){return{l:_i(e.l,t.l,i),a:_i(e.a,t.a,i),b:_i(e.b,t.b,i),alpha:_i(e.alpha,t.alpha,i)}}},zi={forward:function(e){const{l:t,a:i,b:n}=Ii(e),r=Math.atan2(n,i)*Si;return{h:r<0?r+360:r,c:Math.sqrt(i*i+n*n),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Ti,i=e.c;return Pi({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:Ri(e.h,t.h,i),c:_i(e.c,t.c,i),l:_i(e.l,t.l,i),alpha:_i(e.alpha,t.alpha,i)}}};var Di=Object.freeze({__proto__:null,lab:ki,hcl:zi});class Oi{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let o=0;if("exponential"===e.name)o=Fi(t,e.base,n,r);else if("linear"===e.name)o=Fi(t,1,n,r);else if("cubic-bezier"===e.name){const s=e.controlPoints;o=new i(s[0],s[1],s[2],s[3]).solve(Fi(t,1,n,r))}return o}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(r=t.parse(r,2,Ke),!r)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=it:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Oi(a,i,n,r,s):t.error(`Type ${ct(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=fi(t,n),s=Oi.interpolationFactor(this.interpolation,n,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?yi[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?zi.reverse(zi.interpolate(zi.forward(a),zi.forward(l),s)):ki.reverse(ki.interpolate(ki.forward(a),ki.forward(l),s))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;eht(n,e.type)));return new Ni(o?rt:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(e),i&&i instanceof bt&&!i.available&&(t||(t=i),i=null,n===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Ui=Ni;class ji{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let n=1;n=i.length)throw new Ct(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ct(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Hi=Gi;class Wi{constructor(e,t){this.type=tt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,rt),n=t.parse(e[2],2,rt);return i&&n?pt(i.type,[tt,et,Ke,Qe,rt])?new Wi(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ct(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!dt(t,["boolean","string","number","null"]))throw new Ct(`Expected first argument to be of type boolean, string, number or null, but found ${ct(Tt(t))} instead.`);if(!dt(i,["string","array"]))throw new Ct(`Expected second argument to be of type array or string, but found ${ct(Tt(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var qi=Wi;class $i{constructor(e,t,i){this.type=Ke,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,rt),n=t.parse(e[2],2,rt);if(!i||!n)return null;if(!pt(i.type,[tt,et,Ke,Qe,rt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ct(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,Ke);return r?new $i(i,n,r):null}return new $i(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!dt(t,["boolean","string","number","null"]))throw new Ct(`Expected first argument to be of type boolean, string, number or null, but found ${ct(Tt(t))} instead.`);if(!dt(i,["string","array"]))throw new Ct(`Expected second argument to be of type array or string, but found ${ct(Tt(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(e);return i.indexOf(t,n)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Zi=$i;class Xi{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Tt(e)))return null}else i=Tt(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,rt);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new Xi(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Tt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],n={};for(const e of t){const t=n[this.cases[e]];void 0===t?(n[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const r=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,n]of i)e.push(1===n.length?r(n[0]):n.map(r)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var Yi=Xi;class Ji{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const n=[];for(let r=1;rt.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Qi=Ji;class Ki{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,rt),n=t.parse(e[2],2,Ke);if(!i||!n)return null;if(!pt(i.type,[lt(rt),et,rt]))return t.error(`Expected first argument to be of type array or string, but found ${ct(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,Ke);return r?new Ki(i.type,i,n,r):null}return new Ki(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!dt(t,["string","array"]))throw new Ct(`Expected first argument to be of type array or string, but found ${ct(Tt(t))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(e);return t.slice(i,n)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var en=Ki;function tn(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function nn(e,t,i,n){return 0===n.compare(t,i)}function rn(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=tt,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let o=t.parse(e[1],1,rt);if(!o)return null;if(!tn(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${ct(o.type)}'.`);let s=t.parse(e[2],2,rt);if(!s)return null;if(!tn(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${ct(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${ct(o.type)}' and '${ct(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Pt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Pt(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,ot),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Tt(o),i=Tt(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ct(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Tt(o),i=Tt(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const on=rn("==",(function(e,t,i){return t===i}),nn),sn=rn("!=",(function(e,t,i){return t!==i}),(function(e,t,i,n){return!nn(0,t,i,n)})),an=rn("<",(function(e,t,i){return t",(function(e,t,i){return t>i}),(function(e,t,i,n){return n.compare(t,i)>0})),cn=rn("<=",(function(e,t,i){return t<=i}),(function(e,t,i,n){return n.compare(t,i)<=0})),un=rn(">=",(function(e,t,i){return t>=i}),(function(e,t,i,n){return n.compare(t,i)>=0}));class hn{constructor(e,t,i,n,r){this.type=et,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Ke);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,et),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,et),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,Ke),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,Ke),!a)?null:new hn(i,r,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class pn{constructor(e){this.type=Ke,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${ct(i.type)} instead.`):new pn(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Ct(`Expected value to be of type string or array, but found ${ct(Tt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}const dn={"==":on,"!=":sn,">":ln,"<":an,">=":un,"<=":cn,array:Pt,at:Hi,boolean:Pt,case:Qi,coalesce:Ui,collator:jt,format:Rt,image:kt,in:qi,"index-of":Zi,interpolate:Bi,"interpolate-hcl":Bi,"interpolate-lab":Bi,length:pn,let:Vi,literal:At,match:Yi,number:Pt,"number-format":hn,object:Pt,slice:en,step:gi,string:Pt,"to-boolean":Ot,"to-color":Ot,"to-number":Ot,"to-string":Ot,var:ui,within:oi};function fn(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const o=r?r.evaluate(e):1,s=wt(t,i,n,o);if(s)throw new Ct(s);return new _t(t/255*o,i/255*o,n/255*o,o)}function mn(e,t){return e in t}function gn(e,t){const i=t[e];return void 0===i?null:i}function _n(e){return{type:e}}Ut.register(dn,{error:[{kind:"error"},[et],(e,[t])=>{throw new Ct(t.evaluate(e))}],typeof:[et,[rt],(e,[t])=>ct(Tt(t.evaluate(e)))],"to-rgba":[lt(Ke,4),[it],(e,[t])=>t.evaluate(e).toArray()],rgb:[it,[Ke,Ke,Ke],fn],rgba:[it,[Ke,Ke,Ke,Ke],fn],has:{type:tt,overloads:[[[et],(e,[t])=>mn(t.evaluate(e),e.properties())],[[et,nt],(e,[t,i])=>mn(t.evaluate(e),i.evaluate(e))]]},get:{type:rt,overloads:[[[et],(e,[t])=>gn(t.evaluate(e),e.properties())],[[et,nt],(e,[t,i])=>gn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[rt,[et],(e,[t])=>gn(t.evaluate(e),e.featureState||{})],properties:[nt,[],e=>e.properties()],"geometry-type":[et,[],e=>e.geometryType()],id:[rt,[],e=>e.id()],zoom:[Ke,[],e=>e.globals.zoom],pitch:[Ke,[],e=>e.globals.pitch||0],"distance-from-center":[Ke,[],e=>e.distanceFromCenter()],"heatmap-density":[Ke,[],e=>e.globals.heatmapDensity||0],"line-progress":[Ke,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[Ke,[],e=>e.globals.skyRadialProgress||0],accumulated:[rt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Ke,_n(Ke),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[Ke,_n(Ke),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:Ke,overloads:[[[Ke,Ke],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Ke],(e,[t])=>-t.evaluate(e)]]},"/":[Ke,[Ke,Ke],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Ke,[Ke,Ke],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Ke,[],()=>Math.LN2],pi:[Ke,[],()=>Math.PI],e:[Ke,[],()=>Math.E],"^":[Ke,[Ke,Ke],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Ke,[Ke],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Ke,[Ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Ke,[Ke],(e,[t])=>Math.log(t.evaluate(e))],log2:[Ke,[Ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Ke,[Ke],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Ke,[Ke],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Ke,[Ke],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Ke,[Ke],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Ke,[Ke],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Ke,[Ke],(e,[t])=>Math.atan(t.evaluate(e))],min:[Ke,_n(Ke),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Ke,_n(Ke),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Ke,[Ke],(e,[t])=>Math.abs(t.evaluate(e))],round:[Ke,[Ke],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ke,[Ke],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Ke,[Ke],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[tt,[et,rt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[tt,[rt],(e,[t])=>e.id()===t.value],"filter-type-==":[tt,[et],(e,[t])=>e.geometryType()===t.value],"filter-<":[tt,[et,rt],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[tt,[et,rt],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[tt,[rt],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[tt,[et,rt],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[tt,[rt],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[tt,[et,rt],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[tt,[rt],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[tt,[rt],(e,[t])=>t.value in e.properties()],"filter-has-id":[tt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[tt,[lt(et)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[tt,[lt(rt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[tt,[et,lt(rt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[tt,[et,lt(rt)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:tt,overloads:[[[tt,tt],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[_n(tt),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:tt,overloads:[[[tt,tt],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[_n(tt),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[tt,[tt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[tt,[et],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[et,[et],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[et,[et],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[et,_n(rt),(e,t)=>t.map((t=>St(t.evaluate(e)))).join("")],"resolved-locale":[et,[ot],(e,[t])=>t.evaluate(e).resolvedLocale()]});var yn=dn;function vn(e){return{result:"success",value:e}}function xn(e){return{result:"error",value:e}}function bn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function wn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Mn(e){return!!e.expression&&e.expression.interpolated}function Tn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Sn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function En(e){return e}function An(e,t){const i="color"===t.type,n=e.stops&&"object"==typeof e.stops[0][0],r=n||!(n||void 0!==e.property),o=e.type||(Mn(t)?"exponential":"interval");if(i&&((e=We({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],_t.parse(e[1])]))),e.default=_t.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Di[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=Pn;else if("interval"===o)s=In;else if("categorical"===o){s=Ln,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=Rn}if(n){const i={},n=[];for(let t=0;te[0])),evaluate:({zoom:i},n)=>Pn({stops:r,base:e.base},t,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Bi.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?Cn(e.default,t.default):s(e,t,r,a,l)}}}function Cn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Ln(e,t,i,n,r){return Cn(typeof i===r?n[i]:void 0,e.default,t.default)}function In(e,t,i){if("number"!==Tn(i))return Cn(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const r=fi(e.stops.map((e=>e[0])),i);return e.stops[r][1]}function Pn(e,t,i){const n=void 0!==e.base?e.base:1;if("number"!==Tn(i))return Cn(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const o=fi(e.stops.map((e=>e[0])),i),s=function(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=yi[t.type]||En;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Di[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function Rn(e,t,i){return"color"===t.type?i=_t.parse(i):"formatted"===t.type?i=xt.fromString(i.toString()):"resolvedImage"===t.type?i=bt.fromString(i.toString()):Tn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Cn(i,e.default,t.default)}class kn{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Bt,this._defaultValue=t?function(e){return"color"===e.type&&(Sn(e.default)||Array.isArray(e.default))?new _t(0,0,0,0):"color"===e.type?_t.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,n,r,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o,s,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ct(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function zn(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in yn}function Dn(e,t){const i=new pi(yn,[],t?function(e){const t={color:it,string:et,number:Ke,enum:et,boolean:tt,formatted:st,resolvedImage:at};return"array"===e.type?lt(t[e.value]||rt,e.length):t[e.type]}(t):void 0),n=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?vn(new kn(n,t)):xn(i.errors)}class On{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!ai(t.expression)}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}}class Fn{constructor(e,t,i,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!ai(t.expression),this.interpolationType=n}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?Bi.interpolationFactor(this.interpolationType,e,t,i):0}}function Bn(e,t){if("error"===(e=Dn(e,t)).result)return e;const i=e.value.expression,n=si(i);if(!n&&!bn(t))return xn([new Xe("","data expressions not supported")]);const r=li(i,["zoom","pitch","distance-from-center"]);if(!r&&!wn(t))return xn([new Xe("","zoom expressions not supported")]);const o=Un(i);return o||r?o instanceof Xe?xn([o]):o instanceof Bi&&!Mn(t)?xn([new Xe("",'"interpolate" expressions cannot be used with this property')]):vn(o?new Fn(n?"camera":"composite",e.value,o.labels,o instanceof Bi?o.interpolation:void 0):new On(n?"constant":"source",e.value)):xn([new Xe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Nn{constructor(e,t){this._parameters=e,this._specification=t,We(this,An(this._parameters,this._specification))}static deserialize(e){return new Nn(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Un(e){let t=null;if(e instanceof Vi)t=Un(e.result);else if(e instanceof Ui){for(const i of e.args)if(t=Un(i),t)break}else(e instanceof gi||e instanceof Bi)&&e.input instanceof Ut&&"zoom"===e.input.name&&(t=e);return t instanceof Xe||e.eachChild((e=>{const i=Un(e);i instanceof Xe?t=i:!t&&i?t=new Xe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Xe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}class jn{constructor(e,t,i,n){this.message=(e?`${e}: `:"")+i,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__)}}function Vn(e){const t=e.key,i=e.value,n=e.valueSpec||{},r=e.objectElementValidators||{},o=e.style,s=e.styleSpec;let a=[];const l=Tn(i);if("object"!==l)return[new jn(t,i,`object expected, ${l} found`)];for(const e in i){const l=e.split(".")[0],c=n[l]||n["*"];let u;r[l]?u=r[l]:n[l]?u=br:r["*"]?u=r["*"]:n["*"]&&(u=br),u?a=a.concat(u({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:c,style:o,styleSpec:s,object:i,objectKey:e},i)):a.push(new jn(t,i[e],`unknown property "${e}"`))}for(const e in n)r[e]||n[e].required&&void 0===n[e].default&&void 0===i[e]&&a.push(new jn(t,i,`missing required property "${e}"`));return a}function Gn(e){const t=e.value,i=e.valueSpec,n=e.style,r=e.styleSpec,o=e.key,s=e.arrayElementValidator||br;if("array"!==Tn(t))return[new jn(o,t,`array expected, ${Tn(t)} found`)];if(i.length&&t.length!==i.length)return[new jn(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.lengthr)return[new jn(t,i,`${i} is greater than the maximum value ${r}`)]}return[]}function Wn(e){const t=e.valueSpec,i=qe(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Tn(e.value.stops)&&"array"===Tn(e.value.stops[0])&&"object"===Tn(e.value.stops[0][0]),u=Vn({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new jn(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(Gn({key:e.key,value:n,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Tn(n)&&0===n.length&&t.push(new jn(e.key,n,"array must have at least one stop")),t},default:function(e){return br({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new jn(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new jn(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Mn(e.valueSpec)&&u.push(new jn(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!bn(e.valueSpec)?u.push(new jn(e.key,e.value,"property functions not supported")):a&&!wn(e.valueSpec)&&u.push(new jn(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new jn(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==Tn(n))return[new jn(a,n,`array expected, ${Tn(n)} found`)];if(2!==n.length)return[new jn(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Tn(n[0]))return[new jn(a,n,`object expected, ${Tn(n[0])} found`)];if(void 0===n[0].zoom)return[new jn(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new jn(a,n,"object stop key must have value")];const t=qe(n[0].zoom);if("number"!=typeof t)return[new jn(a,n[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new jn(a,n[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,r=void 0,s={}),i=i.concat(Vn({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Hn,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:n[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},n));return zn($e(n[1]))?i.concat([new jn(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(br({key:`${a}[1]`,value:n[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function p(e,o){const a=Tn(e.value),l=qe(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new jn(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new jn(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return bn(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new jn(e.key,c,n)]}return"categorical"!==i||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&"number"==typeof l&&"number"==typeof r&&void 0!==r&&lnew jn(`${e.key}${t.key}`,e.value,t.message)));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new jn(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!ai(i))return[new jn(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return $n(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!li(i,["zoom","feature-state"]))return[new jn(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!si(i))return[new jn(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $n(e,t){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return[];const n=[];return e instanceof Ut&&i.has(e.name)?[new jn(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild((e=>{n.push(...$n(e,t))})),n)}function Zn(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(qe(i))&&r.push(new jn(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(qe(i))&&r.push(new jn(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function Xn(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Xn(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Yn(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Xn(e)||(e=nr(e));const i=e;let n=!0;try{n=function(e){if(!Kn(e))return e;let t=$e(e);return Qn(t),t=Jn(t),t}(i)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const r=He[`filter_${t}`],o=Dn(n,r);let s=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(e,t,i)=>o.value.evaluate(e,t,{},i);let a=null,l=null;if(n!==i){const e=Dn(i,r);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(t,i,n,r,o)=>e.value.evaluate(t,i,{},n,void 0,void 0,r,o),l=!si(e.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:ir(n),needFeature:!!l}}function Jn(e){if(!Array.isArray(e))return e;const t=function(e){if(er.has(e[0]))for(let t=1;tJn(e)))}function Qn(e){let t=!1;const i=[];if("case"===e[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function tr(e,t){return et?1:0}function ir(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?rr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(nr))):"all"===t?["all"].concat(e.slice(1).map(nr)):"none"===t?["all"].concat(e.slice(1).map(nr).map(ar)):"in"===t?or(e[1],e.slice(2)):"!in"===t?ar(or(e[1],e.slice(2))):"has"===t?sr(e[1]):"!has"===t?ar(sr(e[1])):"within"!==t||e;var i}function rr(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function or(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(tr)]]:["filter-in-small",e,["literal",t]]}}function sr(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function ar(e){return["!",e]}function lr(e){return Xn($e(e.value))?qn(We({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):cr(e)}function cr(e){const t=e.value,i=e.key;if("array"!==Tn(t))return[new jn(i,t,`array expected, ${Tn(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new jn(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Zn({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),qe(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===qe(t[1])&&o.push(new jn(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new jn(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Tn(t[1]),"string"!==r&&o.push(new jn(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s{e in i&&t.push(new jn(n,i[e],`"${e}" is prohibited for ref layers`))})),r.layers.forEach((t=>{qe(t.id)===a&&(e=t)})),e?e.ref?t.push(new jn(n,i.ref,"ref cannot reference another ref layer")):s=qe(e.type):"string"==typeof a&&t.push(new jn(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&qe(e.type);e?"vector"===o&&"raster"===s?t.push(new jn(n,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?t.push(new jn(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?t.push(new jn(n,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new jn(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new jn(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new jn(n,i.source,`source "${i.source}" not found`))}else t.push(new jn(n,i,'missing required property "source"'));return t=t.concat(Vn({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>br({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>lr(We({layerType:s},e)),layout:e=>Vn({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>pr(We({layerType:s},e))}}),paint:e=>Vn({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>hr(We({layerType:s},e))}})}})),t}function fr(e){const t=e.value,i=e.key,n=Tn(t);return"string"!==n?[new jn(i,t,`string expected, ${n} found`)]:[]}const mr={promoteId:function({key:e,value:t}){if("string"===Tn(t))return fr({key:e,value:t});{const i=[];for(const n in t)i.push(...fr({key:`${e}.${n}`,value:t[n]}));return i}}};function gr(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style;if(!t.type)return[new jn(i,t,'"type" is required')];const o=qe(t.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=Vn({key:i,value:t,valueSpec:n[`source_${o.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:mr}),s;case"geojson":if(s=Vn({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,objectElementValidators:mr}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;s.push(...qn({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),s.push(...qn({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return Vn({key:i,value:t,valueSpec:n.source_video,style:r,styleSpec:n});case"image":return Vn({key:i,value:t,valueSpec:n.source_image,style:r,styleSpec:n});case"canvas":return[new jn(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Zn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:r,styleSpec:n})}}function _r(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=Tn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new jn("light",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?br({key:e,value:t[e],valueSpec:i.transition,style:r,styleSpec:i}):n[e]?br({key:e,value:t[e],valueSpec:n[e],style:r,styleSpec:i}):[new jn(e,t[e],`unknown property "${e}"`)])}return o}function yr(e){const t=e.value,i=e.key,n=e.style,r=e.styleSpec,o=r.terrain;let s=[];const a=Tn(t);if(void 0===t)return s;if("object"!==a)return s=s.concat([new jn("terrain",t,`object expected, ${a} found`)]),s;for(const e in t){const i=e.match(/^(.*)-transition$/);s=s.concat(i&&o[i[1]]&&o[i[1]].transition?br({key:e,value:t[e],valueSpec:r.transition,style:n,styleSpec:r}):o[e]?br({key:e,value:t[e],valueSpec:o[e],style:n,styleSpec:r}):[new jn(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=n.sources&&n.sources[t.source],r=e&&qe(e.type);e?"raster-dem"!==r&&s.push(new jn(i,t.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 jn(i,t.source,`source "${t.source}" not found`))}else s.push(new jn(i,t,'terrain is missing required property "source"'));return s}function vr(e){const t=e.value,i=e.style,n=e.styleSpec,r=n.fog;let o=[];const s=Tn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new jn("fog",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&r[s[1]]&&r[s[1]].transition?br({key:e,value:t[e],valueSpec:n.transition,style:i,styleSpec:n}):r[e]?br({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}):[new jn(e,t[e],`unknown property "${e}"`)])}return o}const xr={"*":()=>[],array:Gn,boolean:function(e){const t=e.value,i=e.key,n=Tn(t);return"boolean"!==n?[new jn(i,t,`boolean expected, ${n} found`)]:[]},number:Hn,color:function(e){const t=e.key,i=e.value,n=Tn(i);return"string"!==n?[new jn(t,i,`color expected, ${n} found`)]:null===mt.parseCSSColor(i)?[new jn(t,i,`color expected, "${i}" found`)]:[]},enum:Zn,filter:lr,function:Wn,layer:dr,object:Vn,source:gr,light:_r,terrain:yr,fog:vr,string:fr,formatted:function(e){return 0===fr(e).length?[]:qn(e)},resolvedImage:function(e){return 0===fr(e).length?[]:qn(e)},projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style;let o=[];const s=Tn(t);if("object"===s)for(const e in t)o=o.concat(br({key:e,value:t[e],valueSpec:n[e],style:r,styleSpec:i}));else"string"!==s&&(o=o.concat([new jn("projection",t,`object or string expected, ${s} found`)]));return o}};function br(e){const t=e.value,i=e.valueSpec,n=e.styleSpec;return i.expression&&Sn(qe(t))?Wn(e):i.expression&&zn($e(t))?qn(e):i.type&&xr[i.type]?xr[i.type](e):Vn(We({},e,{valueSpec:i.type?n[i.type]:i}))}function wr(e){const t=e.value,i=e.key,n=fr(e);return n.length||(-1===t.indexOf("{fontstack}")&&n.push(new jn(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&n.push(new jn(i,t,'"glyphs" url must include a "{range}" token'))),n}function Mr(e,t=He){return Er(br({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:wr,"*":()=>[]}}))}const Tr=e=>Er(hr(e)),Sr=e=>Er(pr(e));function Er(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function Ar(e,t){let i=!1;if(t&&t.length)for(const n of t)e.fire(new Ve(new Error(n.message))),i=!0;return i}var Cr=Lr;function Lr(e,t,i){var n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var r=new Int32Array(this.arrayBuffer);e=r[0],this.d=(t=r[1])+2*(i=r[2]);for(var o=0;o=u[d+0]&&n>=u[d+1])?(s[p]=!0,o.push(c[p])):s[p]=!1}}},Lr.prototype._forEachCell=function(e,t,i,n,r,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&r.call(this,e,t,i,n,f,o,s,a))return}},Lr.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},Lr.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Lr.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,i=0,n=0;n=0||(r[t]=zr(e[t],i)));e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof e)}function Dr(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||Rr(e)||kr(e)||ArrayBuffer.isView(e)||e instanceof t.ImageData)return e;if(Array.isArray(e))return e.map(Dr);if("object"==typeof e){const t=e.$name||"Object",{klass:i}=Ir[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const t of Object.keys(e))"$name"!==t&&(n[t]=Dr(e[t]));return n}throw new Error("can't deserialize object of type "+typeof e)}class Or{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoome>=1536&&e<=1791,Br=e=>e>=1872&&e<=1919,Nr=e=>e>=2208&&e<=2303,Ur=e=>e>=11904&&e<=12031,jr=e=>e>=12032&&e<=12255,Vr=e=>e>=12272&&e<=12287,Gr=e=>e>=12288&&e<=12351,Hr=e=>e>=12352&&e<=12447,Wr=e=>e>=12448&&e<=12543,qr=e=>e>=12544&&e<=12591,$r=e=>e>=12704&&e<=12735,Zr=e=>e>=12736&&e<=12783,Xr=e=>e>=12784&&e<=12799,Yr=e=>e>=12800&&e<=13055,Jr=e=>e>=13056&&e<=13311,Qr=e=>e>=13312&&e<=19903,Kr=e=>e>=19968&&e<=40959,eo=e=>e>=40960&&e<=42127,to=e=>e>=42128&&e<=42191,io=e=>e>=44032&&e<=55215,no=e=>e>=63744&&e<=64255,ro=e=>e>=64336&&e<=65023,oo=e=>e>=65040&&e<=65055,so=e=>e>=65072&&e<=65103,ao=e=>e>=65104&&e<=65135,lo=e=>e>=65136&&e<=65279,co=e=>e>=65280&&e<=65519;function uo(e){for(const t of e)if(fo(t.charCodeAt(0)))return!0;return!1}function ho(e){for(const t of e)if(!po(t.charCodeAt(0)))return!1;return!0}function po(e){return!(Fr(e)||Br(e)||Nr(e)||ro(e)||lo(e))}function fo(e){return!(746!==e&&747!==e&&(e<4352||!($r(e)||qr(e)||so(e)&&!(e>=65097&&e<=65103)||no(e)||Jr(e)||Ur(e)||Zr(e)||!(!Gr(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Qr(e)||Kr(e)||Yr(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||io(e)||Hr(e)||Vr(e)||(e=>e>=12688&&e<=12703)(e)||jr(e)||Xr(e)||Wr(e)&&12540!==e||!(!co(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!ao(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||oo(e)||(e=>e>=19904&&e<=19967)(e)||eo(e)||to(e))))}function mo(e){return!(fo(e)||function(e){return!!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Gr(e)||Wr(e)||(e=>e>=57344&&e<=63743)(e)||so(e)||ao(e)||co(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function go(e){return e>=1424&&e<=2303||ro(e)||lo(e)}function _o(e,t){return!(!t&&go(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function yo(e){for(const t of e)if(go(t.charCodeAt(0)))return!0;return!1}const vo="deferred",xo="loading",bo="loaded";let wo=null,Mo="unavailable",To=null;const So=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Mo="error"),wo&&wo(e)};function Eo(){Ao.fire(new je("pluginStateChange",{pluginStatus:Mo,pluginURL:To}))}const Ao=new Ge,Co=function(){return Mo},Lo=function(){if(Mo!==vo||!To)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Mo=xo,Eo(),To&&Pe({url:To},(e=>{e?So(e):(Mo=bo,Eo())}))},Io={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Mo===bo||null!=Io.applyArabicShaping,isLoading:()=>Mo===xo,setState(e){Mo=e.pluginStatus,To=e.pluginURL},isParsed:()=>null!=Io.applyArabicShaping&&null!=Io.processBidirectionalText&&null!=Io.processStyledBidirectionalText,getPluginURL:()=>To};class Po{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.zoomHistory=t.zoomHistory,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Or,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const i of e)if(!_o(i.charCodeAt(0),t))return!1;return!0}(e,Io.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}class Ro{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Sn(e))return new Nn(e,t);if(zn(e)){const i=Bn(e,t);if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return i.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=_t.parse(e)),{kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class ko{constructor(e){this.property=e,this.value=new Ro(e,void 0)}transitioned(e,t){return new Do(this.property,this.value,t,v({},e.transition,this.transition),e.now)}untransitioned(){return new Do(this.property,this.value,null,{},0)}}class zo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return L(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new ko(this._values[e].property)),this._values[e].value=new Ro(this._values[e].property,null===t?void 0:L(t))}getTransition(e){return L(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new ko(this._values[e].property)),this._values[e].transition=L(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n)}return e}transitioned(e,t){const i=new Oo(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new Oo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Do{constructor(e,t,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=e,this.value=t,this.begin=r+o,this.end=this.begin+s,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(nn.zoomHistory.lastIntegerZoom?{from:e,to:t,other:i}:{from:i,to:t,other:e}}interpolate(e){return e}}class Go{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){if(void 0!==e.value){if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n);return this._calculate(r,r,r,t)}return this._calculate(e.expression.evaluate(new Po(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Po(Math.floor(t.zoom),t)),e.expression.evaluate(new Po(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Ho{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class Wo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new Po(0,{});for(const i in e){const n=e[i];n.specification.overridable&&this.overridableProperties.push(i);const r=this.defaultPropertyValues[i]=new Ro(n,void 0),o=this.defaultTransitionablePropertyValues[i]=new ko(n);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=r.possiblyEvaluate(t)}}}function qo(e,t){return 256*(e=f(Math.floor(e),0,255))+f(Math.floor(t),0,255)}Pr(jo,"DataDrivenProperty"),Pr(Uo,"DataConstantProperty"),Pr(Vo,"CrossFadedDataDrivenProperty"),Pr(Go,"CrossFadedProperty"),Pr(Ho,"ColorRampProperty");const $o={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Zo{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Xo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_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 Yo(e,t=1){let i=0,n=0;return{members:e.map((e=>{const r=$o[e.type].BYTES_PER_ELEMENT,o=i=Jo(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}})),size:Jo(i,Math.max(n,t)),alignment:t}}function Jo(e,t){return Math.ceil(e/t)*t}class Qo extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}Qo.prototype.bytesPerElement=4,Pr(Qo,"StructArrayLayout2i4");class Ko extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}Ko.prototype.bytesPerElement=6,Pr(Ko,"StructArrayLayout3i6");class es extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,e}}es.prototype.bytesPerElement=8,Pr(es,"StructArrayLayout4i8");class ts extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,e}}ts.prototype.bytesPerElement=12,Pr(ts,"StructArrayLayout2i4ub1f12");class is extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,e}}is.prototype.bytesPerElement=16,Pr(is,"StructArrayLayout4f16");class ns extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,s,a,l,c)}emplace(e,t,i,n,r,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=n,this.uint16[h+3]=r,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}ns.prototype.bytesPerElement=20,Pr(ns,"StructArrayLayout10ui20");class rs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,n,r,o,s,a)}emplace(e,t,i,n,r,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=n,this.uint16[c+3]=r,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}rs.prototype.bytesPerElement=16,Pr(rs,"StructArrayLayout8ui16");class os extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}os.prototype.bytesPerElement=12,Pr(os,"StructArrayLayout6i12");class ss extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,p){const d=12*e;return this.int16[d+0]=t,this.int16[d+1]=i,this.int16[d+2]=n,this.int16[d+3]=r,this.uint16[d+4]=o,this.uint16[d+5]=s,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=h,this.int16[d+11]=p,e}}ss.prototype.bytesPerElement=24,Pr(ss,"StructArrayLayout4i4ui4i24");class as extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,e}}as.prototype.bytesPerElement=20,Pr(as,"StructArrayLayout3i3f20");class ls extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}ls.prototype.bytesPerElement=4,Pr(ls,"StructArrayLayout1ul4");class cs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h,p)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,p,d){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=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]=p,this.uint16[f+19]=d,e}}cs.prototype.bytesPerElement=40,Pr(cs,"StructArrayLayout5i4f1i1ul2ui40");class us extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}us.prototype.bytesPerElement=16,Pr(us,"StructArrayLayout3i2i2i16");class hs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}hs.prototype.bytesPerElement=16,Pr(hs,"StructArrayLayout2f1f2i16");class ps extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[s+1]=n,this.float32[s+2]=r,e}}ps.prototype.bytesPerElement=12,Pr(ps,"StructArrayLayout2ub2f12");class ds extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}ds.prototype.bytesPerElement=12,Pr(ds,"StructArrayLayout3f12");class fs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}fs.prototype.bytesPerElement=6,Pr(fs,"StructArrayLayout3ui6");class ms extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b){const w=30*e,M=15*e,T=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[M+2]=r,this.float32[M+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[M+5]=l,this.uint32[M+6]=c,this.uint32[M+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[M+10]=f,this.float32[M+11]=m,this.uint8[T+48]=g,this.uint8[T+49]=_,this.uint8[T+50]=y,this.uint32[M+13]=v,this.int16[w+28]=x,this.uint8[T+58]=b,e}}ms.prototype.bytesPerElement=60,Pr(ms,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class gs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b,w,M,T,S,E,A,C,L){const I=this.length;return this.resize(I+1),this.emplace(I,e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b,w,M,T,S,E,A,C,L)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b,w,M,T,S,E,A,C,L,I){const P=38*e,R=19*e;return this.int16[P+0]=t,this.int16[P+1]=i,this.int16[P+2]=n,this.float32[R+2]=r,this.float32[R+3]=o,this.int16[P+8]=s,this.int16[P+9]=a,this.int16[P+10]=l,this.int16[P+11]=c,this.int16[P+12]=u,this.int16[P+13]=h,this.uint16[P+14]=p,this.uint16[P+15]=d,this.uint16[P+16]=f,this.uint16[P+17]=m,this.uint16[P+18]=g,this.uint16[P+19]=_,this.uint16[P+20]=y,this.uint16[P+21]=v,this.uint16[P+22]=x,this.uint16[P+23]=b,this.uint16[P+24]=w,this.uint16[P+25]=M,this.uint16[P+26]=T,this.uint16[P+27]=S,this.uint16[P+28]=E,this.uint32[R+15]=A,this.float32[R+16]=C,this.float32[R+17]=L,this.float32[R+18]=I,e}}gs.prototype.bytesPerElement=76,Pr(gs,"StructArrayLayout3i2f6i15ui1ul3f76");class _s extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}_s.prototype.bytesPerElement=4,Pr(_s,"StructArrayLayout1f4");class ys extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}ys.prototype.bytesPerElement=28,Pr(ys,"StructArrayLayout7f28");class vs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,e}}vs.prototype.bytesPerElement=20,Pr(vs,"StructArrayLayout5f20");class xs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,e}}xs.prototype.bytesPerElement=12,Pr(xs,"StructArrayLayout1ul3ui12");class bs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}bs.prototype.bytesPerElement=4,Pr(bs,"StructArrayLayout2ui4");class ws extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}ws.prototype.bytesPerElement=2,Pr(ws,"StructArrayLayout1ui2");class Ms extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}Ms.prototype.bytesPerElement=8,Pr(Ms,"StructArrayLayout2f8");class Ts extends Zo{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Ts.prototype.size=12;class Ss extends os{get(e){return new Ts(this,e)}}Pr(Ss,"FillExtrusionExtArray");class Es extends Zo{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]}}Es.prototype.size=40;class As extends cs{get(e){return new Es(this,e)}}Pr(As,"CollisionBoxArray");class Cs extends Zo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}Cs.prototype.size=60;class Ls extends ms{get(e){return new Cs(this,e)}}Pr(Ls,"PlacedSymbolArray");class Is extends Zo{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(e){this._structArray.uint32[this._pos4+15]=e}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]}}Is.prototype.size=76;class Ps extends gs{get(e){return new Is(this,e)}}Pr(Ps,"SymbolInstanceArray");class Rs extends _s{getoffsetX(e){return this.float32[1*e+0]}}Pr(Rs,"GlyphOffsetArray");class ks extends Ko{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Pr(ks,"SymbolLineVertexArray");class zs extends Zo{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]}}zs.prototype.size=12;class Ds extends xs{get(e){return new zs(this,e)}}Pr(Ds,"FeatureIndexArray");class Os extends Zo{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Os.prototype.size=4;class Fs extends bs{get(e){return new Os(this,e)}}Pr(Fs,"FillExtrusionCentroidArray");class Bs extends Zo{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Bs.prototype.size=12;class Ns extends os{get(e){return new Bs(this,e)}}Pr(Ns,"CircleGlobeExtArray");const Us=Yo([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),js=Yo([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Vs=ft((function(e){e.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c>>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,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:r^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}})),Gs=ft((function(e){e.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}})),Hs=Vs,Ws=Gs;Hs.murmur3=Vs,Hs.murmur2=Ws;class qs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push($s(e)),this.positions.push(t,i,n)}getPositions(e){const t=$s(e);let i=0,n=this.ids.length-1;for(;i>1;this.ids[e]>=t?n=e:i=e+1}const r=[];for(;this.ids[i]===t;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return Zs(i,n,0,i.length-1),t&&t.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(e){const t=new qs;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function $s(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Hs(String(e))}function Zs(e,t,i,n){for(;i>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]r);if(o>=s)break;Xs(e,o,s),Xs(t,3*o,3*s),Xs(t,3*o+1,3*s+1),Xs(t,3*o+2,3*s+2)}s-i`u_${e}`)),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new Ks(e,t):new Js(e,t)}}class oa{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio||1,this.pixelRatioTo=e.pixelRatio||1,this.patternFrom=t.tl.concat(t.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,t,i,n){const r="u_pattern_to"===n||"u_dash_to"===n?this.patternTo:"u_pattern_from"===n||"u_dash_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;r&&e.set(r)}getBinding(e,t,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Qs(e,t):new Js(e,t)}}class sa{constructor(e,t,i,n){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(e,t,i,n,r,o){const s=this.paintVertexArray.length,a=this.expression.evaluate(new Po(0),t,{},r,n,o);this.paintVertexArray.resize(e),this._setPaintValue(s,e,a)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate({zoom:0},i,n,void 0,r);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const n=na(i);for(let i=e;i`u_${e}_t`)),this.type=i,this.useIntegerZoom=n,this.zoom=r,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,i,n,r,o){const s=this.expression.evaluate(new Po(this.zoom),t,{},r,n,o),a=this.expression.evaluate(new Po(this.zoom+1),t,{},r,n,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,s,a)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate({zoom:this.zoom},i,n,void 0,r),s=this.expression.evaluate({zoom:this.zoom+1},i,n,void 0,r);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=na(i),o=na(n);for(let i=e;i!0)){this.binders={},this._buffers=[];const n=[];for(const r in e.paint._values){if(!i(r))continue;const o=e.paint.get(r);if(!(o instanceof Bo&&bn(o.property.specification)))continue;const s=pa(r,e.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,u=o.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u,p="line-dasharray"===String(r)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||h){const i=ma(r,l,"source");this.binders[r]=h?new la(a,s,l,c,t,i,e.id):new sa(a,s,l,i),n.push(`/a_${r}`)}else{const e=ma(r,l,"composite");this.binders[r]=new aa(a,s,l,c,t,e),n.push(`/z_${r}`)}else this.binders[r]=h?new oa(a.value,s):new ra(a.value,s,l),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof sa||t instanceof aa?t.maxValue:0}populatePaintArrays(e,t,i,n,r,o){for(const s in this.binders){const a=this.binders[s];(a instanceof sa||a instanceof aa||a instanceof la)&&a.populatePaintArray(e,t,i,n,r,o)}}setConstantPatternPositions(e,t){for(const i in this.binders){const n=this.binders[i];n instanceof oa&&n.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,i,n,r,o){let s=!1;for(const a in e){const l=t.getPositions(a);for(const t of l){const l=i.feature(t.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof sa||c instanceof aa||c instanceof la)&&!0===c.expression.isStateDependent){const u=n.paint.get(i);c.expression=u.value,c.updatePaintArray(t.start,t.end,l,e[a],r,o),s=!0}}}}return s}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof ra||i instanceof oa)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof sa||i instanceof aa||i instanceof la)for(let t=0;t!0)){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new ca(n,t,i);this.needsUpload=!1,this._featureMap=new qs,this._bufferOffset=0}populatePaintArrays(e,t,i,n,r,o,s){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n,r,o,s);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,n,r){for(const o of i)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,n,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const ha={"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_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function pa(e,t){return ha[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const da={"line-pattern":{source:ns,composite:ns},"fill-pattern":{source:ns,composite:ns},"fill-extrusion-pattern":{source:ns,composite:ns},"line-dasharray":{source:rs,composite:rs}},fa={color:{source:Ms,composite:is},number:{source:_s,composite:Ms}};function ma(e,t,i){const n=da[e];return n&&n[i]||fa[t][i]}Pr(ra,"ConstantBinder"),Pr(oa,"CrossFadedConstantBinder"),Pr(sa,"SourceExpressionBinder"),Pr(la,"CrossFadedCompositeBinder"),Pr(aa,"CompositeExpressionBinder"),Pr(ca,"ProgramConfiguration",{omit:["_buffers"]}),Pr(ua,"ProgramConfigurationSet");const ga="-transition";class _a extends Ge{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new Fo(t.layout)),t.paint)){this._transitionablePaint=new zo(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new No(t.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,i={}){null!=t&&this._validate(Sr,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return E(e,ga)?this._transitionablePaint.getTransition(e.slice(0,-ga.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(Tr,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(E(e,ga))return this._transitionablePaint.setTransition(e.slice(0,-ga.length),t||void 0),!1;{const i=this._transitionablePaint._values[e],n="cross-faded-data-driven"===i.property.specification["property-type"],r=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||r||n||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={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&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),C(e,((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,i,n,r={}){return(!r||!1!==r.validate)&&Ar(this,e.call(Mr,{key:t,layerType:this.type,objectKey:i,value:n,styleSpec:He,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Bo&&bn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Yn(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ya=Yo([{name:"a_pos",components:2,type:"Int16"}],4),va=Yo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class xa{constructor(e=[]){this.segments=e}prepareSegment(e,t,i,n){let r=this.segments[this.segments.length-1];return e>xa.MAX_VERTEX_ARRAY_LENGTH&&P(`Max vertices per segment is ${xa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!r||r.vertexLength+e>xa.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,n){return new xa([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}xa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Pr(xa,"SegmentVector");var ba=8192;class wa{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof Ta?new Ta(e.lng,e.lat):Ta.convert(e),this}setSouthWest(e){return this._sw=e instanceof Ta?new Ta(e.lng,e.lat):Ta.convert(e),this}extend(e){const t=this._sw,i=this._ne;let n,r;if(e instanceof Ta)n=e,r=e;else{if(!(e instanceof wa))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(wa.convert(e)):this.extend(Ta.convert(e)):this;if(n=e._sw,r=e._ne,!n||!r)return this}return t||i?(t.lng=Math.min(n.lng,t.lng),t.lat=Math.min(n.lat,t.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new Ta(n.lng,n.lat),this._ne=new Ta(r.lng,r.lat)),this}getCenter(){return new Ta((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 Ta(this.getWest(),this.getNorth())}getSouthEast(){return new Ta(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:i}=Ta.convert(e);let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&n}static convert(e){return!e||e instanceof wa?e:new wa(e)}}const Ma=6371008.8;class Ta{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ta(g(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return Ma*Math.acos(Math.min(r,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new wa(new Ta(this.lng-i,this.lat-t),new Ta(this.lng+i,this.lat+t))}static convert(e){if(e instanceof Ta)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Ta(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Ta(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Sa=2*Math.PI*Ma;function Ea(e){return Sa*Math.cos(e*Math.PI/180)}function Aa(e){return(180+e)/360}function Ca(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function La(e,t){return e/Ea(t)}function Ia(e){return 360*e-180}function Pa(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Ra(e,t){return e*Ea(Pa(t))}const ka=85.051129;class za{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=Ta.convert(e);return new za(Aa(i.lng),Ca(i.lat),La(t,i.lat))}toLngLat(){return new Ta(Ia(this.x),Pa(this.y))}toAltitude(){return Ra(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Sa*(e=Pa(this.y),1/Math.cos(e*Math.PI/180));var e}}function Da(e,t,i,n,o,s,a,l,c){const u=(t+n)/2,h=(i+o)/2,p=new r(u,h);l(p),function(e,t,i,n,r,o){const s=i-r,a=n-o;return Math.abs((n-t)*s-(i-e)*a)/Math.hypot(s,a)}(p.x,p.y,s.x,s.y,a.x,a.y)>=c?(Da(e,t,i,u,h,s,p,l,c),Da(e,u,h,n,o,p,a,l,c)):e.push(a)}function Oa(e,t,i){let n=e[0],r=n.x,o=n.y;t(n);const s=[n];for(let a=1;ae.x+1||ne.y+1)&&P("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Va(e,t,i){const n=e.loadGeometry(),r=e.extent,o=ba/r;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<{const i=Ia((t.x+e.x/r)/o),n=Pa((t.y+e.y/r)/o),u=c.project(i,n);e.x=(u.x*s-a)*r,e.y=(u.y*s-l)*r};for(let t=0;t=r||i.y<0||i.y>=r||(u(i),e.push(i));n[t]=e}}for(const e of n)for(const t of e)ja(t,o);return n}function Ga(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Va(e):[]}}function Ha(e,t,i,n,r){e.emplaceBack(2*t+(n+1)/2,2*i+(r+1)/2)}function Wa(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n)}class qa{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Qo,this.indexArray=new fs,this.segments=new xa,this.programConfigurations=new ua(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:t,id:r,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ga(t,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),c,i))continue;const u=s?s.evaluate(c,{},i):void 0,h={id:r,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Va(t,i,n),patterns:{},sortKey:u};o.push(h)}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Ns,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=e[o].feature;this.addFeature(n,r,o,t.availableImages,i,a),t.featureIndex.insert(l,r,o,s,this.index)}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ya.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,va.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,i,n,r,o){for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=ba||n<0||n>=ba)continue;if(o){const e=o.projectTilePoint(i,n,r),t=o.upVector(r,i,n),s=this.globeExtVertexArray;Wa(s,e,t),Wa(s,e,t),Wa(s,e,t),Wa(s,e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;Ha(this.layoutVertexArray,i,n,-1,-1),Ha(this.layoutVertexArray,i,n,1,-1),Ha(this.layoutVertexArray,i,n,1,1),Ha(this.layoutVertexArray,i,n,-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,e,i,{},n,r)}}function $a(e,t){for(let i=0;i1){if(Ja(e,t))return!0;for(let n=0;n1?i:i.sub(t)._mult(r)._add(t))}function tl(e,t){let i,n,r,o=!1;for(let s=0;st.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(o=!o)}return o}function il(e,t){let i=!1;for(let n=0,r=e.length-1;nt.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function nl(e,t,i,n,o){for(const r of e)if(t<=r.x&&i<=r.y&&n>=r.x&&o>=r.y)return!0;const s=[new r(t,i),new r(t,o),new r(n,o),new r(n,i)];if(e.length>2)for(const t of s)if(il(e,t))return!0;for(let t=0;tr.x&&t.x>r.x||e.yr.y&&t.y>r.y)return!1;const o=R(e,t,i[0]);return o!==R(e,t,i[1])||o!==R(e,t,i[2])||o!==R(e,t,i[3])}function ol(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function sl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function al(e,t,i,n,o){if(!t[0]&&!t[1])return e;const s=r.convert(t)._mult(o);"viewport"===i&&s._rotate(-n);const a=[];for(let t=0;t0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function zl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Dl(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=r*l-o*a,e[1]=o*s-n*l,e[2]=n*a-r*s,e}function Ol(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e}function Fl(e,t,i){var n=i[0],r=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=r*l-o*a,u=o*s-n*l,h=n*a-r*s,p=r*h-o*u,d=o*c-n*h,f=n*u-r*c,m=2*i[3];return u*=m,h*=m,d*=2,f*=2,e[0]=s+(c*=m)+(p*=2),e[1]=a+u+d,e[2]=l+h+f,e}var Bl,Nl=Al,Ul=Cl,jl=Tl;function Vl(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function Gl(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,e}function Hl(){var e=new pl(4);return pl!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Wl(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ql(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l+s*a,e[1]=r*l+o*a,e[2]=o*l-r*a,e[3]=s*l-n*a,e}function $l(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l-o*a,e[1]=r*l+s*a,e[2]=o*l+n*a,e[3]=s*l-r*a,e}wl(),Bl=new pl(4),pl!=Float32Array&&(Bl[0]=0,Bl[1]=0,Bl[2]=0,Bl[3]=0),wl(),Sl(1,0,0),Sl(0,1,0),Hl(),Hl(),dl();class Zl{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const n=zl(t,this.dir);if(Math.abs(n)<1e-6)return!1;const r=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/n;return i[0]=this.pos[0]+this.dir[0]*r,i[1]=this.pos[1]+this.dir[1]*r,i[2]=this.pos[2]+this.dir[2]*r,!0}closestPointOnSphere(e,t,i){if(function(e,t){var i=e[0],n=e[1],r=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(i-o)<=hl*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-s)<=hl*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(r-a)<=hl*Math.max(1,Math.abs(r),Math.abs(a))}(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[n,r,o]=this.dir,s=this.pos[0]-e[0],a=this.pos[1]-e[1],l=this.pos[2]-e[2],c=n*n+r*r+o*o,u=2*(s*n+a*r+l*o),h=u*u-4*c*(s*s+a*a+l*l-t*t);if(h<0){const e=Math.max(-u/2,0),c=s+n*e,h=a+r*e,p=l+o*e,d=Math.hypot(c,h,p);return i[0]=c*t/d,i[1]=h*t/d,i[2]=p*t/d,!1}{const e=(-u-Math.sqrt(h))/(2*c);if(e<0){const e=Math.hypot(s,a,l);return i[0]=s*t/e,i[1]=a*t/e,i[2]=l*t/e,!1}return i[0]=s+n*e,i[1]=a+r*e,i[2]=l+o*e,!0}}}class Xl{constructor(e,t,i,n,r){this.TL=e,this.TR=t,this.BR=i,this.BL=n,this.horizon=r}static fromInvProjectionMatrix(e,t,i){const n=[-1,1,1],r=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Ol(n,n,e),l=Ol(r,r,e),c=Ol(o,o,e),u=Ol(s,s,e);return new Xl(a,l,c,u,t/i)}}class Yl{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,i,n){const r=Math.pow(2,i),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((i=>{const o=Gl([],i,e),s=1/o[3]/t*r;return function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}(o,o,[s,s,n?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((e=>{const t=kl([],Dl([],Nl([],o[e[0]],o[e[1]]),Nl([],o[e[2]],o[e[1]]))),i=-zl(t,o[e[1]]);return t.concat(i)}));return new Yl(o,s)}}class Jl{constructor(e,t){this.min=e,this.max=t,this.center=Pl([],El([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=Ml(this.min),n=Ml(this.max);for(let e=0;e=0;if(0===o)return 0;o!==t.length&&(i=!1)}if(i)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let r=0;rthis.max[t]-this.min[t])return 0}return 1}}function Ql(e,t,i,n,r,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(a),p=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(h.x,h.y,!0):0,d=i.projection.projectTilePoint(h.x,h.y,c);if(p>0){const e=i.projection.upVector(c,h.x,h.y);d.x+=e[0]*u*p,d.y+=e[1]*u*p,d.z+=e[2]*u*p}const f=o?h:Kl(d.x,d.y,d.z,n),m=o?e.tilespaceRays.map((e=>ic(e,p))):e.queryGeometry.screenGeometry,g=Gl([],[d.x,d.y,d.z,1],n);if(!s&&o?l*=g[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/g[3]),o){const e=Pa((t.y/ba+c.y)/(1<e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;for(let l=0;l{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a)};if(e.clips)for(let t=0,r=0;t80*i){n=o=e[0],r=s=e[1];for(var f=i;fo&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-n,s-r))?1/c:0}return vc(p,d,i,n,r,c),d}function _c(e,t,i,n,r){var o,s;if(r===jc(e,t,i,n)>0)for(o=t;o=t;o-=n)s=Bc(o,e[o],e[o+1],s);return s&&Rc(s,s.next)&&(Nc(s),s=s.next),s}function yc(e,t){if(!e)return e;t||(t=e);var i,n=e;do{if(i=!1,n.steiner||!Rc(n,n.next)&&0!==Pc(n.prev,n,n.next))n=n.next;else{if(Nc(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function vc(e,t,i,n,r,o,s){if(e){!s&&o&&function(e,t,i,n){var r=e;do{null===r.z&&(r.z=Ac(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,i,n,r,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,n=i,a=0,t=0;t0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1)}(r)}(e,n,r,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?bc(e,n,r,o):xc(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),Nc(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?vc(e=wc(yc(e),t,i),t,i,n,r,o,2):2===s&&Mc(e,t,i,n,r,o):vc(yc(e),t,i,n,r,o,1);break}}}function xc(e){var t=e.prev,i=e,n=e.next;if(Pc(t,i,n)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(Lc(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Pc(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function bc(e,t,i,n){var r=e.prev,o=e,s=e.next;if(Pc(r,o,s)>=0)return!1;for(var a=r.x>o.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,l=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,c=Ac(r.x=c&&p&&p.z<=u;){if(h!==e.prev&&h!==e.next&&Lc(r.x,r.y,o.x,o.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==e.prev&&p!==e.next&&Lc(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=c;){if(h!==e.prev&&h!==e.next&&Lc(r.x,r.y,o.x,o.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=u;){if(p!==e.prev&&p!==e.next&&Lc(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function wc(e,t,i){var n=e;do{var r=n.prev,o=n.next.next;!Rc(r,o)&&kc(r,n,n.next,o)&&Oc(r,o)&&Oc(o,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(o.i/i),Nc(n),Nc(n.next),n=e=o),n=n.next}while(n!==e);return yc(n)}function Mc(e,t,i,n,r,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Ic(s,a)){var l=Fc(s,a);return s=yc(s,s.next),l=yc(l,l.next),vc(s,t,i,n,r,o),void vc(l,t,i,n,r,o)}a=a.next}s=s.next}while(s!==e)}function Tc(e,t){return e.x-t.x}function Sc(e,t){var i=function(e,t){var i,n=t,r=e.x,o=e.y,s=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var a=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>s){if(s=a,a===r){if(o===n.y)return n;if(o===n.next.y)return n.next}i=n.x=n.x&&n.x>=u&&r!==n.x&&Lc(oi.x||n.x===i.x&&Ec(i,n)))&&(i=n,p=l)),n=n.next}while(n!==c);return i}(e,t);if(!i)return t;var n=Fc(i,e),r=yc(i,i.next);return yc(n,n.next),t===i?r:t}function Ec(e,t){return Pc(e.prev,e,t.prev)<0&&Pc(t.next,e,e.next)<0}function Ac(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Cc(e){var t=e,i=e;do{(t.x=0&&(e-s)*(n-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(r-s)*(n-a)>=0}function Ic(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&kc(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Oc(e,t)&&Oc(t,e)&&function(e,t){var i=e,n=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Pc(e.prev,e,t.prev)||Pc(e,t.prev,t))||Rc(e,t)&&Pc(e.prev,e,e.next)>0&&Pc(t.prev,t,t.next)>0)}function Pc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Rc(e,t){return e.x===t.x&&e.y===t.y}function kc(e,t,i,n){var r=Dc(Pc(e,t,i)),o=Dc(Pc(e,t,n)),s=Dc(Pc(i,n,e)),a=Dc(Pc(i,n,t));return r!==o&&s!==a||!(0!==r||!zc(e,i,t))||!(0!==o||!zc(e,n,t))||!(0!==s||!zc(i,e,n))||!(0!==a||!zc(i,t,n))}function zc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Dc(e){return e>0?1:e<0?-1:0}function Oc(e,t){return Pc(e.prev,e,e.next)<0?Pc(e,t,e.next)>=0&&Pc(e,e.prev,t)>=0:Pc(e,t,e.prev)<0||Pc(e,e.next,t)<0}function Fc(e,t){var i=new Uc(e.i,e.x,e.y),n=new Uc(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Bc(e,t,i,n){var r=new Uc(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Nc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Uc(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function jc(e,t,i,n){for(var r=0,o=t,s=i-n;oi;){if(n-i>600){var o=n-i+1,s=t-i+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);Gc(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}var u=e[t],h=i,p=n;for(Hc(e,i,t),r(e[n],u)>0&&Hc(e,i,n);h0;)p--}0===r(e[i],u)?Hc(e,i,p):Hc(e,++p,n),p<=t&&(i=p+1),t<=p&&(n=p-1)}}function Hc(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function Wc(e,t){return et?1:0}function qc(e,t){const i=e.length;if(i<=1)return[e];const n=[];let r,o;for(let t=0;t1)for(let e=0;e0&&i.holes.push(n+=e[r-1].length)}return i},fc.default=mc;class Yc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Qo,this.indexArray=new fs,this.indexArray2=new bs,this.programConfigurations=new ua(e.layers,e.zoom),this.segments=new xa,this.segments2=new xa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}populate(e,t,i,n){this.hasPattern=Zc("fill",this.layers,t);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ga(s,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),u,i))continue;const h=r?r.evaluate(u,{},i,t.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Va(s,i,n),patterns:{},sortKey:h};o.push(p)}r&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const e=Xc("fill",this.layers,n,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.availableImages);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,n)}addFeatures(e,t,i,n,r){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,dc),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),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(e,t,i,n,r,o=[]){for(const e of qc(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(n+t.length-1,n),r.push(t[0].x),r.push(t[0].y);for(let e=1;e>3}if(o--,1===n||2===n)s+=e.readSVarint(),a+=e.readSVarint(),1===n&&(t&&l.push(t),t=[]),t.push(new r(s,a));else{if(7!==n)throw new Error("unknown command "+n);t&&t.push(t[0].clone())}}return t&&l.push(t),l},ru.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos>3}if(n--,1===i||2===i)(r+=e.readSVarint())a&&(a=r),(o+=e.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},ru.prototype.toGeoJSON=function(e,t,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=ru.types[this.type];function u(e){for(var t=0;t>3;t=1===n?e.readString():2===n?e.readFloat():3===n?e.readDouble():4===n?e.readVarint64():5===n?e.readVarint():6===n?e.readSVarint():7===n?e.readBoolean():null}return t}(i))}function uu(e,t,i){if(3===e){var n=new au(i,i.readVarint()+i.pos);n.length&&(t[n.name]=n)}}lu.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new nu(this._pbf,t,this.extent,this._keys,this._values)};var hu={VectorTile:function(e,t){this.layers=e.readFields(uu,{},t)},VectorTileFeature:nu,VectorTileLayer:au};function pu(e,t,i,n){const o=[],s=0===n?(e,t,i,n,o,s)=>{e.push(new r(s,i+(s-t)/(n-t)*(o-i)))}:(e,t,i,n,o,s)=>{e.push(new r(t+(s-i)/(o-i)*(n-t),s))};for(const r of e){const e=[];for(const o of r){if(o.length<=2)continue;const r=[];for(let e=0;et&&s(r,a,l,c,u,t):h>i?p=t&&s(r,a,l,c,u,t),p>i&&h<=i&&s(r,a,l,c,u,i)}let a=o[o.length-1];const l=0===n?a.x:a.y;l>=t&&l<=i&&r.push(a),r.length&&(a=r[r.length-1],r[0].x===a.x&&r[0].y===a.y||r.push(r[0]),e.push(r))}e.length&&o.push(e)}return o}const du=hu.VectorTileFeature.types,fu=Math.pow(2,13);function mu(e,t,i,n,r,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(n*fu)<<1)+r,Math.round(a))}function gu(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n)}class _u{constructor(){this.acc=new r(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new r(e.x,e.y),this.max=new r(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const i=this.min,n=this.max;e.xn.x&&(n.x=e.x),e.yn.y&&(n.y=e.y),((0===e.x||e.x===ba)&&e.x===t.x)!=((0===e.y||e.y===ba)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,_i(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>ba!=e.x>ba&&this.addBorderIntersection(1,_i(t.y,e.y,(ba-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,_i(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>ba!=e.y>ba&&this.addBorderIntersection(3,_i(t.x,e.x,(ba-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];ti[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){const e=this.polyCount.reduce(((e,t)=>e+t.edges),0);return 0!==e?this.acc.div(e)._round():new r(0,0)}span(){return new r(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0)}}class yu{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new es,this.centroidVertexArray=new Fs,this.indexArray=new fs,this.programConfigurations=new ua(e.layers,e.zoom),this.segments=new xa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.enableTerrain=e.enableTerrain}populate(e,t,i,n){this.features=[],this.hasPattern=Zc("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<=0;e--){const t=p[e];(0===t.length||(d=t[0]).every((e=>e.x<=0))||d.every((e=>e.x>=ba))||d.every((e=>e.y<=0))||d.every((e=>e.y>=ba)))&&p.splice(e,1)}var d;let f;if(u)f=bu(p,l,n);else{f=[];for(const e of p)f.push({polygon:e,bounds:l})}for(const t of f){const i=t.polygon;let r=0,o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let e=0;e=1){const r=s[e-1];if(!vu(i,r,t.bounds)){h&&h.append(i,r),o.vertexLength+4>xa.MAX_VERTEX_ARRAY_LENGTH&&(o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const e=i.sub(r)._perp(),t=e.x/(Math.abs(e.x)+Math.abs(e.y)),s=e.y>0?1:0,l=r.dist(i);a+l>32768&&(a=0),mu(this.layoutVertexArray,i.x,i.y,t,s,0,0,a),mu(this.layoutVertexArray,i.x,i.y,t,s,0,1,a),a+=l,mu(this.layoutVertexArray,r.x,r.y,t,s,0,0,a),mu(this.layoutVertexArray,r.x,r.y,t,s,0,1,a);const p=o.vertexLength;if(this.indexArray.emplaceBack(p,p+2,p+1),this.indexArray.emplaceBack(p+1,p+2,p+3),o.vertexLength+=4,o.primitiveLength+=2,u){const e=this.layoutVertexExtArray,t=c.projectTilePoint(i.x,i.y,n),o=c.projectTilePoint(r.x,r.y,n),s=c.upVector(n,i.x,i.y),a=c.upVector(n,r.x,r.y);gu(e,t,s),gu(e,t,s),gu(e,o,a),gu(e,o,a)}}}}}if(o.vertexLength+r>xa.MAX_VERTEX_ARRAY_LENGTH&&(o=this.segments.prepareSegment(r,this.layoutVertexArray,this.indexArray)),"Polygon"!==du[e.type])continue;const s=[],a=[],l=o.vertexLength;for(let e=0;e0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const e=h.borders,t=this.featuresOnBorder.push(h)-1;for(let i=0;i<4;i++)e[i][0]!==Number.MAX_VALUE&&this.borders[i].push(t)}this.encodeCentroid(h.borders?void 0:h.centroid(),h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,o,s,n)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort(((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]))}encodeCentroid(e,t,i=!0){let n,r;if(e)if(0!==e.y){const i=t.span()._mult(this.tileToMeter);n=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(i.x/10)),r=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else n=Math.ceil(7*(e.x+450)),r=0;else n=0,r=+i;let o=i?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;t<2*e.edges;t++)this.centroidVertexArray.emplace(o++,0,r),this.centroidVertexArray.emplace(o++,n,r);for(let t=0;ti[1].x)||e.y===t.y&&(e.yi[1].y)}function xu(){const e=Math.PI/32,t=Math.tan(e),i=Ma;return i*Math.sqrt(1+2*t*t)-i}function bu(e,t,i){const n=1<{for(const i of e)a.push({polygon:i,bounds:t})},c=Math.ceil(Math.log2(i)),u=Math.ceil(Math.log2(n)),h=c-u,p=[];for(let e=0;e0?0:1);for(let e=0;et+1?f.push({polygons:d,bounds:e,depth:t+1}):l(d,e)}if(m.length){const e=[new r(0===i?h:n.x,1===i?h:n.y),a];p.length>t+1?f.push({polygons:m,bounds:e,depth:t+1}):l(m,e)}}return a}(e,t,Math.ceil((s-o)/11.25),Math.ceil((a-l)/11.25),1,((e,t,r)=>{if(0===e)return.5*(t+r);{const e=Pa((i.y+t/ba)/n);return(Ca(.5*(Pa((i.y+r/ba)/n)+e))*n-i.y)*ba}}))}Pr(yu,"FillExtrusionBucket",{omit:["layers","features"]}),Pr(_u,"PartMetadata");var wu={paint:new Wo({"fill-extrusion-opacity":new Uo(He["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new jo(He["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Uo(He["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Uo(He["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Vo(He["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new jo(He["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new jo(He["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Uo(He["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Mu(e,t,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[e*n-2*Math.PI*6378137/2,t*n-2*Math.PI*6378137/2]}class Tu{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Au(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=function(e,t,i){var n=Mu(256*e,256*(t=Math.pow(2,i)-t-1),i),r=Mu(256*(e+1),256*(t+1),i);return n[0]+","+n[1]+","+r[0]+","+r[1]}(this.x,this.y,this.z),n=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<this.canonical.z?new Eu(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Eu(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Au(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Au(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Eu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new Eu(t,this.wrap,t,i,n),new Eu(t,this.wrap,t,i+1,n),new Eu(t,this.wrap,t,i,n+1),new Eu(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.id)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new ts,this.layoutVertexArray2=new is,this.indexArray=new fs,this.programConfigurations=new ua(e.layers,e.zoom),this.segments=new xa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,n){this.hasPattern=Zc("line",this.layers,t);const r=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ga(t,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),c,i))continue;const u=r?r.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Va(t,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:s,featureIndex:a}=t,l=this.addConstantDashes(s);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:c}=n;if(l&&this.addFeatureDashes(n,s),this.hasPattern){const e=Xc("line",this.layers,n,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,s.positions,t.availableImages);a.insert(e[o].feature,r,o,c,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)t=!0;else{const t=r.value,i=n.value;if(!i)continue;e.addDash(i.from,t),e.addDash(i.to,t),i.other&&e.addDash(i.other,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a,l,c,u,h;if("constant"===r.kind){const e=r.value;if(!e)continue;s=e.other||e.to,a=e.to,l=e.from}else s=r.evaluate({zoom:i-1},e),a=r.evaluate({zoom:i},e),l=r.evaluate({zoom:i+1},e);"constant"===o.kind?c=u=h=o.value:(c=o.evaluate({zoom:i-1},e),u=o.evaluate({zoom:i},e),h=o.evaluate({zoom:i+1},e)),t.addDash(s,c),t.addDash(a,u),t.addDash(l,h);const p=t.getKey(s,c),d=t.getKey(a,u),f=t.getKey(l,h);e.patterns[n.id]={min:p,mid:d,max:f}}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,n)}addFeatures(e,t,i,n,r){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Du)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ku),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,n,r,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(e,{}),l=s.get("line-cap").evaluate(e,{}),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,a,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,o,n)}addLine(e,t,i,n,r,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[a-1].equals(e[a-2]);)a--;let l=0;for(;l0;if(b&&t>l){const e=h.dist(p);if(e>2*c){const t=h.sub(h.sub(p)._mult(c/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,f,0,0,u),p=t}}const M=p&&d;let T=M?i:s?"butt":n;if(M&&"round"===T&&(vr&&(T="bevel"),"bevel"===T&&(v>2&&(T="flipbevel"),v100)g=m.mult(-1);else{const e=v*f.add(m).mag()/f.sub(m).mag();g._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,g,0,0,u),this.addCurrentVertex(h,g.mult(-1),0,0,u)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(v*v-1),t=w?e:0,i=w?0:e;if(p&&this.addCurrentVertex(h,f,t,i,u),"fakeround"===T){const e=Math.round(180*x/Math.PI/20);for(let t=1;t2*c){const t=h.add(d.sub(h)._mult(c/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,u),h=t}}}}addCurrentVertex(e,t,i,n,r,o=!1){const s=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,r),this.addHalfVertex(e,s,a,o,!0,-n,r)}addHalfVertex({x:e,y:t},i,n,r,o,s,a){this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+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 e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}Pr(Bu,"LineBucket",{omit:["layers","patternFeatures"]});const Nu=new Wo({"line-cap":new jo(He.layout_line["line-cap"]),"line-join":new jo(He.layout_line["line-join"]),"line-miter-limit":new Uo(He.layout_line["line-miter-limit"]),"line-round-limit":new Uo(He.layout_line["line-round-limit"]),"line-sort-key":new jo(He.layout_line["line-sort-key"])});var Uu={paint:new Wo({"line-opacity":new jo(He.paint_line["line-opacity"]),"line-color":new jo(He.paint_line["line-color"]),"line-translate":new Uo(He.paint_line["line-translate"]),"line-translate-anchor":new Uo(He.paint_line["line-translate-anchor"]),"line-width":new jo(He.paint_line["line-width"]),"line-gap-width":new jo(He.paint_line["line-gap-width"]),"line-offset":new jo(He.paint_line["line-offset"]),"line-blur":new jo(He.paint_line["line-blur"]),"line-dasharray":new Vo(He.paint_line["line-dasharray"]),"line-pattern":new Vo(He.paint_line["line-pattern"]),"line-gradient":new Ho(He.paint_line["line-gradient"]),"line-trim-offset":new Uo(He.paint_line["line-trim-offset"])}),layout:Nu};const ju=new class extends jo{possiblyEvaluate(e,t){return t=new Po(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=v({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}(Uu.paint.properties["line-width"].specification);function Vu(e,t){return t>0?t+2*e:e}ju.useIntegerZoom=!0;const Gu=Yo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Hu=Yo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Wu=Yo([{name:"a_projected_pos",components:4,type:"Float32"}],4);Yo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const qu=Yo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),$u=Yo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Yo([{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 Zu=Yo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Xu=Yo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Yo([{name:"triangle",components:3,type:"Uint16"}]),Yo([{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"}]),Yo([{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"}]),Yo([{type:"Float32",name:"offsetX"}]),Yo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Yu=24;const Ju=128;function Qu(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Po(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=i;let r=0;for(;r{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Io.applyArabicShaping&&(e=Io.applyArabicShaping(e)),e}(e.text,t,i)})),e}const nh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function rh(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function oh(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var sh=function(e,t,i,n,r){var o,s,a=8*r-n-1,l=(1<>1,u=-7,h=i?r-1:0,p=i?-1:1,d=e[t+h];for(h+=p,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+h],h+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+e[t+h],h+=p,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},ah=function(e,t,i,n,r,o){var s,a,l,c=8*o-r-1,u=(1<>1,p=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,f=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*l-1)*Math.pow(2,r),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,r),s=0));r>=8;e[i+d]=255&a,d+=f,a/=256,r-=8);for(s=s<0;e[i+d]=255&s,d+=f,s/=256,c-=8);e[i+d-f]|=128*m},lh=ch;function ch(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}ch.Varint=0,ch.Fixed64=1,ch.Bytes=2,ch.Fixed32=5;var uh=4294967296,hh=1/uh,ph="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function dh(e){return e.type===ch.Bytes?e.readVarint()+e.pos:e.pos+1}function fh(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function mh(e,t,i){var n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(var r=i.pos-1;r>=e;r--)i.buf[r+n]=i.buf[r]}function gh(e,t){for(var i=0;i>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Ah(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function Ch(e,t,i){t.glyphs=[],1===e&&i.readMessage(Lh,t)}function Lh(e,t,i){if(3===e){const{id:e,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Ih,{});t.glyphs.push({id:e,bitmap:new ac({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function Ih(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}function Ph(e){let t=0,i=0;for(const n of e)t+=n.w*n.h,i=Math.max(i,n.w);e.sort(((e,t)=>t.h-e.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();e>3,o=this.pos;this.type=7&n,e(r,t,this),this.pos===o&&this.skip(n)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Sh(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Ah(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Sh(this.buf,this.pos)+Sh(this.buf,this.pos+4)*uh;return this.pos+=8,e},readSFixed64:function(){var e=Sh(this.buf,this.pos)+Ah(this.buf,this.pos+4)*uh;return this.pos+=8,e},readFloat:function(){var e=sh(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=sh(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,n=this.buf;return t=127&(i=n[this.pos++]),i<128?t:(t|=(127&(i=n[this.pos++]))<<7,i<128?t:(t|=(127&(i=n[this.pos++]))<<14,i<128?t:(t|=(127&(i=n[this.pos++]))<<21,i<128?t:function(e,t,i){var n,r,o=i.buf;if(n=(112&(r=o[i.pos++]))>>4,r<128)return fh(e,n,t);if(n|=(127&(r=o[i.pos++]))<<3,r<128)return fh(e,n,t);if(n|=(127&(r=o[i.pos++]))<<10,r<128)return fh(e,n,t);if(n|=(127&(r=o[i.pos++]))<<17,r<128)return fh(e,n,t);if(n|=(127&(r=o[i.pos++]))<<24,r<128)return fh(e,n,t);if(n|=(1&(r=o[i.pos++]))<<31,r<128)return fh(e,n,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=n[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&ph?function(e,t,i){return ph.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){for(var n="",r=t;r239?4:l>223?3:l>191?2:1;if(r+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(o=e[r+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(s=e[r+2],128==(192&(o=e[r+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=e[r+2],a=e[r+3],128==(192&(o=e[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,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=u}return n}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==ch.Bytes)return e.push(this.readVarint(t));var i=dh(this);for(e=e||[];this.pos127;);else if(t===ch.Bytes)this.pos=this.readVarint()+this.pos;else if(t===ch.Fixed32)this.pos+=4;else{if(t!==ch.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(n=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,n=n+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(n,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var n,r,o=0;o55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&mh(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),ah(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),ah(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i=128&&mh(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(e,t,i){this.writeTag(e,ch.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,gh,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,_h,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,xh,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,yh,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,vh,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,bh,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,wh,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Mh,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Th,t)},writeBytesField:function(e,t){this.writeTag(e,ch.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,ch.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,ch.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,ch.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,ch.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,ch.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,ch.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,ch.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,ch.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,ch.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};class Rh{constructor(e,{pixelRatio:t,version:i,stretchX:n,stretchY:r,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=n,this.stretchY=r,this.content=o,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class kh{constructor(e,t){const i={},n={};this.haveRenderCallbacks=[];const r=[];this.addImages(e,i,r),this.addImages(t,n,r);const{w:o,h:s}=Ph(r),a=new lc({width:o||1,height:s||1});for(const t in e){const n=e[t],r=i[t].paddedRect;lc.copy(n.data,a,{x:0,y:0},{x:r.x+1,y:r.y+1},n.data)}for(const e in t){const i=t[e],r=n[e].paddedRect,o=r.x+1,s=r.y+1,l=i.data.width,c=i.data.height;lc.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),lc.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),lc.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),lc.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),lc.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=n}addImages(e,t,i){for(const n in e){const r=e[n],o={x:0,y:0,w:r.data.width+2,h:r.data.height+2};i.push(o),t[n]=new Rh(o,r),r.hasRenderCallback&&this.haveRenderCallbacks.push(n)}}patchUpdatedImages(e,t){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((t=>e.hasImage(t))),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in e.updatedImages)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[n,r]=e.tl;i.update(t.data,void 0,{x:n,y:r})}}Pr(Rh,"ImagePosition"),Pr(kh,"ImageAtlas");const zh={horizontal:1,vertical:2,horizontalOnly:3};class Dh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const i=new Dh;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new Dh;return t.imageName=e,t}}class Oh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const i=new Oh;for(let n=0;n=0&&i>=e&&Bh[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new Oh;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Dh.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Fh(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=Oh.fromFeature(e,r);let _;h===zh.vertical&&g.verticalizePunctuation(p);const{processBidirectionalText:y,processStyledBidirectionalText:v}=Io;if(y&&1===g.sections.length){_=[];const e=y(g.toString(),Wh(g,c,o,t,n,d,f));for(const t of e){const e=new Oh;e.text=t,e.sections=g.sections;for(let i=0;i0&&o>b&&(b=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(T=e[m]);const n=t[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Yu:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,i=(e+t)*_;w=0;let u=0;for(let i=0;i-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function Qh(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=_i(n.x,r.x,u),p=_i(n.y,r.y,u),d=new Yh(h,p,0,r.angleTo(n),i);return!s||Jh(e,d,a,s,t)?d:void 0}l+=o}}function ip(e,t,i,n,r,o,s,a,l){const c=Kh(n,o,s),u=ep(n,r),h=u*s,p=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&y=0&&p+c<=u){const i=new Yh(_,y,0,m,t);i._round(),n&&!Jh(e,i,o,n,r)||d.push(i)}}h+=f}return a||d.length||s||(d=np(e,h/2,i,n,r,o,s,!0,l)),d}function rp(e,t,i,n,o){const s=[];for(let a=0;a=n&&u.x>=n||(a.x>=n?a=new r(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=n&&(u=new r(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new r(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new r(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}Pr(Yh,"Anchor");const op=1e20;function sp(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=op}for(let a=0,l=0;a{let n=this.entries[e];n||(n=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[t];if(void 0!==r)return void i(null,{stack:e,id:t,glyph:r});if(r=this._tinySDF(n,e,t),r)return n.glyphs[t]=r,void i(null,{stack:e,id:t,glyph:r});const o=Math.floor(t/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[o])return void i(null,{stack:e,id:t,glyph:r});let s=n.requests[o];s||(s=n.requests[o]=[],cp.loadGlyphRange(e,o,this.url,this.requestManager,((e,t)=>{if(t){n.ascender=t.ascender,n.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=t.glyphs[+e]);n.ranges[o]=!0}for(const i of s)i(e,t);delete n.requests[o]}))),s.push(((n,r)=>{n?i(n):r&&i(null,{stack:e,id:t,glyph:r.glyphs[t]||null})}))}),((e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:n,glyph:r}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}}))}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==lp.none&&(this.localGlyphMode===lp.all?!!this.localFontFamily:!!this.localFontFamily&&(Kr(e)||io(e)||Hr(e)||Wr(e)||Gr(e)))}_tinySDF(e,t,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=e.tinySDF;if(!r){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),r=e.tinySDF=new cp.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCharCode(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new ac({width:a,height:l},s),metrics:{width:c/2,height:u/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}function up(e,t,i,n){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2,u=e.right-e.left,h=e.bottom-e.top,p=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],f=(e,t)=>e+t[1]-t[0],m=p.reduce(f,0),g=d.reduce(f,0),_=l-m,y=c-g;let v=0,x=m,b=0,w=g,M=0,T=_,S=0,E=y;if(s.content&&n){const e=s.content;v=hp(p,0,e[0]),b=hp(d,0,e[1]),x=hp(p,e[0],e[2]),w=hp(d,e[1],e[3]),M=e[0]-v,S=e[1]-b,T=e[2]-e[0]-x,E=e[3]-e[1]-w}const A=(n,o,l,c)=>{const p=dp(n.stretch-v,x,u,e.left),d=fp(n.fixed-M,T,n.stretch,m),f=dp(o.stretch-b,w,h,e.top),_=fp(o.fixed-S,E,o.stretch,g),y=dp(l.stretch-v,x,u,e.left),A=fp(l.fixed-M,T,l.stretch,m),C=dp(c.stretch-b,w,h,e.top),L=fp(c.fixed-S,E,c.stretch,g),I=new r(p,f),P=new r(y,f),R=new r(y,C),k=new r(p,C),z=new r(d/a,_/a),D=new r(A/a,L/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];I._matMult(i),P._matMult(i),k._matMult(i),R._matMult(i)}const F=n.stretch+n.fixed,B=o.stretch+o.fixed;return{tl:I,tr:P,bl:k,br:R,tex:{x:s.paddedRect.x+1+F,y:s.paddedRect.y+1+B,w:l.stretch+l.fixed-F,h:c.stretch+c.fixed-B},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:z,pixelOffsetBR:D,minFontScaleX:T/a/u,minFontScaleY:E/a/h,isSDF:i}};if(n&&(s.stretchX||s.stretchY)){const e=pp(p,_,m),t=pp(d,y,g);for(let i=0;i{if(e)r(e);else if(t){const e={},i=function(e){return new lh(e).readFields(Ch,{})}(t);for(const t of i.glyphs)e[t.id]=t;r(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}}))},cp.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=n,this.radius=i;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}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(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.min(this.size-this.buffer,Math.ceil(o-r)),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);_.fill(op,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}sp(_,0,0,c,u,c,this.f,this.v,this.z),sp(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=o,e=n}t[e]=r}}function _p(e,t){return et?1:0}function yp(e,t=1,i=!1){let n=1/0,o=1/0,s=-1/0,a=-1/0;const l=e[0];for(let e=0;es)&&(s=t.x),(!e||t.y>a)&&(a=t.y)}const c=Math.min(s-n,a-o);let u=c/2;const h=new gp([],vp);if(0===c)return new r(n,o);for(let t=n;tp.d||!p.d)&&(p=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-p.d<=t||(u=n.h/2,h.push(new xp(n.p.x-u,n.p.y-u,u,e)),h.push(new xp(n.p.x+u,n.p.y-u,u,e)),h.push(new xp(n.p.x-u,n.p.y+u,u,e)),h.push(new xp(n.p.x+u,n.p.y+u,u,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${p.d}`)),p.p}function vp(e,t){return t.max-e.max}function xp(e,t,i,n){this.p=new r(e,t),this.h=i,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,el(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}const bp=Number.POSITIVE_INFINITY,wp=Math.sqrt(2);function Mp(e,t){return t[1]!==bp?function(e,t,i){let n=0,r=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}return[n,r]}(e,t[0],t[1]):function(e,t){let i=0,n=0;t<0&&(t=0);const r=t/wp;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":i=-r;break;case"top-left":case"bottom-left":i=r;break;case"left":i=t;break;case"right":i=-t}return[i,n]}(e,t[0])}function Tp(e,t,i,n,r,o,s,a,l,c){e.createArrays(),e.tilePixelRatio=ba/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const u=e.layers[0].layout,h=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Po(t),a),h["text-size"].possiblyEvaluate(new Po(i),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Po(t),a),h["icon-size"].possiblyEvaluate(new Po(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Po(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Po(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Po(18),a);const d="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),f=u.get("text-size");for(const o of e.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=f.evaluate(o,{},a),m=p.layoutTextSize.evaluate(o,{},a),g=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),_=o.text;let y,v=[0,0];if(_){const n=_.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Yu,c=u.get("text-line-height").evaluate(o,{},a)*Yu,p=ho(n)?s:0,f=u.get("text-anchor").evaluate(o,{},a),y=u.get("text-variable-anchor");if(!y){const e=u.get("text-radial-offset").evaluate(o,{},a);v=e?Mp(f,[e*Yu,bp]):u.get("text-offset").evaluate(o,{},a).map((e=>e*Yu))}let x=d?"center":u.get("text-justify").evaluate(o,{},a);const b=u.get("symbol-placement"),w="point"===b,M="point"===b?u.get("text-max-width").evaluate(o,{},a)*Yu:0,T=o=>{e.allowVerticalPlacement&&uo(n)&&(g.vertical=Fh(_,t,i,r,l,M,c,f,o,p,v,zh.vertical,!0,b,m,h))};if(!d&&y){const e="auto"===x?y.map((e=>Sp(e))):[x];let n=!1;for(let o=0;o=0||!uo(n)){const e=Fh(_,t,i,r,l,M,c,f,x,p,v,zh.horizontal,!1,b,m,h);e&&(g.horizontal[x]=e)}T("point"===b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const t=n[o.icon.name];t&&(y=Zh(r[o.icon.name],u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),x=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&P("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const b=Lp(g.horizontal)||g.vertical;e.iconsInText||(e.iconsInText=!!b&&b.iconsInText),(b||y)&&Ep(e,o,g,y,n,p,m,0,v,x,s,a,c)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Sp(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Ep(e,t,i,n,r,o,s,a,c,u,h,p,d){let f=o.textMaxSize.evaluate(t,{},p);void 0===f&&(f=s);const m=e.layers[0].layout,g=m.get("icon-offset").evaluate(t,{},p),_=Lp(i.horizontal)||i.vertical,y="globe"===d.name,v=s/24,x=e.tilePixelRatio*f/24,b=(L=e.overscaling,e.zoom>18&&L>2&&(L>>=1),Math.max(ba/(512*L),1)*m.get("symbol-spacing")),w=m.get("text-padding")*e.tilePixelRatio,M=m.get("icon-padding")*e.tilePixelRatio,T=l(m.get("text-max-angle")),S="map"===m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),E="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),A=m.get("symbol-placement"),C=b/2;var L;const I=m.get("icon-text-fit");let R;n&&"none"!==I&&(e.allowVerticalPlacement&&i.vertical&&(R=Xh(n,i.vertical,I,m.get("icon-text-fit-padding"),g,v)),_&&(n=Xh(n,_,I,m.get("icon-text-fit-padding"),g,v)));const k=(s,a,l)=>{if(a.x<0||a.x>=ba||a.y<0||a.y>=ba)return;let f=null;if(y){const{x:e,y:t,z:i}=d.projectTilePoint(a.x,a.y,l);f={anchor:new Yh(e,t,i,0,void 0),up:d.upVector(l,a.x,a.y)}}!function(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v,x,b,w,M,T){const S=e.addToLineVertexArray(t,n);let E,A,C,L,I,R,k,z=0,D=0,O=0,F=0,B=-1,N=-1;const U={};let j=Hs("");const V=i?i.anchor:t;let G=0,H=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,H]=l.layout.get("text-offset").evaluate(x,{},T).map((e=>e*Yu)):(G=l.layout.get("text-radial-offset").evaluate(x,{},T)*Yu,H=bp),e.allowVerticalPlacement&&r.vertical){const e=r.vertical;if(f)R=Pp(e),a&&(k=Pp(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},T)+90;C=Ip(c,V,t,u,h,p,e,d,i,m),a&&(L=Ip(c,V,t,u,h,p,a,_,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},T),r="none"!==l.layout.get("icon-text-fit"),s=up(o,n,w,r),d=a?up(a,n,w,r):void 0;A=Ip(c,V,t,u,h,p,o,_,n),z=4*s.length;const f=e.iconSizeData;let m=null;"source"===f.kind?(m=[Ju*l.layout.get("icon-size").evaluate(x,{},T)],m[0]>Ap&&P(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Ju*b.compositeIconSizes[0].evaluate(x,{},T),Ju*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Ap||m[1]>Ap)&&P(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,m,v,y,x,!1,i,t,S.lineStartIndex,S.lineLength,-1,M,T),B=e.icon.placedSymbolArray.length-1,d&&(D=4*d.length,e.addSymbols(e.icon,d,m,v,y,x,zh.vertical,i,t,S.lineStartIndex,S.lineLength,-1,M,T),N=e.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];E||(j=Hs(o.text),f?I=Pp(o):E=Ip(c,V,t,u,h,p,o,d,l.layout.get("text-rotate").evaluate(x,{},T),m));const a=1===o.positionedLines.length;if(O+=Cp(e,i,t,o,s,l,f,x,m,S,r.vertical?zh.horizontal:zh.horizontalOnly,a?Object.keys(r.horizontal):[n],U,B,b,M,T),a)break}r.vertical&&(F+=Cp(e,i,t,r.vertical,s,l,f,x,m,S,zh.vertical,["vertical"],U,N,b,M,T));let W=-1;const q=(e,t)=>e?Math.max(e,t):t;W=q(I,W),W=q(R,W),W=q(k,W);const $=W>-1?1:0;e.glyphOffsetArray.length>=Bd.MAX_GLYPHS&&P("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey),e.symbolInstances.emplaceBack(V.x,V.y,V.z,t.x,t.y,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,B,N,j,void 0!==E?E:e.collisionBoxArray.length,void 0!==E?E+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==A?A:e.collisionBoxArray.length,void 0!==A?A+1:e.collisionBoxArray.length,L||e.collisionBoxArray.length,L?L+1:e.collisionBoxArray.length,u,O,F,z,D,$,0,G,H,W)}(e,a,f,s,i,n,r,R,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,w,S,c,0,M,E,g,t,o,u,h,p)};if("line"===A)for(const r of rp(t.geometry,0,0,ba,ba)){const t=ip(r,b,T,i.vertical||_,n,24,x,e.overscaling,ba);for(const i of t){_&&Rp(e,_.text,C,i)||k(r,i,p)}}else if("line-center"===A){for(const e of t.geometry)if(e.length>1){const t=tp(e,T,i.vertical||_,n,24,x);t&&k(e,t,p)}}else if("Polygon"===t.type)for(const e of qc(t.geometry,0)){const t=yp(e,16);k(e[0],new Yh(t.x,t.y,0,0,void 0),p)}else if("LineString"===t.type)for(const e of t.geometry)k(e,new Yh(e[0].x,e[0].y,0,0,void 0),p);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)k([t],new Yh(t.x,t.y,0,0,void 0),p)}const Ap=32640;function Cp(e,t,i,n,o,s,a,l,c,u,h,p,d,f,m,g,_){const y=function(e,t,i,n,o,s,a,l){const c=[];if(0===t.positionedLines.length)return c;const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,h=function(e){const t=e[0],i=e[1],n=t*i;return n>0?[t,-i]:n<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let p=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)p-=e.lineOffset;const d=t.positionedLines.length,f=p/d;let m=t.top-i[1];for(let e=0;eAp&&P(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Ju*m.compositeTextSizes[0].evaluate(l,{},_),Ju*m.compositeTextSizes[1].evaluate(l,{},_)],(x[0]>Ap||x[1]>Ap)&&P(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,y,x,c,a,l,h,t,i,u.lineStartIndex,u.lineLength,f,g,_);for(const t of p)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function Lp(e){for(const t in e)return e[t];return null}function Ip(e,t,i,n,o,s,a,c,u,h){let p=a.top,d=a.bottom,f=a.left,m=a.right;const g=a.collisionPadding;if(g&&(f-=g[0],p-=g[1],m+=g[2],d+=g[3]),u){const e=new r(f,p),t=new r(m,p),i=new r(f,d),n=new r(m,d),o=l(u);let s=new r(0,0);h&&(s=new r(h[0],h[1])),e._rotateAround(o,s),t._rotateAround(o,s),i._rotateAround(o,s),n._rotateAround(o,s),f=Math.min(e.x,t.x,i.x,n.x),m=Math.max(e.x,t.x,i.x,n.x),p=Math.min(e.y,t.y,i.y,n.y),d=Math.max(e.y,t.y,i.y,n.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,f,p,m,d,c,n,o,s),e.length-1}function Pp(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Rp(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])1?null:function(e,t,i,n){const r=Math.sin(i);return e*(Math.sin((1-n)*i)/r)+t*(Math.sin(n*i)/r)}(e.a[t],e.b[t],e.angle,f(i,0,1))+e.center[t]}function qp(e){if(e.z<=1)return Vp[e.z+2*e.y+e.x];const[t,i]=Zp(e),n=[Yp(t[0],t[1]),Yp(t[0],i[1]),Yp(i[0],t[1]),Yp(i[0],i[1])],r=[jp,jp,jp],o=[Up,Up,Up];for(const e of n)r[0]=Math.min(r[0],e[0]),r[1]=Math.min(r[1],e[1]),r[2]=Math.min(r[2],e[2]),o[0]=Math.max(o[0],e[0]),o[1]=Math.max(o[1],e[1]),o[2]=Math.max(o[2],e[2]);return new Jl(r,o)}function $p(e,t,i){const n=t/e.worldSize,r=Number.MAX_VALUE,o=[-r,-r,-r],s=[r,r,r],a=fl(new Float64Array(16));if(_l(a,a,[n,n,n]),ml(a,a,e.globeMatrix),i.z<=1){const e=qp(i).getCorners();for(let t=0;t.5?M-=1:M<-.5&&(M+=1),Math.abs(M)>Math.abs(T))w=M>=0?1:3,b=d;else{w=T>=0?0:2;const e=[a[4],a[5],a[6]];let t;t=T>=0?-Math.sin(l(h.getSouth()))*Fp:-Math.sin(l(h.getNorth()))*Fp,b=Rl(b,d,e,t)}const S=p[w],E=p[(w+1)%4],A=new Hp(S,E,b),C=[Wp(A,0)||S[0],Wp(A,1)||S[1],Wp(A,2)||S[2]];return s[2]=Math.min(S[2],E[2]),Ll(s,s,C),Il(o,o,C),new Jl(s,o)}function Zp(e){const t=1<v&&(x(e,c,n,r,a,l),x(c,i,a,l,o,s))}x(h,p,n,o,r,o),x(p,d,r,o,r,s),x(d,f,r,s,n,s),x(f,h,n,s,n,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:t}}const cd=fl(new Float32Array(16));class ud{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new Ta(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return La(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return ad(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const o=e.horizonLineFromTop(!1),s=new r(t,Math.max(o,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(s,n))}pointCoordinate3D(e,t,i){const n=new r(t,i);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y0?t<-vd+i&&(t=-vd+i):t>vd-i&&(t=vd-i);const o=r/Math.pow(xd(t),n),s=o*Math.sin(n*e),a=r-o*Math.cos(n*e);return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+.5),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,t=(2*(1-t)-.5)*Math.PI;const{n:i,f:n}=this,r=n-t,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(e*e+r*r);let a=Math.atan2(e,Math.abs(r))*o;r*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=f(c(a/i)+this.center[0],-180,180),u=f(c(2*Math.atan(Math.pow(n/s,1/i))-vd),-85.051129,ka);return new Ta(l,u)}}class wd extends ud{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:Aa(e),y:Ca(t),z:0}}unproject(e,t){const i=Ia(e),n=Pa(t);return new Ta(i,n)}}const Md=l(ka);class Td extends ud{project(e,t){const i=(t=l(t))*t,n=i*i;return{x:.5*((e=l(e))*(.8707-.131979*i+n*(n*(.003971*i-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+n*(.028874*i-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=25,r=0,o=i*i;do{o=i*i;const e=o*o;r=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=f(i-r,-Md,Md)}while(Math.abs(r)>1e-6&&--n>0);o=i*i;const s=f(c(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=c(i);return new Ta(s,a)}}const Sd=l(ka);class Ed extends ud{project(e,t){t=l(t),e=l(e);const i=Math.cos(t),n=2/Math.PI,r=Math.acos(i*Math.cos(e/2)),o=Math.sin(r)/r,s=.5*(e*n+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,n=t=(2*(1-t)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,u=r*r,h=Math.cos(i/2),p=Math.sin(i/2),d=2*h*p,m=p*p,g=1-u*h*h,_=g?1/g:0,y=g?Math.acos(r*h)*Math.sqrt(1/g):0,v=.5*(2*y*r*p+2*i/Math.PI)-e,x=.5*(y*o+n)-t,b=.5*_*(u*m+y*r*h*c)+1/Math.PI,w=_*(d*l/4-y*o*p),M=.125*_*(l*p-y*o*u*d),T=.5*_*(c*h+y*m*r)+.5,S=w*M-T*b;s=(x*w-v*T)/S,a=(v*M-x*b)/S,i=f(i-s,-Math.PI,Math.PI),n=f(n-a,-Sd,Sd)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new Ta(c(i),c(n))}}class Ad extends ud{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(l(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:i,cosPhi:n}=this;return{x:l(e)*n*i+.5,y:-Math.sin(l(t))/n*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:n}=this,r=-(t-.5)/i,o=f(c((e-.5)/i)/n,-180,180),s=Math.asin(f(r*n,-1,1)),a=f(c(s),-85.051129,ka);return new Ta(o,a)}}class Cd extends wd{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(e,t,i){const n=Math.pow(2,i.z),r=(e/ba+i.x)/n,o=Yp(Pa((t/ba+i.y)/n),Ia(r));return Ol(o,o,Kp(qp(i))),{x:o[0],y:o[1],z:o[2]}}locationPoint(e,t){const i=Yp(t.lat,t.lng),n=kl([],i),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;Rl(i,i,n,La(1,0)*ba*o);const s=fl(new Float64Array(16));return ml(s,e.pixelMatrix,e.globeMatrix),Ol(i,i,s),new r(i[0],i[1])}pixelsPerMeter(e,t){return La(1,0)*t}pixelSpaceConversion(e,t,i){const n=_i(La(1,45)*t,La(1,e)*t,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(e,t,i){const n=ed(qp(i.canonical));return ml(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:i}=e,n=fl(new Float64Array(16));return ml(n,n,Kp(qp(t))),vl(n,n,l(i.lng)),yl(n,n,l(i.lat)),_l(n,n,[e._projectionScaler,e._projectionScaler,1]),Float32Array.from(n)}pointCoordinate(e,t,i,n){return Gp(e,t,i,!0)||new za(0,0)}pointCoordinate3D(e,t,i){const n=this.pointCoordinate(e,t,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(e,t){return!Gp(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,n=e._centerAltitude*t,r=e._camera,o=e._camera.forward(),s=El([],Pl([],o,-i),[0,0,n]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=Pl([],r.up(),u),p=Pl([],r.right(),u*c),d=kl([],El([],El([],o,h),p)),f=[];let m;if(new Zl(s,d).closestPointOnSphere(l,a,f)){const t=El([],f,l),i=Nl([],t,s);m=Math.cos(e.fovAboveCenter)*Tl(i)}else{const e=Nl([],s,l),t=Nl([],l,s);kl(t,t);const i=Tl(e)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(zl(o,t));m*=Math.cos(n)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=id(e.zoom);if(i>0){const n=ad(e,La(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return _i(t,n+r*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){const n=1<0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Hu.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(e))}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())}}Pr(Od,"SymbolBuffers");class Fd{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new xa,this.collisionVertexArray=new ps,this.collisionVertexArrayExt=new ds}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,qu.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,$u.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Pr(Fd,"CollisionBuffers");class Bd{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=fl([]),this.placementViewportMatrix=fl([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Qu(this.zoom,t["text-size"]),this.iconSizeData=Qu(this.zoom,t["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((e=>zh[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Od(new ua(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Od(new ua(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Rs,this.lineVertexArray=new ks,this.symbolInstances=new Ps}calculateGlyphDependencies(e,t,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=o.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=t.iconDependencies,f=t.glyphDependencies,m=t.availableImages,g=new Po(this.zoom);for(const{feature:t,id:l,index:c,sourceLayerIndex:_}of e){const e=r._featureFilter.needGeometry,y=Ga(t,e);if(!r._featureFilter.filter(g,y,i))continue;if(e||(y.geometry=Va(t,i,n)),s&&1!==t.type&&i.z<=5){const e=y.geometry,t=1<e),((e,i)=>zl(Yp(Pa((e.y/ba+r)/t),Ia((e.x/ba+n)/t),1),Yp(Pa((i.y/ba+r)/t),Ia((i.x/ba+n)/t),1))=0;for(const i of v.sections)if(i.image)d[i.image.name]=!0;else{const n=uo(v.toString()),r=i.fontStack||e,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,i,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,i,n),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,i,n))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Ld(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length,n=e.segment;if(void 0!==n){let i=e.dist(t[n+1]),r=e.dist(t[n]);const o={};for(let e=n+1;e=0;e--)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:r},e>0&&(r+=t[e-1].dist(t[e]));for(let e=0;e=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),o=Ku(this.textSizeData,e,r)/Yu;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const n=this.icon.placedSymbolArray.get(i),r=Ku(this.iconSizeData,e,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(e,t,i){e.emplaceBack(t,-i,-i),e.emplaceBack(t,i,-i),e.emplaceBack(t,i,i),e.emplaceBack(t,-i,i)}_updateTextDebugCollisionBoxes(e,t,i,n,r,o){for(let s=n;s0}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(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tn[e]-n[t]||r[t]-r[e])),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach(((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)})),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Pr(Bd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Bd.MAX_GLYPHS=65535,Bd.addDynamicAttributes=zd;const Nd=new Wo({"symbol-placement":new Uo(He.layout_symbol["symbol-placement"]),"symbol-spacing":new Uo(He.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Uo(He.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo(He.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Uo(He.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Uo(He.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Uo(He.layout_symbol["icon-ignore-placement"]),"icon-optional":new Uo(He.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Uo(He.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo(He.layout_symbol["icon-size"]),"icon-text-fit":new Uo(He.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Uo(He.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo(He.layout_symbol["icon-image"]),"icon-rotate":new jo(He.layout_symbol["icon-rotate"]),"icon-padding":new Uo(He.layout_symbol["icon-padding"]),"icon-keep-upright":new Uo(He.layout_symbol["icon-keep-upright"]),"icon-offset":new jo(He.layout_symbol["icon-offset"]),"icon-anchor":new jo(He.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Uo(He.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Uo(He.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Uo(He.layout_symbol["text-rotation-alignment"]),"text-field":new jo(He.layout_symbol["text-field"]),"text-font":new jo(He.layout_symbol["text-font"]),"text-size":new jo(He.layout_symbol["text-size"]),"text-max-width":new jo(He.layout_symbol["text-max-width"]),"text-line-height":new jo(He.layout_symbol["text-line-height"]),"text-letter-spacing":new jo(He.layout_symbol["text-letter-spacing"]),"text-justify":new jo(He.layout_symbol["text-justify"]),"text-radial-offset":new jo(He.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Uo(He.layout_symbol["text-variable-anchor"]),"text-anchor":new jo(He.layout_symbol["text-anchor"]),"text-max-angle":new Uo(He.layout_symbol["text-max-angle"]),"text-writing-mode":new Uo(He.layout_symbol["text-writing-mode"]),"text-rotate":new jo(He.layout_symbol["text-rotate"]),"text-padding":new Uo(He.layout_symbol["text-padding"]),"text-keep-upright":new Uo(He.layout_symbol["text-keep-upright"]),"text-transform":new jo(He.layout_symbol["text-transform"]),"text-offset":new jo(He.layout_symbol["text-offset"]),"text-allow-overlap":new Uo(He.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Uo(He.layout_symbol["text-ignore-placement"]),"text-optional":new Uo(He.layout_symbol["text-optional"])});var Ud={paint:new Wo({"icon-opacity":new jo(He.paint_symbol["icon-opacity"]),"icon-color":new jo(He.paint_symbol["icon-color"]),"icon-halo-color":new jo(He.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo(He.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo(He.paint_symbol["icon-halo-blur"]),"icon-translate":new Uo(He.paint_symbol["icon-translate"]),"icon-translate-anchor":new Uo(He.paint_symbol["icon-translate-anchor"]),"text-opacity":new jo(He.paint_symbol["text-opacity"]),"text-color":new jo(He.paint_symbol["text-color"],{runtimeType:it,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new jo(He.paint_symbol["text-halo-color"]),"text-halo-width":new jo(He.paint_symbol["text-halo-width"]),"text-halo-blur":new jo(He.paint_symbol["text-halo-blur"]),"text-translate":new Uo(He.paint_symbol["text-translate"]),"text-translate-anchor":new Uo(He.paint_symbol["text-translate-anchor"])}),layout:Nd};class jd{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Qe,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Pr(jd,"FormatSectionOverride",{omit:["defaultValue"]});class Vd extends _a{constructor(e){super(e,Ud)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||zn(o.value)||!r?r:function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))}(t.properties,r)}createBucket(e){return new Bd(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Ud.paint.overridableProperties){if(!Vd.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new jd(t),n=new kn(i,t.property.specification);let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new On("source",n):new Fn("composite",n,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Bo(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Vd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=Ud.paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof xt)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof At&&Tt(t.value)===st?o(t.value.sections):t instanceof Rt?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}getProgramConfiguration(e){return new ca(this,e)}}var Gd={paint:new Wo({"background-color":new Uo(He.paint_background["background-color"]),"background-pattern":new Go(He.paint_background["background-pattern"]),"background-opacity":new Uo(He.paint_background["background-opacity"])})},Hd={paint:new Wo({"raster-opacity":new Uo(He.paint_raster["raster-opacity"]),"raster-hue-rotate":new Uo(He.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Uo(He.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Uo(He.paint_raster["raster-brightness-max"]),"raster-saturation":new Uo(He.paint_raster["raster-saturation"]),"raster-contrast":new Uo(He.paint_raster["raster-contrast"]),"raster-resampling":new Uo(He.paint_raster["raster-resampling"]),"raster-fade-duration":new Uo(He.paint_raster["raster-fade-duration"])})};class Wd extends _a{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var qd={paint:new Wo({"sky-type":new Uo(He.paint_sky["sky-type"]),"sky-atmosphere-sun":new Uo(He.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Uo(He.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Uo(He.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Uo(He.paint_sky["sky-gradient-radius"]),"sky-gradient":new Ho(He.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Uo(He.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Uo(He.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Uo(He.paint_sky["sky-opacity"])})};function $d(e,t,i){const n=[0,0,1],r=Wl([]);return $l(r,r,i?-l(e)+Math.PI:l(e)),ql(r,r,-l(t)),Fl(n,n,r),kl(n,n)}const Zd={circle:class extends _a{constructor(e){super(e,ul)}createBucket(e){return new qa(e)}queryRadius(e){const t=e;return ol("circle-radius",this,t)+ol("circle-stroke-width",this,t)+sl(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,n,r,o,s,a){const l=ll(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return Ql(e,n,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new ca(this,e)}},heatmap:class extends _a{createBucket(e){return new nc(e)}constructor(e){super(e,cc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=uc({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(e){return ol("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,n,o,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(t,i);return Ql(e,n,s,a,l,!0,!0,new r(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new ca(this,e)}},hillshade:class extends _a{constructor(e){super(e,hc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends _a{constructor(e){super(e,Qc)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(e){return new ca(this,e)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Yc(e)}queryRadius(){return sl(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,n,r,o){return!e.queryGeometry.isAboveHorizon&&Xa(al(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),n)}isTileClipped(){return!0}},"fill-extrusion":class extends _a{constructor(e){super(e,wu)}createBucket(e){return new yu(e)}queryRadius(){return sl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new ca(this,e)}queryIntersectsFeature(e,t,i,n,o,s,a,l,c){const u=ll(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,i),p=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1,g=e.tile.getBucket(this);if(f&&g instanceof yu){const e=g.centroidVertexArray,t=c+1;if(te.polygon)).flat());const _=function(e,t,i,n,o,s,a,l,c,u,h){return"globe"===e.projection.name?function(e,t,i,n,r,o,s,a,l,c,u){const h=[],p=[],d=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],g=(e,t,i,n)=>{e[0]=t,e[1]=i,e[2]=n,e[3]=1},_=xu();i>0&&(i+=_),n+=_;for(const _ of t){const t=[],y=[];for(const h of _){const p=h.x+r.x,_=h.y+r.y,v=e.projection.projectTilePoint(p,_,u),x=e.projection.upVector(u,h.x,h.y);let b=i,w=n;if(s){const e=Pu(p,_,i,n,s,a,l,c);b+=e.base,w+=e.top}0!==i?g(f,v.x+x[0]*d*b,v.y+x[1]*d*b,v.z+x[2]*d*b):g(f,v.x,v.y,v.z),g(m,v.x+x[0]*d*w,v.y+x[1]*d*w,v.z+x[2]*d*w),Ol(f,f,o),Ol(m,m,o),t.push(Iu(f)),y.push(Iu(m))}h.push(t),p.push(y)}return[h,p]}(e,t,i,n,o,s,a,l,c,u,h):a?function(e,t,i,n,r,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],d=[];for(const c of p){const u=c.x+n.x,p=c.y+n.y,f=Pu(u,p,t,i,o,s,a,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,Gl(h,h,r),h[3]=Math.max(h[3],1e-5);const m=Iu([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,Gl(h,h,r),h[3]=Math.max(h[3],1e-5);const g=Iu([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);e.push(m),d.push(g)}c.push(e),u.push(d)}return[c,u]}(t,i,n,o,s,a,l,c,u):function(e,t,i,n,o){const s=[],a=[],l=o[8]*t,c=o[9]*t,u=o[10]*t,h=o[11]*t,p=o[8]*i,d=o[9]*i,f=o[10]*i,m=o[11]*i;for(const t of e){const e=[],i=[];for(const s of t){const t=s.x+n.x,a=s.y+n.y,g=o[0]*t+o[4]*a+o[12],_=o[1]*t+o[5]*a+o[13],y=o[2]*t+o[6]*a+o[14],v=o[3]*t+o[7]*a+o[15],x=g+l,b=_+c,w=y+u,M=Math.max(v+h,1e-5),T=g+p,S=_+d,E=y+f,A=Math.max(v+m,1e-5),C=new r(x/M,b/M);C.z=w/M,e.push(C);const L=new r(T/A,S/A);L.z=E/A,i.push(L)}s.push(e),a.push(i)}return[s,a]}(t,i,n,o,s)}(s,n,p,h,u,a,f?l:null,d,m,s.center.lat,e.tileID.canonical),y=e.queryGeometry;return function(e,t,i){let n=1/0;Xa(i,t)&&(n=Lu(i,t[0]));for(let r=0;r=3)for(let t=0;t1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const p=t/i*(n+1);if(s.isDash){const e=n-Math.abs(p);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+p*p);this.image.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const i=e[0],n=e[e.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i1&&(s=e[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const n="round"===t,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return P("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;t{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 Qd{constructor(){this.tasks={},this.taskQueue=[],S(["process"],this),this.invoker=new Jd(this.process),this.nextId=0}add(e,t){const i=this.nextId++,n=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===n){z();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:t,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){z();try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i>=1)>1;){const e=i+r>>1,l=n+o>>1;1&t?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=e,a=l}const l=4*e;of[l+0]=i,of[l+1]=n,of[l+2]=r,of[l+3]=o}const sf=new Uint16Array(2178),af=new Uint8Array(1089),lf=new Uint16Array(1089);function cf(e){return 0===e?-.03125:32===e?.03125:0}var uf=Yo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const hf={type:2,extent:ba,loadGeometry:()=>[[new r(0,0),new r(8193,0),new r(8193,8193),new r(0,8193),new r(0,0)]]};class pf{constructor(e,t,i,n,r){this.tileID=e,this.uid=b(),this.uses=0,this.tileSize=t,this.tileZoom=i,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",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;t<$.now()||this.fadeEndTime&&tt.getLayer(e))).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=n}}return i}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Bd){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Bd&&t.hasRTLText){this.hasRTLText=!0,Io.isLoading()||Io.isLoaded()||"deferred"!==Co()||Lo();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(i))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new As}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.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._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=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(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Xd(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Xd(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Xd(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,n,r,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:n,pixelPosMatrix:s,transform:o,params:r,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const n=i.loadVTLayers(),r=t?t.sourceLayer:"",o=n._geojsonTileLayer||n[r];if(!o)return;const s=Yn(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let t=0;te)i=!1;else if(t)if(this.expirationTime=0;e--){const t=4*e,i=of[t+0],n=of[t+1],r=of[t+2],o=of[t+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,u=n*rf+i,h=o*rf+r,p=a*rf+s,d=Math.hypot((sf[2*u+0]+sf[2*h+0])/2-sf[2*p+0],(sf[2*u+1]+sf[2*h+1])/2-sf[2*p+1])>=16;if(af[p]=af[p]||(d?1:0),e<1022){const e=(n+c>>1)*rf+(i+l>>1),t=(o+c>>1)*rf+(r+l>>1);af[p]=af[p]||af[e]||af[t]}}const r=new es,o=new fs;let s=0;function a(e,t){const i=t*rf+e;return 0===lf[i]&&(r.emplaceBack(sf[2*i+0],sf[2*i+1],e*ba/nf,t*ba/nf),lf[i]=++s),lf[i]-1}function l(e,t,i,n,r,s){const c=e+i>>1,u=t+n>>1;if(Math.abs(e-r)+Math.abs(t-s)>1&&af[u*rf+c])l(r,s,e,t,c,u),l(i,n,r,s,c,u);else{const l=a(e,t),c=a(i,n),u=a(r,s);o.emplaceBack(l,c,u)}}return l(0,0,nf,nf,nf,0),l(nf,nf,0,0,0,nf),{vertices:r,indices:o}}(this.tileID.canonical,t);n=e.vertices,r=e.indices}else{n=new es,r=new fs;for(const{x:e,y:t}of i)n.emplaceBack(e,t,0,0);const e=fc(n.int16,void 0,4);for(let t=0;t{const u=(a-e)/(c-1),h=(l-s)/(c-1),p=n.length;for(let a=0;as*e+t;for(let e=0;et[s])return null}else{const a=1/n[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>r&&(r=l),co)return null}return r}function gf(e,t,i,n,r,o,s,a,l,c,u){const h=n-e,p=r-t,d=o-i,f=s-e,m=a-t,g=l-i,_=u[1]*g-u[2]*m,y=u[2]*f-u[0]*g,v=u[0]*m-u[1]*f,x=h*_+p*y+d*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=c[0]-e,M=c[1]-t,T=c[2]-i,S=(w*_+M*y+T*v)*b;if(S<0||S>1)return null;const E=M*d-T*p,A=T*h-w*d,C=w*p-M*h,L=(u[0]*E+u[1]*A+u[2]*C)*b;return L<0||S+L>1?null:(f*E+m*A+g*C)*b}function _f(e,t,i){return(e-t)/(i-t)}function yf(e,t,i,n,r,o,s,a,l){const c=1<{const o=n?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;r[0]=e*i,r[1]=a,r[2]=s,r[3]=l};let s=new ff(n);const a=[];for(let t=0;t=1;n/=2){const e=i[i.length-1];s=new ff(n);for(let t=0;t0;){const{idx:a,t:d,nodex:f,nodey:m,depth:g}=p.pop();if(this.leaves[a]){yf(f,m,g,e,t,i,n,u,h);const a=1<=e[2])return d}continue}let _=0;for(let p=0;p=l[c[i]]&&(c.splice(i,0,p),t=!0);t||(c[_]=p),_++}}for(let e=0;e<_;e++){const t=c[e];p.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:g+1})}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,n,r){if(1===e[n].isLeaf(t,i))return;this.childOffsets[r]||(this.childOffsets[r]=this.nodeCount);const o=n-1,s=e[o];let a=0,l=0;for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}_unpackMapbox(e,t,i){return(256*e*256+256*t+i)/10-1e4}_unpackTerrarium(e,t,i){return 256*e+t+i/256-32768}static pack(e,t){const i=[0,0,0,0],n=Mf.getUnpackVector(t);let r=Math.floor((e+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new lc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t{this.remove(e,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}}class Sf{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}Sf.ReadOnly=!1,Sf.ReadWrite=!0,Sf.disabled=new Sf(519,Sf.ReadOnly,[0,1]);const Ef=7680;class Af{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Af.disabled=new Af({func:519,mask:0},0,0,Ef,Ef,Ef);class Cf{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}Cf.Replace=[1,0],Cf.disabled=new Cf(Cf.Replace,_t.transparent,[!1,!1,!1,!1]),Cf.unblended=new Cf(Cf.Replace,_t.transparent,[!0,!0,!0,!0]),Cf.alphaBlended=new Cf([1,771],_t.transparent,[!0,!0,!0,!0]);const Lf=1029,If=2305;class Pf{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Pf.disabled=new Pf(!1,Lf,If),Pf.backCCW=new Pf(!0,Lf,If),Pf.backCW=new Pf(!0,Lf,2304),Pf.frontCW=new Pf(!0,1028,2304),Pf.frontCCW=new Pf(!0,1028,If);class Rf extends Ge{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new Tf(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new df,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const t in this._tiles){const i=this._tiles[t];this._source.prepareTile(i)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,i.tileID),i.upload(e),i.prepare(this.map.style.imageManager)}else for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager)}}getIds(){return y(this._tiles).map((e=>e.tileID)).sort(kf).map((e=>e.key))}getRenderableIds(e){const t=[];for(const i in this._tiles)this._isIdRenderable(+i,e)&&t.push(this._tiles[i]);return e?t.sort(((e,t)=>{const i=e.tileID,n=t.tileID,o=new r(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new r(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):t.map((e=>e.tileID)).sort(kf).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(e,t,i,n){if(n)if(e.state="errored",404!==n.status)this._source.fire(new Ve(n,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=$.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new je("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){n[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),n=this._getLoadedTile(t);if(n)return n}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,n=Math.ceil(e.height/t)+1,r=Math.floor(i*n*5),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(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,i){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let n;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new Eu(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(n=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(n=n.filter((e=>this._source.hasTile(e))))):n=[];const r=this._updateRetainedTiles(n);if(zf(this._source.type)&&0!==n.length){const e={},t={},i=Object.keys(r);for(const n of i){const i=r[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=$.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Rf.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),e[s.tileID.key]=s.tileID),t[n]=i}const o=n[n.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(r[e]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>o;){n=n.scaledTo(n.overscaledZ-1);const o=this._tiles[n.key];if(o&&o.hasData()&&t[n.key]){r[e]=i.tileID;break}}}for(const t in e)r[t]||(this._coveredTiles[t]=!0,r[t]=e[t])}for(const e in r)this._tiles[e].clearFadeHold();const o=function(e,t){const i=[];for(const n in e)n in t||i.push(n);return i}(this._tiles,r);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},n=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),r=e[0].overscaledZ,o=Math.max(r-Rf.maxOverzooming,this._source.minzoom),s=Math.max(r+Rf.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||n=this._source.maxzoom){const e=n.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=n.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&r&&(e=this._addTile(o)),e&&(t[o.key]=o,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,n=this._tiles[e].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}t.push(n.key);const e=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;n=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(e){let t=this._tiles[e.key];if(t)return this._source.prepareTile&&this._source.prepareTile(t),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null;t=new pf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._source.prepareTile&&this._source.prepareTile(t)||this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new je("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),i))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Aa(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(f(s,...Df(e,-1))-s),Math.abs(f(s,...Df(e,1))-s)];c=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(f(s,...Df(e,-1))-s),Math.abs(f(s,...Df(e,0))-s),Math.abs(f(s,...Df(e,1))-s)];c=[t.indexOf(Math.min(...t))-1]}}else c=[0];for(const i of c){const o=e.containsTile(l,r,t,i);o&&n.push(o)}}return n}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(zf(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=$.now())return!0}return!1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i)}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const n=this._tiles[e];n&&n.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)))}_preloadTiles(e,t){const i=new Map,n=Array.isArray(e)?e:[e],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const e of n){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}_(Array.from(i.values()),((e,t)=>{const i=new pf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)}))}),t)}}function kf(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function zf(e){return"raster"===e||"image"===e||"video"===e}function Df(e,t){const i=1<=0&&n[3]>=0&&a.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new hu.VectorTile(new lh(this.rawTileData)).layers,this.sourceLayerCoder=new Kd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,i,n){this.loadVTLayers();const r=e.params||{},o=Yn(r.filter),s=e.tileResult,a=e.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,i,n)=>nl(s.bufferedTilespaceGeometry,e,t,i,n)));c.sort(Nf);let u=null;a.elevation&&c.length>0&&(u=Of.create(a.elevation,this.tileID));const h={};let p;for(let a=0;a(f||(f=Va(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(s,t,n,f,this.z,e.transform,e.pixelPosMatrix,u,r))))}return h}loadMatchingFeature(e,t,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=t,d=this.bucketLayerIDs[u];if(n&&!function(e,t){for(let i=0;i=0)return!0;return!1}(n,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=Ga(m,!0);if(!i.filter(new Po(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new Po(this.tileID.overscaledZ),m))return;const g=this.getId(m,f);for(let t=0;t{const s=t instanceof No?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Nf(e,t){return t-e}Pr(Ff,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Uf{constructor(e){const t={},i=[];for(const n in e){const r=e[n],o=t[n]={};for(const e in r.glyphs){const t=r.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const n=t.metrics.localGlyph?2:1,s={x:0,y:0,w:t.bitmap.width+2*n,h:t.bitmap.height+2*n};i.push(s),o[e]=s}}const{w:n,h:r}=Ph(i),o=new ac({width:n||1,height:r||1});for(const i in e){const n=e[i];for(const e in n.glyphs){const r=n.glyphs[+e];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const s=t[i][e],a=r.metrics.localGlyph?2:1;ac.copy(r.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},r.bitmap)}}this.image=o,this.positions=t}}Pr(Uf,"GlyphAtlas");class jf{constructor(e){this.tileID=new Eu(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.enableTerrain=!!e.enableTerrain,this.isSymbolTile=e.isSymbolTile,this.tileTransform=ld(e.tileID.canonical,e.projection),this.projection=e.projection}parse(e,t,i,n,r){this.status="parsing",this.data=e,this.collisionBoxArray=new As;const o=new Kd(Object.keys(e.layers).sort()),s=new Ff(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new Yd(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},u=t.familiesBySource[this.source];for(const t in u){const n=e.layers[t];if(!n)continue;let r=!1,l=!1;for(const e of u[t])"symbol"===e[0].type?r=!0:l=!0;if(!0===this.isSymbolTile&&!r)continue;if(!1===this.isSymbolTile&&!l)continue;1===n.version&&P(`Vector tile source "${this.source}" layer "${t}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=o.encode(t),p=[];for(let e=0;e=t.maxzoom||"none"!==t.visibility&&(Vf(e,this.zoom,i),(a[t.id]=t.createBucket({index:s.bucketLayerIDs.length,layers:e,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:i})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(e.map((e=>e.id))))}}let h,p,d,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},g=A(c.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(g).length?n.send("getGlyphs",{uid:this.uid,stacks:g},((e,t)=>{h||(h=e,p=t,x.call(this))}),void 0,!1,m):p={};const _=Object.keys(c.iconDependencies);_.length?n.send("getImages",{icons:_,source:this.source,tileID:this.tileID,type:"icons"},((e,t)=>{h||(h=e,d=t,x.call(this))}),void 0,!1,m):d={};const v=Object.keys(c.patternDependencies);function x(){if(h)return r(h);if(p&&d&&f){const e=new Uf(p),t=new kh(d,f);for(const n in a){const r=a[n];r instanceof Bd?(Vf(r.layers,this.zoom,i),Tp(r,p,e.positions,d,t.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection)):r.hasPattern&&(r instanceof Bu||r instanceof Yc||r instanceof yu)&&(Vf(r.layers,this.zoom,i),r.addFeatures(c,this.tileID.canonical,t.patternPositions,i,this.tileTransform))}this.status="done",r(null,{buckets:y(a).filter((e=>!e.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?e.positions:null})}}v.length?n.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"patterns"},((e,t)=>{h||(h=e,f=t,x.call(this))}),void 0,!1,m):f={},x.call(this)}}function Vf(e,t,i){const n=new Po(t);for(const t of e)t.recalculate(n,i)}class Gf{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,n){const r=this.entries[e]=this.entries[e]||{callbacks:[]};if(r.result){const[e,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(e,i)}),t):n(e,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const e of r.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,n)}),t):e(i,n);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((e=>e!==n)),r.callbacks.length||(r.cancel(),delete this.entries[e]))}}}function Hf(e,t,i){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const n=Pe(e.request,((e,n,r,o)=>{e?t(e):n&&t(null,{vectorTile:i?void 0:new hu.VectorTile(new lh(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),t()}}),t)}e.ARRAY_TYPE=pl,e.AUTH_ERR_MSG=ne,e.Aabb=Jl,e.Actor=class{constructor(e,i,n){this.target=e,this.parent=i,this.mapId=n,this.callbacks={},this.cancelCallbacks={},S(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=z()?e:t,this.scheduler=new Qd}send(e,t,i,n,r=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=F(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:e,hasCallback:!!i,targetMapId:n,mustQueue:r,sourceMapId:this.mapId,data:zr(t,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||z()){const e=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"})}else this.processTask(i,t)}processTask(e,t){if(""===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(Dr(t.error)):i(null,Dr(t.data)))}else{const i=F(this.globalScope)?void 0:[],n=t.hasCallback?(t,n)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?zr(t):null,data:zr(n,i)},i)}:e=>{},r=Dr(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,r,n);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],r.source)[e[1]](r,n)}else n(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=Tu,e.Color=_t,e.ColorMode=Cf,e.CullFaceMode=Pf,e.DEMData=Mf,e.DataConstantProperty=Uo,e.DedupedRequest=Gf,e.DepthMode=Sf,e.EXTENT=ba,e.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,n=1<1)return t;const r=n.getSource().maxzoom,o=1<{const o=this.getAtTileOffset(e,r.x,r.y),s=n.upVector(e.canonical,r.x,r.y);return Pl(s,s,o*n.upVectorScale(e.canonical,t,i).metersToTile),s}}getForTilePoints(e,t,i,n){const r=Of.create(this,e,n);return!!r&&(t.forEach((e=>{e[2]=this.exaggeration()*r.getElevationAt(e[0],e[1],i)})),!0)}getMinMaxForTile(e){const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,n=t.tileID,r=1<this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!re(e))return e;const i=ae(e);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!re(e))return e;const i=ae(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,n){if(!re(e))return e;const r=ae(e);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,n){const r=ae(e);return re(e)?(r.path=`/styles/v1${r.path}/sprite${t}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${t}${i}`,le(r))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!re(e))return e;const n=ae(e);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==n.authority&&512===i?"@2x":""}${Y.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${X.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${X.TILE_URL_VERSION}${n.path}`);const r=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(n.params)||X.ACCESS_TOKEN;return X.REQUIRE_ACCESS_TOKEN&&r&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,r)}canonicalizeTileURL(e,t){const i=ae(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${X.RASTER_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${X.TILE_URL_VERSION}/`,"")}`;let r=i.params;return t&&(r=r.filter((e=>!e.match(/^access_token=/)))),r.length&&(n+=`?${r.join("&")}`),n}canonicalizeTileset(e,t){const i=!!t&&re(t),n=[];for(const t of e.tiles||[])oe(t)?n.push(this.canonicalizeTileURL(t,i)):n.push(t);return n}_makeAPIURL(e,t){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",n=ae(X.API_URL);if(e.protocol=n.protocol,e.authority=n.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==n.path&&(e.path=`${n.path}${e.path}`),!X.REQUIRE_ACCESS_TOKEN)return le(e);if(t=t||X.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),le(e)}},e.ResourceType=Ae,e.SegmentVector=xa,e.SourceCache=Rf,e.StencilMode=Af,e.StructArrayLayout1ui2=ws,e.StructArrayLayout2f1f2i16=hs,e.StructArrayLayout2i4=Qo,e.StructArrayLayout2ui4=bs,e.StructArrayLayout3f12=ds,e.StructArrayLayout3ui6=fs,e.StructArrayLayout4i8=es,e.StructArrayLayout5f20=vs,e.Texture=Xd,e.Tile=pf,e.Transitionable=zo,e.Uniform1f=Js,e.Uniform1i=class extends Ys{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.Uniform2f=class extends Ys{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.Uniform3f=class extends Ys{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.Uniform4f=Qs,e.UniformColor=Ks,e.UniformMatrix2f=class extends Ys{constructor(e,t){super(e,t),this.current=ia}set(e){for(let t=0;t<4;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix2fv(this.location,!1,e);break}}},e.UniformMatrix3f=class extends Ys{constructor(e,t){super(e,t),this.current=ta}set(e){for(let t=0;t<9;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix3fv(this.location,!1,e);break}}},e.UniformMatrix4f=class extends Ys{constructor(e,t){super(e,t),this.current=ea}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.UnwrappedTileID=Su,e.ValidationError=jn,e.VectorTileWorkerSource=class extends Ge{constructor(e,t,i,n,r){super(),this.actor=e,this.layerIndex=t,this.availableImages=i,this.loadVectorData=r||Hf,this.loading={},this.loaded={},this.deduped=new Gf(e.scheduler),this.isSpriteLoaded=n,this.scheduler=e.scheduler}loadTile(e,t){const i=e.uid,n=e&&e.request,r=n&&n.collectResourceTiming,o=this.loading[i]=new jf(e);o.abort=this.loadVectorData(e,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return o.status="done",l||(this.loaded[i]=o),t(s);const c=a.rawData,u={};a.expires&&(u.expires=a.expires),a.cacheControl&&(u.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new hu.VectorTile(new lh(c));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((e,i)=>{if(e||!i)return t(e);const o={};if(r){const e=j(n);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,v({rawTileData:c.slice(0)},i,u,o))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[i]=o}))}reloadTile(e,t){const i=this.loaded,n=e.uid,r=this;if(i&&i[n]){const o=i[n];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection,o.tileTransform=ld(e.tileID.canonical,e.projection);const s=(e,i)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,r.layerIndex,this.availableImages,r.actor,n)),t(e,i)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}},e.WritingMode=zh,e.ZoomHistory=Or,e.add=El,e.addDynamicAttributes=zd,e.adjoint=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=s*u-a*c,e[1]=r*c-n*u,e[2]=n*a-r*s,e[3]=a*l-o*u,e[4]=i*u-r*l,e[5]=r*o-i*a,e[6]=o*c-s*l,e[7]=n*l-i*c,e[8]=i*s-n*o,e},e.asyncAll=_,e.bezier=p,e.bindAll=S,e.boundsAttributes=uf,e.bufferConvexPolygon=function(e,t){const i=[];for(let n=0;nxe&&(e.getActor().send("enforceCacheSizeLimit",ve),Ee=0)},e.calculateGlobeLabelMatrix=function(e,t){const{x:i,y:n}=e.point,r=td(i,n,e.worldSize/e._projectionScaler,0,0);return ml(r,r,ed(qp(t)))},e.calculateGlobeMatrix=function(e){const{x:t,y:i}=e.point,{lng:n,lat:r}=e._center;return td(t,i,e.worldSize,n,r)},e.calculateGlobeMercatorMatrix=function(e){const t=e.worldSize,i=e.point,n=La(1,e.center.lat)*t,r=e.pixelsPerMeter,o=t/(n/e.pixelsPerMeter),s=fl(new Float64Array(16));return gl(s,s,[i.x,i.y,0]),_l(s,s,[o,o,r]),Float32Array.from(s)},e.circumferenceAtLatitude=Ea,e.clamp=f,e.clearTileCache=function(e){const i=[];for(const e in be)i.push(t.caches.delete(e)),delete be[e];e&&Promise.all(i).catch(e).then((()=>e()))},e.clipLine=rp,e.clone=function(e){var t=new pl(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.clone$1=L,e.collisionCircleLayout=Xu,e.config=X,e.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.create=function(){var e=new pl(16);return pl!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.create$1=dl,e.createExpression=Dn,e.createLayout=Yo,e.createStyleLayer=function(e){return"custom"===e.type?new Wd(e):new Zd[e.type](e)},e.cross=Dl,e.degToRad=l,e.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},e.div=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e},e.dot=zl,e.ease=d,e.easeCubicInOut=h,e.emitValidationErrors=Ar,e.endsWith=E,e.enforceCacheSizeLimit=function(e){for(const t in be)Me(t),be[t].then((t=>{t.keys().then((i=>{for(let n=0;no&&(n+=(e[r]-o)*(e[r]-o)),t[r]{}}},e.globeCenterToScreenPoint=function(e){const t=[0,0,0],i=fl(new Float64Array(16));return ml(i,e.pixelMatrix,e.globeMatrix),Ol(t,t,i),new r(t[0],t[1])},e.globeECEFOrigin=function(e,t){const i=[0,0,0];return Ol(i,i,Kp(qp(t.canonical))),Ol(i,i,e),i},e.globeNormalizeECEF=Kp,e.globePixelsToTileUnits=function(e,t){return ba/(512*Math.pow(2,e))*Qp(qp(t))},e.globePoleMatrixForTile=function(e,t,i){const n=fl(new Float64Array(16)),r=1<0;return 0===n&&!r&&!s&&o},e.identity=fl,e.identity$1=Wl,e.invert=function(e,t){var i=t[0],n=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],p=t[10],d=t[11],f=t[12],m=t[13],g=t[14],_=t[15],y=i*a-n*s,v=i*l-r*s,x=i*c-o*s,b=n*l-r*a,w=n*c-o*a,M=r*c-o*l,T=u*m-h*f,S=u*g-p*f,E=u*_-d*f,A=h*g-p*m,C=h*_-d*m,L=p*_-d*g,I=y*L-v*C+x*A+b*E-w*S+M*T;return I?(e[0]=(a*L-l*C+c*A)*(I=1/I),e[1]=(r*C-n*L-o*A)*I,e[2]=(m*M-g*w+_*b)*I,e[3]=(p*w-h*M-d*b)*I,e[4]=(l*E-s*L-c*S)*I,e[5]=(i*L-r*E+o*S)*I,e[6]=(g*x-f*M-_*v)*I,e[7]=(u*M-p*x+d*v)*I,e[8]=(s*C-a*E+c*T)*I,e[9]=(n*E-i*C-o*T)*I,e[10]=(f*w-m*x+_*y)*I,e[11]=(h*x-u*w-d*y)*I,e[12]=(a*S-s*A-l*T)*I,e[13]=(i*A-n*S+r*T)*I,e[14]=(m*v-f*b-g*y)*I,e[15]=(u*b-h*v+p*y)*I,e):null},e.isLngLatBehindGlobe=function(e,t){return nd(e,t)>Math.PI/2*1.01},e.isMapAuthenticated=function(e){return _e.has(e)},e.isMapboxURL=re,e.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!F(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.latFromMercatorY=Pa,e.len=jl,e.length=Tl,e.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},e.loadVectorTile=Hf,e.makeRequest=Ie,e.mapValue=function(e,t,i,n,r){return f((e-t)/(i-t)*(r-n)+n,n,r)},e.mercatorXfromLng=Aa,e.mercatorYfromLat=Ca,e.mercatorZfromAltitude=La,e.mul=bl,e.mul$1=Ul,e.multiply=ml,e.multiply$1=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=i[0],d=i[1],f=i[2],m=i[3],g=i[4],_=i[5],y=i[6],v=i[7],x=i[8];return e[0]=p*n+d*s+f*c,e[1]=p*r+d*a+f*u,e[2]=p*o+d*l+f*h,e[3]=m*n+g*s+_*c,e[4]=m*r+g*a+_*u,e[5]=m*o+g*l+_*h,e[6]=y*n+v*s+x*c,e[7]=y*r+v*a+x*u,e[8]=y*o+v*l+x*h,e},e.multiply$2=Cl,e.nextPowerOfTwo=M,e.normalize=kl,e.normalize$1=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=i*i+n*n+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=n*s,e[2]=r*s,e[3]=o*s,e},e.number=_i,e.ortho=function(e,t,i,n,r,o,s){var a=1/(t-i),l=1/(n-r),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e},e.pbf=lh,e.perspective=function(e,t,i,n,r){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0?(e[10]=(r+n)*(o=1/(n-r)),e[14]=2*r*n*o):(e[10]=-1,e[14]=-2*n),e},e.pick=function(e,t){const i={};for(let n=0;nEr(lr(e)),e.validateFog=e=>Er(vr(e)),e.validateLayer=e=>Er(dr(e)),e.validateLight=e=>Er(_r(e)),e.validateSource=e=>Er(gr(e)),e.validateStyle=Mr,e.validateTerrain=e=>Er(yr(e)),e.values=y,e.vectorTile=hu,e.version=V,e.warnOnce=P,e.window=t,e.wrap=g}));n(0,(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let i="[";for(const n of e)i+=`${t(n)},`;return`${i}]`}let i="{";for(const n of Object.keys(e).sort())i+=`${n}:${t(e[n])},`;return`${i}}`}function i(i){let n="";for(const r of e.refProperties)n+=`/${t(i[r])}`;return n}class n{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,n){for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.createStyleLayer(i)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const r=function(e,t){const n={};for(let r=0;rthis._layers[e.id])),i=t[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(t)}}}class r{loadTile(t,i){const{uid:n,encoding:r,rawImageData:o,padding:s,buildQuadTree:a}=t,l=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap?this.getImageData(o,s):o;i(null,new e.DEMData(n,l,r,s<1,a))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const i=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),i}}var o=function e(t,i){var n,r=t&&t.type;if("FeatureCollection"===r)for(n=0;n=Math.abs(a)?i-l+a:a-l+i,i=l}i+n>=0!=!!t&&e.reverse()}const l=e.vectorTile.VectorTileFeature.prototype.toGeoJSON;class c{constructor(t){this._feature=t,this.extent=e.EXTENT,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.pointGeometry(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const n=[];for(const t of i)n.push(new e.pointGeometry(t[0],t[1]));t.push(n)}return t}}toGeoJSON(e,t,i){return l.call(this,e,t,i)}}class u{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.EXTENT,this.length=t.length,this._features=t}feature(e){return new c(this._features[e])}}var h=e.vectorTile.VectorTileFeature,p=d;function d(e,t){this.options=t||{},this.features=e,this.length=e.length}function f(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096}d.prototype.feature=function(e){return new f(this.features[e],this.options.extent)},f.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function M(e,t){for(var i=e.loadGeometry(),n=e.type,r=0,o=0,s=i.length,a=0;a>1;E(e,t,s,n,r,o%2),S(e,t,i,n,s-1,o+1),S(e,t,i,s+1,r,o+1)}function E(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+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);E(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(A(e,t,n,i),t[2*r+o]>s&&A(e,t,n,r);as;)l--}t[2*n+o]===s?A(e,t,n,l):(l++,A(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function A(e,t,i,n){C(e,i,n),C(t,2*i,2*n),C(t,2*i+1,2*n+1)}function C(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function L(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}m.fromVectorTileJs=_,m.fromGeojsonVt=function(e,t){t=t||{};var i={};for(var n in e)i[n]=new p(e[n].features,t),i[n].name=n,i[n].version=t.version,i[n].extent=t.extent;return _({layers:i})},m.GeoJSONWrapper=g;const I=e=>e[0],P=e=>e[1];class R{constructor(e,t=I,i=P,n=64,r=Float64Array){this.nodeSize=n,this.points=e;const o=e.length<65536?Uint16Array:Uint32Array,s=this.ids=new o(e.length),a=this.coords=new r(2*e.length);for(let n=0;n=i&&c<=r&&u>=n&&u<=o&&l.push(e[s]);continue}const f=Math.floor((d+p)/2);c=t[2*f],u=t[2*f+1],c>=i&&c<=r&&u>=n&&u<=o&&l.push(e[f]);const m=(h+1)%2;(0===h?i<=c:n<=u)&&(a.push(d),a.push(f-1),a.push(m)),(0===h?r>=c:o>=u)&&(a.push(f+1),a.push(p),a.push(m))}return l}(this.ids,this.coords,e,t,i,n,this.nodeSize)}within(e,t,i){return function(e,t,i,n,r,o){const s=[0,e.length-1,0],a=[],l=r*r;for(;s.length;){const c=s.pop(),u=s.pop(),h=s.pop();if(u-h<=o){for(let r=h;r<=u;r++)L(t[2*r],t[2*r+1],i,n)<=l&&a.push(e[r]);continue}const p=Math.floor((h+u)/2),d=t[2*p],f=t[2*p+1];L(d,f,i,n)<=l&&a.push(e[p]);const m=(c+1)%2;(0===c?i-r<=d:n-r<=f)&&(s.push(h),s.push(p-1),s.push(m)),(0===c?i+r>=d:n+r>=f)&&(s.push(p+1),s.push(u),s.push(m))}return a}(this.ids,this.coords,e,t,i,this.nodeSize)}}const k={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},z=Math.fround||(D=new Float32Array(1),e=>(D[0]=+e,D[0]));var D;class O{constructor(e){this.options=H(Object.create(k),e),this.trees=new Array(this.options.maxZoom+1)}load(e){const{log:t,minZoom:i,maxZoom:n,nodeSize:r}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;let s=[];for(let t=0;t=i;e--){const i=+Date.now();s=this._cluster(s,e),this.trees[e]=new R(s,W,q,r,Float32Array),t&&console.log("z%d: %d clusters in %dms",e,s.length,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(j(i),V(o),j(r),V(n)),l=[];for(const e of a){const t=s.points[e];l.push(t.numPoints?N(t):this.points[t.index])}return l}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.points[t];if(!o)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o.x,o.y,s),l=[];for(const t of a){const i=r.points[t];i.parentId===e&&l.push(i.numPoints?N(i):this.points[i.index])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.points,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.points,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.points,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):rt&&(h+=i.numPoints||1)}if(h>u&&h>=s){let e=r.x*u,s=r.y*u,a=o&&u>1?this._map(r,!0):null;const p=(n<<5)+(t+1)+this.points.length;for(const i of c){const n=l.points[i];if(n.zoom<=t)continue;n.zoom=t;const c=n.numPoints||1;e+=n.x*c,s+=n.y*c,n.parentId=p,o&&(a||(a=this._map(r,!0)),o(a,this._map(n)))}r.parentId=p,i.push(F(e/h,s/h,p,h,a))}else if(i.push(r),h>1)for(const e of c){const n=l.points[e];n.zoom<=t||(n.zoom=t,i.push(n))}}return i}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?H({},e.properties):e.properties;const i=this.points[e.index].properties,n=this.options.map(i);return t&&n===i?H({},n):n}}function F(e,t,i,n,r){return{x:z(e),y:z(t),zoom:1/0,id:i,parentId:-1,numPoints:n,properties:r}}function B(e,t){const[i,n]=e.geometry.coordinates;return{x:z(j(i)),y:z(V(n)),zoom:1/0,index:t,parentId:-1}}function N(e){return{type:"Feature",id:e.id,properties:U(e),geometry:{type:"Point",coordinates:[(t=e.x,360*(t-.5)),G(e.y)]}};var t}function U(e){const t=e.numPoints,i=t>=1e4?`${Math.round(t/1e3)}k`:t>=1e3?Math.round(t/100)/10+"k":t;return H(H({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:i})}function j(e){return e/360+.5}function V(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function G(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function H(e,t){for(const i in t)e[i]=t[i];return e}function W(e){return e.x}function q(e){return e.y}function $(e,t,i,n){for(var r,o=n,s=i-t>>1,a=i-t,l=e[t],c=e[t+1],u=e[i],h=e[i+1],p=t+3;po)r=p,o=d;else if(d===o){var f=Math.abs(p-s);fn&&(r-t>3&&$(e,t,r,n),e[r+2]=o,i-r>3&&$(e,r,i,n))}function Z(e,t,i,n,r,o){var s=r-i,a=o-n;if(0!==s||0!==a){var l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return(s=e-i)*s+(a=t-n)*a}function X(e,t,i,n){var r={id:void 0===e?null:e,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,i=e.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)Y(e,t);else if("Polygon"===i||"MultiLineString"===i)for(var n=0;n0&&(s+=n?(r*c-l*o)/2:Math.sqrt(Math.pow(l-r,2)+Math.pow(c-o,2))),r=l,o=c}var u=t.length-3;t[2]=1,$(t,0,u,i),t[u+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function ee(e,t,i,n){for(var r=0;r1?1:i}function ne(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;for(var l=[],c=0;c=i&&f=n)){var m=[];if("Point"===p||"MultiPoint"===p)re(h,m,i,n,r);else if("LineString"===p)oe(h,m,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===p)ae(h,m,i,n,r,!1);else if("Polygon"===p)ae(h,m,i,n,r,!0);else if("MultiPolygon"===p)for(var g=0;g=i&&s<=n&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function oe(e,t,i,n,r,o,s){for(var a,l,c=se(e),u=0===r?ce:ue,h=e.start,p=0;pi&&(l=u(c,d,f,g,_,i),s&&(c.start=h+a*l)):y>n?v=i&&(l=u(c,d,f,g,_,i),x=!0),v>n&&y<=n&&(l=u(c,d,f,g,_,n),x=!0),!o&&x&&(s&&(c.end=h+a*l),t.push(c),c=se(e)),s&&(h+=a)}var b=e.length-3;d=e[b],f=e[b+1],m=e[b+2],(y=0===r?d:f)>=i&&y<=n&&le(c,d,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&le(c,c[0],c[1],c[2]),c.length&&t.push(c)}function se(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ae(e,t,i,n,r,o){for(var s=0;ss.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function ge(e,t,i,n){var r=t.geometry,o=t.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a0&&t.size<(r?s:n))i.numPoints+=t.length/3;else{for(var a=[],l=0;ls)&&(i.numSimplified++,a.push(t[l]),a.push(t[l+1])),i.numPoints++;r&&function(e,t){for(var i=0,n=0,r=e.length,o=r-2;n0===t)for(n=0,r=e.length;n24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var n=function(e,t){var i=[];if("FeatureCollection"===e.type)for(var n=0;n1&&console.time("creation"),p=this.tiles[h]=me(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+t;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=e,r){if(t===l.maxZoom||t===r)continue;var f=1<1&&console.time("clipping");var m,g,_,y,v,x,b=.5*l.buffer/l.extent,w=.5-b,M=.5+b,T=1+b;m=g=_=y=null,v=ne(e,u,i-b,i+M,0,p.minX,p.maxX,l),x=ne(e,u,i+w,i+T,0,p.minX,p.maxX,l),e=null,v&&(m=ne(v,u,n-b,n+M,1,p.minY,p.maxY,l),g=ne(v,u,n+w,n+T,1,p.minY,p.maxY,l),v=null),x&&(_=ne(x,u,n-b,n+M,1,p.minY,p.maxY,l),y=ne(x,u,n+w,n+T,1,p.minY,p.maxY,l),x=null),c>1&&console.timeEnd("clipping"),a.push(m||[],t+1,2*i,2*n),a.push(g||[],t+1,2*i,2*n+1),a.push(_||[],t+1,2*i+1,2*n),a.push(y||[],t+1,2*i+1,2*n+1)}}},ye.prototype.getTile=function(e,t,i){var n=this.options,r=n.extent,o=n.debug;if(e<0||e>24)return null;var s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);for(var l,c=e,u=t,h=i;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[ve(c,u,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,h),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?de(this.tiles[a],r):null):null};class be extends e.VectorTileWorkerSource{constructor(e,t,i,n,r){super(e,t,i,n,xe),r&&(this.loadGeoJSON=r)}loadData(t,i){const n=t&&t.request,r=n&&n.collectResourceTiming;this.loadGeoJSON(t,((s,a)=>{if(s||!a)return i(s);if("object"!=typeof a)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{o(a,!0);try{if(t.filter){const i=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const n=a.features.filter((e=>i.value.evaluate({zoom:0},e)));a={type:"FeatureCollection",features:n}}this._geoJSONIndex=t.cluster?new O(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.createExpression(s),l=e.createExpression("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(t)).load(a.features):function(e,t){return new ye(e,t)}(a,t.geojsonVtOptions)}catch(s){return i(s)}this.loaded={};const l={};if(r){const i=e.getPerformanceMeasurement(n);i&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}}))}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.getJSON(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class we{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:"mercator"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:be},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error("RTL text plugin already registered.");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,i){this.isSpriteLoaded[t]=i;for(const n in this.workerSources[t]){const r=this.workerSources[t][n];for(const t in r)r[t]instanceof e.VectorTileWorkerSource&&(r[t].isSpriteLoaded=i,r[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,i){this.availableImages[e]=t;for(const i in this.workerSources[e]){const n=this.workerSources[e][i];for(const e in n)n[e].availableImages=t}i()}enableTerrain(e,t,i){this.terrain=t,i()}setProjection(t,i){this.projections[t]=e.getProjection(i)}setLayers(e,t,i){this.getLayerIndex(e).replace(t),i()}updateLayers(e,t,i){this.getLayerIndex(e).update(t.layers,t.removedIds),i()}loadTile(t,i,n){const r=this.enableTerrain?e.extend({enableTerrain:this.terrain},i):i;r.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,i.type,i.source).loadTile(r,n)}loadDEMTile(t,i,n){const r=this.enableTerrain?e.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(t,i.source).loadTile(r,n)}reloadTile(t,i,n){const r=this.enableTerrain?e.extend({enableTerrain:this.terrain},i):i;r.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,i.type,i.source).reloadTile(r,n)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source).removeTile(t,i)}removeSource(e,t,i){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const n=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==n.removeSource?n.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,n){try{e.plugin.setState(i);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const i=e.plugin.isParsed();n(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),i)}}catch(e){n(e.toString())}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new n),t}getWorkerSource(e,t,i){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),this.workerSources[e][t][i]||(this.workerSources[e][t][i]=new this.workerSourceTypes[t]({send:(t,i,n,r,o,s)=>{this.actor.send(t,i,n,e,o,s)},scheduler:this.actor.scheduler},this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])),this.workerSources[e][t][i]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new r),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,i){e.enforceCacheSizeLimit(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new we(self)),we}));n(0,(function(e){function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let n=0;n{e.window.removeEventListener("click",p,!0)}),0)}function f(e,t){const i=e.getBoundingClientRect();return _(e,i,t)}function m(e,t){const i=e.getBoundingClientRect(),n=[];for(let r=0;r=0?0:t.button}function _(t,i,n){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.pointGeometry((n.clientX-i.left)*r,(n.clientY-i.top)*r)}function y(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=i*o-r*n;return s?(e[0]=o*(s=1/s),e[1]=-n*s,e[2]=-r*s,e[3]=i*s,e):null}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class x extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(t,i){let n=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]{this.ready=!0}))}broadcast(t,i,n){e.asyncAll(this.actors,((e,n)=>{e.send(t,i,n)}),n=n||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove()})),this.actors=[],this.workerPool.release(this.id)}}function k(t,i,n){return i*(e.EXTENT/(t.tileSize*Math.pow(2,n-t.tileID.overscaledZ)))}R.Actor=e.Actor;class z{constructor(e,t,i,n){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,n)}static createFromScreenPoints(t,i){let n,r;if(t instanceof e.pointGeometry||"number"==typeof t[0]){const o=e.pointGeometry.convert(t);n=[e.pointGeometry.convert(t)],r=i.isPointAboveHorizon(o)}else{const o=e.pointGeometry.convert(t[0]),s=e.pointGeometry.convert(t[1]);n=[o,s],r=e.polygonizeBounds(o,s).every((e=>i.isPointAboveHorizon(e)))}return new z(n,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],r=e.polygonizeBounds(i,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.bufferConvexPolygon(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],r=e.polygonizeBounds(i,n,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>n.y))+((o.x>i.x)+(o.x>n.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(t,i,n,r=0){const o=t.queryPadding/i._projectionScaler+1,s=n?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map((i=>e.getTilePoint(t.tileTransform,i,a)));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((i=>e.getTileVec3(t.tileTransform,i,a))),u=c.map((t=>new e.pointGeometry(t[0],t[1]))),h=i.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),p=e.getTileVec3(t.tileTransform,h,a),d=c.map((t=>{const i=e.sub(t,t,p);return e.normalize(i,i),new e.Ray(p,i)})),f=k(t,1,i.zoom)*i._projectionScaler;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=F(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=n,n}}_bufferedCameraMercator(e,t){const i=F(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=n,n}}_projectAndResample(t,i){const n=function(t,i){const n=e.multiply([],i.pixelMatrix,i.globeMatrix),r=[0,-e.GLOBE_RADIUS,0,1],o=[0,e.GLOBE_RADIUS,0,1],s=[0,0,0,1];e.transformMat4$1(r,r,n),e.transformMat4$1(o,o,n),e.transformMat4$1(s,s,n);const a=new e.pointGeometry(r[0]/r[3],r[1]/r[3]),l=new e.pointGeometry(o[0]/o[3],o[1]/o[3]),c=e.polygonContainsPoint(t,a)&&r[3]1?D(t.slice(0,p),i):[],m=pnew e.pointGeometry(O(t.x),t.y))),m=m.map((t=>new e.pointGeometry(O(t.x),t.y)));const g=[...f];0===g.length&&g.push(m[m.length-1]);const _=e.number(g[g.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=c?[new e.pointGeometry(0,_),new e.pointGeometry(0,0),new e.pointGeometry(1,0),new e.pointGeometry(1,_)]:[new e.pointGeometry(1,_),new e.pointGeometry(1,1),new e.pointGeometry(0,1),new e.pointGeometry(0,_)],g.push(...y),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:!1}}(t,i);if(n)return n;const r=function(t,i){let n=!1,r=-1/0,o=0;for(let e=0;er&&(r=t[e].x,o=e);for(let e=0;e.5&&(r.x{e.x-=1})),{polygon:t,unwrapped:n}}(D(t,i).map((t=>new e.pointGeometry(O(t.x),t.y))),i);return{polygon:r.polygon.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:r.unwrapped}}}function D(t,i){return e.resample(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),1/256)}function O(e){return e<0?1+e%1:e%1}function F(e){return 100*e|0}function B(t,i,n,r,o){const s=function(n,r){if(n)return o(n);if(r){const n=e.pick(e.extend(r,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(n.vectorLayers=r.vector_layers,n.vectorLayerIds=n.vectorLayers.map((e=>e.id))),r.language_options&&(n.languageOptions=r.language_options),r.language&&r.language[r.id]&&(n.language=r.language[r.id]),r.worldview_options&&(n.worldviewOptions=r.worldview_options),r.worldview?n.worldview=r.worldview[r.id]:r.worldview_default&&(n.worldview=r.worldview_default),n.tiles=i.canonicalizeTileset(n,t.url),o(null,n)}};return t.url?e.getJSON(i.transformRequest(i.normalizeSourceURL(t.url,null,n,r),e.ResourceType.Source),s):e.exported.frame((()=>s(null,t)))}class N{constructor(t,i,n){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=n||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),n=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*i),r=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*i),o=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*i);return t.x>=n&&t.x=r&&t.y{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(e.extend(this,i),i.bounds&&(this.tileBounds=new N(i.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(i.tiles),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const n=e.exported.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),((n,r,o,s)=>(delete t.request,t.aborted?(t.state="unloaded",i(null)):n?(t.state="errored",i(n)):r?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(r,this.map.painter),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),void i(null)):i(null))))}static loadTileData(e,t,i){e.setTexture(t,i)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}}let Ce;function Le(t,i,n,r,o,s,a,l){const c=[t,n,o,i,r,s,1,1,1],u=[a,l,1],h=e.adjoint([],c),[p,d,f]=e.transformMat3(u,u,e.transpose(h,h));return e.multiply$1(c,[p,0,0,0,d,0,0,0,f],c)}class Ie extends e.Evented{constructor(e,t,i,n){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(n),this.options=t}load(t,i){this._loaded=i||!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),((i,n)=>{if(this._loaded=!0,i)this.fire(new e.ErrorEvent(i));else if(n){const{HTMLImageElement:i}=e.window;this.image=n instanceof i?e.exported.getImageData(n):n,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const i=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let i=1/0,n=1/0,r=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x),o=Math.max(o,e.y);const s=Math.max(r-i,o-n),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new e.CanonicalTileID(a,Math.floor((i+r)/2*l),Math.floor((n+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const i=e.tileTransform(this.tileID,this.map.transform.projection),[n,r,o,s]=this.coordinates.map((t=>{const n=i.projection.project(t[0],t[1]);return e.getTilePoint(i,n)._round()}));this.perspectiveTransform=function(t,i,n,r,o,s,a,l,c,u){const h=Le(0,0,t,0,0,i,t,i),p=Le(n,r,o,s,a,l,c,u);return e.multiply$1(p,e.adjoint(h,h),p),[p[6]/p[8]*t/e.EXTENT,p[7]/p[8]*i/e.EXTENT]}(this.width,this.height,n.x,n.y,r.x,r.y,s.x,s.y,o.x,o.y);const a=this._boundsArray=new e.StructArrayLayout4i8;a.emplaceBack(n.x,n.y,0,0),a.emplaceBack(r.x,r.y,e.EXTENT,0),a.emplaceBack(s.x,s.y,0,e.EXTENT),a.emplaceBack(o.x,o.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(a,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Pe={vector:class extends e.Evented{constructor(t,i,n,r){if(super(),this.id=t,this.dispatcher=n,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.extend(this,e.pick(i,["url","scheme","tileSize","promoteId"])),this._options=e.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.DedupedRequest}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"}));const i=this.language||this.map._language,n=this.worldview||this.map._worldview;this._tileJSONRequest=B(this._options,this.map._requestManager,i,n,((r,o)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${i}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new e.ErrorEvent(r))):o&&(e.extend(this,o),o.bounds&&(this.tileBounds=new N(o.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.cancel(),e(),this.load((()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles()}))}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}_setLanguage(e){return e===this.language||this.setSourceProperty((()=>{this.language=e})),this}_setWorldview(e){return e===this.worldview?this:this.worldviewOptions&&e&&!this.worldviewOptions[e]?(console.warn(`Vector tile source "${this.id}" does not support worldview "${e}".`),this):(this.setSourceProperty((()=>{this.worldview=e})),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return e.extend({},this._options)}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",r,o.bind(this));else if(t.actor=this._tileWorkers[n]=this._tileWorkers[n]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",r,o.bind(this),void 0,!0);else{const i=e.loadVectorTile.call({deduped:this._deduped},r,((e,i)=>{e||!i?o.call(this,e):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",r,o.bind(this),void 0,!0))}),!0);t.request={cancel:i}}function o(n,r){return delete t.request,t.aborted?i(null):n&&404!==n.status?i(n):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Ae,"raster-dem":class extends Ae{constructor(t,i,n,r){super(t,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(e,n){e&&(t.state="errored",i(e)),n&&(t.dem=n,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null))}t.request=e.getImage(this.map._requestManager.transformRequest(n,e.ResourceType.Tile),function(n,o,s,a){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(n)t.state="errored",i(n);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a});const i=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap&&(null==Ce&&(Ce=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),Ce),n=1-(o.width-e.prevPowerOfTwo(o.width))/2;n<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?o:e.exported.getImageData(o,n),c={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:n};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,r.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const i=t.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+n)%n,a=i.x+1===n?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.resourceTiming[this.id]),this.fire(new e.Event("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,i){const n=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(n,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((e,r)=>(delete t.request,t.unloadVectorData(),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===n),i(null)))),void 0,"loadTile"===n)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ie{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.ResourceType.Source).url);e.getVideo(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ie,canvas:class extends Ie{constructor(t,i,n,r){super(t,i,n,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.Evented{constructor(t,i,n,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=i,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.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)),i.update=this._update.bind(this),i.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:n}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const{x:n,y:r,z:o}=t.tileID.canonical,s=new e.window.AbortController,a=this._implementation.loadTile({x:n,y:r,z:o},{signal:s.signal});if(!a)return this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null);a.cancel=()=>s.abort(),t.request=a.then(function(n){return delete t.request,t.aborted?(t.state="unloaded",i(null)):n?function(t){return t instanceof e.window.ImageData||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLCanvasElement}(n)?(this.loadTileData(t,n),t.state="loaded",void i(null)):(t.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null))}.bind(this)).catch((e=>{20!==e.code&&(t.state="errored",i(e))}))}loadTileData(e,t){Ae.loadTileData(e,t,this._map.painter)}unloadTileData(e){Ae.unloadTileData(e,this._map.painter)}prepareTile(e){if(!this._implementation.prepareTile)return null;const{x:t,y:i,z:n}=e.tileID.canonical,r=this._implementation.prepareTile({x:t,y:i,z:n});return r?(this.loadTileData(e,r),e.state="loaded",r):null}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:i,z:n}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:n})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_update(){this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Re=function(t,i,n,r){const o=new Pe[i.type](t,i,n,r);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bindAll(["load","abort","unload","serialize","prepare"],o),o};function ke(t,i){const n=e.identity([]);return e.scale(n,n,[.5*t.width,.5*-t.height,1]),e.translate(n,n,[1,-1,0]),e.multiply(n,n,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(n)}function ze(e,t,i,n,r,o,s,a=!1){const l=e.tilesIn(n,s,a);l.sort(Oe);const c=[];for(const n of l)c.push({wrappedTileID:n.tile.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(t,i,e._state,n,r,o,ke(e.transform,n.tile.tileID),a)});const u=function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(c);for(const t in u)u[t].forEach((t=>{const i=t.feature,n=i.layer;n&&"background"!==n.type&&"sky"!==n.type&&(i.source=n.source,n["source-layer"]&&(i.sourceLayer=n["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(n["source-layer"],i.id):{})}));return u}function De(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),n=[],r={};for(let e=0;e{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Be]}numActive(){return Object.keys(this.active).length}}let Ue;function je(){return Ue||(Ue=new Ne),Ue}function Ve(t,i){const n={};for(const e in t)"ref"!==e&&(n[e]=t[e]);return e.refProperties.forEach((e=>{e in i&&(n[e]=i[e])})),n}function Ge(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Ke{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return!r&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return!0;for(let e=0;e0:s}_queryCircle(e,t,i,n,r){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!n&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),n?c.length>0:c}query(e,t,i,n,r){return this._query(e,t,i,n,!1,r)}hitTest(e,t,i,n,r){return this._query(e,t,i,n,!0,r)}hitTestCircle(e,t,i,n){return this._queryCircle(e,t,i,!0,n)}_queryCell(e,t,i,n,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(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&n>=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],e,t,i,n)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=r[u],t=r[u+1],i=r[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,n,r,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[r];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[r];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,this.xCellCount*l+p,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,p=u-c;return h*h+p*p<=i*i}}const et=Math.tan(85*Math.PI/180);function tt(t,i,n,r,o,s,a){const l=e.create();if(n)if("globe"===s.name){const t=e.calculateGlobeLabelMatrix(o,i);e.multiply(l,l,t)}else{const t=y([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.rotateZ(l,l,o.angle)}else e.multiply(l,o.labelPlaneMatrix,t);return l}function it(e,t,i,n,r,o,s){const a=tt(e,t,i,n,r,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function nt(t,i,n,r,o,s,a){if(n){if("globe"===s.name){const l=tt(t,i,n,r,o,s,a);return e.invert(l,l),e.multiply(l,t,l),l}{const i=e.clone(t),n=e.identity([]);return n[0]=a[0],n[1]=a[1],n[4]=a[2],n[5]=a[3],e.multiply(i,i,n),r||e.rotateZ(i,i,-o.angle),i}}return o.glCoordMatrix}function rt(t,i,n=0){const r=[t.x,t.y,n,1];n?e.transformMat4$1(r,r,i):_t(r,r,i);const o=r[3];return{point:[r[0]/o,r[1]/o,r[2]/o],signedDistanceFromCamera:o}}function ot(t,i){const n=[t[0],t[1],t[2],1];e.transformMat4$1(n,n,i);const r=n[3];return{point:[n[0]/r,n[1]/r,n[2]/r],signedDistanceFromCamera:r}}function st(e,t){return Math.min(.5+e/t*.5,1.5)}function at(e,t){const i=e[0]/e[3],n=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&n>=-t[1]&&n<=t[1]}function lt(t,i,n,r,o,s,a,l,c,u){const h=n.transform,p=r?t.textSizeData:t.iconSizeData,d=e.evaluateSizeForZoom(p,n.transform.zoom),f="globe"===h.projection.name,m=[256/n.width*2+1,256/n.height*2+1],g=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let _=null;f&&(_=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=n.transform.width/n.transform.height;let b=!1;for(let r=0;rMath.abs(n.x-i.x)*r?{useVertical:!0}:t.writingMode===e.WritingMode.vertical?i.yet}(i,n,r)?1===t.flipState?{needsFlipping:!0}:null:i.x>n.x?{needsFlipping:!0}:null}function ht(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y,v){const x=i/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x;let M;if(t.numGlyphs>1){const i=t.glyphStartIndex+t.numGlyphs,o=t.lineStartIndex,u=t.lineStartIndex+t.lineLength,h=ct(x,l,b,w,n,p,d,t,c,s,f,g,!1,_,y,v);if(!h)return{notEnoughRoom:!0};const T=ot(h.first.point,a).point,S=ot(h.last.point,a).point,E=new e.pointGeometry(T[0],T[1]),A=new e.pointGeometry(S[0],S[1]);if(r&&!n){const e=ut(t,E,A,m);if(t.flipState=e&&e.needsFlipping?1:2,e)return e}M=[h.first];for(let e=t.glyphStartIndex+1;e0?s.point:dt(d,r,i,1,o,void 0,_,y.canonical),l=ut(t,new e.pointGeometry(i[0],i[1]),new e.pointGeometry(a[0],a[1]),m);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=ft(x*l.getoffsetX(t.glyphStartIndex),b,w,n,p,d,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,c,s,f,g,!1,!1,_,y,v);if(!i)return{notEnoughRoom:!0};M=[i]}if(h)for(const t of M)e.updateGlobeVertexNormal(h,u.length+0,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+1,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+2,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+3,t.up[0],t.up[1],t.up[2]),e.addDynamicAttributes(u,t.point[0],t.point[1],t.point[2],t.angle);else for(const t of M)e.addDynamicAttributes(u,t.point[0],t.point[1],t.point[2],t.angle);return{}}function pt(t,i,n,r,o){const s=r.projectTilePoint(t.x,t.y,i);if(!o)return rt(s,n,s.z);const a=o(t);return rt(new e.pointGeometry(s.x+a[0],s.y+a[1]),n,s.z+a[2])}function dt(t,i,n,r,o,s,a,l){const c=pt(t.add(t.sub(i)._unit()),l,o,a,s).point,u=e.sub([],n,c);return e.scaleAndAdd([],n,u,r/e.length(u))}function ft(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_,y){const v=r?t-i:t+i;let x=v>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=x>0?l+a:l+a+1,M=o,T=o,S=0,E=0;const A=Math.abs(v),C=[],L=[];let I=s;const P=()=>{const t=w-x;return 0===S?s:new e.pointGeometry(u.getx(t),u.gety(t))},R=()=>dt(P(),I,T,A-S+1,h,d,g,_.canonical);for(;S+E<=A;){if(w+=x,w=c)return null;if(T=M,C.push(M),f&&L.push(I||P()),M=p[w],void 0===M){I=new e.pointGeometry(u.getx(w),u.gety(w));const t=pt(I,_.canonical,h,g,d);M=t.signedDistanceFromCamera>0?p[w]=t.point:R()}else I=null;S+=E,E=e.distance(T,M)}I=I||new e.pointGeometry(u.getx(w),u.gety(w));const k=P();m&&d&&(p[w]=M=void 0===p[w]?M:R(),E=e.distance(T,M));const z=(A-S)/E,D=I.sub(k).mult(z)._add(k),O=e.sub([],M,T),F=e.scaleAndAdd([],T,O,z);let B=[0,0,1],N=O[0],U=O[1];if(y&&(B=g.upVector(_.canonical,D.x,D.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[1,0,0],i=[0,1,0];t[0]=B[2],t[1]=0,t[2]=-B[0],e.cross(i,B,t),e.normalize(t,t),e.normalize(i,i),N=e.dot(O,t),U=e.dot(O,i)}if(n){const t=e.cross([],B,O);e.normalize(t,t),e.scaleAndAdd(F,F,t,n*x)}const j=b+Math.atan2(U,N);return C.push(F),f&&L.push(D),{point:F,angle:j,path:C,tilePath:L,up:B}}const mt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function gt(e,t){for(let i=0;i0,e.getProjection()),f=o*d.perspectiveRatio,m=(i.x1*t+n.x-i.padding)*f+d.point.x,g=(i.y1*t+n.y-i.padding)*f+d.point.y,_=(i.x2*t+n.x+i.padding)*f+d.point.x,y=(i.y2*t+n.y+i.padding)*f+d.point.y,v=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,g,_,y)||!r&&this.grid.hitTest(m,g,_,y,a)||v?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,g,_,y],offscreen:this.isOffscreen(m,g,_,y),occluded:!1}}placeCollisionCircles(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=[],_=this.transform.elevation,y=_?_.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,t.getProjection()):e=>[0,0,0],v=new e.pointGeometry(n.tileAnchorX,n.tileAnchorY),x=t.getProjection().projectTilePoint(n.tileAnchorX,n.tileAnchorY,m.canonical),b=y(v),w=[x.x+b[0],x.y+b[1],x.z+b[2]],M="globe"===t.projection.name,T=this.projectAndGetPerspectiveRatio(a,[w[0],w[1],w[2]],m,M||!!_||this.transform.pitch>0,t.getProjection()),{perspectiveRatio:S}=T,E=(h?s/S:s*S)/e.ONE_EM,A=rt(new e.pointGeometry(w[0],w[1]),l,w[2]).point,C=T.signedDistanceFromCamera>0?ct(E,o,n.lineOffsetX*E,n.lineOffsetY*E,!1,A,v,n,r,l,{},_&&!h?y:null,h&&!!_,t.getProjection(),m,h):null;let L=!1,I=!1,P=!0;if(C&&!T.occluded){const t=.5*d*S+f,n=new e.pointGeometry(-100,-100),r=new e.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new Qe,s=C.first,a=C.last;let l=[];for(let e=s.path.length-1;e>=1;e--)l.push(s.path[e]);for(let e=1;e{const i=y(tot(e,c));l=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let m=[];if(l.length>0){const t=l.map((t=>new e.pointGeometry(t[0],t[1])));let i=1/0,o=-1/0,s=1/0,a=-1/0;for(let e=0;e=n.x&&o<=r.x&&s>=n.y&&a<=r.y?[t]:or.x||ar.y?[]:e.clipLine([t],n.x,n.y,r.x,r.y)}for(const e of m){o.reset(e,.25*t);let n=0;n=o.length<=.5*t?1:Math.ceil(o.paddedLength/h)+1;for(let e=0;e0){e.transformMat4$1(s,s,t);const r="globe"===o.name;this.fogState&&n&&!r&&(a=function(t,i,n,r,o,s){const a=s.calculateFogTileMatrix(o),l=[i,n,r];return e.transformMat4(l,l,a),A(t,l,s.pitch,s._fov)}(this.fogState,i[0],i[1],i[2],n.toUnwrapped(),this.transform)>.9)}else _t(s,s,t);return{point:new e.pointGeometry((s[0]/s[3]+1)/2*this.transform.width+yt,(-s[1]/s[3]+1)/2*this.transform.height+yt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(o)/s[3]*.5,1.5),signedDistanceFromCamera:s[3],occluded:r&&s[2]>s[3]||a}}isOffscreen(e,t,i,n){return i=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function Lt(t,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=e.getAnchorAlignment(t),l=-(s-.5)*i,c=-(a-.5)*n,u=e.evaluateVariableOffset(t,r);return new e.pointGeometry(l+u[0]*o,c+u[1]*o)}function It(t,i,n,r,o){const s=new e.pointGeometry(t,i);return n&&s._rotate(r?o:-o),s}class Pt{constructor(e,t,i,n,r){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new vt(this.transform,r),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Ct(i),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=o.layers[0].layout,l=n.collisionBoxArray,c=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),u=n.tileSize/e.EXTENT,h=n.tileID.toUnwrapped();this.transform.setProjection(o.projection);const p=(d=n.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):xt(m,f,d));var d,f,m;const g="map"===a.get("text-pitch-alignment"),_="map"===a.get("text-rotation-alignment");i.compileFilter();const y=i.dynamicFilter(),v=i.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(n),b=it(p,n.tileID.canonical,g,_,this.transform,o.getProjection(),x);let w=null;if(g){const t=nt(p,n.tileID.canonical,g,_,this.transform,o.getProjection(),x);w=e.multiply([],this.transform.labelPlaneMatrix,t)}let M=null;y&&n.latestFeatureIndex&&(M={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:n.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new At(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const T={bucket:o,layout:a,posMatrix:p,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:M,scale:c,textPixelRatio:u,holdingForFade:n.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:T})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:T})}attemptAnchorPlacement(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,_){const y=[h.textOffset0,h.textOffset1],v=Lt(e,i,n,y,r),x=this.collisionIndex.placeCollisionBox(d,r,t,It(v.x,v.y,o,s,this.transform.angle),u,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(_,this.transform.zoom,p),m,It(v.x,v.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)&&x.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(t=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:i,height:n,anchor:e,textScale:r,prevAnchor:t},this.markUsedJustification(d,e,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[h.crossTileID]=f),{shift:v,placedGlyphBoxes:x}}}placeLayerBucketPart(t,i,n,r){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:g}=t.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"),w="map"===s.get("text-pitch-alignment"),M="none"!==s.get("icon-text-fit"),T="viewport-y"===s.get("symbol-z-order");this.transform.setProjection(o.projection);let S=v&&(x||!o.hasIconData()||y),E=x&&(v||!o.hasTextData()||_);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d),n&&r&&o.updateCollisionDebugBuffers(this.transform.zoom,d);const A=(t,r,d)=>{if(u){const n={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(u.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];r=u.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(n,r,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.pointGeometry(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[t.crossTileID]=new St(!1,!1,!1,!0),void(i[t.crossTileID]=!0)}if(i[t.crossTileID])return;if(p)return void(this.placements[t.crossTileID]=new St(!1,!1,!1));let T=!1,A=!1,C=!0,L=!1,I=!1,P=null,R={box:null,offscreen:null,occluded:null},k={box:null,offscreen:null,occluded:null},z=null,D=null,O=null,F=0,B=0,N=0;d.textFeatureIndex?F=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),d.verticalTextFeatureIndex&&(B=d.verticalTextFeatureIndex);const U=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[o.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},j=d.textBox;if(j){U(j);const i=i=>{let n=e.WritingMode.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,n=e,this.markUsedOrientation(o,n,t))}return n},n=(i,n)=>{if(o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of o.writingModes)if(t===e.WritingMode.vertical?(R=n(),k=R):R=i(),R&&R.box&&R.box.length)break}else R=i()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor))}const c=(e,i,n)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,r),c=(e.x2-e.x1)*s+2*e.padding,u=(e.y2-e.y1)*s+2*e.padding,p=M&&!x?i:null;p&&U(p);let d={box:[],offscreen:!1,occluded:!1};const _=v?2*l.length:l.length;for(let i=0;i<_;++i){const _=this.attemptAnchorPlacement(l[i%l.length],e,c,u,s,b,w,h,a,g,i>=l.length,t,r,o,n,p,f,m);if(_&&(d=_.placedGlyphBoxes,d&&d.box&&d.box.length)){T=!0,P=_.shift;break}}return d};n((()=>c(j,d.iconBox,e.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return i&&U(i),o.allowVerticalPlacement&&!(R&&R.box&&R.box.length)&&t.numVerticalGlyphVertices>0&&i?c(i,d.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),R&&(T=R.box,C=R.offscreen,L=R.occluded);const u=i(R&&R.box);if(!T&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(o,e.anchor,t,u))}}else{const s=(i,n)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(o,s,i,new e.pointGeometry(0,0),v,h,a,g.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,n,t),this.placedOrientations[t.crossTileID]=n),l};n((()=>s(j,e.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?(U(i),s(i,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),i(R&&R.box&&R.box.length)}}if(z=R,T=z&&z.box&&z.box.length>0,C=z&&z.offscreen,L=z&&z.occluded,t.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=e.evaluateSizeForFeature(o.textSizeData,f,i),u=s.get("text-padding");D=this.collisionIndex.placeCollisionCircles(o,v,i,o.lineVertexArray,o.glyphOffsetArray,r,a,l,c,n,w,g.predicate,t.collisionCircleDiameter*r/e.ONE_EM,u,this.retainedQueryData[o.bucketInstanceId].tileID),T=v||D.circles.length>0&&!D.collisionDetected,C=C&&D.offscreen,L=D.occluded}if(d.iconFeatureIndex&&(N=d.iconFeatureIndex),d.iconBox){const t=t=>{U(t);const i=M&&P?It(P.x,P.y,b,w,this.transform.angle):new e.pointGeometry(0,0),n=o.getSymbolInstanceIconSize(m,this.transform.zoom,r);return this.collisionIndex.placeCollisionBox(o,n,t,i,x,h,a,g.predicate)};k&&k.box&&k.box.length&&d.verticalIconBox?(O=t(d.verticalIconBox),A=O.box.length>0):(O=t(d.iconBox),A=O.box.length>0),C=C&&O.offscreen,I=O.occluded}const V=_||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,G=y||0===t.numIconVertices;if(V||G?G?V||(A=A&&T):T=A&&T:A=T=A&&T,T&&z&&z.box&&this.collisionIndex.insertCollisionBox(z.box,s.get("text-ignore-placement"),o.bucketInstanceId,k&&k.box&&B?B:F,g.ID),A&&O&&this.collisionIndex.insertCollisionBox(O.box,s.get("icon-ignore-placement"),o.bucketInstanceId,N,g.ID),D&&(T&&this.collisionIndex.insertCollisionCircles(D.circles,s.get("text-ignore-placement"),o.bucketInstanceId,F,g.ID),n)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Et);for(let e=0;e=0;--t){const i=e[t];A(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:n.crossTileID)}markUsedOrientation(t,i,n){const r=i===e.WritingMode.horizontal||i===e.WritingMode.horizontalOnly?i:0,o=i===e.WritingMode.vertical?i:0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const e of s)t.text.placedSymbolArray.get(e).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new Tt(o,n,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Tt(null,n,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new Tt(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,i,n.collisionBoxArray)}}updateBucketOpacities(t,i,n){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),s=new Tt(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"),p="none"!==r.get("icon-text-fit"),d=new Tt(null,0,a&&(l||!t.hasIconData()||r.get("icon-optional")),l&&(a||!t.hasTextData()||r.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);const f=(e,t,i)=>{for(let n=0;n0||l>0,v=r.numIconVertices>0,x=this.placedOrientations[r.crossTileID],b=x===e.WritingMode.vertical,w=x===e.WritingMode.horizontal||x===e.WritingMode.horizontalOnly;if(!y&&!v||_.isHidden()||m++,y){const e=Ut(_.text);f(t.text,a,b?jt:e),f(t.text,l,w?jt:e);const i=_.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||b?1:0)})),r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(t,n.anchor,r,x);const o=this.placedOrientations[r.crossTileID];o&&(this.markUsedJustification(t,"left",r,o),this.markUsedOrientation(t,o,r))}if(v){const e=Ut(_.icon);r.placedIconSymbolIndex>=0&&(f(t.icon,r.numIconVertices,b?jt:e),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=_.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(f(t.icon,r.numVerticalIconVertices,w?jt:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=_.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[n];if(i){let n=new e.pointGeometry(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(c){const e=this.variableOffsets[g];e?(n=Lt(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&n._rotate(h?this.transform.angle:-this.transform.angle)):r=!1}o&&(r=!_.clipped),i.textBox&&Rt(t.textCollisionBox.collisionVertexArray,_.text.placed,!r||b,n.x,n.y),i.verticalTextBox&&Rt(t.textCollisionBox.collisionVertexArray,_.text.placed,!r||w,n.x,n.y)}const s=r&&Boolean(!w&&i.verticalIconBox);i.iconBox&&Rt(t.iconCollisionBox.collisionVertexArray,_.icon.placed,s,p?n.x:0,p?n.y:0),i.verticalIconBox&&Rt(t.iconCollisionBox.collisionVertexArray,_.icon.placed,!s,p?n.x:0,p?n.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Rt(e,t,i,n,r){e.emplaceBack(t?1:0,i?1:0,n||0,r||0),e.emplaceBack(t?1:0,i?1:0,n||0,r||0),e.emplaceBack(t?1:0,i?1:0,n||0,r||0),e.emplaceBack(t?1:0,i?1:0,n||0,r||0)}const kt=Math.pow(2,25),zt=Math.pow(2,24),Dt=Math.pow(2,17),Ot=Math.pow(2,16),Ft=Math.pow(2,9),Bt=Math.pow(2,8),Nt=Math.pow(2,1);function Ut(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*kt+t*zt+i*Dt+t*Ot+i*Ft+t*Bt+i*Nt+t}const jt=0;class Vt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,n,r){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const t=e.exported.now()-r;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=i[t[this._currentPlacementIndex]],r=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=r)&&(!e.maxzoom||e.maxzoom>r)){if(this._inProgressLayer||(this._inProgressLayer=new Vt(e)),this._inProgressLayer.continuePlacement(n[e.source],this.placement,this._showCollisionBoxes,e,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ht=512/e.EXTENT/2;class Wt{constructor(e,t,i){this.tileID=e,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;ie.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Xt=(t,i)=>e.emitValidationErrors(t,i&&i.filter((e=>"source.canvas"!==e.identifier))),Yt=e.pick(He,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Jt=e.pick(He,["setCenter","setZoom","setBearing","setPitch"]),Qt={version:8,layers:[],sources:{}},Kt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class ei extends e.Evented{constructor(t,i={}){super(),this.map=t,this.dispatcher=new R(je(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,i.localFontFamily?e.LocalGlyphMode.all:i.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,i.localFontFamily||i.localIdeographFontFamily),this.lineAtlas=new e.LineAtlas(256,512),this.crossTileSymbolIndex=new Zt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new e.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const n=this;this._rtlTextPluginCallback=ei.registerForPluginStateChange((t=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.triggerPluginCompletionEvent(t),i&&i.every((e=>e)))for(const e in n._sourceCaches){const t=n._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}}))}loadURL(t,i={}){this.fire(new e.Event("dataloading",{dataType:"style"}));const n="boolean"==typeof i.validate?i.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,i.accessToken);const r=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(r,((t,i)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):i&&this._load(i,n)}))}loadJSON(t,i={}){this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame((()=>{this._request=null,this._load(t,!1!==i.validate)}))}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Qt,!1)}_updateLayerCount(e,t){const i=t?1:-1;e.is3D()&&(this._num3DLayers+=i),"circle"===e.type&&(this._numCircleLayers+=i),"symbol"===e.type&&(this._numSymbolLayers+=i)}_load(t,i){if(i&&Xt(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=e.clone$1(t),this._updateMapProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const n=Ge(this.stylesheet.layers);this._order=n.map((e=>e.id)),this._layers={},this._serializedLayers={};for(let t of n)t=e.createStyleLayer(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize(),this._updateLayerCount(t,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new M(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 e.Event("data",{dataType:"style"})),this.fire(new e.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}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))}_loadSprite(t){this._spriteRequest=function(t,i,n){let r,o,s;const a=e.exported.devicePixelRatio>1?"@2x":"";let l=e.getJSON(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.ResourceType.SpriteJSON),((e,t)=>{l=null,s||(s=e,r=t,u())})),c=e.getImage(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.ResourceType.SpriteImage),((e,t)=>{c=null,s||(s=e,o=t,u())}));function u(){if(s)n(s);else if(r&&o){const t=e.exported.getImageData(o),i={};for(const n in r){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:p,content:d}=r[n],f=new e.RGBAImage({width:o,height:s});e.RGBAImage.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),i[n]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:p,content:d}}n(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,((t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(i)for(const e in i)this.imageManager.addImage(e,i[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new e.Event("data",{dataType:"style"}))}))}_validateLayer(t){const i=this.getSource(t.source);if(!i)return;const n=t.sourceLayer;n&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(n))&&this.fire(new e.ErrorEvent(new Error(`Source layer "${n}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&Kt[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const i=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const n={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];n[e]=t.used,t.used=!1}for(const e of this._order){const i=this._layers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this._getLayerSourceCache(i);e&&(e.used=!0)}const n=this.map.painter;if(n){const e=i.getProgramIds();if(!e)continue;const r=i.getProgramConfiguration(t.zoom);for(const t of e)n.useProgram(t,r)}}for(const t in n){const i=this._sourceCaches[t];n[t]!==i.used&&i.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new e.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(i){if(this._checkLoaded(),Xt(this,e.validateStyle(i)))return!1;(i=e.clone$1(i)).layers=Ge(i.layers);const n=function(e,i){if(!e)return[{command:He.setStyle,args:[i]}];let n=[];try{if(!t(e.version,i.version))return[{command:He.setStyle,args:[i]}];t(e.center,i.center)||n.push({command:He.setCenter,args:[i.center]}),t(e.zoom,i.zoom)||n.push({command:He.setZoom,args:[i.zoom]}),t(e.bearing,i.bearing)||n.push({command:He.setBearing,args:[i.bearing]}),t(e.pitch,i.pitch)||n.push({command:He.setPitch,args:[i.pitch]}),t(e.sprite,i.sprite)||n.push({command:He.setSprite,args:[i.sprite]}),t(e.glyphs,i.glyphs)||n.push({command:He.setGlyphs,args:[i.glyphs]}),t(e.transition,i.transition)||n.push({command:He.setTransition,args:[i.transition]}),t(e.light,i.light)||n.push({command:He.setLight,args:[i.light]}),t(e.fog,i.fog)||n.push({command:He.setFog,args:[i.fog]}),t(e.projection,i.projection)||n.push({command:He.setProjection,args:[i.projection]});const r={},o=[];!function(e,i,n,r){let o;for(o in i=i||{},e=e||{})e.hasOwnProperty(o)&&(i.hasOwnProperty(o)||qe(o,n,r));for(o in i)i.hasOwnProperty(o)&&(e.hasOwnProperty(o)?t(e[o],i[o])||("geojson"===e[o].type&&"geojson"===i[o].type&&Ze(e,i,o)?n.push({command:He.setGeoJSONSourceData,args:[o,i[o].data]}):$e(o,i,n,r)):We(o,i,n))}(e.sources,i.sources,o,r);const s=[];e.layers&&e.layers.forEach((e=>{e.source&&r[e.source]?n.push({command:He.removeLayer,args:[e.id]}):s.push(e)}));let a=e.terrain;a&&r[a.source]&&(n.push({command:He.setTerrain,args:[void 0]}),a=void 0),n=n.concat(o),t(a,i.terrain)||n.push({command:He.setTerrain,args:[i.terrain]}),function(e,i,n){i=i||[];const r=(e=e||[]).map(Ye),o=i.map(Ye),s=e.reduce(Je,{}),a=i.reduce(Je,{}),l=r.slice(),c=Object.create(null);let u,h,p,d,f,m,g;for(u=0,h=0;u!(e.command in Jt)));if(0===n.length)return!1;const r=n.filter((e=>!(e.command in Yt)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((e=>e.command)).join(", ")}.`);return n.forEach((e=>{"setTransition"!==e.command&&this[e.command].apply(this,e.args)})),this.stylesheet=i,this._updateMapProjection(),!0}addImage(t,i){return this.getImage(t)?this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,i),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new e.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new e.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,i,n={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(e.validateSource,`sources.${t}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=Re(t,i,this.dispatcher,this);r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:r.serialize(),sourceId:t})));const o=i=>{const n=(i?"symbol:":"other:")+t,o=this._sourceCaches[n]=new e.SourceCache(n,r,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[t]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),r.onAdd&&r.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const i=this.getSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const n=this._getSourceCaches(t);for(const t of n)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}addLayer(t,i,n={}){this._checkLoaded();const r=t.id;if(this.getLayer(r))return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${r}" already exists on this map`)));let o;if("custom"===t.type){if(Xt(this,e.validateCustomStyleLayer(t)))return;o=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.clone$1(t),t=e.extend(t,{source:r})),this._validate(e.validateLayer,`layers.${r}`,t,{arrayIndex:-1},n))return;o=e.createStyleLayer(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" 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 e=this._removedLayers[r];delete this._removedLayers[r],e.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(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const n=this._order.indexOf(t);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`))):(this._order.splice(r,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));i.setEventedParent(null),this._updateLayerCount(i,!1);const n=this._order.indexOf(t);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(t,i,n){this._checkLoaded();const r=this.getLayer(t);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(i,n,r={}){this._checkLoaded();const o=this.getLayer(i);if(o){if(!t(o.filter,n))return null==n?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(e.validateFilter,`layers.${o.id}.filter`,n,{layerType:o.type},r)||(o.filter=e.clone$1(n),this._updateLayer(o)))}else this.fire(new e.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){const i=this.getLayer(t);return i&&e.clone$1(i.filter)}setLayoutProperty(i,n,r,o={}){this._checkLoaded();const s=this.getLayer(i);s?t(s.getLayoutProperty(n),r)||(s.setLayoutProperty(n,r,o),this._updateLayer(s)):this.fire(new e.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,i){const n=this.getLayer(t);if(n)return n.getLayoutProperty(i);this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(i,n,r,o={}){this._checkLoaded();const s=this.getLayer(i);s?t(s.getPaintProperty(n),r)||(s.setPaintProperty(n,r,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[i]=!0):this.fire(new e.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const i=this.getLayer(e);return i&&i.getPaintProperty(t)}setFeatureState(t,i){this._checkLoaded();const n=t.source,r=t.sourceLayer,o=this.getSource(n);if(!o)return void this.fire(new e.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.type;if("geojson"===s&&r)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(n);for(const e of a)e.setFeatureState(r,t.id,i)}removeFeatureState(t,i){this._checkLoaded();const n=t.source,r=this.getSource(n);if(!r)return void this.fire(new e.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(n);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){this._checkLoaded();const i=t.source,n=t.sourceLayer,r=this.getSource(i);if(r){if("vector"!==r.type||n)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(i)[0].getFeatureState(n,t.id);this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new e.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return e.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const i=this._sourceCaches[e].getSource();t[i.id]||(t[i.id]=i.serialize())}return e.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,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:t,layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(t(o)){i[o]=r;for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t)}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),a=z.createFromScreenPoints(t,n);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;i.layers&&!r[t]||o.push(ze(this._sourceCaches[e],this._layers,this._serializedLayers,a,i,n,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(Oe);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,r.filter,r.layers,r.availableImages,e);for(const e in n){const t=a[e]=a[e]||[],r=n[e];r.sort(((e,t)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of r)t.push(e)}}for(const t in a)a[t].forEach((n=>{const r=n.feature,o=i(e[t]).getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=o}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,i){i&&i.filter&&this._validate(e.validateFilter,"querySourceFeatures.filter",i.filter,null,i);const n=this._getSourceCaches(t);let r=[];for(const e of n)r=r.concat(De(e,i));return r}addSourceType(e,t,i){return ei.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(ei.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(e,i={}){this._checkLoaded();const n=this.light.getLight();let r=!1;for(const i in e)if(!t(e[i],n[i])){r=!0;break}if(!r)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,i),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(i,n=1){if(this._checkLoaded(),!i)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===n){if("object"==typeof i.source){const t="terrain-dem-src";this.addSource(t,i.source),i=e.clone$1(i),i=e.extend(i,{source:t})}if(this._validate(e.validateTerrain,"terrain",i))return}if(!this.terrain||this.terrain&&n!==this.terrain.drapeRenderMode)this._createTerrain(i,n);else{const n=this.terrain,r=n.get();for(const t of Object.keys(e.spec.terrain))!i.hasOwnProperty(t)&&e.spec.terrain[t].default&&(i[t]=e.spec.terrain[t].default);for(const e in i)if(!t(i[e],r[e])){n.set(i),this.stylesheet.terrain=i;const e=this._setTransitionParameters({duration:0});n.updateTransitions(e);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new P(e,this.map.transform);this.stylesheet.fog=e;const i=this._setTransitionParameters({duration:0});t.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog,n=i.get();0===Object.keys(e).length&&i.set(e);for(const r in e)if(!t(e[r],n[r])){i.set(e),this.stylesheet.fog=e;const t=this._setTransitionParameters({duration:0});i.updateTransitions(t);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(t){return{now:e.exported.now(),transition:e.extend(t,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter((e=>this.isLayerDraped(this._layers[e]))),t=this._order.filter((e=>!this.isLayerDraped(this._layers[e])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const i=this.terrain=new E(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const n=this._setTransitionParameters({duration:0});i.updateTransitions(n)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,i,n,r,o={}){return(!o||!1!==o.validate)&&Xt(this,t.call(e.validateStyle,e.extend({key:i,style:this.serialize(),value:n,styleSpec:e.spec},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,i,n,r,o=!1){let s=!1,a=!1;const l={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!l[i.source]){const e=this._getLayerSourceCache(i);if(!e)continue;l[i.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const n=this.crossTileSymbolIndex.addLayer(i,l[i.source],t.center.lng,t.projection);s=s||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new e.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom))&&(this.pauseablePlacement=new Gt(t,this._order,o,i,n,r,this.placement,this.fog&&t.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(e.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.exported.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,i){this.imageManager.getImages(t.icons,i),this._updateTilesForChangedImages();const n=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};n(this._otherSourceCaches[t.source]),n(this._symbolSourceCaches[t.source])}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(t,i,n){return e.makeRequest(i,n)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this._getSourceCaches(t);return 0===i.length?(this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t}'`))),!1):i.every((e=>e.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)}}ei.getSourceType=function(e){return Pe[e]},ei.setSourceType=function(e,t){Pe[e]=t},ei.registerForPluginStateChange=e.registerForPluginStateChange;var ti="\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",ii="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;}";let ni={},ri={};ni=ci("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\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) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.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;vec4 bounds=vec4(d,vec2(1.0)-d);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",!0),ri=ci("#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","#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",!0);const oi=ci("\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;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\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."),si=ti,ai="\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 li={background:ci("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\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;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:ci("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\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_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:ci("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 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;attribute float a_scale;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);\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(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);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 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();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 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:ci("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:ci("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);\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;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=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:ci("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:ci("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:ci("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:ci("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:ci("#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 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:ci("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 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:ci("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\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 vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);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}"),fillPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\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 vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:ci("varying vec4 v_color;void main() {vec4 color=v_color;\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;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#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\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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));base=max(0.0,base);height=max(0.0,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\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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*(pos.z+lift));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);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\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 vec3 u_scale;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_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;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\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:ci("#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);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=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+f+f+i)-(a+d+d+g),(g+h+h+i)-(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:ci("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 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:ci("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;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\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_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\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);}}\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\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 mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\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_from\n#pragma mapbox: define lowp vec4 dash_to\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_from\n#pragma mapbox: initialize lowp vec4 dash_to\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 tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.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:ci("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.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_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\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_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\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:ci("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 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:ci("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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float 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) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetProjected_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);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_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 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\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:ci("#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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float 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) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetprojected_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);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_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 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\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:ci("#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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float 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);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_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 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\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:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\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;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:ci("#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;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:ci("\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}",ii),skyboxGradient:ci("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}",ii),skyboxCapture:ci("\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:ci("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() {\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);vec4 color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\nvec4 color=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;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_merc_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 merc_pos=a_merc_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector.xyz*height;vec4 globe=u_globe_matrix*vec4(globe_pos,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:ci("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);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat globe_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);\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));float 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\nfloat horizon_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 ci(e,t,i){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,o=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=e.match(r),a=t.match(r),l=ti.match(r);let c=a?a.concat(s):s;i||(ni.staticUniforms&&(c=ni.staticUniforms.concat(c)),ri.staticUniforms&&(c=ri.staticUniforms.concat(c))),c&&(c=c.concat(l));const u={};return{fragmentSource:e=e.replace(n,((e,t,i,n,r)=>(u[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nvarying ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = u_${r};\n#endif\n`))),vertexSource:t=t.replace(n,((e,t,i,n,r)=>{const o="float"===n?"vec2":"vec4",s=r.match(/color/)?"color":o;return u[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nattribute ${i} ${o} a_${r};\nvarying ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nattribute ${i} ${o} a_${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`})),staticAttributes:o,staticUniforms:c}}class ui{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,n,r,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!c&&e{const r=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=e.transform.angle);const l=!e.options.moving;return{u_matrix:n||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:hi(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:r,u_highlight:o,u_accent:s}})(t,n,r,t.terrain?i.projMatrix:null);t.prepareDrawProgram(l,h,i.toUnwrapped());const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=t.getTileBoundsBuffers(n);h.draw(l,c.TRIANGLES,o,s,a,e.CullFaceMode.disabled,p,r.id,d,f,m)}function di(t,i,n){if(!i.needsDEMTextureUpload)return;const r=t.context,o=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(n.stride);const s=n.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.Texture(r,s,o.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function fi(t,i,n,r,o,s){const a=t.context,l=a.gl;if(!i.dem)return;const c=i.dem;if(a.activeTexture.set(l.TEXTURE1),di(t,i,c),!i.demTexture)return;i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const u=c.dim;a.activeTexture.set(l.TEXTURE0);let h=i.fbo;if(!h){const t=new e.Texture(a,{width:u,height:u,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=i.fbo=a.createFramebuffer(u,u,!0),h.colorAttachment.set(t.texture)}a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,u,u]);const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,r,o,s,e.CullFaceMode.disabled,((t,i)=>{const n=i.stride,r=e.create();return e.ortho(r,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(r,r,[0,-e.EXTENT,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ,u_unpack:i.unpackVector}})(i.tileID,c),n.id,p,d,f),i.needsHillshadePrepare=!1}const mi=(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image0:new e.Uniform1i(t,i.u_image0),u_skirt_height:new e.Uniform1f(t,i.u_skirt_height)}),gi=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),_i=(e,t,i,n,r,o,s,a,l,c,u,h,p,d)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(n),u_merc_matrix:i,u_zoom_transition:r,u_merc_center: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:p,u_grid_matrix:d?Float32Array.from(d):new Float32Array(9)});function yi(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const vi=new class{constructor(){this.operations={}}newMorphing(e,t,i,n,r){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:n,phase:0,duration:r,from:t,to:i,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},xi={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function bi(e,t){const i=1<({u_matrix:e});function Mi(t,i,n,r,o){if(o>0){const s=e.exported.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=n.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),p=h&&t.refreshedUponExpiration?1:e.clamp(h?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}class Ti extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new R(je(),null),n=Re("mock-dem",t,i,e.style);super("mock-dem",n,!1),n.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Si extends e.SourceCache{constructor(e){const t=Re("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new R(je(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,i,n){if(t.freezeTileCoverage)return;this.transform=t;const r=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,n)=>{if(i[n.key]="",!this._tiles[n.key]){const i=new e.Tile(n,this._source.tileSize*n.overscaleFactor(),t.tileZoom);i.state="loaded",this._tiles[n.key]=i}return i}),{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ei extends e.OverscaledTileID{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i}}class Ai extends e.Elevation{constructor(t,i){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[n,r,o]=function(t){const i=new e.StructArrayLayout4i8,n=new e.StructArrayLayout3ui6,r=131;i.reserve(17161),n.reserve(33800);const o=e.EXTENT/128,s=e.EXTENT+o/2,a=s+o;for(let t=-o;ts||t<0||t>s?24575:0,o=e.clamp(Math.round(n),0,e.EXTENT),a=e.clamp(Math.round(t),0,e.EXTENT);i.emplaceBack(o+r,a,o,a)}const l=(e,t)=>{const i=t*r+e;n.emplaceBack(i+1,i,i+r),n.emplaceBack(i+r,i+r+1,i+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)})),[i,n,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(n,e.boundsAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=e.SegmentVector.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,n.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Si(i.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,0,e.EXTENT,0,e.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new e.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Ti(i.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(t,i,n){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const r=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const o=()=>{this.sourceCache.used&&e.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 t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),i.updateElevation(!n),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&e.warnOnce(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map((e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=n.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,i){const n=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.pointGeometry(n.x,n.y);t.sort(((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const n=new e.pointGeometry(t.canonical.x+(1<{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const n=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(n)}this.proxiedCoords[i.id]=r.map((e=>new Ei(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const n=this.terrainTileForTile[i],r=n.dem;!r||n.demTexture&&!n.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),di(this.painter,n,r))}}_prepareDemTileUniforms(e,t,i,n){if(!t||null==t.demTexture)return!1;const r=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-r.z),s=n||"";return i[`u_dem_tl${s}`]=[r.x*o%1,r.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,i=t.gl;if(!this._emptyDepthBufferTexture){const n=new e.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.Texture(t,n,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const n=i.dem.tree.minimums[0];return n>0&&e++,t+n}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const n=this._getLoadedAreaMinimum(),r=new e.RGBAImage({width:1,height:1},new Uint8Array(e.DEMData.pack(n,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(r,{premultiply:!1}):o=this._emptyDEMTexture=new e.Texture(t,r,i.RGBA,{premultiply:!1}),o}setupElevationDraw(t,i,n){const r=this.painter.context,o=r.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.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,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const l=this.painter.transform,c=l.projection,u=t.tileID.canonical;s.u_tile_tl_up=c.upVector(u,0,0),s.u_tile_tr_up=c.upVector(u,e.EXTENT,0),s.u_tile_br_up=c.upVector(u,e.EXTENT,e.EXTENT),s.u_tile_bl_up=c.upVector(u,0,e.EXTENT),s.u_tile_up_scale=n&&n.useDenormalizedUpVectorScale?e.GLOBE_METERS_TO_ECEF:c.upVectorScale(u,l.center.lat,l.worldSize).metersToTile;let h=null,p=null,d=1;if(n&&n.morphing&&this._useVertexMorphing){const e=n.morphing.srcDemTile,i=n.morphing.dstDemTile;d=n.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(p=e),this._prepareDemTileUniforms(t,i,s)&&(h=i))}if(p&&h?(r.activeTexture.set(o.TEXTURE2),h.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),r.activeTexture.set(o.TEXTURE4),p.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_dem_lerp=d):(h=this.terrainTileForTile[t.tileID.key],r.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(t,h,s)?h.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),r.activeTexture.set(o.TEXTURE3),n&&n.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]),n&&n.useMeterToDem&&h){const t=(1<{if(c===e)return;const n=[xi[e],"PROJECTION_GLOBE_VIEW"];p&&n.push("CUSTOM_ANTIALIASING"),i&&n.push(xi[u]),l=t.useProgram("globeRaster",null,n),c=e},f=t.colorModeForRenderPass(),m=new e.DepthMode(a.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);vi.update(o);const g=e.calculateGlobeMercatorMatrix(h),_=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],y=t.globeSharedBuffers,v=[h.width*e.exported.devicePixelRatio,h.height*e.exported.devicePixelRatio];if((u?[!1,!0]:[!1]).forEach((u=>{c=-1;const p=u?a.LINES:a.TRIANGLES;for(const c of r){const r=n.getTile(c),x=e.StencilMode.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];yi(b,w)&&vi.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const M=vi.getMorphValuesForProxy(c.key),T=M?1:0,S={useDenormalizedUpVectorScale:!0};M&&e.extend$1(S,{morphing:{srcDemTile:M.from,dstDemTile:M.to,phase:e.easeCubicInOut(M.phase)}});const E=Float32Array.from(h.globeMatrix),A=e.globeTileLatLngCorners(c.canonical),C=e.getLatitudinalLod((A[0][0]+A[1][0])/2),L=e.getGridMatrix(c.canonical,A,C),I=e.globeNormalizeECEF(e.globeTileBounds(c.canonical)),P=_i(h.projMatrix,E,g,I,e.globeToMercatorTransition(h.zoom),_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,L);if(d(T,u),i.setupElevationDraw(r,l,S),t.prepareDrawProgram(s,l,c.toUnwrapped()),y){const[i,n,r]=u?y.getWirefameBuffers(t.context,C):y.getGridBuffers(C);l.draw(s,p,m,x,f,e.CullFaceMode.backCCW,P,"globe_raster",i,n,r)}}})),y){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&o.push("CUSTOM_ANTIALIASING"),l=t.useProgram("globeRaster",null,o);for(const o of r){const{x:r,y:c,z:u}=o.canonical,p=0===c,d=c===(1<t.draw(s,a.TRIANGLES,m,e.StencilMode.disabled,f,e.CullFaceMode.disabled,_i(h.projMatrix,y,y,M,0,_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,{}),t.prepareDrawProgram(s,l,o.toUnwrapped()),p&&T(l,g),d&&(y=e.scale(e.create(),y,[1,-1,1]),T(l,x))}}}}(t,i,n,r,o);else{const s=t.context,a=s.gl;let l,c;const u=t.options.showTerrainWireframe?2:0,h=(e,i)=>{if(c===e)return;const n=[xi[e]];i&&n.push(xi[u]),l=t.useProgram("terrainRaster",null,n),c=e},p=t.colorModeForRenderPass(),d=new e.DepthMode(a.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);vi.update(o);const f=t.transform,m=6*Math.pow(1.5,22-f.zoom)*i.exaggeration();(u?[!1,!0]:[!1]).forEach((u=>{c=-1;const g=u?a.LINES:a.TRIANGLES,[_,y]=u?i.getWirefameBuffer():[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=n.getTile(c),v=e.StencilMode.disabled,x=i.prevTerrainTileForTile[c.key],b=i.terrainTileForTile[c.key];yi(x,b)&&vi.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 w=vi.getMorphValuesForProxy(c.key),M=w?1:0;let T;w&&(T={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:e.easeCubicInOut(w.phase)}});const S=gi(c.projMatrix,bi(c.canonical,f.renderWorldCopies)?m/10:m);h(M,u),i.setupElevationDraw(r,l,T),t.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,g,d,v,p,e.CullFaceMode.backCCW,S,"terrain_raster",i.gridBuffer,_,y)}}))}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,n=this.painter.context,r=this.proxySourceCache,o=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=[],l=i.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][t]:void 0,p=void 0!==h?r.renderCache[h]:this.pool[c++],d=void 0!==h;if(o.texture=p.tex,d&&!p.dirty){a.push(o.tileID);continue}let f;n.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(n.clear({color:e.Color.transparent,stencil:0}),p.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._layers[l[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style._getLayerSourceCache(t),o=r?this.proxyToSource[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,p.fb.width,p.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(p,o,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s)}this.renderedToTile?(p.dirty=!0,a.push(o.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let i,n=0,r=0,o=!1;for(let s=0;se.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const n=this._visibleDemTiles.filter((e=>e.dem)).map((n=>{const r=n.tileID,o=Math.pow(2,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:n.dem.tree.raycastRoot(l,u,c,h,e,t,i),tile:n}}));n.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const r of n){if(null==r.t)return null;const n=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=n)return n}return null}_createFBO(){const t=this.painter.context,i=t.gl,n=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.Texture(t,{width:n[0],height:n[1],data:null},i.RGBA);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(n[0],n[1],!1);return o.colorAttachment.set(r.texture),o.depthAttachment=new Te(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,n[0],n[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._layers[e],i=t.isHidden(this.painter.transform.zoom),n=t.getCrossfadeParameters(),r=!!n&&1!==n.t,o=t.hasTransition();return"custom"!==t.type&&!i&&(r||o)}))}_clearRasterFadeFromRenderCache(){let e=!1;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t]._source instanceof Ae){e=!0;break}if(e)for(let e=0;et.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i=0;r--){const o=i[r];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],r=this.proxyToSource[o.key];let s=0;for(const e in r){const t=r[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||n[e]&&n[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length}}const r=[...this._drapedRenderBatches];r.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of r)for(const n of i){if(t.proxyCachedFBO[n.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[n.key]={},t.proxyCachedFBO[n.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,n){if(!n||!this._sourceTilesOverlap[n.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,o=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.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,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.StencilMode.disabled}_renderTileClippingMasks(t,i){const n=this.painter,r=this.painter.context,o=r.gl;n._tileClippingMaskIDs={},r.setColorMode(e.ColorMode.disabled),r.setDepthMode(e.DepthMode.disabled);const s=n.useProgram("clippingMask");for(const a of t){const t=n._tileClippingMaskIDs[a.key]=--i;s.draw(r,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,wi(a.projMatrix),"$clipping",n.tileExtentBuffer,n.quadTriangleIndexBuffer,n.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const n=[t.x,t.y,1,1];e.transformMat4$1(n,n,i.pixelMatrixInverse),e.scale$1(n,n,1/n[3]),n[0]/=i.worldSize,n[1]/=i.worldSize;const r=i._camera.position,o=e.mercatorZfromAltitude(1,i.center.lat),s=[r[0],r[1],r[2]/o,0],a=e.subtract([],n.slice(0,3),s);e.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const t=this.painter,i=t.context,n=this.proxySourceCache,r=Math.ceil(t.width),o=Math.ceil(t.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 t=i.gl,n=i.createFramebuffer(r,o,!0);i.activeTexture.set(t.TEXTURE0);const s=new e.Texture(i,{width:r,height:o,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),n.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,r,o);n.depthAttachment.set(a),this._depthFBO=n,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,r,o]),function(t,i,n,r){if("globe"===t.transform.projection.name)return;const o=t.context,s=o.gl;o.clear({depth:1});const a=t.useProgram("terrainDepth"),l=new e.DepthMode(s.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const t of r){const r=n.getTile(t),c=gi(t.projMatrix,0);i.setupElevationDraw(r,a),a.draw(o,s.TRIANGLES,l,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}}(t,this,n,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof Ie)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const n=this.proxiedCoords[e.id]=[],r=this.proxyCoords;for(let t=0;t(e.min.x=Math.min(e.min.x,t.x-a.x),e.min.y=Math.min(e.min.y,t.y-a.y),e.max.x=Math.max(e.max.x,t.x-a.x),e.max.y=Math.max(e.max.y,t.y-a.y),e)),{min:new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(t,i)=>{const n=t.wrap+t.canonical.x/(1<s+l.max.x||r+oa+l.max.y};for(let e=0;ee.key===i.tileID.key));if(e)return e}if(i.tileID.key!==t.key){const n=t.canonical.z-i.tileID.canonical.z;let o,s,a;r=e.create();const l=i.tileID.wrap-t.wrap<0?(o=e.EXTENT>>n,s=o*((i.tileID.canonical.x<=r){const n=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.OverscaledTileID(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n)):0!==n&&(a=r,s=new e.OverscaledTileID(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n))}s.key!==t.key&&(c.push(s.key),n=i.getTile(s))}const u=e=>{c.forEach((t=>{r[t]=e})),c.length=0};for(a-=1;a>=l&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const e=s.calculateScaledKey(a);if(n=i.getTileByID(e),n&&n.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):n=i.getTileByID(t)}return u(n?n.tileID.key:null),n&&n.hasData()?n:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let i=0;const n=new e.StructArrayLayout2ui4,r=131;for(let e=1;e<129;e++){for(let t=1;t<129;t++)i=e*r+t,n.emplaceBack(i,i+1),n.emplaceBack(i,i+r),n.emplaceBack(i+1,i+r),128===e&&n.emplaceBack(i+r,i+r+1);n.emplaceBack(i+1,i+1+r)}return n}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function Ci(e){const t=[];for(let i=0;i`#define ${e}`)));const g=m.concat(t.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(ai):ai,ai,si,oi.fragmentSource,ri.fragmentSource,n.fragmentSource).join("\n"),_=m.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",si,oi.vertexSource,ri.vertexSource,ni.vertexSource,n.vertexSource).join("\n"),y=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(y,g),a.compileShader(y),a.attachShader(this.program,y);const v=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(v,_),a.compileShader(v),a.attachShader(this.program,v),this.attributes={};const x={};this.numAttributes=u.length;for(let e=0;e({u_dem:new e.Uniform1i(t,i.u_dem),u_dem_prev:new e.Uniform1i(t,i.u_dem_prev),u_dem_unpack:new e.Uniform4f(t,i.u_dem_unpack),u_dem_tl:new e.Uniform2f(t,i.u_dem_tl),u_dem_scale:new e.Uniform1f(t,i.u_dem_scale),u_dem_tl_prev:new e.Uniform2f(t,i.u_dem_tl_prev),u_dem_scale_prev:new e.Uniform1f(t,i.u_dem_scale_prev),u_dem_size:new e.Uniform1f(t,i.u_dem_size),u_dem_lerp:new e.Uniform1f(t,i.u_dem_lerp),u_exaggeration:new e.Uniform1f(t,i.u_exaggeration),u_depth:new e.Uniform1i(t,i.u_depth),u_depth_size_inv:new e.Uniform2f(t,i.u_depth_size_inv),u_meter_to_dem:new e.Uniform1f(t,i.u_meter_to_dem),u_label_plane_matrix_inv:new e.UniformMatrix4f(t,i.u_label_plane_matrix_inv),u_tile_tl_up:new e.Uniform3f(t,i.u_tile_tl_up),u_tile_tr_up:new e.Uniform3f(t,i.u_tile_tr_up),u_tile_br_up:new e.Uniform3f(t,i.u_tile_br_up),u_tile_bl_up:new e.Uniform3f(t,i.u_tile_bl_up),u_tile_up_scale:new e.Uniform1f(t,i.u_tile_up_scale)}))(t,x)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((t,i)=>({u_fog_matrix:new e.UniformMatrix4f(t,i.u_fog_matrix),u_fog_range:new e.Uniform2f(t,i.u_fog_range),u_fog_color:new e.Uniform4f(t,i.u_fog_color),u_fog_horizon_blend:new e.Uniform1f(t,i.u_fog_horizon_blend),u_fog_temporal_offset:new e.Uniform1f(t,i.u_fog_temporal_offset),u_frustum_tl:new e.Uniform3f(t,i.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,i.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,i.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,i.u_frustum_bl),u_globe_pos:new e.Uniform3f(t,i.u_globe_pos),u_globe_radius:new e.Uniform1f(t,i.u_globe_radius),u_globe_transition:new e.Uniform1f(t,i.u_globe_transition),u_is_globe:new e.Uniform1i(t,i.u_is_globe),u_viewport:new e.Uniform2f(t,i.u_viewport)}))(t,x))}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].location&&i[e].set(t[e])}}draw(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g){const _=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(n),e.setColorMode(r),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(s[e]);d&&d.setUniforms(e,this.binderUniforms,h,{zoom:p});const y={[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t];for(const i of u.get()){const n=i.vaos||(i.vaos={});(n[a]||(n[a]=new ui)).bind(e,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f,m,g),_.drawElements(t,i.primitiveLength*y,_.UNSIGNED_SHORT,i.primitiveOffset*y*2)}}}function Ii(e,t,i){const n=1/k(i,1,t.transform.tileZoom),r=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,s=o*(i.tileID.canonical.x+i.tileID.wrap*r),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[n,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const Pi=e.create(),Ri=(t,i,n,r,o,s,a,l,c)=>{const u=i.style.light,h=u.properties.get("position"),p=[h.x,h.y,h.z],d=e.create$1();"viewport"===u.properties.get("anchor")&&(e.fromRotation(d,-i.transform.angle),e.transformMat3(p,p,d));const f=u.properties.get("color"),m=i.transform,g={u_matrix:t,u_lightpos:p,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[f.r,f.g,f.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Pi,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===m.projection.name&&(g.u_tile_id=[o.canonical.x,o.canonical.y,1<{const p=Ri(t,i,n,r,o,l,c,u,h),d={u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8};return e.extend(p,Ii(s,i,a),d)},zi=e=>({u_matrix:e}),Di=(t,i,n,r)=>e.extend(zi(t),Ii(n,i,r)),Oi=(e,t)=>({u_matrix:e,u_world:t}),Fi=(t,i,n,r,o)=>e.extend(Di(t,i,n,r),{u_world:o}),Bi=e.create(),Ni=(t,i,n,r,o,s)=>{const a=t.transform,l="globe"===a.projection.name;let c;if("map"===s.paint.get("circle-pitch-alignment"))if(l){const t=e.globePixelsToTileUnits(a.zoom,i.canonical)*a._projectionScaler;c=Float32Array.from([t,0,0,t])}else c=a.calculatePixelsToTileUnitsMatrix(n);else c=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:t.translatePosMatrix(i.projMatrix,n,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:c,u_inv_rot_matrix:Bi,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=[i.canonical.x,i.canonical.y,1<{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},ji=(t,i,n,r)=>{const o=e.EXTENT/n.tileSize;return{u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(r),u_extrude_scale:[i.pixelsToGLUnits[0]/o,i.pixelsToGLUnits[1]/o]}},Vi=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Gi=e.create(),Hi=(t,i,n,r,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.globePixelsToTileUnits(l.zoom,i.canonical)*l._projectionScaler:k(n,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:Gi,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=[i.canonical.x,i.canonical.y,1<{const l=e.transform,c=l.calculatePixelsToTileUnitsMatrix(t),u={u_matrix:Zi(e,t,i,r),u_pixels_to_tile_units:c,u_device_pixel_ratio:s,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:a};if(Xi(i)){const i=$i(t,e.transform);u.u_texsize=t.lineAtlasTexture.size,u.u_scale=[i,n.fromScale,n.toScale],u.u_mix=n.t}return u},qi=(e,t,i,n,r,o)=>{const s=e.transform,a=$i(t,s);return{u_matrix:Zi(e,t,i,r),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:o,u_image:0,u_scale:[a,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function $i(e,t){return 1/k(e,1,t.tileZoom)}function Zi(e,t,i,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function Xi(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const Yi=(e,t,i,n,r,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:i,u_fade_t:n.mix,u_opacity:n.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:Ji(r.paint.get("raster-hue-rotate")),u_perspective_transform:o};var s,a};function Ji(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Qi=e.create(),Ki=(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g)=>{const _=o.transform,y={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_rotate_symbol:+n,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:Qi,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Qi,u_up_vector:[0,-1,0]};return"globe"===g.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<e.extend(Ki(t,i,n,r,o,s,a,l,c,u,p,d,f,m,g,_),{u_gamma_scale:r?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+h}),tn=(t,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g)=>e.extend(en(t,i,n,r,o,s,a,l,!0,c,!0,h,p,d,f,m,g),{u_texsize_icon:u,u_texture_icon:1}),nn=(e,t,i)=>({u_matrix:e,u_opacity:t,u_color:i}),rn=(t,i,n,r,o,s)=>e.extend(function(e,t,i,n){const r=i.imageManager.getPattern(e.from.toString()),o=i.imageManager.getPattern(e.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(n.tileID.canonical.x+n.tileID.wrap*l),h=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:r.tl,u_pattern_br_a:r.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,a],u_mix:t.t,u_pattern_size_a:r.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/k(n,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(r,s,n,o),{u_matrix:t,u_opacity:i}),on={fillExtrusion:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_lightpos:new e.Uniform3f(t,i.u_lightpos),u_lightintensity:new e.Uniform1f(t,i.u_lightintensity),u_lightcolor:new e.Uniform3f(t,i.u_lightcolor),u_vertical_gradient:new e.Uniform1f(t,i.u_vertical_gradient),u_opacity:new e.Uniform1f(t,i.u_opacity),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_up_dir:new e.Uniform3f(t,i.u_up_dir),u_height_lift:new e.Uniform1f(t,i.u_height_lift)}),fillExtrusionPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_lightpos:new e.Uniform3f(t,i.u_lightpos),u_lightintensity:new e.Uniform1f(t,i.u_lightintensity),u_lightcolor:new e.Uniform3f(t,i.u_lightcolor),u_vertical_gradient:new e.Uniform1f(t,i.u_vertical_gradient),u_height_factor:new e.Uniform1f(t,i.u_height_factor),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_up_dir:new e.Uniform3f(t,i.u_up_dir),u_height_lift:new e.Uniform1f(t,i.u_height_lift),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade),u_opacity:new e.Uniform1f(t,i.u_opacity)}),fill:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix)}),fillPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade)}),fillOutline:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_world:new e.Uniform2f(t,i.u_world)}),fillOutlinePattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_world:new e.Uniform2f(t,i.u_world),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade)}),circle:(t,i)=>({u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_extrude_scale:new e.UniformMatrix2f(t,i.u_extrude_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_up_dir:new e.Uniform3f(t,i.u_up_dir)}),collisionBox:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_extrude_scale:new e.Uniform2f(t,i.u_extrude_scale)}),collisionCircle:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_inv_matrix:new e.UniformMatrix4f(t,i.u_inv_matrix),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_viewport_size:new e.Uniform2f(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.UniformColor(t,i.u_color),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_overlay:new e.Uniform1i(t,i.u_overlay),u_overlay_scale:new e.Uniform1f(t,i.u_overlay_scale)}),clippingMask:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix)}),heatmap:(t,i)=>({u_extrude_scale:new e.Uniform1f(t,i.u_extrude_scale),u_intensity:new e.Uniform1f(t,i.u_intensity),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_up_dir:new e.Uniform3f(t,i.u_up_dir)}),heatmapTexture:(t,i)=>({u_image:new e.Uniform1i(t,i.u_image),u_color_ramp:new e.Uniform1i(t,i.u_color_ramp),u_opacity:new e.Uniform1f(t,i.u_opacity)}),hillshade:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_latrange:new e.Uniform2f(t,i.u_latrange),u_light:new e.Uniform2f(t,i.u_light),u_shadow:new e.UniformColor(t,i.u_shadow),u_highlight:new e.UniformColor(t,i.u_highlight),u_accent:new e.UniformColor(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_dimension:new e.Uniform2f(t,i.u_dimension),u_zoom:new e.Uniform1f(t,i.u_zoom),u_unpack:new e.Uniform4f(t,i.u_unpack)}),line:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_pixels_to_tile_units:new e.UniformMatrix2f(t,i.u_pixels_to_tile_units),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.Uniform2f(t,i.u_units_to_pixels),u_dash_image:new e.Uniform1i(t,i.u_dash_image),u_gradient_image:new e.Uniform1i(t,i.u_gradient_image),u_image_height:new e.Uniform1f(t,i.u_image_height),u_texsize:new e.Uniform2f(t,i.u_texsize),u_scale:new e.Uniform3f(t,i.u_scale),u_mix:new e.Uniform1f(t,i.u_mix),u_alpha_discard_threshold:new e.Uniform1f(t,i.u_alpha_discard_threshold),u_trim_offset:new e.Uniform2f(t,i.u_trim_offset)}),linePattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixels_to_tile_units:new e.UniformMatrix2f(t,i.u_pixels_to_tile_units),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_image:new e.Uniform1i(t,i.u_image),u_units_to_pixels:new e.Uniform2f(t,i.u_units_to_pixels),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade),u_alpha_discard_threshold:new e.Uniform1f(t,i.u_alpha_discard_threshold)}),raster:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_tl_parent:new e.Uniform2f(t,i.u_tl_parent),u_scale_parent:new e.Uniform1f(t,i.u_scale_parent),u_fade_t:new e.Uniform1f(t,i.u_fade_t),u_opacity:new e.Uniform1f(t,i.u_opacity),u_image0:new e.Uniform1i(t,i.u_image0),u_image1:new e.Uniform1i(t,i.u_image1),u_brightness_low:new e.Uniform1f(t,i.u_brightness_low),u_brightness_high:new e.Uniform1f(t,i.u_brightness_high),u_saturation_factor:new e.Uniform1f(t,i.u_saturation_factor),u_contrast_factor:new e.Uniform1f(t,i.u_contrast_factor),u_spin_weights:new e.Uniform3f(t,i.u_spin_weights),u_perspective_transform:new e.Uniform2f(t,i.u_perspective_transform)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_camera_forward:new e.Uniform3f(t,i.u_camera_forward),u_tile_matrix:new e.UniformMatrix4f(t,i.u_tile_matrix),u_up_vector:new e.Uniform3f(t,i.u_up_vector),u_ecef_origin:new e.Uniform3f(t,i.u_ecef_origin),u_texture:new e.Uniform1i(t,i.u_texture)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_texture:new e.Uniform1i(t,i.u_texture),u_gamma_scale:new e.Uniform1f(t,i.u_gamma_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_camera_forward:new e.Uniform3f(t,i.u_camera_forward),u_tile_matrix:new e.UniformMatrix4f(t,i.u_tile_matrix),u_up_vector:new e.Uniform3f(t,i.u_up_vector),u_ecef_origin:new e.Uniform3f(t,i.u_ecef_origin),u_is_halo:new e.Uniform1i(t,i.u_is_halo)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_texsize_icon:new e.Uniform2f(t,i.u_texsize_icon),u_texture:new e.Uniform1i(t,i.u_texture),u_texture_icon:new e.Uniform1i(t,i.u_texture_icon),u_gamma_scale:new e.Uniform1f(t,i.u_gamma_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_is_halo:new e.Uniform1i(t,i.u_is_halo)}),background:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_opacity:new e.Uniform1f(t,i.u_opacity),u_color:new e.UniformColor(t,i.u_color)}),backgroundPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_opacity:new e.Uniform1f(t,i.u_opacity),u_image:new e.Uniform1i(t,i.u_image),u_pattern_tl_a:new e.Uniform2f(t,i.u_pattern_tl_a),u_pattern_br_a:new e.Uniform2f(t,i.u_pattern_br_a),u_pattern_tl_b:new e.Uniform2f(t,i.u_pattern_tl_b),u_pattern_br_b:new e.Uniform2f(t,i.u_pattern_br_b),u_texsize:new e.Uniform2f(t,i.u_texsize),u_mix:new e.Uniform1f(t,i.u_mix),u_pattern_size_a:new e.Uniform2f(t,i.u_pattern_size_a),u_pattern_size_b:new e.Uniform2f(t,i.u_pattern_size_b),u_scale_a:new e.Uniform1f(t,i.u_scale_a),u_scale_b:new e.Uniform1f(t,i.u_scale_b),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.Uniform1f(t,i.u_tile_units_to_pixels)}),terrainRaster:mi,terrainDepth:mi,skybox:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_sun_direction:new e.Uniform3f(t,i.u_sun_direction),u_cubemap:new e.Uniform1i(t,i.u_cubemap),u_opacity:new e.Uniform1f(t,i.u_opacity),u_temporal_offset:new e.Uniform1f(t,i.u_temporal_offset)}),skyboxGradient:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_color_ramp:new e.Uniform1i(t,i.u_color_ramp),u_center_direction:new e.Uniform3f(t,i.u_center_direction),u_radius:new e.Uniform1f(t,i.u_radius),u_opacity:new e.Uniform1f(t,i.u_opacity),u_temporal_offset:new e.Uniform1f(t,i.u_temporal_offset)}),skyboxCapture:(t,i)=>({u_matrix_3f:new e.UniformMatrix3f(t,i.u_matrix_3f),u_sun_direction:new e.Uniform3f(t,i.u_sun_direction),u_sun_intensity:new e.Uniform1f(t,i.u_sun_intensity),u_color_tint_r:new e.Uniform4f(t,i.u_color_tint_r),u_color_tint_m:new e.Uniform4f(t,i.u_color_tint_m),u_luminance:new e.Uniform1f(t,i.u_luminance)}),globeRaster:(t,i)=>({u_proj_matrix:new e.UniformMatrix4f(t,i.u_proj_matrix),u_globe_matrix:new e.UniformMatrix4f(t,i.u_globe_matrix),u_normalize_matrix:new e.UniformMatrix4f(t,i.u_normalize_matrix),u_merc_matrix:new e.UniformMatrix4f(t,i.u_merc_matrix),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_image0:new e.Uniform1i(t,i.u_image0),u_grid_matrix:new e.UniformMatrix3f(t,i.u_grid_matrix),u_frustum_tl:new e.Uniform3f(t,i.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,i.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,i.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,i.u_frustum_bl),u_globe_pos:new e.Uniform3f(t,i.u_globe_pos),u_globe_radius:new e.Uniform1f(t,i.u_globe_radius),u_viewport:new e.Uniform2f(t,i.u_viewport)}),globeAtmosphere:(t,i)=>({u_frustum_tl:new e.Uniform3f(t,i.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,i.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,i.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,i.u_frustum_bl),u_horizon:new e.Uniform1f(t,i.u_horizon),u_transition:new e.Uniform1f(t,i.u_transition),u_fadeout_range:new e.Uniform1f(t,i.u_fadeout_range),u_color:new e.Uniform4f(t,i.u_color),u_high_color:new e.Uniform4f(t,i.u_high_color),u_space_color:new e.Uniform4f(t,i.u_space_color),u_star_intensity:new e.Uniform1f(t,i.u_star_intensity),u_star_density:new e.Uniform1f(t,i.u_star_density),u_star_size:new e.Uniform1f(t,i.u_star_size),u_temporal_offset:new e.Uniform1f(t,i.u_temporal_offset),u_horizon_angle:new e.Uniform1f(t,i.u_horizon_angle),u_rotation_matrix:new e.UniformMatrix4f(t,i.u_rotation_matrix)})};let sn;function an(t,i,n,r,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=t.useProgram("collisionBox"),p=[];let d=0,f=0;for(let m=0;m0){const t=e.create(),i=x;e.mul(t,y.placementInvProjMatrix,u.glCoordMatrix),e.mul(t,t,y.placementViewportMatrix),p.push({circleArray:w,circleOffset:f,transform:i,invTransform:t,projection:y.getProjection()}),d+=w.length/4,f=d}b&&(t.terrain&&t.terrain.setupElevationDraw(_,h),h.draw(l,c.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,ji(x,u,_,y.getProjection()),n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,u.zoom,null,b.collisionVertexBuffer,b.collisionVertexBufferExt))}if(!a||!p.length)return;const m=t.useProgram("collisionCircle"),g=new e.StructArrayLayout2f1f2i16;g.resize(4*d),g._trim();let _=0;for(const e of p)for(let t=0;t=0&&(m[v.associatedIconIndex]={shiftedAnchor:I,angle:P})}else gt(v.numGlyphs,d)}if(h){f.clear();const i=t.icon.placedSymbolArray;for(let t=0;t[0,0,0],n=it(U,r.tileID.canonical,_,g,m,c.getProjection(),j);lt(c,U,t,o,n,H,_,u,i,l)}const $=y||o&&T||q,Z=t.translatePosMatrix(U,r,s,a),X=$?ln:V,Y=t.translatePosMatrix(H,r,s,a,!0),J=c.getProjection().createInversionMatrix(m,l.canonical),Q=[];t.terrain&&_&&Q.push("PITCH_WITH_MAP_TERRAIN"),F&&Q.push("PROJECTION_GLOBE_VIEW"),$&&Q.push("PROJECTED_POS_ON_VIEWPORT");const K=d&&0!==n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let ee;ee=d?c.iconsInText?tn(w.kind,I,v,_,t,Z,X,Y,P,D,l,N,M,J,B,c.getProjection()):en(w.kind,I,v,_,t,Z,X,Y,o,P,!0,l,N,M,J,B,c.getProjection()):Ki(w.kind,I,v,_,t,Z,X,Y,o,P,l,N,M,J,B,c.getProjection());const te={program:t.useProgram(hn(d,o,c),p,Q),buffers:h,uniformValues:ee,atlasTexture:R,atlasTextureIcon:O,atlasInterpolation:k,atlasInterpolationIcon:z,isSDF:d,hasHalo:K,tile:r,labelPlaneMatrixInv:G};if(x&&c.canOverlap){b=!0;const t=h.segments.get();for(const i of t)E.push({segments:new e.SegmentVector([i]),sortKey:i.sortKey,state:te})}else E.push({segments:h.segments,sortKey:0,state:te})}b&&E.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of E){const i=e.state;if(t.terrain&&t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),d.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(d.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,dn(i.buffers,e.segments,n,t,i.program,w,h,p,r)),r.u_is_halo=0}dn(i.buffers,e.segments,n,t,i.program,w,h,p,i.uniformValues)}}function dn(t,i,n,r,o,s,a,l,c){const u=r.context;o.draw(u,u.gl.TRIANGLES,s,a,l,e.CullFaceMode.disabled,c,n.id,t.layoutVertexBuffer,t.indexBuffer,i,n.paint,r.transform.zoom,t.programConfigurations.get(n.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.globeExtVertexBuffer)}function fn(t,i,n,r,o,s,a){const l=t.context.gl,c=n.paint.get("fill-pattern"),u=c&&c.constantOr(1),h=n.getCrossfadeParameters();let p,d,f,m,g;a?(d=u&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(d=u?"fillPattern":"fill",p=l.TRIANGLES);for(const _ of r){const r=i.getTile(_);if(u&&!r.patternsLoaded())continue;const y=r.getBucket(n);if(!y)continue;t.prepareDrawTile();const v=y.programConfigurations.get(n.id),x=t.useProgram(d,v);u&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers(h));const b=c.constantOr(null);if(b&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[b.to.toString()],i=e.patternPositions[b.from.toString()];t&&i&&v.setConstantPatternPositions(t,i)}const w=t.translatePosMatrix(_.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,g=y.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&u?Fi(w,t,h,r,e):Oi(w,e)}else m=y.indexBuffer,g=y.segments,f=u?Di(w,t,h,r):zi(w);t.prepareDrawProgram(t.context,x,_.toUnwrapped()),x.draw(t.context,p,o,t.stencilModeForClipping(_),s,e.CullFaceMode.disabled,f,n.id,y.layoutVertexBuffer,m,g,n.paint,t.transform.zoom,v)}}function mn(t,i,n,r,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=n.paint.get("fill-extrusion-pattern"),p=h.constantOr(1),d=n.getCrossfadeParameters(),f=n.paint.get("fill-extrusion-opacity"),m="globe"===u.projection.name?e.fillExtrusionHeightLift():0,g="globe"===u.projection.name,_=g?e.globeToMercatorTransition(u.zoom):0,y=[e.mercatorXfromLng(u.center.lng),e.mercatorYfromLat(u.center.lat)],v=[];g&&v.push("PROJECTION_GLOBE_VIEW");for(const x of r){const r=i.getTile(x),b=r.getBucket(n);if(!b||b.projection.name!==u.projection.name)continue;const w=b.programConfigurations.get(n.id),M=t.useProgram(p?"fillExtrusionPattern":"fillExtrusion",w,v);if(t.terrain){const e=t.terrain;if(t.style.terrainSetForDrapingOnly())e.setupElevationDraw(r,M,{useMeterToDem:!0});else{if(!b.enableTerrain)continue;if(e.setupElevationDraw(r,M,{useMeterToDem:!0}),gn(l,i,x,b,n,e),!b.centroidVertexBuffer){const e=M.attributes.a_centroid_pos;void 0!==e&&c.vertexAttrib2f(e,0,0)}}}p&&(t.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),w.updatePaintBuffers(d));const T=h.constantOr(null);if(T&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[T.to.toString()],i=e.patternPositions[T.from.toString()];t&&i&&w.setConstantPatternPositions(t,i)}const S=t.translatePosMatrix(x.projMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),E=u.projection.createInversionMatrix(u,x.canonical),A=n.paint.get("fill-extrusion-vertical-gradient"),C=p?ki(S,t,A,f,x,d,r,m,_,y,E):Ri(S,t,A,f,x,m,_,y,E);t.prepareDrawProgram(l,M,x.toUnwrapped()),M.draw(l,l.gl.TRIANGLES,o,s,a,e.CullFaceMode.backCCW,C,n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,n.paint,t.transform.zoom,w,t.terrain?b.centroidVertexBuffer:null,g?b.layoutVertexExtBuffer:null)}}function gn(t,i,n,r,o,s){const a=[t=>{let i=t.canonical.x-1,n=t.wrap;return i<0&&(i=(1<{let i=t.canonical.x+1,n=t.wrap;return i===1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<{const t=i.getSource().minzoom,n=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i(c[0]=Math.min(t.min.y,i.min.y),c[1]=Math.max(t.max.y,i.max.y),c[2]=e.EXTENT-i.min.x>t.max.x?i.min.x-e.EXTENT:t.max.x,c),h=(t,i)=>(c[0]=Math.min(t.min.x,i.min.x),c[1]=Math.max(t.max.x,i.max.x),c[2]=e.EXTENT-i.min.y>t.max.y?i.min.y-e.EXTENT:t.max.y,c),p=[(e,t)=>u(e,t),(e,t)=>u(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],d=new e.pointGeometry(0,0);let f,m,g;const _=(t,i,r,o,a)=>{const l=[[o?r:t,o?t:r,0],[o?r:i,o?i:r,0]],c=a<0?e.EXTENT+a:a,u=[o?c:(t+i)/2,o?(t+i)/2:c,0];return 0===r&&a<0||0!==r&&a>0?s.getForTilePoints(g,[u],!0,m):l.push(u),s.getForTilePoints(n,l,!0,f),Math.max(l[0][2],l[1][2],u[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=(t<2?1:5)-t,o=r.borders[t];if(0===o.length)continue;const c=g=a[t](n),u=l(c);if(!(u&&u instanceof e.FillExtrusionBucket&&u.enableTerrain))continue;if(r.borderDoneWithNeighborZ[t]===u.canonical.z&&u.borderDoneWithNeighborZ[i]===r.canonical.z)continue;if(m=s.findDEMTileFor(c),!m||!m.dem)continue;if(!f){const e=s.findDEMTileFor(n);if(!e||!e.dem)return;f=e}const h=u.borders[i];let y=0;const v=u.borderDoneWithNeighborZ[i]!==r.canonical.z;if(r.canonical.z===u.canonical.z){for(let n=0;na[0]+3));)v&&u.encodeCentroid(void 0,l,!1),y++;if(l&&ya[1]-3)&&(o++,++y!==h.length);)l=u.featuresOnBorder[h[y]];if(l=u.featuresOnBorder[h[n]],s.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=n),r.encodeCentroid(void 0,s,!1),v&&u.encodeCentroid(void 0,l,!1);continue}const c=p[t](s,l),f=t%2?e.EXTENT-1:0;d.x=_(c[0],Math.min(e.EXTENT-1,c[1]),f,t<2,c[2]),d.y=0,r.encodeCentroid(d,s,!1),v&&u.encodeCentroid(d,l,!1)}else r.encodeCentroid(void 0,s,!1)}r.borderDoneWithNeighborZ[t]=u.canonical.z,r.needsCentroidUpdate=!0,v&&(u.borderDoneWithNeighborZ[i]=r.canonical.z,u.needsCentroidUpdate=!0)}else{for(const e of o)r.encodeCentroid(void 0,r.featuresOnBorder[e],!1);if(v){for(const e of h)u.encodeCentroid(void 0,u.featuresOnBorder[e],!1);u.borderDoneWithNeighborZ[i]=r.canonical.z,u.needsCentroidUpdate=!0}r.borderDoneWithNeighborZ[t]=u.canonical.z,r.needsCentroidUpdate=!0}}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t)}const _n=new e.Color(1,0,0,1),yn=new e.Color(0,1,0,1),vn=new e.Color(0,0,1,1),xn=new e.Color(1,0,1,1),bn=new e.Color(0,1,1,1);function wn(e,t,i,n){Tn(e,0,t+i/2,e.transform.width,i,n)}function Mn(e,t,i,n){Tn(e,t-i/2,0,i,e.transform.height,n)}function Tn(t,i,n,r,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.exported.devicePixelRatio,n*e.exported.devicePixelRatio,r*e.exported.devicePixelRatio,o*e.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}function Sn(t,i,n){const r=t.context,o=r.gl,s="globe"===t.transform.projection.name,a=n.projMatrix,l=t.useProgram("debug",null,s?["PROJECTION_GLOBE_VIEW"]:null),c=i.getTileByID(n.key);t.terrain&&t.terrain.setupElevationDraw(c,l);const u=e.DepthMode.disabled,h=e.StencilMode.disabled,p=t.colorModeForRenderPass(),d="$debug";r.activeTexture.set(o.TEXTURE0),t.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s?c._makeGlobeTileDebugBuffers(t.context,t.transform.projection):c._makeDebugTileBoundsBuffers(t.context,t.transform.projection);const f=c._tileDebugBuffer||t.debugBuffer,m=c._tileDebugIndexBuffer||t.debugIndexBuffer,g=c._tileDebugSegments||t.debugSegments;l.draw(r,o.LINE_STRIP,u,h,p,e.CullFaceMode.disabled,Vi(a,e.Color.red),d,f,m,g,null,null,null,c._globeTileDebugBorderBuffer);const _=c.latestRawTileData,y=Math.floor((_&&_.byteLength||0)/1024),v=i.getTile(n).tileSize,x=512/Math.min(v,512)*(n.overscaledZ/t.transform.zoom)*.5;let b=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(b+=` => ${n.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(t,`${b} ${y}kb`);const w=c._tileDebugTextBuffer||t.debugBuffer,M=c._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,T=c._tileDebugTextSegments||t.debugSegments;l.draw(r,o.TRIANGLES,u,h,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,Vi(a,e.Color.transparent,x),d,w,M,T,null,null,null,c._globeTileDebugTextBuffer)}const En=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:An}=En;function Cn(e,t,i,n){e.emplaceBack(t,i,n)}class Ln{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,Cn(this.vertexArray,-1,-1,1),Cn(this.vertexArray,1,-1,1),Cn(this.vertexArray,-1,1,1),Cn(this.vertexArray,1,1,1),Cn(this.vertexArray,-1,-1,-1),Cn(this.vertexArray,1,-1,-1),Cn(this.vertexArray,-1,1,-1),Cn(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,An),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}function In(t,i,n,r,o,s){const a=t.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,n,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[n.r,n.g,n.b,n.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.fromMat4(e.create$1(),r),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),n.draw(t,a.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Pn=e.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Rn{constructor(t){const i=new e.StructArrayLayout5f20;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const n=new e.StructArrayLayout3ui6;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Pn.members),this.indexBuffer=t.createIndexBuffer(n),this.segments=e.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const kn={symbol:function(t,i,n,r,o){if("translucent"!==t.renderPass)return;const s=e.StencilMode.disabled,a=t.colorModeForRenderPass();n.layout.get("text-variable-anchor")&&function(t,i,n,r,o,s,a){const l=i.transform,c="map"===o,u="map"===s;for(const i of t){const t=r.getTile(i),o=t.getBucket(n);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.evaluateSizeForZoom(o.textSizeData,l.zoom),h=wt(i,o.getProjection(),l),p=l.calculatePixelsToTileUnitsMatrix(t),d=tt(h,t.tileID.canonical,u,c,l,o.getProjection(),p),f="none"!==n.layout.get("icon-text-fit")&&o.hasIconData();if(s){const n=Math.pow(2,l.zoom-t.tileID.overscaledZ);un(o,c,u,a,e.symbolSize,l,d,i,n,s,f)}}}(r,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&pn(t,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),s,a),0!==n.paint.get("text-opacity").constantOr(1)&&pn(t,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),s,a),i.map.showCollisionBoxes&&(an(t,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),an(t,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("circle-opacity"),s=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),l=void 0!==n.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=t.context,u=c.gl,h=t.transform,p=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),d=e.StencilMode.disabled,f=t.colorModeForRenderPass(),m="globe"===h.projection.name,g=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],_=[];for(let o=0;oe.sortKey-t.sortKey));const y={useDepthForOcclusion:!m};for(const i of _){const{programConfiguration:r,program:o,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:g,tile:_}=i.state,v=i.segments;t.terrain&&t.terrain.setupElevationDraw(_,o,y),t.prepareDrawProgram(c,o,_.tileID.toUnwrapped()),o.draw(c,u.TRIANGLES,p,d,f,e.CullFaceMode.disabled,g,n.id,s,l,v,n.paint,h.zoom,r,m?a:null)}},heatmap:function(t,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=e.StencilMode.disabled,l=new e.ColorMode([s.ONE,s.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,i,n){const r=e.gl,o=t.width*n,s=t.height*n;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=r.createTexture();r.bindTexture(r.TEXTURE_2D,t),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=i.heatmapFbo=e.createFramebuffer(o,s,!1),function(e,t,i,n,r,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,r,o,0,s.RGBA,e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),n.colorAttachment.set(i)}(e,0,t,a,o,s)}else r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,n,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.Color.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:null,p=u?e.CullFaceMode.frontCCW:e.CullFaceMode.disabled,d=[e.mercatorXfromLng(c.center.lng),e.mercatorYfromLat(c.center.lat)];for(let f=0;f({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,n))},line:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("line-opacity"),s=n.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),l=t.colorModeForRenderPass(),c=t.terrain&&t.terrain.renderingToTexture?1:e.exported.devicePixelRatio,u=n.paint.get("line-dasharray"),h=u.constantOr(1),p=n.layout.get("line-cap"),d=n.paint.get("line-pattern"),f=d.constantOr(1),m=n.paint.get("line-gradient"),g=n.getCrossfadeParameters(),_=f?"linePattern":"line",y=t.context,v=y.gl,x=(e=>{const t=[];Xi(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET");const n=e.paint.get("line-pattern").constantOr(1),r=1!==e.paint.get("line-opacity").constantOr(1);return!n&&r&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(n);let b=x.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const o of r){const r=i.getTile(o);if(f&&!r.patternsLoaded())continue;const s=r.getBucket(n);if(!s)continue;t.prepareDrawTile();const w=s.programConfigurations.get(n.id),M=t.useProgram(_,w,x),T=d.constantOr(null);if(T&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[T.to.toString()],i=e.patternPositions[T.from.toString()];t&&i&&w.setConstantPatternPositions(t,i)}const S=u.constantOr(null),E=p.constantOr(null);if(!f&&S&&E&&r.lineAtlas){const e=r.lineAtlas,t=e.getDash(S.to,E),i=e.getDash(S.from,E);t&&i&&w.setConstantPatternPositions(t,i)}let[A,C]=n.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;A!==C&&(0===A&&(A-=e),1===C&&(C+=e))}const L=t.terrain?o.projMatrix:null,I=f?qi(t,r,n,g,L,c):Wi(t,r,n,g,L,s.lineClipsArray.length,c,[A,C]);if(m){const r=s.gradients[n.id];let a=r.texture;if(n.gradientVersion!==r.version){let l=256;if(n.stepInterpolant){const n=i.getSource().maxzoom,r=o.canonical.z===n?Math.ceil(1<{M.draw(y,v.TRIANGLES,a,i,l,e.CullFaceMode.disabled,I,n.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,n.paint,t.transform.zoom,w,s.layoutVertexBuffer2)};if(b){const i=t.stencilModeForClipping(o).ref;0===i&&t.terrain&&y.clear({stencil:0});const n={func:v.EQUAL,mask:255};I.u_alpha_discard_threshold=.8,P(new e.StencilMode(n,i,255,v.KEEP,v.KEEP,v.INVERT)),I.u_alpha_discard_threshold=0,P(new e.StencilMode(n,i,255,v.KEEP,v.KEEP,v.KEEP))}else P(t.stencilModeForClipping(o))}b&&(t.resetStencilClippingMasks(),t.terrain&&y.clear({stencil:0}))},fill:function(t,i,n,r){const o=n.paint.get("fill-color"),s=n.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=t.colorModeForRenderPass(),l=n.paint.get("fill-pattern"),c=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(e.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===c){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);fn(t,i,n,r,o,a,!1)}if("translucent"===t.renderPass&&n.paint.get("fill-antialias")){const o=t.depthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);fn(t,i,n,r,o,a,!0)}},"fill-extrusion":function(t,i,n,r){const o=n.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===t.renderPass){const s=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==o||n.paint.get("fill-extrusion-pattern").constantOr(1))mn(t,i,n,r,s,e.StencilMode.disabled,e.ColorMode.disabled),mn(t,i,n,r,s,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const o=t.colorModeForRenderPass();mn(t,i,n,r,s,e.StencilMode.disabled,o)}}},hillshade:function(t,i,n,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const o=t.context,s=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),a=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture,[c,u]="translucent"!==t.renderPass||l?[{},r]:t.stencilConfigForOverlap(r);for(const r of u){const o=i.getTile(r);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)fi(t,o,n,s,e.StencilMode.disabled,a);else if("translucent"===t.renderPass){const e=l&&t.terrain?t.terrain.stencilModeForRTTOverlap(r):c[r.overscaledZ];pi(t,r,o,n,s,e,a)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,i,n,r,o,s){if("translucent"!==t.renderPass)return;if(0===n.paint.get("raster-opacity"))return;if(!r.length)return;const a=t.context,l=a.gl,c=i.getSource(),u=t.useProgram("raster"),h=t.colorModeForRenderPass(),p=t.terrain&&t.terrain.renderingToTexture,[d,f]=c instanceof Ie||p?[{},r]:t.stencilConfigForOverlap(r),m=f[f.length-1].overscaledZ,g=!t.options.moving;for(const r of f){const o=p?e.DepthMode.disabled:t.depthModeForSublayer(r.overscaledZ-m,1===n.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,l.LESS),f=r.toUnwrapped(),_=i.getTile(r);if(p&&(!_||!_.hasData()))continue;const y=p?r.projMatrix:t.transform.calculateProjMatrix(f,g),v=t.terrain&&p?t.terrain.stencilModeForRTTOverlap(r):d[r.overscaledZ],x=s?0:n.paint.get("raster-fade-duration");_.registerFadeDuration(x);const b=i.findLoadedParent(r,0),w=Mi(_,b,i,t.transform,x);let M,T;t.terrain&&t.terrain.prepareDrawTile();const S="nearest"===n.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),_.texture.bind(S,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),M=Math.pow(2,b.tileID.overscaledZ-_.tileID.overscaledZ),T=[_.tileID.canonical.x*M%1,_.tileID.canonical.y*M%1]):_.texture.bind(S,l.CLAMP_TO_EDGE);const E=Yi(y,T||[0,0],M||1,w,n,c instanceof Ie?c.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(a,u,f),c instanceof Ie)c.boundsBuffer&&c.boundsSegments&&u.draw(a,l.TRIANGLES,o,e.StencilMode.disabled,h,e.CullFaceMode.disabled,E,n.id,c.boundsBuffer,t.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:i,tileBoundsIndexBuffer:r,tileBoundsSegments:s}=t.getTileBoundsBuffers(_);u.draw(a,l.TRIANGLES,o,v,h,e.CullFaceMode.disabled,E,n.id,i,r,s)}}t.resetStencilClippingMasks()},background:function(t,i,n,r){const o=n.paint.get("background-color"),s=n.paint.get("background-opacity");if(0===s)return;const a=t.context,l=a.gl,c=t.transform,u=c.tileSize,h=n.paint.get("background-pattern");if(t.isPatternMissing(h))return;const p=!h&&1===o.a&&1===s&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==p)return;const d=e.StencilMode.disabled,f=t.depthModeForSublayer(0,"opaque"===p?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),g=t.useProgram(h?"backgroundPattern":"background");let _,y=r;y||(_=t.getBackgroundTiles(),y=Object.values(_).map((e=>e.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),t.imageManager.bind(t.context));const v=n.getCrossfadeParameters();for(const p of y){const y=p.toUnwrapped(),x=r?p.projMatrix:t.transform.calculateProjMatrix(y);t.prepareDrawTile();const b=i?i.getTile(p):_?_[p.key]:new e.Tile(p,u,c.zoom,t),w=h?rn(x,s,t,h,{tileID:p,tileSize:u},v):nn(x,s,o);t.prepareDrawProgram(a,g,y);const{tileBoundsBuffer:M,tileBoundsIndexBuffer:T,tileBoundsSegments:S}=t.getTileBoundsBuffers(b);g.draw(a,l.TRIANGLES,f,d,m,e.CullFaceMode.disabled,w,n.id,M,T,S)}},sky:function(t,i,n){const r=t.transform,o="mercator"===r.projection.name||"globe"===r.projection.name?1:e.smoothstep(7,8,r.zoom),s=n.paint.get("sky-opacity")*o;if(0===s)return;const a=t.context,l=n.paint.get("sky-type"),c=new e.DepthMode(a.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),u=t.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===t.renderPass?n.needsSkyboxCapture(t)&&(function(t,i,n,r){const o=t.context,s=o.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=o.createFramebuffer(32,32,!1),i.skyboxGeometry=new Ln(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=i.getCenter(t,!0),c=t.useProgram("skyboxCapture"),u=new Float64Array(16);e.identity(u),e.rotateY(u,u,.5*-Math.PI),In(o,i,c,u,l,0),e.identity(u),e.rotateY(u,u,.5*Math.PI),In(o,i,c,u,l,1),e.identity(u),e.rotateX(u,u,.5*-Math.PI),In(o,i,c,u,l,2),e.identity(u),e.rotateX(u,u,.5*Math.PI),In(o,i,c,u,l,3),e.identity(u),In(o,i,c,u,l,4),e.identity(u),e.rotateY(u,u,Math.PI),In(o,i,c,u,l,5),o.viewport.set([0,0,t.width,t.height])}(t,n),n.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,i,n,r,o){const s=t.context,a=s.gl,l=t.transform,c=t.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const u=((e,t,i,n,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:n,u_temporal_offset:r}))(l.skyboxMatrix,i.getCenter(t,!1),0,r,o);t.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,n,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,u,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,n,c,s,u):"gradient"===l&&"sky"===t.renderPass&&function(t,i,n,r,o){const s=t.context,a=s.gl,l=t.transform,c=t.useProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ln(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new e.Texture(s,i.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,i,n,r,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.degToRad(n),u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,o);t.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,n,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,n,c,s,u)},debug:function(e,t,i){for(let n=0;nn)return void(this.transform.fogCullDistSq=null);const r=i+.78*(n-i);this.transform.fogCullDistSq=r*r}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,i){if(this.width=t*e.exported.devicePixelRatio,this.height=i*e.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,i=new e.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(e.EXTENT,0),i.emplaceBack(0,e.EXTENT),i.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const n=new e.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(e.EXTENT,0),n.emplaceBack(0,e.EXTENT),n.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const r=new e.StructArrayLayout2i4;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const o=new e.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(e.EXTENT,0,e.EXTENT,0),o.emplaceBack(0,e.EXTENT,0,e.EXTENT),o.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const s=new e.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.Texture(t,new e.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.create();const l=this.context.gl;this.stencilClearMode=new e.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.window.performance.now()),this.atmosphereBuffer=new Rn(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,i.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,wi(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,i,n){if(!i||this.currentStencilSource===i.id||!t.isTileClipped()||!n||0===n.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of n)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=i.id;const r=this.context,o=r.gl;this.nextStencilID+n.length>256&&this.clearStencil(),r.setColorMode(e.ColorMode.disabled),r.setDepthMode(e.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of n){const n=i.getTile(t),a=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:u}=this.getTileBoundsBuffers(n);s.draw(r,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},a,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,wi(t.projMatrix),"$clipping",l,c,u)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,i=this.context.gl;return new e.StencilMode({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const i=this.context.gl;return new e.StencilMode({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(t){const i=this.context.gl,n=t.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,o=n[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let n=0;n=0;this.currentLayer--){const e=this.style._layers[n[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky())continue;const r=i?s[i.id]:void 0;this._renderTileClippingMasks(e,i,r),this.renderLayer(this,i,e,r)}if(this.style.fog&&this.transform.projection.supportsFog&&function(t,i){const n=t.context,r=n.gl,o=t.transform,s=new e.DepthMode(r.LEQUAL,e.DepthMode.ReadOnly,[0,1]),a=t.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=e.globeToMercatorTransition(o.zoom),c=i.properties.get("color").toArray01(),u=i.properties.get("high-color").toArray01(),h=i.properties.get("space-color").toArray01PremultipliedAlpha(),p=e.identity$1([]);e.rotateY$1(p,p,-e.degToRad(o._center.lng)),e.rotateX$1(p,p,e.degToRad(o._center.lat)),e.rotateZ$1(p,p,o.angle),e.rotateX$1(p,p,-o._pitch);const d=e.fromQuat(new Float32Array(16),p),f=e.mapValue(i.properties.get("star-intensity"),0,1,0,.25),m=5e-4,g=e.mapValue(i.properties.get("horizon-blend"),0,1,m,.25),_=e.globeUseCustomAntiAliasing(t,n,o)&&g===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,v=e.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(_,2)),b=Math.acos(x/v),w=((t,i,n,r,o,s,a,l,c,u,h,p,d,f)=>({u_frustum_tl:t,u_frustum_tr:i,u_frustum_br:n,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*e.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:p,u_horizon_angle:d,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,d);t.prepareDrawProgram(n,a);const M=t.atmosphereBuffer;M&&a.draw(n,r.TRIANGLES,s,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,w,"skybox",M.vertexBuffer,M.indexBuffer,M.segments)}(this,this.style.fog),this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const n=t._getLayerSourceCache(e);n&&!e.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),t&&!e&&0!==t.getOpacity(this.transform.pitch)&&i.push("FOG"),e&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(e,t,i){this.cache=this.cache||{};const n=i||[],r=this.currentGlobalDefines().concat(n),o=Li.cacheKey(e,r,t);return this.cache[o]||(this.cache[o]=new Li(this.context,e,li[e],t,on[e],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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.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(t,i,n){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const o=r.getOpacity(this.transform.pitch),s=((t,i,n,r,o,s,a,l,c,u,h)=>{const p=t.transform,d=i.properties.get("color").toArray01();d[3]=r;const f=t.frameCounter/1e3%1;return{u_fog_matrix:n?p.calculateFogTileMatrix(n):t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:d,u_fog_horizon_blend:i.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:e.globeToMercatorTransition(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,r,n,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*e.exported.devicePixelRatio,this.transform.height*e.exported.devicePixelRatio]);i.setFogUniformValues(t,s)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,i=this._backgroundTiles={},n=this.transform.coveringTiles({tileSize:512});for(const r of n)i[r.key]=t[r.key]||new e.Tile(r,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={}}}class Dn{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=n}interpolate(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.number(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.number(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.number(t.right,i.right,n)),this}getCenter(t,i){const n=e.clamp((this.left+t-this.right)/2,0,t),r=e.clamp((this.top+i-this.bottom)/2,0,i);return new e.pointGeometry(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Dn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function On(t,i){const n=e.getColumn(t,3);e.fromQuat(t,i),e.setColumn(t,3,n)}function Fn(t,i){const n=e.identity$1([]);return e.rotateZ$1(n,n,-i),e.rotateX$1(n,n,-t),n}function Bn(t,i){const n=[t[0],t[1],0],r=[i[0],i[1],0];if(e.length(n)>=1e-15){const t=e.normalize([],n);e.scale$2(r,t,e.dot(r,t)),i[0]=r[0],i[1]=r[1]}const o=e.cross([],i,t);if(e.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Fn(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class Nn{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.MercatorCoordinate?t:new e.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.wrap(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const n=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,r=this.position,o=e.MercatorCoordinate.fromLngLat(t,n),s=[o.x-r.x,o.y-r.y,o.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Bn(s,i)}setPitchBearing(t,i){this.orientation=Fn(e.degToRad(t),e.degToRad(-i))}}class Un{constructor(t,i){this._transform=e.identity([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.MercatorCoordinate(t[0],t[1],t[2])}get position(){const t=e.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.setColumn(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.identity$1([]),t&&On(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Fn(e,t),On(this._transform,this._orientation)}forward(){const t=e.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const n=new Float64Array(16);return e.invert(n,this.getWorldToCamera(t,i)),n}getWorldToCameraPosition(t,i,n){const r=this.position;e.scale$2(r,r,-t);const o=new Float64Array(16);return e.fromScaling(o,[n,n,n]),e.translate(o,o,r),o[10]*=i,o}getWorldToCamera(t,i){const n=new Float64Array(16),r=new Float64Array(4),o=this.position;return e.conjugate(r,this._orientation),e.scale$2(o,o,-t),e.fromQuat(n,r),e.translate(n,n,o),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=i,n[9]*=i,n[10]*=i,n[11]*=i,n}getCameraToClipPerspective(t,i,n,r){const o=new Float64Array(16);return e.perspective(o,t,i,n,r),o}getDistanceToElevation(t){const i=0===t?0:e.mercatorZfromAltitude(t,this.position[1]),n=this.forward();return(i-this.position[2])/n[2]}clone(){return new Un([...this.position],[...this.orientation])}}function jn(t,i){const n=Gn(t.projection,t.zoom,t.width,t.height),r=function(t,i,n,r,o){const s=new e.LngLat(n.lng-180*Hn,n.lat),a=new e.LngLat(n.lng+180*Hn,n.lat),l=t.project(s.lng,s.lat),c=t.project(a.lng,a.lat),u=-Math.atan2(c.y-l.y,c.x-l.x),h=e.MercatorCoordinate.fromLngLat(n);h.y=e.clamp(h.y,-.999975,.999975);const p=h.toLngLat(),d=t.project(p.lng,p.lat),f=e.MercatorCoordinate.fromLngLat(p);f.x+=Hn;const m=f.toLngLat(),g=t.project(m.lng,m.lat),_=qn(g.x-d.x,g.y-d.y,u),y=e.MercatorCoordinate.fromLngLat(p);y.y+=Hn;const v=y.toLngLat(),x=t.project(v.lng,v.lat),b=qn(x.x-d.x,x.y-d.y,u),w=Math.abs(_.x)/Math.abs(b.y),M=e.identity([]);e.rotateZ(M,M,-u*(1-(o?0:r)));const T=e.identity([]);return e.scale(T,T,[1,1-(1-w)*r,1]),T[4]=-b.x/b.y*r,e.rotateZ(T,T,u),e.multiply(T,M,T),T}(t.projection,0,t.center,n,i),o=Vn(t);return e.scale(r,r,[o,o,1]),r}function Vn(t){const i=t.projection,n=Gn(t.projection,t.zoom,t.width,t.height),r=Wn(i,t.center),o=Wn(i,e.LngLat.convert(i.center));return Math.pow(2,r*n+(1-n)*o)}function Gn(t,i,n,r,o=1/0){const s=t.range;if(!s)return 0;const a=Math.min(o,Math.max(n,r)),l=Math.log(a/1024)/Math.LN2;return e.smoothstep(s[0]+l,s[1]+l,i)}const Hn=1/4e4;function Wn(t,i){const n=e.clamp(i.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),r=new e.LngLat(i.lng-180*Hn,n),o=new e.LngLat(i.lng+180*Hn,n),s=t.project(r.lng,n),a=t.project(o.lng,n),l=e.MercatorCoordinate.fromLngLat(r),c=e.MercatorCoordinate.fromLngLat(o),u=a.x-s.x,h=a.y-s.y,p=c.x-l.x,d=c.y-l.y,f=Math.sqrt((p*p+d*d)/(u*u+h*h));return Math.log(f)/Math.LN2}function qn(e,t,i){const n=Math.cos(i),r=Math.sin(i);return{x:e*n-t*r,y:e*r+t*n}}class $n{constructor(t,i,n,r,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=null==n?0:n,this._maxPitch=null==r?60:r,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.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 Dn,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Un,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new $n(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e){const t=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||t)&&this._updateCameraOnTerrain(),(e||t)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return e.pick(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const n=this.projection?this.getProjection():void 0;this.projection=e.getProjection(this.projectionOptions);const r=!t(n,this.getProjection());return r&&this._calcMatrices(),r}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.mercatorZfromAltitude(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.pointGeometry(this.width,this.height)}get bearing(){return e.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;var n;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(n=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n),function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+o*a,e[1]=r*l+s*a,e[2]=n*-a+o*l,e[3]=r*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.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 t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let r=0,o=0;for(let s=0;st.maxzoom&&(i=t.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<{const i=1/4e4,n=new e.MercatorCoordinate(t.x+i,t.y,t.z),r=new e.MercatorCoordinate(t.x,t.y+i,t.z),o=t.toLngLat(),s=n.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),p=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*p)*b/i},M=t=>{const i=v,n=x;return{aabb:e.tileAABB(this,l,0,0,0,t,n,i,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:i,wrap:t,fullyVisible:!1}},T=[];let S=[];const E=i,A=t.reparseOverscaled?n:i,C=e=>e*e,L=C((m-this._centerAltitude)*f),I=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=P(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},P=t=>{if(t.zoom=.9)return!0}else if(r&&(s=C(t.aabb.distanceZ(g)*f)),this.projection.isReprojectedInTileSpace&&n<=5){const i=Math.pow(2,t.zoom),n=w(new e.MercatorCoordinate((t.x+.5)/i,(t.y+.5)/i));l=n>.85?1:n}const c=i*i+o*o+s;return c{if(t*C(.707)0;){const n=T.pop(),s=n.x,a=n.y;let h=n.fullyVisible;if(!h){const e=n.aabb.intersects(p);if(0===e)continue;h=2===e}if(n.zoom!==E&&P(n))for(let t=0;t<4;t++){const i=(s<<1)+t%2,c=(a<<1)+(t>>1),p={aabb:o?n.aabb.quadrant(t):e.tileAABB(this,l,n.zoom+1,i,c,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:i,y:c,wrap:n.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};r&&!u&&(p.tileID=new e.OverscaledTileID(n.zoom+1===E?A:n.zoom+1,n.wrap,n.zoom+1,i,c),I(p)),T.push(p)}else{const r=n.zoom===E?A:n.zoom;if(t.minzoom&&t.minzoom>r)continue;const o=c[0]-(.5+s+(n.wrap<{const o=[0,0,0,1],s=[e.EXTENT,e.EXTENT,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.transformMat4$1(o,o,a),e.transformMat4$1(s,s,a);const l=e.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>i&&0!==n){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=u.getMinMaxForTile(r.tileID)),o||(o={min:x,max:v});const s=e.furthestTileCorner(this.rotation),a=[s[0]*e.EXTENT,s[1]*e.EXTENT,o.max];e.transformMat4(a,a,i),c=(1-a[1])*this.height*.5e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const i=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),n=this.projection.project(t.lng,i);return new e.pointGeometry(n.x*this.worldSize,n.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(t,i){let n,r;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;n=(i.x-o.x)/e,r=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);n=e.x-t.x,r=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(s.x-n,s.y-r))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,i){const n=i?e.mercatorZfromAltitude(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(r.x,r.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const n=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.transformMat4$1(r,r,this.pixelMatrixInverse),e.transformMat4$1(o,o,this.pixelMatrixInverse);const s=o[3];e.scale$1(r,r,1/r[3]),e.scale$1(o,o,1/s);const a=r[2],l=o[2];return{p0:r,p1:o,t:a===l?0:(n-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],n=[t.x,t.y,1,1];return e.transformMat4$1(i,i,this.pixelMatrixInverse),e.transformMat4$1(n,n,this.pixelMatrixInverse),e.scale$1(i,i,1/i[3]),e.scale$1(n,n,1/n[3]),i[2]=e.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,n[2]=e.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,e.scale$1(i,i,1/this.worldSize),e.scale$1(n,n,1/this.worldSize),new e.Ray([i[0],i[1],i[2]],e.normalize([],e.sub([],n,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:n,t:r}=t,o=e.mercatorZfromAltitude(i[2],this._center.lat),s=e.mercatorZfromAltitude(n[2],this._center.lat);return new e.MercatorCoordinate(e.number(i[0],n[0],r)/this.worldSize,e.number(i[1],n[1],r)/this.worldSize,e.number(o,s,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let i=this.projection.pointCoordinate3D(this,t.x,t.y);if(i)return new e.MercatorCoordinate(i[0],i[1],i[2]);let n=0,r=this.horizonLineFromTop();if(t.y>r)return this.pointCoordinate(t);const o=.02*r,s=t.clone();for(let t=0;t<10&&r-n>o;t++){s.y=e.number(n,r,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(r=s.y,i=t):n=s.y}return i?new e.MercatorCoordinate(i[0],i[1],i[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}_coordinatePoint(t,i){const n=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,n+t.toAltitude(),1];return e.transformMat4$1(r,r,this.pixelMatrix),r[3]>0?new e.pointGeometry(r[0]/r[3],r[1]/r[3]):new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(t,i){const n=new e.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),r=new e.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new e.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new e.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(n,t),l=this.pointCoordinate(r,t);const c=this.pointCoordinate(o,i),u=this.pointCoordinate(s,i),h=(e,t)=>(t.y-e.y)/(t.x-e.x);return a.y>1&&l.y>=0?a=new e.MercatorCoordinate((1-u.y)/h(u,a)+u.x,1):a.y<0&&l.y<=1&&(a=new e.MercatorCoordinate(-u.y/h(u,a)+u.x,0)),l.y>1&&a.y>=0?l=new e.MercatorCoordinate((1-c.y)/h(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new e.MercatorCoordinate(-c.y/h(c,l)+c.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(c))}_getBounds3D(){const e=this.elevation;if(!e.visibleDemTiles.length)return this._getBounds(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBounds(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.MAX_MERCATOR_LATITUDE,this.maxLat=e.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngu&&(s=u-l),u-ct&&(o=t-a),t-e.5?v-1:v,x>.5?x-1:x,0]),this.alignedProjMatrix=b,s=e.create(),e.scale(s,s,[this.width/2,-this.height/2,1]),e.translate(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=e.create(),e.scale(s,s,[1,-1,1]),e.translate(s,s,[-1,-1,0]),e.scale(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=e.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=e.invert(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=s,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.calculateGlobeMatrix(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.transformMat4(t,t,r),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=s;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSize,i=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._projectionScaler,o=[t,t,i];e.scale$2(o,o,r),e.scale$2(n,n,-1),e.multiply$2(n,n,o);const s=e.create();e.translate(s,s,n),e.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),n=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[n.x/this.worldSize-i[0]*r,n.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=t[2];let r=1;n>0&&(r=Math.min((i-this._camera.position[2])/n,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,r),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),o=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(n),s),l=this._zoomFromMercatorZ(a);e.scaleAndAdd(t,t,i,a),this._pitch=e.clamp(n,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(r,-Math.PI,Math.PI),this._setZoom(e.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.MercatorCoordinate(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,i){const n=Math.min(t.x,i.x),r=Math.max(t.x,i.x),o=Math.min(t.y,i.y),s=Math.max(t.y,i.y);if(oc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.pointGeometry(0,0),new e.pointGeometry(this.width,this.height))}zoomDeltaToMovement(t,i){const n=e.length(e.sub([],this._camera.position,t)),r=this._zoomFromMercatorZ(n)+i;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function(t,i){const n=[t[0],t[1],t[2],1];e.transformMat4$1(n,n,i);const r=Math.max(n[3],1e-6);return[n[0]/r,n[1]/r,n[2]/r,r]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.pointGeometry(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.pointGeometry(0,t))}}getCameraToCenterDistance(e){const t=Gn(e,this.zoom,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,this.worldSize,t);return.5/Math.tan(.5*this._fov)*this.height*i}}function Zn(e,t){let i=!1,n=null;const r=()=>{n=null,i&&(e(),n=setTimeout(r,t),i=!1)};return()=>(i=!0,n||r(),n)}class Xn{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Zn(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(t){const i=this._map;if(!i)return"";const n=i.getCenter(),r=Math.round(100*i.getZoom())/100,o=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,o),a=Math.round(n.lng*s)/s,l=Math.round(n.lat*s)/s,c=i.getBearing(),u=i.getPitch();let h="";if(h+=t?`/${a}/${l}/${r}`:`${r}/${l}/${a}`,(c||u)&&(h+="/"+Math.round(10*c)/10),u&&(h+=`/${Math.round(u)}`),this._hashName){const t=this._hashName;let i=!1;const n=e.window.location.hash.slice(1).split("&").map((e=>{const n=e.split("=")[0];return n===t?(i=!0,`${n}=${h}`):e})).filter((e=>e));return i||n.push(`${t}=${h}`),`#${n.join("&")}`}return`#${h}`}_getCurrentHash(){const t=e.window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((e=>e.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.window.location.href.replace(/(#.+)?$/,this.getHashString());e.window.history.replaceState(e.window.history.state,null,t)}}const Yn={linearity:.3,easing:e.bezier(0,0,.3,1)},Jn=e.extend({deceleration:2500,maxSpeed:1400},Yn),Qn=e.extend({deceleration:20,maxSpeed:1400},Yn),Kn=e.extend({deceleration:1e3,maxSpeed:360},Yn),er=e.extend({deceleration:1e3,maxSpeed:90},Yn);class tr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.exported.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=nr(i.pan.mag(),n,e.extend({},Jn,t||{}));r.offset=i.pan.mult(o.amount/i.pan.mag()),r.center=this._map.transform.center,ir(r,o)}if(i.zoom){const e=nr(i.zoom,n,Qn);r.zoom=this._map.transform.zoom+e.amount,ir(r,e)}if(i.bearing){const t=nr(i.bearing,n,Kn);r.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),ir(r,t)}if(i.pitch){const e=nr(i.pitch,n,er);r.pitch=this._map.transform.pitch+e.amount,ir(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function ir(e,t){(!e.duration||e.durationi.unproject(e))),a=o.reduce(((e,t,i,n)=>e.add(t.div(n.length))),new e.pointGeometry(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class sr extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class ar{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new sr(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new rr(e.type,this._map,e))}mouseup(e){this._map.fire(new rr(e.type,this._map,e))}preclick(t){const i=e.extend({},t);i.type="preclick",this._map.fire(new rr(i.type,this._map,i))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new rr(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new rr(e.type,this._map,e))}mouseover(e){this._map.fire(new rr(e.type,this._map,e))}mouseout(e){this._map.fire(new rr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new or(e.type,this._map,e))}touchmove(e){this._map.fire(new or(e.type,this._map,e))}touchend(e){this._map.fire(new or(e.type,this._map,e))}touchcancel(e){this._map.fire(new or(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lr{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new rr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new rr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new rr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cr{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(u(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${r}px,${a}px)`,this._box.style.width=s-r+"px",this._box.style.height=l-a+"px")}))}mouseupWindow(t,i){if(!this._active)return;if(0!==t.button)return;const n=this._startPos,r=i;if(this.reset(),d(),n.x!==r.x||n.y!==r.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(n,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.Event(t,{originalEvent:i}))}}function ur(e,t){const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=function(t){const i=new e.pointGeometry(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=ur(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=ur(i,t);for(const e in this.touches){const t=this.touches[e],i=n[e];(!i||i.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class pr{constructor(e){this.singleTap=new hr(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class dr{constructor(){this._zoomIn=new pr({numTouches:1,numTaps:2}),this._zoomOut=new pr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(n)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const fr={0:1,2:2};class mr{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const i=g(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i)}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=fr[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const r=ur(n,i),o=new e.pointGeometry(0,0),s=new e.pointGeometry(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")}),500)}}class xr{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){const n=this._firstTwoTouches;if(!n)return;e.preventDefault();const[r,o]=n,s=br(i,t,r),a=br(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[n,r]=this._firstTwoTouches,o=br(i,t,n),s=br(i,t,r);o&&s||(this._active&&d(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function br(e,t,i){for(let n=0;nMath.abs(e.x)}class Ar extends xr{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Er(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){const n=this._lastPoints;if(!n)return;const r=e[0].sub(n[0]),o=e[1].sub(n[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Er(e)&&Er(t)&&o}}const Cr={panStep:100,bearingStep:15,pitchStep:10};class Lr{constructor(){const e=Cr;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=0,r=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Ir,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Ir(e){return e*(2-e)}const Pr=4.000244140625;class Rr{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const n=e.exported.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==i&&i%Pr==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=f(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform,i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Pr?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==n&&(n=1/n);const r=i(),o=Math.pow(2,r),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*n))),"wheel"===this._type&&(this._startZoom=i(),this._easing=this._smoothOutEasing(200)),this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&r&&o){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.number(r,n,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=n,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-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.ease;if(this._prevEase){const t=this._prevEase,n=(e.exported.now()-t.start)/t.duration,r=t.easing(n+.01)-t.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.bezier(o,s,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:i},i}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(e.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`)}_isFullscreen(){return!!e.window.document.fullscreenElement||!!e.window.document.webkitFullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")}),200)}}class kr{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class zr{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Dr{constructor(){this._tap=new pr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Or{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Fr{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Br{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Nr=e=>e.zoom||e.drag||e.pitch||e.rotate;class Ur extends e.Event{}class jr{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const n=e.sub([],i,t);this.radius=e.length(n[2]<0?e.div([],n,this.constants):[n[0],n[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const i=e.scale$2([],t,this.radius);if(i[2]>0){const t=e.scale$2([],[0,0,1],e.dot(i,[0,0,1])),n=e.scale$2([],e.normalize([],[i[0],i[1],0]),this.radius),r=e.add([],i,e.scale$2([],e.sub([],e.add([],n,t),i),2));i[0]=r[0],i[1]=r[1]}return i}}function Vr(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Gr{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new tr(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new jr,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.bindAll(["handleEvent","handleWindowEvent"],this);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[e.window.document,"mousemove",{capture:!0}],[e.window.document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[e.window,"blur",void 0]];for(const[t,i,n]of this._listeners)t.addEventListener(i,t===e.window.document?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(const[t,i,n]of this._listeners)t.removeEventListener(i,t===e.window.document?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new ar(t,e));const n=t.boxZoom=new cr(t,e);this._add("boxZoom",n);const r=new dr,o=new zr;t.doubleClickZoom=new kr(o,r),this._add("tapZoom",r),this._add("clickZoom",o);const s=new Dr;this._add("tapDragZoom",s);const a=t.touchPitch=new Ar(t);this._add("touchPitch",a);const l=new _r(e),c=new yr(e);t.dragRotate=new Fr(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new gr(e),h=new vr(t,e);t.dragPan=new Or(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new Sr,d=new Mr;t.touchZoomRotate=new Br(i,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new lr(t));const f=t.scrollZoom=new Rr(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new Lr;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i])}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Nr(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,n=i?void 0:e,r={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?m(this._el,a):i?void 0:f(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(r,o,h,i,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=n);this._previousActiveHandlers=s,(Object.keys(c).length||Vr(r))&&(this._changes.push([r,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Vr(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(t,i,n,r,o){if(!n)return;e.extend(t,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const t={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.pointGeometry(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),e.extend(i,o),e.extend(n,s);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,i,n){const r=this._map,o=r.transform,s=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Vr(t)){const e=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",e!==o.zoom&&this._map._update(!0)}if(!Vr(t))return void this._fireEvents(i,n,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:p,pinchAround:d}=t;void 0!==d&&(h=d),(e=>i.drag&&!this._eventsInProgress.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){const t=o.pointCoordinate(h);if("globe"===o.projection.name){const i=e.latFromMercatorY(t.y),n=o.center.lat,r=Math.min(e.mercatorZfromAltitude(1,i)/e.mercatorZfromAltitude(1,n),2);a=a.rotate(-o.angle),f[0]=-a.x/o.worldSize*r,f[1]=-a.y/o.worldSize*r}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,g=[0,0,0];if(l){const t=s(p||o.pointCoordinate3D(h)),i={dir:e.normalize([],e.sub([],t,o._camera.position))};if(i.dir[2]<0){const n=o.zoomDeltaToMovement(t,l);e.scale$2(g,i.dir,n)}}const _=e.add(f,f,g);o._translateCameraConstrained(_),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,n,!0)}_fireEvents(t,i,n){const r=Nr(this._eventsInProgress),o=Nr(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||n,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=Nr(this._eventsInProgress);if(n&&(r||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Ur("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Hr="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Wr extends e.Evented{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,e.bindAll(["_renderFrameCallback"],this)}getCenter(){return new e.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,n){return t=e.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},i),n)}panTo(t,i,n){return this.easeTo(e.extend({center:t},i),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,n){return this.easeTo(e.extend({zoom:t},i),n)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,i,n){return this.easeTo(e.extend({bearing:t},i),n)}resetNorth(t,i){return this.rotateTo(0,e.extend({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())M=>{if(v&&(n.zoom=e.number(r,l,M)),x&&(n.bearing=e.number(o,c,M)),b&&(n.pitch=e.number(s,u,M)),w&&(n.interpolatePadding(a,h,M),d=n.centerPoint.add(p)),_)n.setLocationAtPoint(_,y);else{const e=n.zoomScale(n.zoom-r),t=l>r?Math.min(2,g):Math.max(.5,g),i=Math.pow(t,1-M),o=n.unproject(f.add(m.mult(M*i)).mult(e));n.setLocationAtPoint(n.renderWorldCopies?o.wrap():o,d)}return t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(M,t.duration,n);return this._preloadTiles(e),this}const T={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,T),this._ease(M(n),(e=>{n.recenterOnTerrain(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",i||n.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.Event("move",t)),this._zooming&&this.fire(new e.Event("zoom",t)),this._rotating&&this.fire(new e.Event("rotate",t)),this._pitching&&this.fire(new e.Event("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.Event("zoomend",t)),r&&this.fire(new e.Event("rotateend",t)),o&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,i){if(!t.essential&&e.exported.prefersReducedMotion){const n=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,i)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.clamp(+t.zoom,n.minZoom,n.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h="padding"in t?t.padding:n.padding,p=n.zoomScale(l-r),d=e.pointGeometry.convert(t.offset);let f=n.centerPoint.add(d);const m=n.pointLocation(f),g=e.LngLat.convert(t.center||m);this._normalizeCenter(g);const _=n.project(m),y=n.project(g).sub(_);let v=t.curve;const x=Math.max(n.width,n.height),b=x/p,w=y.mag();if("minZoom"in t){const i=e.clamp(Math.min(t.minZoom,r,l),n.minZoom,n.maxZoom),o=x/n.zoomScale(i-r);v=Math.sqrt(o/w*2)}const M=v*v;function T(e){const t=(b*b-x*x+(e?-1:1)*M*M*w*w)/(2*(e?b:x)*M*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function E(e){return(Math.exp(e)+Math.exp(-e))/2}const A=T(0);let C=function(e){return E(A)/E(A+v*e)},L=function(e){return x*((E(A)*(S(t=A+v*e)/E(t))-S(A))/M)/w;var t},I=(T(1)-A)/v;if(Math.abs(w)<1e-6||!isFinite(I)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,i);const e=bt.maxDuration&&(t.duration=0);const P=o!==c,R=u!==s,k=!n.isPaddingEqual(h),z=n=>p=>{const m=p*I,v=1/C(m);n.zoom=1===p?l:r+n.scaleZoom(v),P&&(n.bearing=e.number(o,c,p)),R&&(n.pitch=e.number(s,u,p)),k&&(n.interpolatePadding(a,h,p),f=n.centerPoint.add(d));const x=1===p?g:n.unproject(_.add(y.mult(L(m))).mult(v));return n.setLocationAtPoint(n.renderWorldCopies?x.wrap():x,f),n._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(z,t.duration,n);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=R,this._padding=k,this._prepareEase(i,!1),this._ease(z(n),(()=>this._afterEase(i)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,i,n){!1===n.animate||0===n.duration?(t(1),i()):(this._easeStart=e.exported.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){t=e.wrap(t,-180,180);const n=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0}_emulate(e,t,i){const n=Math.ceil(15*t/1e3),r=[],o=e(i.clone());for(let e=0;e<=n;e++){const t=o(e/n);r.push(t.clone())}return r}}class qr{constructor(t={}){this.options=t,e.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,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"),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.setAttribute("aria-label",i),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.config.ACCESS_TOKEN}];if(t){const n=i.reduce(((e,t,n)=>(t.value&&(e+=`${t.key}=${t.value}${ne.length-t.length)),e=e.filter(((t,i)=>{for(let n=i+1;n=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class $r{constructor(){e.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Zr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Xr(t,i,n){if(t=new e.LngLat(t.lng,t.lat),i){const r=new e.LngLat(t.lng-360,t.lat),o=new e.LngLat(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-n.center.lng)/360),a=n.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>n.width||i.y>n.height;n.locationPoint(r).distSqr(i)180;){const e=n.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t}const Yr={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 Jr extends e.Evented{constructor(t,i){if(super(),(t instanceof e.window.HTMLElement||i)&&(t=e.extend({element:t},i)),e.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),t&&t.element)this._element=t.element,this._offset=e.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const i=41,n=27,r=s("svg",{display:"block",height:i*this._scale+"px",width:n*this._scale+"px",viewBox:`0 0 ${n} ${i}`},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=e.pointGeometry.convert(t&&t.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",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const n=this._element.classList;for(const e in Yr)n.remove(`mapboxgl-marker-anchor-${e}`);n.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,n=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map;if(!e)return!1;const t=e.unproject(this._pos),i=e.getFreeCameraOptions();if(!i.position)return!1;const n=i.position.toLngLat();return n.distanceTo(t)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const n=t.unproject(i);let r;t._usingGlobe()&&e.isLngLatBehindGlobe(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(n),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(r*=.2)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._calculateXYTransform()+this._calculateZTransform(),i=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px) ${Yr[this._anchor]}\n ${t}\n translate(${i.x}px,${i.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map;if("map"!==this.getPitchAlignment()||!i||!t)return"";if(!i._usingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const n=e.radToDeg(e.globeTiltAtLngLat(i.transform,this._lngLat)),r=t.sub(e.globeCenterToScreenPoint(i.transform)),o=n/(Math.abs(r.x)+Math.abs(r.y)),s=r.x*o,a=-r.y*o;return a||s?`rotateX(${a}deg) rotateY(${s}deg)`:""}_calculateZTransform(){const e=this._calculateRotation();return e?`rotateZ(${e}deg)`:""}_calculateRotation(){if("viewport"===this._rotationAlignment||"auto"===this._rotationAlignment)return this._rotation;if(this._map&&"map"===this._rotationAlignment){const t=this._map;if(this._pos&&t&&t._usingGlobe()){const i=t.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),n=t.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(i);return this._rotation+e.radToDeg(Math.atan2(n.y,n.x))-90}return this._rotation-this._map.getBearing()}return 0}_update(t){e.window.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=Xr(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===t?this._updateFrameId=e.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._usingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.pointGeometry.convert(t),this._update(),this}_onMove(t){const i=this._map;if(i){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=i.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.Event("dragstart"))),this.fire(new e.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.Event("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map;t&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}}class Qr{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}const Kr={"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"},eo={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,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,crossSourceCollisions:!0};function to(e){e.parentNode&&e.parentNode.removeChild(e)}const io={showCompass:!0,showZoom:!0,visualizePitch:!1};class no{constructor(t,i,n=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new _r({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,n&&(this.mousePitch=new yr({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),u()}move(e,t){const i=this.map,n=this.mouseRotate.mousemoveWindow(e,t),r=n&&n.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const n=this.mousePitch.mousemoveWindow(e,t),r=n&&n.pitchDelta;r&&i.setPitch(i.getPitch()+r)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),f(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,f(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i),a=s/i;o._requestDomTask((()=>{e.style.width=t*a+"px",e.innerHTML="nautical-mile"!==r?new Intl.NumberFormat(n,{style:"unit",unitDisplay:"narrow",unit:r}).format(s):`${s} nm`}))}const ao={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},lo=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function co(t=new e.pointGeometry(0,0),i="bottom"){if("number"==typeof t){const n=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case"top":return new e.pointGeometry(0,t);case"top-left":return new e.pointGeometry(n,n);case"top-right":return new e.pointGeometry(-n,n);case"bottom":return new e.pointGeometry(0,-t);case"bottom-left":return new e.pointGeometry(n,-n);case"bottom-right":return new e.pointGeometry(-n,-n);case"left":return new e.pointGeometry(t,0);case"right":return new e.pointGeometry(-t,0)}return new e.pointGeometry(0,0)}return t instanceof e.pointGeometry||Array.isArray(t)?e.pointGeometry.convert(t):e.pointGeometry.convert(t[i]||[0,0])}const uo={version:e.version,supported:i,setRTLTextPlugin:e.setRTLTextPlugin,getRTLTextPluginStatus:e.getRTLTextPluginStatus,Map:class extends Wr{constructor(t){if(null!=(t=e.extend({},eo,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.isSafariWithAntialiasingBug(e.window)&&(t.antialias=!1,e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new $n(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language="auto"===t.language?e.window.navigator.language:t.language,this._worldview=t.worldview,this._renderTaskQueue=new Zr,this._domRenderTaskQueue=new Zr,this._controls=[],this._markers=[],this._mapId=e.uniqueId(),this._locale=e.extend({},Kr,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Qr(0),this._explicitProjection=null,this._requestManager=new e.RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.window.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.bindAll(["_onWindowOnline","_onWindowResize","_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!==e.window&&(e.window.addEventListener("online",this._onWindowOnline,!1),e.window.addEventListener("resize",this._onWindowResize,!1),e.window.addEventListener("orientationchange",this._onWindowResize,!1),e.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new Gr(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Xn("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.extend({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new qr({customAttribution:t.customAttribution})),this._logoControl=new $r,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.Event(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.Event(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),i&&this.fire(new e.Event("moveend",t)),this}getBounds(){return"globe"===this.transform.projection.name&&e.warnOnce('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.LngLatBounds.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.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(e){return this.transform.renderWorldCopies=e,this._update()}getLanguage(){return this._language}setLanguage(t){if(this._language="auto"===t?e.window.navigator.language:t,this.style)for(const e in this.style._sourceCaches){const t=this.style._sourceCaches[e]._source;t._setLanguage&&t._setLanguage(this._language)}for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){if(this._worldview=e,this.style)for(const t in this.style._sourceCaches){const i=this.style._sourceCaches[t]._source;i._setWorldview&&i._setWorldview(e)}return this}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}_usingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._updateProjection(e)}_updateProjection(t){const i=this.getProjection();null===t&&(this._explicitProjection=null);const n=t||this.getProjection();let r;if(n&&"globe"===n.name&&this.transform.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?(r=this.transform.setProjection({name:"mercator"}),this.transform.mercatorFromTransition=!0):(r=this.transform.setProjection(n),this.transform.mercatorFromTransition=!1),t&&(this._explicitProjection="globe"===t.name?{name:"globe",center:[0,0]}:this.transform.getProjection()),this.style.applyProjectionUpdate(),r){if("globe"===i.name&&"globe"===this.getProjection().name)this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles()}this._update(!0)}return this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.pointGeometry.convert(t))}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}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let n=!1;const r=r=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new rr(e,this,r.originalEvent,{features:s}))):n=!1},o=()=>{n=!1};return{layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const r=r=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new rr(e,this,r.originalEvent)))},o=t=>{n&&(n=!1,i.call(this,new rr(e,this,t.originalEvent)))};return{layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=e=>{const n=t.filter((e=>this.getLayer(e))),r=n.length?this.queryRenderedFeatures(e.point,{layers:n}):[];r.length&&(e.features=r,i.call(this,e),delete e.features)};return{layers:new Set(t),listener:i,delegates:{[e]:n}}}}on(e,t,i){if(void 0===i)return super.on(e,t);Array.isArray(t)||(t=[t]);const n=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(n);for(const e in n.delegates)this.on(e,n.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);Array.isArray(t)||(t=[t]);const n=this._createDelegatedListener(e,t,i);for(const e in n.delegates)this.once(e,n.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const n=(e,t)=>{if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0},r=this._delegatedListeners?this._delegatedListeners[e]:void 0;return r&&(e=>{for(let r=0;r{t?this.fire(new e.ErrorEvent(t)):n&&this._updateDiff(n,i)}))}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t)&&this._update(!0)}catch(n){e.warnOnce(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.warnOnce("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,i,{pixelRatio:n=1,sdf:r=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&i instanceof e.window.ImageBitmap){const{width:l,height:c,data:u}=e.exported.getImageData(i);this.style.addImage(t,{data:new e.RGBAImage({width:l,height:c},u),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new e.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}=i,u=i;this.style.addImage(t,{data:new e.RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0,userImage:u}),u.onAdd&&u.onAdd(this,t)}}updateImage(t,i){const n=this.style.getImage(t);if(!n)return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&i instanceof e.window.ImageBitmap?e.exported.getImageData(i):i,{width:o,height:s}=r;void 0!==o&&void 0!==s?o===n.data.width&&s===n.data.height?(n.data.replace(r.data,!(i instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&i instanceof e.window.ImageBitmap)),this.style.updateImage(t,n)):this.fire(new e.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 (${n.data.width}, ${n.data.height})`))):this.fire(new e.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(t){return t?!!this.style.getImage(t):(this.fire(new e.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,i){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),((t,n)=>{i(t,n instanceof e.window.HTMLImageElement?e.exported.getImageData(n):n)}))}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,n={}){return this.style.setPaintProperty(e,t,i,n),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,n={}){return this.style.setLayoutProperty(e,t,i,n),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let n,r,o,s=this._container;for(;s&&(!r||!o);){const t=e.window.getComputedStyle(s).transform;t&&"none"!==t&&(n=t.match(/matrix.*\((.+)\)/)[1].split(", "),n[0]&&"0"!==n[0]&&"1"!==n[0]&&(r=n[0]),n[3]&&"0"!==n[3]&&"1"!==n[3]&&(o=n[3])),s=s.parentElement}this._containerWidth=r?Math.abs(t/r):t,this._containerHeight=o?Math.abs(i/o):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=o("canvas","mapboxgl-canvas",t),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 i=this._controlContainer=o("div","mapboxgl-control-container",e),n=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{n[e]=o("div",`mapboxgl-ctrl-${e}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const n=e.exported.devicePixelRatio||1;this._canvas.width=n*Math.ceil(t),this._canvas.height=n*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_setupPainter(){const t=e.extend({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),n=this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t);n?(e.storeAuthState(n,!0),this.painter=new zn(n,this.transform),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.exported$1.testSupport(n)):this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.Event("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.Event("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.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(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let i;const n=this.painter.context.extTimerQuery,r=e.exported.now();if(this.listens("gpu-timing-frame")&&(i=n.createQueryEXT(),n.beginQueryEXT(n.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;"globe"===this.getProjection().name&&(this.transform.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let o=!1;const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,n=e.exported.now();this.style.zoomHistory.update(t,n);const r=new e.EvaluationParameters(t,{now:n,fadeDuration:s,pitch:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=r.crossFadingFactor();1===a&&a===this._crossFadingFactor||(o=!0,this._crossFadingFactor=a),this.style.update(r)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(r),this.style._updateSources(this.transform),this._forceMarkerUpdate()):a=this._updateAverageElevation(r),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&(this.style.hasTransitions()||o)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=e.exported.now()-r;n.endQueryEXT(n.TIME_ELAPSED_EXT,i),setTimeout((()=>{const o=n.getQueryObjectEXT(i,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(i),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.window.performance.mark("frame-gpu",{startTime:r,detail:{gpuTime:o}})}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.Event("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(r,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const e of this._markers)e._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation(),r=!1;this.transform.elevation&&(r=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){e.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.AUTH_ERR_MSG||401===t.status)){const t=this.painter.context.gl;e.storeAuthState(t,!1),this._logoControl instanceof $r&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.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/")))}})),e.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,n=i.createFramebuffer();function r(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,n),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let n=i[1]-i[0];const r=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const i=this.style?Object.values(this.style._sourceCaches):[];return e.asyncAll(i,((e,i)=>e._preloadTiles(t,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}_setCacheLimits(t,i){e.setCacheLimits(t,i)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},io,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),n=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new no(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const i=o("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends e.Evented{constructor(t){super(),this.options=e.extend({geolocation:e.window.navigator.geolocation},ro,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Zn(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,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(t){void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.window.navigator.permissions?e.window.navigator.permissions.query({name:"geolocation"}).then((e=>{this._supportsGeolocation="denied"!==e.state,t(this._supportsGeolocation)})):(this._supportsGeolocation=!!this.geolocation,t(this._supportsGeolocation))}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.Event("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("geolocate",t)),this._finish()}}_updateCamera(t){const i=new e.LngLat(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,r=this._map.getBearing(),o=e.extend({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(n),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,i=e.mercatorZfromAltitude(1,t._center.lat)*t.worldSize,n=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(this._container.addEventListener("contextmenu",(e=>e.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===t){e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=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 Jr({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Jr({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",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.Event("trackuserlocationend")))}))}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.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 e.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 e.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 e.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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.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 t=()=>{e.window.addEventListener("ondeviceorientationabsolute"in e.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((e=>{"granted"===e&&t()})).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientation),e.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:qr,ScaleControl:class{constructor(t){this.options=e.extend({},oo,t),e.bindAll(["_update","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){!function(e,t,i,n){const r=n&&n.maxWidth||100,o=e._containerHeight/2,s=e._containerWidth/2-r/2,a=e.unproject([s,o]),l=e.unproject([s+r,o]),c=a.distanceTo(l);if(n&&"imperial"===n.unit){const n=3.2808*c;n>5280?so(t,r,n/5280,i,"mile",e):so(t,r,n,i,"foot",e)}else n&&"nautical"===n.unit?so(t,r,c/1852,i,"nautical-mile",e):c>=1e3?so(t,r,c/1e3,i,"kilometer",e):so(t,r,c,i,"meter",e)}(this._map,this._container,this._language,this.options)}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.window.HTMLElement?this._container=t.container:e.warnOnce("Full screen control 'container' must be a DOM element.")),e.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,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",e.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.window.document.fullscreenEnabled&&!e.window.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(e.window.document.fullscreenElement||e.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()?e.window.document.exitFullscreen?e.window.document.exitFullscreen():e.window.document.webkitCancelFullScreen&&e.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.Evented{constructor(t){super(),this.options=e.extend(Object.create(ao),t),e.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const i=e.window.document.createDocumentFragment(),n=e.window.document.createElement("body");let r;for(n.innerHTML=t;r=n.firstChild,r;)i.appendChild(r);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,n=this._pos;if(!t||!i||!n)return"bottom";const r=i.offsetWidth,o=i.offsetHeight,s=n.xt.transform.width-r/2;if(n.y+et.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const i=this._map,n=this._content;if(!i||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=o("div","mapboxgl-popup",i.getContainer()),this._tip=o("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Xr(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:i.project(this._lngLat),n=co(this.options.offset),r=this._anchor=this._getAnchor(n.y),o=co(this.options.offset,r),s=e.add(o).round();i._requestDomTask((()=>{this._container&&r&&(this._container.style.transform=`${Yr[r]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&i._usingGlobe()){const t=e.isLngLatBehindGlobe(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(lo);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:Jr,Style:ei,LngLat:e.LngLat,LngLatBounds:e.LngLatBounds,Point:e.pointGeometry,MercatorCoordinate:e.MercatorCoordinate,FreeCameraOptions:Nn,Evented:e.Evented,config:e.config,prewarm:function(){je().acquire(Be)},clearPrewarmedResources:function(){const e=Ue;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Be),Ue=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return e.config.ACCESS_TOKEN},set accessToken(t){e.config.ACCESS_TOKEN=t},get baseApiUrl(){return e.config.API_URL},set baseApiUrl(t){e.config.API_URL=t},get workerCount(){return Ne.workerCount},set workerCount(e){Ne.workerCount=e},get maxParallelImageRequests(){return e.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.clearTileCache(t)},workerUrl:"",workerClass:null,setNow:e.exported.setNow,restoreNow:e.exported.restoreNow};return uo}));return i}));!function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;sthis._bounds.width&&(t=this._bounds.width),t},_getY:function(e){var t=(e=e.touches?e.touches[0]:e).clientY-this._bounds.top;return t<0&&(t=0),t>this._bounds.height&&(t=this._bounds.height),t},setSlider:function(e){this._setPosition(e)},on:function(e,t){return this._ev.on(e,t),this},fire:function(e,t){return this._ev.emit(e,t),this},off:function(e,t){return this._ev.removeListener(e,t),this},remove:function(){this._clearSync(),this._mapB.off("resize",this._onResize);var e=this._mapA.getContainer();e&&(e.style.clip=null,e.removeEventListener("mousemove",this._onMove));var t=this._mapB.getContainer();t&&(t.style.clip=null,t.removeEventListener("mousemove",this._onMove)),this._swiper.removeEventListener("mousedown",this._onDown),this._swiper.removeEventListener("touchstart",this._onDown),this._controlContainer.remove()}},window.mapboxgl?mapboxgl.Compare=o:void 0!==t&&(t.exports=o)},{"@mapbox/mapbox-gl-sync-move":2,events:3}],2:[function(e,t,i){t.exports=function(){var e,t=arguments.length;if(1===t)e=arguments[0];else{e=[];for(var i=0;io){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=s[t]=i,++e._eventsCount;return e}function p(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t=0?1:-1)}function o(e,t,i){var n=(e=r(e*i))-(t=r(t*i));n<<=1;e-t<0&&(n=~n);for(var o="";n>=32;){o+=String.fromCharCode(63+(32|31&n));n>>=5}return o+=String.fromCharCode(n+63)}n.decode=function(e,t){for(var i,n=0,r=0,o=0,s=[],a=0,l=0,c=null,u=Math.pow(10,Number.isInteger(t)?t:5);n=32);i=1&l?~(l>>1):l>>1;a=l=0;do{l|=(31&(c=e.charCodeAt(n++)-63))<=32);r+=i;o+=1&l?~(l>>1):l>>1;s.push([r/u,o/u])}return s};n.encode=function(e,t){if(!e.length)return"";for(var i=Math.pow(10,Number.isInteger(t)?t:5),n=o(e[0][0],0,i)+o(e[0][1],0,i),r=1;r0&&this._events[e].length>i){this._events[e].warned=!0;console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length);"function"==typeof console.trace&&console.trace()}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var i=!1;function n(){this.removeListener(e,n);if(!i){i=!0;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var i,n,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;s=(i=this._events[e]).length;n=-1;if(i===t||r(i.listener)&&i.listener===t){delete this._events[e];this._events.removeListener&&this.emit("removeListener",e,t)}else if(o(i)){for(a=s;a-- >0;)if(i[a]===t||i[a].listener&&i[a].listener===t){n=a;break}if(n<0)return this;if(1===i.length){i.length=0;delete this._events[e]}else i.splice(n,1);this._events.removeListener&&this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener){0===arguments.length?this._events={}:this._events[e]&&delete this._events[e];return this}if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);this.removeAllListeners("removeListener");this._events={};return this}if(r(i=this._events[e]))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);delete this._events[e];return this};n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]};n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0};n.listenerCount=function(e,t){return e.listenerCount(t)};function r(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}},{}],4:[function(e,t,i){!function(){var e={};void 0!==i?t.exports=e:this.fuzzy=e;e.simpleFilter=function(t,i){return i.filter((function(i){return e.test(t,i)}))};e.test=function(t,i){return null!==e.match(t,i)};e.match=function(e,t,i){i=i||{};var n,r=0,o=[],s=t.length,a=0,l=0,c=i.pre||"",u=i.post||"",h=i.caseSensitive&&t||t.toLowerCase();e=i.caseSensitive&&e||e.toLowerCase();for(var p=0;p/g},{}],7:[function(e,t,i){(function(e){var i=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,l=parseInt,c="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,h=c||u||Function("return this")(),p=Object.prototype.toString,d=Math.max,f=Math.min,m=function(){return h.Date.now()};function g(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function _(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&p.call(e)==n}(e))return i;if(g(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=g(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var c=s.test(e);return c||a.test(e)?l(e.slice(2),c?2:8):o.test(e)?i:+e}t.exports=function(e,t,i){var n,r,o,s,a,l,c=0,u=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError("Expected a function");t=_(t)||0;if(g(i)){u=!!i.leading;o=(h="maxWait"in i)?d(_(i.maxWait)||0,t):o;p="trailing"in i?!!i.trailing:p}function y(t){var i=n,o=r;n=r=void 0;c=t;return s=e.apply(o,i)}function v(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function x(){var e=m();if(v(e))return b(e);a=setTimeout(x,function(e){var i=t-(e-l);return h?f(i,o-(e-c)):i}(e))}function b(e){a=void 0;if(p&&n)return y(e);n=r=void 0;return s}function w(){var e=m(),i=v(e);n=arguments;r=this;l=e;if(i){if(void 0===a)return function(e){c=e;a=setTimeout(x,t);return u?y(e):s}(l);if(h){a=setTimeout(x,t);return y(l)}}void 0===a&&(a=setTimeout(x,t));return s}w.cancel=function(){void 0!==a&&clearTimeout(a);c=0;n=l=r=a=void 0};w.flush=function(){return void 0===a?s:b(m())};return w}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,t,i){(function(e){var n="__lodash_hash_undefined__",r=1,o=2,s=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",h="[object Date]",p="[object Error]",d="[object Function]",f="[object GeneratorFunction]",m="[object Map]",g="[object Number]",_="[object Null]",y="[object Object]",v="[object Promise]",x="[object Proxy]",b="[object RegExp]",w="[object Set]",M="[object String]",T="[object Symbol]",S="[object Undefined]",E="[object WeakMap]",A="[object ArrayBuffer]",C="[object DataView]",L=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,P={};P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0;P[a]=P[l]=P[A]=P[u]=P[C]=P[h]=P[p]=P[d]=P[m]=P[g]=P[y]=P[b]=P[w]=P[M]=P[E]=!1;var R="object"==typeof e&&e&&e.Object===Object&&e,k="object"==typeof self&&self&&self.Object===Object&&self,z=R||k||Function("return this")(),D="object"==typeof i&&i&&!i.nodeType&&i,O=D&&"object"==typeof t&&t&&!t.nodeType&&t,F=O&&O.exports===D,B=F&&R.process,N=function(){try{return B&&B.binding&&B.binding("util")}catch(e){}}(),U=N&&N.isTypedArray;function j(e,t){for(var i=-1,n=null==e?0:e.length;++i-1};Se.prototype.set=function(e,t){var i=this.__data__,n=Ie(i,e);if(n<0){++this.size;i.push([e,t])}else i[n][1]=t;return this};function Ee(e){var t=-1,i=null==e?0:e.length;this.clear();for(;++tc))return!1;var h=a.get(e);if(h&&a.get(t))return h==t;var p=-1,d=!0,f=i&o?new Ae:void 0;a.set(e,t);a.set(t,e);for(;++p-1&&e%1==0&&e-1&&e%1==0&&e<=s}function Ye(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Je(e){return null!=e&&"object"==typeof e}var Qe=U?function(e){return function(t){return e(t)}}(U):function(e){return Je(e)&&Xe(e.length)&&!!P[Pe(e)]};function Ke(e){return null!=(t=e)&&Xe(t.length)&&!Ze(t)?Le(e):De(e);var t}t.exports=function(e,t){return ke(e,t)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,t,i){(function(n){var r=e("lodash._reinterpolate"),o=e("lodash.templatesettings"),s=1/0,a=9007199254740991,l="[object Arguments]",c="[object AsyncFunction]",u="[object DOMException]",h="[object Error]",p="[object Function]",d="[object GeneratorFunction]",f="[object Null]",m="[object Object]",g="[object Proxy]",_="[object Symbol]",y="[object Undefined]",v=/\b__p \+= '';/g,x=/\b(__p \+=) '' \+/g,b=/(__e\(.*?\)|\b__t\)) \+\n'';/g,w=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,M=/^\[object .+?Constructor\]$/,T=/^(?:0|[1-9]\d*)$/,S=/($^)/,E=/['\n\r\u2028\u2029\\]/g,A={};A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0;A[l]=A["[object Array]"]=A["[object ArrayBuffer]"]=A["[object Boolean]"]=A["[object DataView]"]=A["[object Date]"]=A[h]=A[p]=A["[object Map]"]=A["[object Number]"]=A[m]=A["[object RegExp]"]=A["[object Set]"]=A["[object String]"]=A["[object WeakMap]"]=!1;var C={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},L="object"==typeof n&&n&&n.Object===Object&&n,I="object"==typeof self&&self&&self.Object===Object&&self,P=L||I||Function("return this")(),R="object"==typeof i&&i&&!i.nodeType&&i,k=R&&"object"==typeof t&&t&&!t.nodeType&&t,z=k&&k.exports===R,D=z&&L.process,O=function(){try{var e=k&&k.require&&k.require("util").types;return e||D&&D.binding&&D.binding("util")}catch(e){}}(),F=O&&O.isTypedArray;function B(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}function N(e,t){for(var i=-1,n=null==e?0:e.length,r=Array(n);++i-1&&e%1==0&&e0){if(++Te>=800)return arguments[0]}else Te=0;return Me.apply(void 0,arguments)});function Ae(e,t){return e===t||e!=e&&t!=t}var Ce=fe(function(){return arguments}())?fe:function(e){return Oe(e)&&$.call(e,"callee")&&!te.call(e,"callee")},Le=Array.isArray;function Ie(e){return null!=e&&ze(e.length)&&!ke(e)}var Pe=re||function(){return!1};function Re(e){if(!Oe(e))return!1;var t=de(e);return t==h||t==u||"string"==typeof e.message&&"string"==typeof e.name&&!function(e){if(!Oe(e)||de(e)!=m)return!1;var t=ee(e);if(null===t)return!0;var i=$.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&q.call(i)==Y}(e)}function ke(e){if(!De(e))return!1;var t=de(e);return t==p||t==d||t==c||t==g}function ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function De(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Oe(e){return null!=e&&"object"==typeof e}var Fe=F?function(e){return function(t){return e(t)}}(F):function(e){return Oe(e)&&ze(e.length)&&!!A[de(e)]};var Be,Ne=(Be=function(e,t,i,n){!function(e,t,i,n){var r=!i;i||(i={});for(var o=-1,s=t.length;++o1?t[n-1]:void 0,o=n>2?t[2]:void 0;r=Be.length>3&&"function"==typeof r?(n--,r):void 0;if(o&&be(t[0],t[1],o)){r=n<3?void 0:r;n=1}e=Object(e);for(;++i"']/g,c=RegExp(l.source),u="object"==typeof i&&i&&i.Object===Object&&i,h="object"==typeof self&&self&&self.Object===Object&&self,p=u||h||Function("return this")();var d,f=(d={"&":"&","<":"<",">":">",'"':""","'":"'"},function(e){return null==d?void 0:d[e]}),m=Object.prototype,g=m.hasOwnProperty,_=m.toString,y=p.Symbol,v=y?y.toStringTag:void 0,x=y?y.prototype:void 0,b=x?x.toString:void 0,w={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:n,variable:"",imports:{_:{escape:function(e){return(e=(t=e,null==t?"":T(t)))&&c.test(e)?e.replace(l,f):e;var t}}}};function M(e){return null==e?void 0===e?a:o:v&&v in Object(e)?function(e){var t=g.call(e,v),i=e[v];try{e[v]=void 0;var n=!0}catch(e){}var r=_.call(e);n&&(t?e[v]=i:delete e[v]);return r}(e):function(e){return _.call(e)}(e)}function T(e){if("string"==typeof e)return e;if(S(e))return function(e,t){for(var i=-1,n=null==e?0:e.length,r=Array(n);++i1)for(var i=1;i0&&void 0!==arguments[0]?arguments[0]:{},i=arguments[1];if(p)throw p;if("production"!==t.env.NODE_ENV){var l=function(e,t,i,o){var s=Object.keys(t),a=i&&i.type===n.ActionTypes.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===s.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!(0,r.default)(e))return"The "+a+' has unexpected type of "'+{}.toString.call(e).match(/\s([a-z|A-Z]+)/)[1]+'". Expected argument to be an object with the following keys: "'+s.join('", "')+'"';var l=Object.keys(e).filter((function(e){return!t.hasOwnProperty(e)&&!o[e]}));l.forEach((function(e){o[e]=!0}));if(l.length>0)return"Unexpected "+(l.length>1?"keys":"key")+' "'+l.join('", "')+'" found in '+a+'. Expected to find one of the known reducer keys instead: "'+s.join('", "')+'". Unexpected keys will be ignored.'}(e,s,i,h);l&&(0,o.default)(l)}for(var c=!1,d={},f=0;f-1};s.prototype.value=function(e){this.selected=e;this.el.value=this.getItemValue(e);if(document.createEvent){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1);this.el.dispatchEvent(t)}else this.el.fireEvent("onchange")};s.prototype.getCandidates=function(e){var t={pre:"",post:"",extract:function(e){return this.getItemValue(e)}.bind(this)};e(this.options.filter?r.filter(this.query,this.data,t):this.data.map(function(e){for(var t=this.getItemValue(e),i=this.normalize(t),n=i.lastIndexOf(this.query);n>-1;){var r=n+this.query.length;t=t.slice(0,n)+""+t.slice(n,r)+""+t.slice(r);n=i.slice(0,n).lastIndexOf(this.query)}return{original:e,string:t}}.bind(this)))};s.prototype.getItemValue=function(e){return e};t.exports=s},{"./list":31,fuzzy:4,xtend:37}],33:[function(e,t,i){(function(n){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r,o,s=e("./ponyfill.js"),a=(r=s)&&r.__esModule?r:{default:r};o="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n?n:void 0!==t?t:Function("return this")();var l=(0,a.default)(o);i.default=l}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./ponyfill.js":34}],34:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.default=function(e){var t,i=e.Symbol;if("function"==typeof i)if(i.observable)t=i.observable;else{t=i("observable");i.observable=t}else t="@@observable";return t}},{}],35:[function(e,t,i){var n=e("turf-meta").coordEach;t.exports=function(e){var t=[1/0,1/0,-1/0,-1/0];n(e,(function(e){t[0]>e[0]&&(t[0]=e[0]);t[1]>e[1]&&(t[1]=e[1]);t[2]=200&&a.status<400)){e(u([]));return e(f(JSON.parse(a.responseText).message))}var t=JSON.parse(a.responseText);if(t.error){e(u([]));return e(f(t.error))}e(f(null));t.routes[o]||e(_(0));e(u(t.routes));e(l(t.waypoints[0].location));e(c(t.waypoints[t.waypoints.length-1].location))};a.onerror=function(){e(u([]));return e(f(JSON.parse(a.responseText).message))};a.send()}}}function d(e){var t={id:"waypoint"};return Object.assign(e,{properties:e.properties?Object.assign(e.properties,t):t})}function f(e){return function(t){t({type:"ERROR",error:e});e&&t(x("error",{error:e}))}}function m(e){return{type:r.ORIGIN_FROM_COORDINATES,coordinates:e}}function g(e){return{type:r.DESTINATION_FROM_COORDINATES,coordinates:e}}function _(e){return{type:r.ROUTE_INDEX,routeIndex:e}}function y(e){return function(t,i){var n=i().destination;t(l(e));n.geometry&&t(p())}}function v(e){return function(t,i){var n=i().origin;t(c(e));n.geometry&&t(p())}}function x(e,t){var i=this;return function(n,o){var s=o().events;if(!s[e])return{type:r.EVENTS,events:s};for(var a=s[e].slice(),l=0;l=200&&this.request.status<400){var e=JSON.parse(this.request.responseText);if(e.features.length)this._clearEl.classList.add("active");else{this._clearEl.classList.remove("active");this._typeahead.selected=null}this.fire("results",{results:e.features});this._typeahead.update(e.features);return t(e.features)}this.fire("error",{error:JSON.parse(this.request.responseText).message})}.bind(this);this.request.onerror=function(){this._loadingEl.classList.remove("active");this.fire("error",{error:JSON.parse(this.request.responseText).message})}.bind(this);this.request.send()}},{key:"_queryFromInput",value:function(e){(e=e.trim())||this._clear();e.length>2&&this._geocode(e,function(e){this._results=e}.bind(this))}},{key:"_change",value:function(){var e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1);this._inputEl.dispatchEvent(e)}},{key:"_query",value:function(e){if(e){"object"===(void 0===e?"undefined":n(e))&&e.length&&(e=[l.default.wrap(e[0]),l.default.wrap(e[1])].join());this._geocode(e,function(e){if(e.length){var t=e[0];this._results=e;this._typeahead.selected=t;this._inputEl.value=t.place_name;this._change()}}.bind(this))}}},{key:"_setInput",value:function(e){if(e){"object"===(void 0===e?"undefined":n(e))&&e.length&&(e=[l.default.roundWithOriginalPrecision(l.default.wrap(e[0]),e[0]),l.default.roundWithOriginalPrecision(l.default.wrap(e[1]),e[1])].join());this._inputEl.value=e;this._input=null;this._typeahead.selected=null;this._typeahead.clear();this._change()}}},{key:"_clear",value:function(){this._input=null;this._inputEl.value="";this._typeahead.selected=null;this._typeahead.clear();this._change();this._inputEl.focus();this._clearEl.classList.remove("active");this.fire("clear")}},{key:"getResult",value:function(){return this._input}},{key:"query",value:function(e){this._query(e);return this}},{key:"setInput",value:function(e){this._setInput(e);return this}},{key:"on",value:function(e,t){this._ev.on(e,t);this._ev.on("error",(function(e){console.log(e)}));return this}},{key:"fire",value:function(e,t){this._ev.emit(e,t);return this}},{key:"off",value:function(e,t){this._ev.removeListener(e,t);return this}}]);return e}();i.default=u},{"../utils":47,events:3,"lodash.debounce":7,suggestions:30}],41:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i\n
\n
\n \n
\n
\n\n \n \n\n
\n \n
\n
\n
\n\n <% if (controls.profileSwitcher) { %>\n
checked<% } %>\n />\n \n checked<% } %>\n />\n \n checked<% } %>\n />\n \n checked<% } %>\n />\n \n
\n <% } %>\n\n"),u=function(){function e(t,i,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var o=i.getState(),s=o.originQuery,a=o.destinationQuery,l=o.profile,u=o.controls;t.innerHTML=c({originQuery:s,destinationQuery:a,profile:l,controls:u});this.container=t;this.actions=n;this.store=i;this._map=r;this.onAdd();this.render()}n(e,[{key:"animateToCoordinates",value:function(e,t){var i=this.store.getState(),n=i.origin,r=i.destination,o=i.routePadding;if(n.geometry&&r.geometry&&!(0,s.default)(n.geometry,r.geometry)){var l=(0,a.default)({type:"FeatureCollection",features:[n,r]});this._map.fitBounds([[l[0],l[1]],[l[2],l[3]]],{padding:o})}else this._map.flyTo({center:t})}},{key:"onAdd",value:function(){var e=this,t=this.actions,i=t.clearOrigin,n=t.clearDestination,o=t.createOrigin,s=t.createDestination,a=t.setProfile,l=t.reverse,c=this.store.getState(),u=c.geocoder,h=c.accessToken,p=c.flyTo,d=c.placeholderOrigin,f=c.placeholderDestination,m=c.zoom;this.originInput=new r.default(Object.assign({},{accessToken:h},u,{flyTo:p,placeholder:d,zoom:m}));var g=this.originInput.onAdd(this._map);this.container.querySelector("#mapbox-directions-origin-input").appendChild(g);this.destinationInput=new r.default(Object.assign({},{accessToken:h},u,{flyTo:p,placeholder:f,zoom:m}));var _=this.destinationInput.onAdd(this._map);this.container.querySelector("#mapbox-directions-destination-input").appendChild(_);this.originInput.on("result",(function(t){var i=t.result.center;o(i);e.animateToCoordinates("origin",i)}));this.originInput.on("clear",i);this.destinationInput.on("result",(function(t){var i=t.result.center;s(i);e.animateToCoordinates("destination",i)}));this.destinationInput.on("clear",n);var y=this.container.querySelectorAll('input[type="radio"]');Array.prototype.forEach.call(y,(function(e){e.addEventListener("change",(function(){a(e.value)}))}));this.container.querySelector(".js-reverse-inputs").addEventListener("click",(function(){var t=e.store.getState(),i=t.origin,n=t.destination;i&&e.actions.queryDestination(i.geometry.coordinates);n&&e.actions.queryOrigin(n.geometry.coordinates);l()}))}},{key:"render",value:function(){var e=this;this.store.subscribe((function(){var t=e.store.getState(),i=t.originQuery,n=t.destinationQuery,r=t.originQueryCoordinates,o=t.destinationQueryCoordinates;if(i){e.originInput.query(i);e.actions.queryOrigin(null)}if(n){e.destinationInput.query(n);e.actions.queryDestination(null)}if(r){e.originInput.setInput(r);e.animateToCoordinates("origin",r);e.actions.queryOriginCoordinates(null)}if(o){e.destinationInput.setInput(o);e.animateToCoordinates("destination",o);e.actions.queryDestinationCoordinates(null)}}))}}]);return e}();i.default=u},{"./geocoder":40,"lodash.isequal":8,"lodash.template":9,"turf-extent":35}],42:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i\n
\n <% if (routes > 1) { %>\n
\n <% for (var i = 0; i < routes; i++) { %>\n checked<% } %>>\n \n <% } %>\n
\n <% } %>\n

<%- duration %>

\n <%- distance %>\n
\n\n
\n
\n
    \n <% steps.forEach(function(step) { %>\n <%\n var distance = step.distance ? format(step.distance) : false;\n var icon = step.maneuver.modifier ? step.maneuver.modifier.replace(/\\s+/g, '-').toLowerCase() : step.maneuver.type.replace(/\\s+/g, '-').toLowerCase();\n\n if (step.maneuver.type === 'arrive' || step.maneuver.type === 'depart') {\n icon = step.maneuver.type;\n }\n\n if (step.maneuver.type === 'roundabout' || step.maneuver.type === 'rotary') {\n icon= 'roundabout';\n }\n\n var lng = step.maneuver.location[0];\n var lat = step.maneuver.location[1];\n %>\n \n \n
    \n <%= step.maneuver.instruction %>\n
    \n <% if (distance) { %>\n
    \n <%= distance %>\n
    \n <% } %>\n \n <% }); %>\n
\n
\n
\n\n"),c=(0,o.default)("
\n
\n <%= error %>\n
\n
\n"),u=function(){function e(t,i,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);this.container=t;this.actions=n;this.store=i;this._map=r;this.directions={};this.render()}n(e,[{key:"render",value:function(){var e=this;this.store.subscribe((function(){var t=e.actions,i=t.hoverMarker,n=t.setRouteIndex,o=e.store.getState(),a=o.routeIndex,u=o.unit,h=o.directions,p=o.error,d=o.compile,f=!(0,s.default)(h[a],e.directions);if(p)e.container.innerHTML=c({error:p});else if(h.length&&f){var m=e.directions=h[a];d&&m.legs.forEach((function(e){e.steps.forEach((function(e){e.maneuver.instruction=d("en",e)}))}));e.container.innerHTML=l({routeIndex:a,routes:h.length,steps:m.legs[0].steps,format:r.default.format[u],duration:r.default.format[u](m.distance),distance:r.default.format.duration(m.duration)});var g=e.container.querySelectorAll(".mapbox-directions-step");Array.prototype.forEach.call(g,(function(t){var n=t.getAttribute("data-lng"),r=t.getAttribute("data-lat");t.addEventListener("mouseover",(function(){i([n,r])}));t.addEventListener("mouseout",(function(){i(null)}));t.addEventListener("click",(function(){e._map.flyTo({center:[n,r],zoom:16})}))}));var _=e.container.querySelectorAll('input[type="radio"]');Array.prototype.forEach.call(_,(function(e){e.addEventListener("change",(function(e){n(parseInt(e.target.id,10))}))}))}else e.container.innerHTML&&f&&(e.container.innerHTML="")}))}}]);return e}();i.default=u},{"../utils":47,"lodash.isequal":8,"lodash.template":9}],43:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:a,t=arguments[1];switch(t.type){case r.SET_OPTIONS:return(0,s.default)({},e,t.options);case r.DIRECTIONS_PROFILE:return Object.assign({},e,{profile:t.profile});case r.ORIGIN:return Object.assign({},e,{origin:t.origin,hoverMarker:{}});case r.DESTINATION:return Object.assign({},e,{destination:t.destination,hoverMarker:{}});case r.HOVER_MARKER:return Object.assign({},e,{hoverMarker:t.hoverMarker});case r.WAYPOINTS:return Object.assign({},e,{waypoints:t.waypoints});case r.ORIGIN_QUERY:return Object.assign({},e,{originQuery:t.query});case r.DESTINATION_QUERY:return Object.assign({},e,{destinationQuery:t.query});case r.ORIGIN_FROM_COORDINATES:return Object.assign({},e,{originQueryCoordinates:t.coordinates});case r.DESTINATION_FROM_COORDINATES:return Object.assign({},e,{destinationQueryCoordinates:t.coordinates});case r.ORIGIN_CLEAR:return Object.assign({},e,{origin:{},originQuery:"",waypoints:[],directions:[]});case r.DESTINATION_CLEAR:return Object.assign({},e,{destination:{},destinationQuery:"",waypoints:[],directions:[]});case r.DIRECTIONS:return Object.assign({},e,{directions:t.directions});case r.ROUTE_INDEX:return Object.assign({},e,{routeIndex:t.routeIndex});case r.ERROR:return Object.assign({},e,{error:t.error});default:return e}}},{"../constants/action_types.js":39,"deep-assign":2}],47:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={duration:function(e){var t=Math.floor(e/60),i=Math.floor(t/60);e%=60;t%=60;return 0===i&&0===t?e+"s":0===i?t+"min":i+"h "+t+"min"},imperial:function(e){var t=e/1609.344;return t>=100?t.toFixed(0)+"mi":t>=10?t.toFixed(1)+"mi":t>=.1?t.toFixed(2)+"mi":(5280*t).toFixed(0)+"ft"},metric:function(e){return e>=1e5?(e/1e3).toFixed(0)+"km":e>=1e4?(e/1e3).toFixed(1)+"km":e>=100?(e/1e3).toFixed(2)+"km":e.toFixed(0)+"m"}};i.default={format:n,coordinateMatch:function(e,t){e=e.geometry.coordinates;t=t.geometry.coordinates;return e.join()===t.join()||e[0].toFixed(3)===t[0].toFixed(3)&&e[1].toFixed(3)===t[1].toFixed(3)},createPoint:function(e,t){return{type:"Feature",geometry:{type:"Point",coordinates:e},properties:t||{}}},validCoords:function(e){return e[0]>=-180&&e[0]<=180&&e[1]>=-90&&e[1]<=90},wrap:function(e){var t=((e- -180)%360+360)%360-180;return-180===t?180:t},roundWithOriginalPrecision:function(e,t){var i=0;Math.floor(t)!==t&&(i=t.toString().split(".")[1].length);return e.toFixed(Math.min(i,5))}}},{}]},{},[45])(45)}));!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MapboxGeocoder=e()}}((function(){return function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&(this.send(this.eventQueue),this.eventQueue=new Array),this.timer&&clearTimeout(this.timer),this.flushInterval&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval))},push:function(e,t){this.eventQueue.push(e),(this.eventQueue.length>=this.maxQueueSize||t)&&this.flush()},remove:function(){this.flush()}},t.exports=n},{nanoid:30}],2:[function(e,t,i){t.exports={fr:{name:"France",bbox:[[-4.59235,41.380007],[9.560016,51.148506]]},us:{name:"United States",bbox:[[-171.791111,18.91619],[-66.96466,71.357764]]},ru:{name:"Russia",bbox:[[19.66064,41.151416],[190.10042,81.2504]]},ca:{name:"Canada",bbox:[[-140.99778,41.675105],[-52.648099,83.23324]]}}},{}],3:[function(e,t,i){"use strict";function n(e){this._eventEmitter=new a,this.options=s({},this.options,e),this.inputString="",this.fresh=!0,this.lastSelected=null}var r=e("suggestions"),o=e("lodash.debounce"),s=e("xtend"),a=e("events").EventEmitter,l=e("./exceptions"),c=e("@mapbox/mapbox-sdk"),u=e("@mapbox/mapbox-sdk/services/geocoding"),h=e("./events"),p=e("./localization"),d=e("subtag");const f=0,m=1,g=2;n.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,minLength:2,reverseGeocode:!1,limit:5,origin:"https://api.mapbox.com",enableEventLogging:!0,marker:!0,mapboxgl:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,getItemValue:function(e){return e.place_name},render:function(e){var t=e.place_name.split(",");return'
'+t[0]+'
'+t.splice(1,t.length).join(",")+"
"}},addTo:function(e){function t(e,t){if(!document.body.contains(t))throw new Error("Element provided to #addTo() exists, but is not in the DOM");const i=e.onAdd();t.appendChild(i)}if(e._controlContainer)e.addControl(this);else if(e instanceof HTMLElement)t(this,e);else{if("string"!=typeof e)throw new Error("Error: addTo must be a mapbox-gl-js map, an html element, or a CSS selector query for a single html element");const i=document.querySelectorAll(e);if(0===i.length)throw new Error("Element ",e,"not found.");if(i.length>1)throw new Error("Geocoder can only be added to a single html element");t(this,i[0])}},onAdd:function(e){if(e&&"string"!=typeof e&&(this._map=e),this.setLanguage(),this.options.localGeocoderOnly||(this.geocoderService=u(c({accessToken:this.options.accessToken,origin:this.options.origin}))),this.options.localGeocoderOnly&&!this.options.localGeocoder)throw new Error("A localGeocoder function must be specified to use localGeocoderOnly mode");this.eventManager=new h(this.options),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPaste=this._onPaste.bind(this),this._onBlur=this._onBlur.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this);var t=this.container=document.createElement("div");t.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var i=this.createIcon("search",'');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-ctrl-geocoder--input",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse)),(this.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",o(this._onKeyDown,200)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton),this._inputEl.addEventListener("keyup",function(e){this.eventManager.keyevent(e,this)}.bind(this));var n=document.createElement("div");n.classList.add("mapboxgl-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="mapboxgl-ctrl-geocoder--button";var s=this.createIcon("close",'');return this._clearEl.appendChild(s),this._loadingEl=this.createIcon("loading",''),n.appendChild(this._clearEl),n.appendChild(this._loadingEl),t.appendChild(i),t.appendChild(this._inputEl),t.appendChild(n),this._typeahead=new r(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit}),this.setRenderFunction(this.options.render),this._typeahead.getItemValue=this.options.getItemValue,this.mapMarker=null,this._handleMarker=this._handleMarker.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._mapboxgl=this.options.mapboxgl,!this._mapboxgl&&this.options.marker&&(console.error("No mapboxgl detected in options. Map markers are disabled. Please set options.mapboxgl."),this.options.marker=!1)),t},createIcon:function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+e),i.setAttribute("viewBox","0 0 18 18"),i.setAttribute("xml:space","preserve"),i.setAttribute("width",18),i.setAttribute("height",18),"innerHTML"in i)i.innerHTML=t;else{var n=document.createElement("div");n.innerHTML=""+t.valueOf().toString()+"";var r=n.firstChild.firstChild;i.appendChild(r)}return i},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_onPaste:function(e){var t=(e.clipboardData||window.clipboardData).getData("text");t.length>=this.options.minLength&&this._geocode(t)},_onKeyDown:function(e){if(27===e.keyCode&&this.options.clearAndBlurOnEsc)return this._clear(e),this._inputEl.blur();var t=e.target&&e.target.shadowRoot?e.target.shadowRoot.activeElement:e.target;if(!t||!t.value)return this.fresh=!0,9!==e.keyCode&&this.clear(e),this._clearEl.style.display="none";e.metaKey||-1!==[9,27,37,39,13,38,40].indexOf(e.keyCode)||t.value.length>=this.options.minLength&&this._geocode(t.value)},_showButton:function(){this._typeahead.selected&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onBlur:function(e){this.options.clearOnBlur&&this._clearOnBlur(e),this.options.collapsed&&this._collapse()},_onChange:function(){var e=this._typeahead.selected;if(e&&JSON.stringify(e)!==this.lastSelected){if(this._clearEl.style.display="none",this.options.flyTo){var t;if(e.properties&&l[e.properties.short_code])t=s({},this.options.flyTo),this._map&&this._map.fitBounds(l[e.properties.short_code].bbox,t);else if(e.bbox){var i=e.bbox;t=s({},this.options.flyTo),this._map&&this._map.fitBounds([[i[0],i[1]],[i[2],i[3]]],t)}else{var n={zoom:this.options.zoom};t=s({},n,this.options.flyTo),e.center?t.center=e.center:e.geometry&&e.geometry.type&&"Point"===e.geometry.type&&e.geometry.coordinates&&(t.center=e.geometry.coordinates),this._map&&this._map.flyTo(t)}}this.options.marker&&this._mapboxgl&&this._handleMarker(e),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(e),this._eventEmitter.emit("result",{result:e}),this.eventManager.select(e,this)}},_requestType:function(e,t){return e.localGeocoderOnly?m:e.reverseGeocode&&/^[ ]*(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)[ ]*$/.test(t)?g:f},_setupConfig:function(e,t){const i=/[\s,]+/;var n=this,r=["bbox","limit","proximity","countries","types","language","reverseMode","mode"].reduce((function(e,t){if(!n.options[t])return e;["countries","types","language"].indexOf(t)>-1?e[t]=n.options[t].split(i):e[t]=n.options[t];const r="number"==typeof n.options[t].longitude&&"number"==typeof n.options[t].latitude;if("proximity"===t&&r){const i=n.options[t].longitude,r=n.options[t].latitude;e[t]=[i,r]}return e}),{});switch(e){case g:var o=t.split(i).map((function(e){return parseFloat(e,10)})).reverse();r.types&&r.types[0],"proximity"in(r=s(r,{query:o,limit:1}))&&delete r.proximity;break;case f:/^[ ]*(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)*[ ]*$/.test(t)&&(t=t.replace(/,/g," ")),r=s(r,{query:t})}return r},_geocode:function(e){this.inputString=e,this._loadingEl.style.display="block",this._eventEmitter.emit("loading",{query:e});const t=this._requestType(this.options,e),i=this._setupConfig(t,e);var n;switch(t){case m:n=Promise.resolve();break;case f:n=this.geocoderService.forwardGeocode(i).send();break;case g:n=this.geocoderService.reverseGeocode(i).send()}var r=this.options.localGeocoder&&this.options.localGeocoder(e)||[],o=[],s=null;return n.catch(function(e){s=e}.bind(this)).then(function(t){this._loadingEl.style.display="none";var n={};return t?"200"==t.statusCode&&((n=t.body).request=t.request,n.headers=t.headers):n={type:"FeatureCollection",features:[]},n.config=i,this.fresh&&(this.eventManager.start(this),this.fresh=!1),n.features=n.features?r.concat(n.features):r,this.options.externalGeocoder?(o=this.options.externalGeocoder(e,n.features)||[]).then((function(e){return n.features=n.features?e.concat(n.features):e,n}),(function(){return n})):n}.bind(this)).then(function(e){if(s)throw s;this.options.filter&&e.features.length&&(e.features=e.features.filter(this.options.filter)),e.features.length?(this._clearEl.style.display="block",this._eventEmitter.emit("results",e),this._typeahead.update(e.features)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",e))}.bind(this)).catch(function(e){this._loadingEl.style.display="none",r.length&&this.options.localGeocoder||o.length&&this.options.externalGeocoder?(this._clearEl.style.display="block",this._typeahead.update(r)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:r}),this._eventEmitter.emit("error",{error:e})}.bind(this)),n},_clear:function(e){e&&e.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this._clearEl.style.display="none",this._removeMarker(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(e){this._clear(e),this._inputEl.focus()},_clearOnBlur:function(e){e.relatedTarget&&this._clear(e)},_onQueryResult:function(e){var t=e.body;if(t.features.length){var i=t.features[0];this._typeahead.selected=i,this._inputEl.value=i.place_name,this._onChange()}},_updateProximity:function(){if(this._map)if(this._map.getZoom()>9){var e=this._map.getCenter().wrap();this.setProximity({longitude:e.lng,latitude:e.lat})}else this.setProximity(null)},_collapse:function(){this._inputEl.value||this._inputEl===document.activeElement||this.container.classList.add("mapboxgl-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("mapboxgl-ctrl-geocoder--collapsed")},query:function(e){return this._geocode(e).then(this._onQueryResult),this},_renderError:function(){this._renderMessage("
There was an error reaching the server
")},_renderNoResults:function(){this._renderMessage("
No results found
")},_renderMessage:function(e){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(e)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var e=this.options.language.split(",")[0],t=d.language(e),i=p.placeholder[t];if(i)return i}return"Search"},setInput:function(e){return this._inputEl.value=e,this._typeahead.selected=null,this._typeahead.clear(),e.length>=this.options.minLength&&this._geocode(e),this},setProximity:function(e){return this.options.proximity=e,this},getProximity:function(){return this.options.proximity},setRenderFunction:function(e){return e&&"function"==typeof e&&(this._typeahead.render=e),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(e){var t=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=e||this.options.language||t,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(e){return this.options.zoom=e,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(e){return this.options.flyTo=e,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(e){return this.placeholder=e||this._getPlaceholderText(),this._inputEl.placeholder=this.placeholder,this._inputEl.setAttribute("aria-label",this.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(e){return this.options.bbox=e,this},getCountries:function(){return this.options.countries},setCountries:function(e){return this.options.countries=e,this},getTypes:function(){return this.options.types},setTypes:function(e){return this.options.types=e,this},getMinLength:function(){return this.options.minLength},setMinLength:function(e){return this.options.minLength=e,this._typeahead&&(this._typeahead.options.minLength=e),this},getLimit:function(){return this.options.limit},setLimit:function(e){return this.options.limit=e,this._typeahead&&(this._typeahead.options.limit=e),this},getFilter:function(){return this.options.filter},setFilter:function(e){return this.options.filter=e,this},setOrigin:function(e){return this.options.origin=e,this.geocoderService=u(c({accessToken:this.options.accessToken,origin:this.options.origin})),this},getOrigin:function(){return this.options.origin},_handleMarker:function(e){if(this._map){this._removeMarker();var t=s({},{color:"#4668F2"},this.options.marker);return this.mapMarker=new this._mapboxgl.Marker(t),e.center?this.mapMarker.setLngLat(e.center).addTo(this._map):e.geometry&&e.geometry.type&&"Point"===e.geometry.type&&e.geometry.coordinates&&this.mapMarker.setLngLat(e.geometry.coordinates).addTo(this._map),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(e,t){return this._eventEmitter.on(e,t),this},off:function(e,t){return this._eventEmitter.removeListener(e,t),this.eventManager.remove(),this}},t.exports=n},{"./events":1,"./exceptions":2,"./localization":4,"@mapbox/mapbox-sdk":6,"@mapbox/mapbox-sdk/services/geocoding":17,events:25,"lodash.debounce":29,subtag:32,suggestions:33,xtend:36}],4:[function(e,t,i){"use strict";t.exports={placeholder:{de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"לחפש",ja:"サーチ",lv:"Meklēt",pt:"Procurar",sr:"Претрага",zh:"搜索",cs:"Vyhledávání",hu:"Keresés",ka:"ძიება",nb:"Søke",sk:"Vyhľadávanie",th:"ค้นหา",fi:"Hae",is:"Leita",ko:"수색",pl:"Szukaj",sl:"Iskanje",fa:"جستجو",ru:"Поиск"}}},{}],5:[function(e,t,i){"use strict";function n(e){var t=Array.isArray(e),i=function(i){return t?e[i]:e};return function(n){var o=r(h.plainArray,n);if(o)return o;if(t&&n.length!==e.length)return"an array with "+e.length+" items";for(var s=0;se.length?t:e}))}},h.equal=function(e){return function(t){if(t!==e)return JSON.stringify(e)}},h.oneOf=function(){var e=(Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments)).map((function(e){return h.equal(e)}));return h.oneOfType.apply(this,e)},h.range=function(e){var t=e[0],i=e[1];return function(e){if(r(h.number,e)||ei)return"number between "+t+" & "+i+" (inclusive)"}},h.any=function(){},h.boolean=function(e){if("boolean"!=typeof e)return"boolean"},h.number=function(e){if("number"!=typeof e)return"number"},h.plainArray=function(e){if(!Array.isArray(e))return"array"},h.plainObject=function(e){if(!l(e))return"object"},h.string=function(e){if("string"!=typeof e)return"string"},h.func=function(e){if("function"!=typeof e)return"function"},h.validate=r,h.processMessage=o,t.exports=h},{"is-plain-obj":28,xtend:36}],6:[function(e,t,i){"use strict";var n=e("./lib/client");t.exports=n},{"./lib/client":7}],7:[function(e,t,i){"use strict";function n(e){o.call(this,e)}var r=e("./browser-layer"),o=e("../classes/mapi-client");n.prototype=Object.create(o.prototype),n.prototype.constructor=n,n.prototype.sendRequest=r.browserSend,n.prototype.abortRequest=r.browserAbort,t.exports=function(e){return new n(e)}},{"../classes/mapi-client":9,"./browser-layer":8}],8:[function(e,t,i){"use strict";function n(e){var t=e.total,i=e.loaded;return{total:t,transferred:i,percent:100*i/t}}function r(e,t){return new Promise((function(i,r){t.onprogress=function(t){e.emitter.emit(l.EVENT_PROGRESS_DOWNLOAD,n(t))};var o=e.file;o&&(t.upload.onprogress=function(t){e.emitter.emit(l.EVENT_PROGRESS_UPLOAD,n(t))}),t.onerror=function(e){r(e)},t.onabort=function(){var t=new a({request:e,type:l.ERROR_REQUEST_ABORTED});r(t)},t.onload=function(){if(delete u[e.id],t.status<200||t.status>=400){var n=new a({request:e,body:t.response,statusCode:t.status});r(n)}else i(t)};var s=e.body;"string"==typeof s?t.send(s):s?t.send(JSON.stringify(s)):o?t.send(o):t.send(),u[e.id]=t})).then((function(t){return function(e,t){return new s(e,{body:t.response,headers:c(t.getAllResponseHeaders()),statusCode:t.status})}(e,t)}))}function o(e,t){var i=e.url(t),n=new window.XMLHttpRequest;return n.open(e.method,i),Object.keys(e.headers).forEach((function(t){n.setRequestHeader(t,e.headers[t])})),n}var s=e("../classes/mapi-response"),a=e("../classes/mapi-error"),l=e("../constants"),c=e("../helpers/parse-headers"),u={};t.exports={browserAbort:function(e){var t=u[e.id];t&&(t.abort(),delete u[e.id])},sendRequestXhr:r,browserSend:function(e){return Promise.resolve().then((function(){var t=o(e,e.client.accessToken);return r(e,t)}))},createRequestXhr:o}},{"../classes/mapi-error":10,"../classes/mapi-response":12,"../constants":13,"../helpers/parse-headers":14}],9:[function(e,t,i){"use strict";function n(e){if(!e||!e.accessToken)throw new Error("Cannot create a client without an access token");r(e.accessToken),this.accessToken=e.accessToken,this.origin=e.origin||s.API_ORIGIN}var r=e("@mapbox/parse-mapbox-token"),o=e("./mapi-request"),s=e("../constants");n.prototype.createRequest=function(e){return new o(this,e)},t.exports=n},{"../constants":13,"./mapi-request":11,"@mapbox/parse-mapbox-token":23}],10:[function(e,t,i){"use strict";var n=e("../constants");t.exports=function(e){var t,i=e.type||n.ERROR_HTTP;if(e.body)try{t=JSON.parse(e.body)}catch(i){t=e.body}else t=null;var r=e.message||null;r||("string"==typeof t?r=t:t&&"string"==typeof t.message?r=t.message:i===n.ERROR_REQUEST_ABORTED&&(r="Request aborted")),this.message=r,this.type=i,this.statusCode=e.statusCode||null,this.request=e.request,this.body=t}},{"../constants":13}],11:[function(e,t,i){"use strict";function n(e,t){if(!e)throw new Error("MapiRequest requires a client");if(!t||!t.path||!t.method)throw new Error("MapiRequest requires an options object with path and method properties");var i={};t.body&&(i["content-type"]="application/json");var n=o(i,t.headers),r=Object.keys(n).reduce((function(e,t){return e[t.toLowerCase()]=n[t],e}),{});this.id=c++,this._options=t,this.emitter=new s,this.client=e,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=t.path,this.method=t.method,this.origin=t.origin||e.origin,this.query=t.query||{},this.params=t.params||{},this.body=t.body||null,this.file=t.file||null,this.encoding=t.encoding||"utf8",this.sendFileAs=t.sendFileAs||null,this.headers=r}var r=e("@mapbox/parse-mapbox-token"),o=e("xtend"),s=e("eventemitter3"),a=e("../helpers/url-utils"),l=e("../constants"),c=1;n.prototype.url=function(e){var t=a.prependOrigin(this.path,this.origin);t=a.appendQueryObject(t,this.query);var i=this.params,n=null==e?this.client.accessToken:e;if(n){t=a.appendQueryParam(t,"access_token",n);var s=r(n).user;i=o({ownerId:s},i)}return t=a.interpolateRouteParams(t,i)},n.prototype.send=function(){var e=this;if(e.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return e.sent=!0,e.client.sendRequest(e).then((function(t){return e.response=t,e.emitter.emit(l.EVENT_RESPONSE,t),t}),(function(t){throw e.error=t,e.emitter.emit(l.EVENT_ERROR,t),t}))},n.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},n.prototype.eachPage=function(e){function t(t){e(null,t,(function(){delete r._nextPageRequest;var e=t.nextPage();e&&(r._nextPageRequest=e,n(e))}))}function i(t){e(t,null,(function(){}))}function n(e){e.send().then(t,i)}var r=this;n(this)},n.prototype.clone=function(){return this._extend()},n.prototype._extend=function(e){var t=o(this._options,e);return new n(this.client,t)},t.exports=n},{"../constants":13,"../helpers/url-utils":16,"@mapbox/parse-mapbox-token":23,eventemitter3:26,xtend:36}],12:[function(e,t,i){"use strict";function n(e,t){this.request=e,this.headers=t.headers,this.rawBody=t.body,this.statusCode=t.statusCode;try{this.body=JSON.parse(t.body||"{}")}catch(e){this.body=t.body}this.links=r(this.headers.link)}var r=e("../helpers/parse-link-header");n.prototype.hasNextPage=function(){return!!this.links.next},n.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null},t.exports=n},{"../helpers/parse-link-header":15}],13:[function(e,t,i){"use strict";t.exports={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"}},{}],14:[function(e,t,i){"use strict";t.exports=function(e){var t={};return e?(e.trim().split(/[\r|\n]+/).forEach((function(e){var i=function(e){var t=e.indexOf(":");return{name:e.substring(0,t).trim().toLowerCase(),value:e.substring(t+1).trim()}}(e);t[i.name]=i.value})),t):t}},{}],15:[function(e,t,i){"use strict";t.exports=function(e){return e?e.split(/,\s*]*)>(.*)/);if(!t)return null;var i=t[1],n=t[2].split(";"),r=null,o=n.reduce((function(e,t){var i=function(e){var t=e.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return t?{key:t[1],value:t[2]}:null}(t);return i?"rel"===i.key?(r||(r=i.value),e):(e[i.key]=i.value,e):e}),{});return r?{url:i,rel:r,params:o}:null}(t);return i?(i.rel.split(/\s+/).forEach((function(t){e[t]||(e[t]={url:i.url,params:i.params})})),e):e}),{}):{}}},{}],16:[function(e,t,i){"use strict";function n(e){return Array.isArray(e)?function(e){return e.map(encodeURIComponent).join(",")}(e):encodeURIComponent(String(e))}function r(e,t,i){if(!1===i||null===i)return e;var r=/\?/.test(e)?"&":"?",o=encodeURIComponent(t);return void 0!==i&&""!==i&&!0!==i&&(o+="="+n(i)),""+e+r+o}t.exports={appendQueryObject:function(e,t){if(!t)return e;var i=e;return Object.keys(t).forEach((function(e){var n=t[e];void 0!==n&&(Array.isArray(n)&&(n=n.filter((function(e){return null!=e})).join(",")),i=r(i,e,n))})),i},appendQueryParam:r,prependOrigin:function(e,t){if(!t)return e;if("http"===e.slice(0,4))return e;var i="/"===e[0]?"":"/";return""+t.replace(/\/$/,"")+i+e},interpolateRouteParams:function(e,t){return t?e.replace(/\/:([a-zA-Z0-9]+)/g,(function(e,i){var r=t[i];if(void 0===r)throw new Error("Unspecified route parameter "+i);return"/"+n(r)})):e}}},{}],17:[function(e,t,i){"use strict";var n=e("xtend"),r=e("./service-helpers/validator"),o=e("./service-helpers/pick"),s=e("./service-helpers/stringify-booleans"),a=e("./service-helpers/create-service-factory"),l={},c=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];l.forwardGeocode=function(e){r.assertShape({query:r.required(r.string),mode:r.oneOf("mapbox.places","mapbox.places-permanent"),countries:r.arrayOf(r.string),proximity:r.coordinates,types:r.arrayOf(r.oneOf(c)),autocomplete:r.boolean,bbox:r.arrayOf(r.number),limit:r.number,language:r.arrayOf(r.string),routing:r.boolean})(e),e.mode=e.mode||"mapbox.places";var t=s(n({country:e.countries},o(e,["proximity","types","autocomplete","bbox","limit","language","routing"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(e,["mode","query"]),query:t})},l.reverseGeocode=function(e){r.assertShape({query:r.required(r.coordinates),mode:r.oneOf("mapbox.places","mapbox.places-permanent"),countries:r.arrayOf(r.string),types:r.arrayOf(r.oneOf(c)),bbox:r.arrayOf(r.number),limit:r.number,language:r.arrayOf(r.string),reverseMode:r.oneOf("distance","score"),routing:r.boolean})(e),e.mode=e.mode||"mapbox.places";var t=s(n({country:e.countries},o(e,["country","types","bbox","limit","language","reverseMode","routing"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(e,["mode","query"]),query:t})},t.exports=a(l)},{"./service-helpers/create-service-factory":18,"./service-helpers/pick":20,"./service-helpers/stringify-booleans":21,"./service-helpers/validator":22,xtend:36}],18:[function(e,t,i){"use strict";var n=e("../../lib/classes/mapi-client"),r=e("../../lib/client");t.exports=function(e){return function(t){var i;i=n.prototype.isPrototypeOf(t)?t:r(t);var o=Object.create(e);return o.client=i,o}}},{"../../lib/classes/mapi-client":9,"../../lib/client":7}],19:[function(e,t,i){"use strict";t.exports=function(e,t){return Object.keys(e).reduce((function(i,n){return i[n]=t(n,e[n]),i}),{})}},{}],20:[function(e,t,i){"use strict";t.exports=function(e,t){var i=function(e,i){return-1!==t.indexOf(e)&&void 0!==i};return"function"==typeof t&&(i=t),Object.keys(e).filter((function(t){return i(t,e[t])})).reduce((function(t,i){return t[i]=e[i],t}),{})}},{}],21:[function(e,t,i){"use strict";var n=e("./object-map");t.exports=function(e){return n(e,(function(e,t){return"boolean"==typeof t?JSON.stringify(t):t}))}},{"./object-map":19}],22:[function(e,t,i){(function(i){"use strict";var n=e("xtend"),r=e("@mapbox/fusspot");t.exports=n(r,{file:function(e){if("undefined"!=typeof window){if(e instanceof i.Blob||e instanceof i.ArrayBuffer)return;return"Blob or ArrayBuffer"}if("string"!=typeof e&&void 0===e.pipe)return"Filename or Readable stream"},date:function(e){if("boolean"==typeof e)return"date";try{var t=new Date(e);if(t.getTime&&isNaN(t.getTime()))return"date"}catch(e){return"date"}},coordinates:function(e){return r.tuple(r.number,r.number)(e)},assertShape:function(e,t){return r.assert(r.strictShape(e),t)}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"@mapbox/fusspot":5,xtend:36}],23:[function(e,t,i){"use strict";function n(e){try{return JSON.parse(o.decode(e))}catch(e){throw new Error("Invalid token")}}function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var o=e("base-64"),s={};t.exports=function(e){if(s[e])return s[e];var t=e.split("."),i=t[0],o=t[1];if(!o)throw new Error("Invalid token");var a=n(o),l={usage:i,user:a.u};return r(a,"a")&&(l.authorization=a.a),r(a,"exp")&&(l.expires=1e3*a.exp),r(a,"iat")&&(l.created=1e3*a.iat),r(a,"scopes")&&(l.scopes=a.scopes),r(a,"client")&&(l.client=a.client),r(a,"ll")&&(l.lastLogin=a.ll),r(a,"iu")&&(l.impersonator=a.iu),s[e]=l,l}},{"base-64":24}],24:[function(e,t,i){(function(e){!function(n){var r="object"==typeof i&&i,o="object"==typeof t&&t&&t.exports==r&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s||(n=s);var a=function(e){this.message=e};(a.prototype=new Error).name="InvalidCharacterError";var l=function(e){throw new a(e)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,h={encode:function(e){e=String(e),/[^\0-\xFF]/.test(e)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var t,i,n,r,o=e.length%3,s="",a=-1,u=e.length-o;++a>18&63)+c.charAt(r>>12&63)+c.charAt(r>>6&63)+c.charAt(63&r);return 2==o?(t=e.charCodeAt(a)<<8,i=e.charCodeAt(++a),s+=c.charAt((r=t+i)>>10)+c.charAt(r>>4&63)+c.charAt(r<<2&63)+"="):1==o&&(r=e.charCodeAt(a),s+=c.charAt(r>>2)+c.charAt(r<<4&63)+"=="),s},decode:function(e){var t=(e=String(e).replace(u,"")).length;t%4==0&&(t=(e=e.replace(/==?$/,"")).length),(t%4==1||/[^+a-zA-Z0-9/]/.test(e))&&l("Invalid character: the string to be decoded is not correctly encoded.");for(var i,n,r=0,o="",s=-1;++s>(-2*r&6)));return o},version:"0.1.0"};if(r&&!r.nodeType)if(o)o.exports=h;else for(var p in h)h.hasOwnProperty(p)&&(r[p]=h[p]);else n.base64=h}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],25:[function(e,t,i){function n(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=h(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function r(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function o(e,t,i,n){var o,s,a;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),s=e._events),a=s[t]):(s=e._events=h(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=n?[i,a]:[a,i]:n?a.unshift(i):a.push(i),!a.warned&&(o=r(e))&&o>0&&a.length>o){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=s[t]=i,++e._eventsCount;return e}function s(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t1&&(t=arguments[1]),t instanceof Error)throw t;var l=new Error('Unhandled "error" event. ('+t+")");throw l.context=t,l}if(!(i=s[e]))return!1;var c="function"==typeof i;switch(n=arguments.length){case 1:!function(e,t,i){if(t)e.call(i);else for(var n=e.length,r=u(e,n),o=0;o=0;o--)if(i[o]===t||i[o].listener===t){s=i[o].listener,r=o;break}if(r<0)return this;0===r?i.shift():function(e,t){for(var i=t,n=i+1,r=e.length;n=0;n--)this.removeListener(e,t[n]);return this},n.prototype.listeners=function(e){return l(this,e,!0)},n.prototype.rawListeners=function(e){return l(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):c.call(e,t)},n.prototype.listenerCount=c,n.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],26:[function(e,t,i){"use strict";function n(){}function r(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function o(e,t,i,n,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new r(i,n||e,o),a=c?c+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],s]:e._events[a].push(s):(e._events[a]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}var l=Object.prototype.hasOwnProperty,c="~";Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(c=!1)),a.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)l.call(e,t)&&i.push(c?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=c?c+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,r=i.length,o=new Array(r);n=t||i<0||w&&e-x>=d}function l(){var e=y();if(a(e))return c(e);m=setTimeout(l,function(e){var i=t-(e-v);return w?_(i,d-(e-x)):i}(e))}function c(e){return m=void 0,M&&h?s(e):(h=p=void 0,f)}function u(){var e=y(),i=a(e);if(h=arguments,p=this,v=e,i){if(void 0===m)return function(e){return x=e,m=setTimeout(l,t),b?s(e):f}(v);if(w)return m=setTimeout(l,t),s(v)}return void 0===m&&(m=setTimeout(l,t)),f}var h,p,d,f,m,v,x=0,b=!1,w=!1,M=!0;if("function"!=typeof e)throw new TypeError(r);return t=n(t)||0,i(o)&&(b=!!o.leading,d=(w="maxWait"in o)?g(n(o.maxWait)||0,t):d,M="trailing"in o?!!o.trailing:M),u.cancel=function(){void 0!==m&&clearTimeout(m),x=0,h=v=p=m=void 0},u.flush=function(){return void 0===m?f:c(y())},u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],30:[function(e,t,i){(function(e){if("production"!==e.env.NODE_ENV&&("undefined"==typeof self||!self.crypto&&!self.msCrypto))throw new Error("Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.");var i=self.crypto||self.msCrypto;t.exports=function(e){e=e||21;for(var t="",n=i.getRandomValues(new Uint8Array(e));01)for(var i=1;i-1},s.prototype.value=function(e){if(this.selected=e,this.el.value=this.getItemValue(e),document.createEvent){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1),this.el.dispatchEvent(t)}else this.el.fireEvent("onchange")},s.prototype.getCandidates=function(e){var t,i={pre:"",post:"",extract:function(e){return this.getItemValue(e)}.bind(this)};this.options.filter?t=(t=r.filter(this.query,this.data,i)).map(function(e){return{original:e.original,string:this.render(e.original,e.string)}}.bind(this)):t=this.data.map(function(e){return{original:e,string:this.render(e)}}.bind(this)),e(t)},s.prototype.getItemValue=function(e){return e},s.prototype.render=function(e,t){if(t)return t;for(var i=e.original?this.getItemValue(e.original):this.getItemValue(e),n=this.normalize(i),r=n.lastIndexOf(this.query);r>-1;){var o=r+this.query.length;i=i.slice(0,r)+""+i.slice(r,o)+""+i.slice(o),r=n.slice(0,r).lastIndexOf(this.query)}return i},s.prototype.renderError=function(e){this.list.drawError(e)},t.exports=s},{"./list":34,fuzzy:27,xtend:36}],36:[function(e,t,i){t.exports=function(){for(var e={},t=0;t>8&255]+re[e>>16&255]+re[e>>24&255]+"-"+re[255&t]+re[t>>8&255]+"-"+re[t>>16&15|64]+re[t>>24&255]+"-"+re[63&i|128]+re[i>>8&255]+"-"+re[i>>16&255]+re[i>>24&255]+re[255&n]+re[n>>8&255]+re[n>>16&255]+re[n>>24&255]).toUpperCase()}function ce(e,t,i){return Math.max(t,Math.min(i,e))}function ue(e,t){return(e%t+t)%t}function he(e,t,i){return(1-i)*e+i*t}function pe(e){return 0==(e&e-1)&&0!==e}function de(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function fe(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var me=Object.freeze({__proto__:null,DEG2RAD:se,RAD2DEG:ae,generateUUID:le,clamp:ce,euclideanModulo:ue,mapLinear:function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},inverseLerp:function(e,t,i){return e!==t?(i-e)/(t-e):0},lerp:he,damp:function(e,t,i,n){return he(e,t,1-Math.exp(-i*n))},pingpong:function(e,t=1){return t-Math.abs(ue(e,2*t)-t)},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(oe=e%2147483647),((oe=16807*oe%2147483647)-1)/2147483646},degToRad:function(e){return e*se},radToDeg:function(e){return e*ae},isPowerOfTwo:pe,ceilPowerOfTwo:de,floorPowerOfTwo:fe,setQuaternionFromProperEuler:function(e,t,i,n,r){const o=Math.cos,s=Math.sin,a=o(i/2),l=s(i/2),c=o((t+n)/2),u=s((t+n)/2),h=o((t-n)/2),p=s((t-n)/2),d=o((n-t)/2),f=s((n-t)/2);switch(r){case"XYX":e.set(a*u,l*h,l*p,a*c);break;case"YZY":e.set(l*p,a*u,l*h,a*c);break;case"ZXZ":e.set(l*h,l*p,a*u,a*c);break;case"XZX":e.set(a*u,l*f,l*d,a*c);break;case"YXY":e.set(l*d,a*u,l*f,a*c);break;case"ZYZ":e.set(l*f,l*d,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}});class ge{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*n+e.x,this.y=r*n+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}ge.prototype.isVector2=!0;class _e{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,n,r,o,s,a,l){const c=this.elements;return c[0]=e,c[1]=n,c[2]=s,c[3]=t,c[4]=r,c[5]=a,c[6]=i,c[7]=o,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,o=i[0],s=i[3],a=i[6],l=i[1],c=i[4],u=i[7],h=i[2],p=i[5],d=i[8],f=n[0],m=n[3],g=n[6],_=n[1],y=n[4],v=n[7],x=n[2],b=n[5],w=n[8];return r[0]=o*f+s*_+a*x,r[3]=o*m+s*y+a*b,r[6]=o*g+s*v+a*w,r[1]=l*f+c*_+u*x,r[4]=l*m+c*y+u*b,r[7]=l*g+c*v+u*w,r[2]=h*f+p*_+d*x,r[5]=h*m+p*y+d*b,r[8]=h*g+p*v+d*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8];return t*o*c-t*s*l-i*r*c+i*s*a+n*r*l-n*o*a}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=c*o-s*l,h=s*a-c*r,p=l*r-o*a,d=t*u+i*h+n*p;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const f=1/d;return e[0]=u*f,e[1]=(n*l-c*i)*f,e[2]=(s*i-n*o)*f,e[3]=h*f,e[4]=(c*t-n*a)*f,e[5]=(n*r-s*t)*f,e[6]=p*f,e[7]=(i*a-l*t)*f,e[8]=(o*t-i*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,r,o,s){const a=Math.cos(r),l=Math.sin(r);return this.set(i*a,i*l,-i*(a*o+l*s)+o+e,-n*l,n*a,-n*(-l*o+a*s)+s+t,0,0,1),this}scale(e,t){const i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),n=this.elements,r=n[0],o=n[3],s=n[6],a=n[1],l=n[4],c=n[7];return n[0]=t*r+i*a,n[3]=t*o+i*l,n[6]=t*s+i*c,n[1]=-i*r+t*a,n[4]=-i*o+t*l,n[7]=-i*s+t*c,this}translate(e,t){const i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}let ye;_e.prototype.isMatrix3=!0;class ve{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===ye&&(ye=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),ye.width=e.width,ye.height=e.height;const i=ye.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=ye}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let xe=0;class be extends ne{constructor(e=be.DEFAULT_IMAGE,t=be.DEFAULT_MAPPING,i=1001,n=1001,r=1006,o=1008,s=1023,a=1009,l=1,c=3e3){super(),Object.defineProperty(this,"id",{value:xe++}),this.uuid=le(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new ge(0,0),this.repeat=new ge(1,1),this.center=new ge(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new _e,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}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(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=le()),!t&&void 0===e.images[n.uuid]){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e1)switch(this.wrapS){case u:e.x=e.x-Math.floor(e.x);break;case h:e.x=e.x<0?0:1;break;case p:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case u:e.y=e.y-Math.floor(e.y);break;case h:e.y=e.y<0?0:1;break;case p:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function we(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ve.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}be.DEFAULT_IMAGE=void 0,be.DEFAULT_MAPPING=n,be.prototype.isTexture=!0;class Me{constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*n+o[12]*r,this.y=o[1]*t+o[5]*i+o[9]*n+o[13]*r,this.z=o[2]*t+o[6]*i+o[10]*n+o[14]*r,this.w=o[3]*t+o[7]*i+o[11]*n+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;const o=.01,s=e.elements,a=s[0],l=s[4],c=s[8],u=s[1],h=s[5],p=s[9],d=s[2],f=s[6],m=s[10];if(Math.abs(l-u)s&&e>g?eg?s=0?1:-1,n=1-t*t;if(n>Number.EPSILON){const r=Math.sqrt(n),o=Math.atan2(r,t*i);e=Math.sin(e*o)/r,s=Math.sin(s*o)/r}const r=s*i;if(a=a*e+h*r,l=l*e+p*r,c=c*e+d*r,u=u*e+f*r,e===1-s){const e=1/Math.sqrt(a*a+l*l+c*c+u*u);a*=e,l*=e,c*=e,u*=e}}e[t]=a,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,r,o){const s=i[n],a=i[n+1],l=i[n+2],c=i[n+3],u=r[o],h=r[o+1],p=r[o+2],d=r[o+3];return e[t]=s*d+c*u+a*p-l*h,e[t+1]=a*d+c*h+l*u-s*p,e[t+2]=l*d+c*p+s*h-a*u,e[t+3]=c*d-s*u-a*h-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=e._x,n=e._y,r=e._z,o=e._order,s=Math.cos,a=Math.sin,l=s(i/2),c=s(n/2),u=s(r/2),h=a(i/2),p=a(n/2),d=a(r/2);switch(o){case"XYZ":this._x=h*c*u+l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u-h*p*d;break;case"YXZ":this._x=h*c*u+l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u+h*p*d;break;case"ZXY":this._x=h*c*u-l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u-h*p*d;break;case"ZYX":this._x=h*c*u-l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u+h*p*d;break;case"YZX":this._x=h*c*u+l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u-h*p*d;break;case"XZY":this._x=h*c*u-l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u+h*p*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],r=t[8],o=t[1],s=t[5],a=t[9],l=t[2],c=t[6],u=t[10],h=i+s+u;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(c-a)*e,this._y=(r-l)*e,this._z=(o-n)*e}else if(i>s&&i>u){const e=2*Math.sqrt(1+i-s-u);this._w=(c-a)/e,this._x=.25*e,this._y=(n+o)/e,this._z=(r+l)/e}else if(s>u){const e=2*Math.sqrt(1+s-i-u);this._w=(r-l)/e,this._x=(n+o)/e,this._y=.25*e,this._z=(a+c)/e}else{const e=2*Math.sqrt(1+u-i-s);this._w=(o-n)/e,this._x=(r+l)/e,this._y=(a+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ce(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(0===i)return this;const n=Math.min(1,t/i);return this.slerp(e,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,r=e._z,o=e._w,s=t._x,a=t._y,l=t._z,c=t._w;return this._x=i*c+o*s+n*l-r*a,this._y=n*c+o*a+r*s-i*l,this._z=r*c+o*l+i*a-n*s,this._w=o*c-i*s-n*a-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const i=this._x,n=this._y,r=this._z,o=this._w;let s=o*e._w+i*e._x+n*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=o,this._x=i,this._y=n,this._z=r,this;const a=1-s*s;if(a<=Number.EPSILON){const e=1-t;return this._w=e*o+t*this._w,this._x=e*i+t*this._x,this._y=e*n+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(a),c=Math.atan2(l,s),u=Math.sin((1-t)*c)/l,h=Math.sin(t*c)/l;return this._w=o*u+this._w*h,this._x=i*u+this._x*h,this._y=n*u+this._y*h,this._z=r*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){this.copy(e).slerp(t,i)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Ae.prototype.isQuaternion=!0;class Ce{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Ie.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ie.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,o=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,o=e.y,s=e.z,a=e.w,l=a*t+o*n-s*i,c=a*i+s*t-r*n,u=a*n+r*i-o*t,h=-r*t-o*i-s*n;return this.x=l*a+h*-r+c*-s-u*-o,this.y=c*a+h*-o+u*-r-l*-s,this.z=u*a+h*-s+l*-o-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,r=e.z,o=t.x,s=t.y,a=t.z;return this.x=n*a-r*s,this.y=r*o-i*a,this.z=i*s-n*o,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Le.copy(this).projectOnVector(e),this.sub(Le)}reflect(e){return this.sub(Le.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ce(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}Ce.prototype.isVector3=!0;const Le=new Ce,Ie=new Ae;class Pe{constructor(e=new Ce(1/0,1/0,1/0),t=new Ce(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;for(let a=0,l=e.length;ar&&(r=l),c>o&&(o=c),u>s&&(s=u)}return this.min.set(t,i,n),this.max.set(r,o,s),this}setFromBufferAttribute(e){let t=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;for(let a=0,l=e.count;ar&&(r=l),c>o&&(o=c),u>s&&(s=u)}return this.min.set(t,i,n),this.max.set(r,o,s),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ke),ke.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(je),Ve.subVectors(this.max,je),De.subVectors(e.a,je),Oe.subVectors(e.b,je),Fe.subVectors(e.c,je),Be.subVectors(Oe,De),Ne.subVectors(Fe,Oe),Ue.subVectors(De,Fe);let t=[0,-Be.z,Be.y,0,-Ne.z,Ne.y,0,-Ue.z,Ue.y,Be.z,0,-Be.x,Ne.z,0,-Ne.x,Ue.z,0,-Ue.x,-Be.y,Be.x,0,-Ne.y,Ne.x,0,-Ue.y,Ue.x,0];return!!We(t,De,Oe,Fe,Ve)&&!!We(t=[1,0,0,0,1,0,0,0,1],De,Oe,Fe,Ve)&&(Ge.crossVectors(Be,Ne),We(t=[Ge.x,Ge.y,Ge.z],De,Oe,Fe,Ve))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return ke.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(ke).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Re[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Re[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Re[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Re[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Re[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Re[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Re[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Re[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Re)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}Pe.prototype.isBox3=!0;const Re=[new Ce,new Ce,new Ce,new Ce,new Ce,new Ce,new Ce,new Ce],ke=new Ce,ze=new Pe,De=new Ce,Oe=new Ce,Fe=new Ce,Be=new Ce,Ne=new Ce,Ue=new Ce,je=new Ce,Ve=new Ce,Ge=new Ce,He=new Ce;function We(e,t,i,n,r){for(let o=0,s=e.length-3;o<=s;o+=3){He.fromArray(e,o);const s=r.x*Math.abs(He.x)+r.y*Math.abs(He.y)+r.z*Math.abs(He.z),a=t.dot(He),l=i.dot(He),c=n.dot(He);if(Math.max(-Math.max(a,l,c),Math.min(a,l,c))>s)return!1}return!0}const qe=new Pe,$e=new Ce,Ze=new Ce,Xe=new Ce;class Ye{constructor(e=new Ce,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;void 0!==t?i.copy(t):qe.setFromPoints(e).getCenter(i);let n=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){Xe.subVectors(e,this.center);const t=Xe.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),i=.5*(e-this.radius);this.center.add(Xe.multiplyScalar(i/e)),this.radius+=i}return this}union(e){return Ze.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint($e.copy(e.center).add(Ze)),this.expandByPoint($e.copy(e.center).sub(Ze)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Je=new Ce,Qe=new Ce,Ke=new Ce,et=new Ce,tt=new Ce,it=new Ce,nt=new Ce;class rt{constructor(e=new Ce,t=new Ce(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Je)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Je.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Je.copy(this.direction).multiplyScalar(t).add(this.origin),Je.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){Qe.copy(e).add(t).multiplyScalar(.5),Ke.copy(t).sub(e).normalize(),et.copy(this.origin).sub(Qe);const r=.5*e.distanceTo(t),o=-this.direction.dot(Ke),s=et.dot(this.direction),a=-et.dot(Ke),l=et.lengthSq(),c=Math.abs(1-o*o);let u,h,p,d;if(c>0)if(h=o*s-a,d=r*c,(u=o*a-s)>=0)if(h>=-d)if(h<=d){const e=1/c;p=(u*=e)*(u+o*(h*=e)+2*s)+h*(o*u+h+2*a)+l}else h=r,p=-(u=Math.max(0,-(o*h+s)))*u+h*(h+2*a)+l;else h=-r,p=-(u=Math.max(0,-(o*h+s)))*u+h*(h+2*a)+l;else h<=-d?p=-(u=Math.max(0,-(-o*r+s)))*u+(h=u>0?-r:Math.min(Math.max(-r,-a),r))*(h+2*a)+l:h<=d?(u=0,p=(h=Math.min(Math.max(-r,-a),r))*(h+2*a)+l):p=-(u=Math.max(0,-(o*r+s)))*u+(h=u>0?r:Math.min(Math.max(-r,-a),r))*(h+2*a)+l;else h=o>0?-r:r,p=-(u=Math.max(0,-(o*h+s)))*u+h*(h+2*a)+l;return i&&i.copy(this.direction).multiplyScalar(u).add(this.origin),n&&n.copy(Ke).multiplyScalar(h).add(Qe),p}intersectSphere(e,t){Je.subVectors(e.center,this.origin);const i=Je.dot(this.direction),n=Je.dot(Je)-i*i,r=e.radius*e.radius;if(n>r)return null;const o=Math.sqrt(r-n),s=i-o,a=i+o;return s<0&&a<0?null:s<0?this.at(a,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,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?(i=(e.min.x-h.x)*l,n=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,n=(e.min.x-h.x)*l),c>=0?(r=(e.min.y-h.y)*c,o=(e.max.y-h.y)*c):(r=(e.max.y-h.y)*c,o=(e.min.y-h.y)*c),i>o||r>n?null:((r>i||i!=i)&&(i=r),(o=0?(s=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u):(s=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u),i>a||s>n?null:((s>i||i!=i)&&(i=s),(a=0?i:n,t)))}intersectsBox(e){return null!==this.intersectBox(e,Je)}intersectTriangle(e,t,i,n,r){tt.subVectors(t,e),it.subVectors(i,e),nt.crossVectors(tt,it);let o,s=this.direction.dot(nt);if(s>0){if(n)return null;o=1}else{if(!(s<0))return null;o=-1,s=-s}et.subVectors(this.origin,e);const a=o*this.direction.dot(it.crossVectors(et,it));if(a<0)return null;const l=o*this.direction.dot(tt.cross(et));if(l<0)return null;if(a+l>s)return null;const c=-o*et.dot(nt);return c<0?null:this.at(c/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class ot{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,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]=p,g[7]=d,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 ot).fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,n=1/st.setFromMatrixColumn(e,0).length(),r=1/st.setFromMatrixColumn(e,1).length(),o=1/st.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,i=e.x,n=e.y,r=e.z,o=Math.cos(i),s=Math.sin(i),a=Math.cos(n),l=Math.sin(n),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=o*c,i=o*u,n=s*c,r=s*u;t[0]=a*c,t[4]=-a*u,t[8]=l,t[1]=i+n*l,t[5]=e-r*l,t[9]=-s*a,t[2]=r-e*l,t[6]=n+i*l,t[10]=o*a}else if("YXZ"===e.order){const e=a*c,i=a*u,n=l*c,r=l*u;t[0]=e+r*s,t[4]=n*s-i,t[8]=o*l,t[1]=o*u,t[5]=o*c,t[9]=-s,t[2]=i*s-n,t[6]=r+e*s,t[10]=o*a}else if("ZXY"===e.order){const e=a*c,i=a*u,n=l*c,r=l*u;t[0]=e-r*s,t[4]=-o*u,t[8]=n+i*s,t[1]=i+n*s,t[5]=o*c,t[9]=r-e*s,t[2]=-o*l,t[6]=s,t[10]=o*a}else if("ZYX"===e.order){const e=o*c,i=o*u,n=s*c,r=s*u;t[0]=a*c,t[4]=n*l-i,t[8]=e*l+r,t[1]=a*u,t[5]=r*l+e,t[9]=i*l-n,t[2]=-l,t[6]=s*a,t[10]=o*a}else if("YZX"===e.order){const e=o*a,i=o*l,n=s*a,r=s*l;t[0]=a*c,t[4]=r-e*u,t[8]=n*u+i,t[1]=u,t[5]=o*c,t[9]=-s*c,t[2]=-l*c,t[6]=i*u+n,t[10]=e-r*u}else if("XZY"===e.order){const e=o*a,i=o*l,n=s*a,r=s*l;t[0]=a*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=o*c,t[9]=i*u-n,t[2]=n*u-i,t[6]=s*c,t[10]=r*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(lt,e,ct)}lookAt(e,t,i){const n=this.elements;return pt.subVectors(e,t),0===pt.lengthSq()&&(pt.z=1),pt.normalize(),ut.crossVectors(i,pt),0===ut.lengthSq()&&(1===Math.abs(i.z)?pt.x+=1e-4:pt.z+=1e-4,pt.normalize(),ut.crossVectors(i,pt)),ut.normalize(),ht.crossVectors(pt,ut),n[0]=ut.x,n[4]=ht.x,n[8]=pt.x,n[1]=ut.y,n[5]=ht.y,n[9]=pt.y,n[2]=ut.z,n[6]=ht.z,n[10]=pt.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,o=i[0],s=i[4],a=i[8],l=i[12],c=i[1],u=i[5],h=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],_=i[3],y=i[7],v=i[11],x=i[15],b=n[0],w=n[4],M=n[8],T=n[12],S=n[1],E=n[5],A=n[9],C=n[13],L=n[2],I=n[6],P=n[10],R=n[14],k=n[3],z=n[7],D=n[11],O=n[15];return r[0]=o*b+s*S+a*L+l*k,r[4]=o*w+s*E+a*I+l*z,r[8]=o*M+s*A+a*P+l*D,r[12]=o*T+s*C+a*R+l*O,r[1]=c*b+u*S+h*L+p*k,r[5]=c*w+u*E+h*I+p*z,r[9]=c*M+u*A+h*P+p*D,r[13]=c*T+u*C+h*R+p*O,r[2]=d*b+f*S+m*L+g*k,r[6]=d*w+f*E+m*I+g*z,r[10]=d*M+f*A+m*P+g*D,r[14]=d*T+f*C+m*R+g*O,r[3]=_*b+y*S+v*L+x*k,r[7]=_*w+y*E+v*I+x*z,r[11]=_*M+y*A+v*P+x*D,r[15]=_*T+y*C+v*R+x*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[12],o=e[1],s=e[5],a=e[9],l=e[13],c=e[2],u=e[6],h=e[10],p=e[14];return e[3]*(+r*a*u-n*l*u-r*s*h+i*l*h+n*s*p-i*a*p)+e[7]*(+t*a*p-t*l*h+r*o*h-n*o*p+n*l*c-r*a*c)+e[11]*(+t*l*u-t*s*p-r*o*u+i*o*p+r*s*c-i*l*c)+e[15]*(-n*s*c-t*a*u+t*s*h+n*o*u-i*o*h+i*a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],p=e[11],d=e[12],f=e[13],m=e[14],g=e[15],_=u*m*l-f*h*l+f*a*p-s*m*p-u*a*g+s*h*g,y=d*h*l-c*m*l-d*a*p+o*m*p+c*a*g-o*h*g,v=c*f*l-d*u*l+d*s*p-o*f*p-c*s*g+o*u*g,x=d*u*a-c*f*a-d*s*h+o*f*h+c*s*m-o*u*m,b=t*_+i*y+n*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 w=1/b;return e[0]=_*w,e[1]=(f*h*r-u*m*r-f*n*p+i*m*p+u*n*g-i*h*g)*w,e[2]=(s*m*r-f*a*r+f*n*l-i*m*l-s*n*g+i*a*g)*w,e[3]=(u*a*r-s*h*r-u*n*l+i*h*l+s*n*p-i*a*p)*w,e[4]=y*w,e[5]=(c*m*r-d*h*r+d*n*p-t*m*p-c*n*g+t*h*g)*w,e[6]=(d*a*r-o*m*r-d*n*l+t*m*l+o*n*g-t*a*g)*w,e[7]=(o*h*r-c*a*r+c*n*l-t*h*l-o*n*p+t*a*p)*w,e[8]=v*w,e[9]=(d*u*r-c*f*r-d*i*p+t*f*p+c*i*g-t*u*g)*w,e[10]=(o*f*r-d*s*r+d*i*l-t*f*l-o*i*g+t*s*g)*w,e[11]=(c*s*r-o*u*r-c*i*l+t*u*l+o*i*p-t*s*p)*w,e[12]=x*w,e[13]=(c*f*n-d*u*n+d*i*h-t*f*h-c*i*m+t*u*m)*w,e[14]=(d*s*n-o*f*n-d*i*a+t*f*a+o*i*m-t*s*m)*w,e[15]=(o*u*n-c*s*n+c*i*a-t*u*a-o*i*h+t*s*h)*w,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,o=e.x,s=e.y,a=e.z,l=r*o,c=r*s;return this.set(l*o+i,l*s-n*a,l*a+n*s,0,l*s+n*a,c*s+i,c*a-n*o,0,l*a-n*s,c*a+n*o,r*a*a+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,o){return this.set(1,i,r,0,e,1,o,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,o=t._y,s=t._z,a=t._w,l=r+r,c=o+o,u=s+s,h=r*l,p=r*c,d=r*u,f=o*c,m=o*u,g=s*u,_=a*l,y=a*c,v=a*u,x=i.x,b=i.y,w=i.z;return n[0]=(1-(f+g))*x,n[1]=(p+v)*x,n[2]=(d-y)*x,n[3]=0,n[4]=(p-v)*b,n[5]=(1-(h+g))*b,n[6]=(m+_)*b,n[7]=0,n[8]=(d+y)*w,n[9]=(m-_)*w,n[10]=(1-(h+f))*w,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;let r=st.set(n[0],n[1],n[2]).length();const o=st.set(n[4],n[5],n[6]).length(),s=st.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],at.copy(this);const a=1/r,l=1/o,c=1/s;return at.elements[0]*=a,at.elements[1]*=a,at.elements[2]*=a,at.elements[4]*=l,at.elements[5]*=l,at.elements[6]*=l,at.elements[8]*=c,at.elements[9]*=c,at.elements[10]*=c,t.setFromRotationMatrix(at),i.x=r,i.y=o,i.z=s,this}makePerspective(e,t,i,n,r,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const s=this.elements,a=2*r/(t-e),l=2*r/(i-n),c=(t+e)/(t-e),u=(i+n)/(i-n),h=-(o+r)/(o-r),p=-2*o*r/(o-r);return s[0]=a,s[4]=0,s[8]=c,s[12]=0,s[1]=0,s[5]=l,s[9]=u,s[13]=0,s[2]=0,s[6]=0,s[10]=h,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,i,n,r,o){const s=this.elements,a=1/(t-e),l=1/(i-n),c=1/(o-r),u=(t+e)*a,h=(i+n)*l,p=(o+r)*c;return s[0]=2*a,s[4]=0,s[8]=0,s[12]=-u,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-h,s[2]=0,s[6]=0,s[10]=-2*c,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}ot.prototype.isMatrix4=!0;const st=new Ce,at=new ot,lt=new Ce(0,0,0),ct=new Ce(1,1,1),ut=new Ce,ht=new Ce,pt=new Ce,dt=new ot,ft=new Ae;class mt{constructor(e=0,t=0,i=0,n=mt.DefaultOrder){this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,r=n[0],o=n[4],s=n[8],a=n[1],l=n[5],c=n[9],u=n[2],h=n[6],p=n[10];switch(t){case"XYZ":this._y=Math.asin(ce(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ce(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(ce(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-ce(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(ce(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,p));break;case"XZY":this._z=Math.asin(-ce(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return dt.makeRotationFromQuaternion(e),this.setFromRotationMatrix(dt,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ft.setFromEuler(this),this.setFromQuaternion(ft,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new Ce(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}mt.prototype.isEuler=!0,mt.DefaultOrder="XYZ",mt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class gt{constructor(){this.mask=1}set(e){this.mask=1<1){for(let e=0;e1){for(let e=0;e0){n.children=[];for(let t=0;t0){n.animations=[];for(let t=0;t0&&(i.geometries=t),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),s.length>0&&(i.images=s),a.length>0&&(i.shapes=a),l.length>0&&(i.skeletons=l),c.length>0&&(i.animations=c)}return i.object=n,i;function o(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){Pt.subVectors(n,t),Rt.subVectors(i,t),kt.subVectors(e,t);const o=Pt.dot(Pt),s=Pt.dot(Rt),a=Pt.dot(kt),l=Rt.dot(Rt),c=Rt.dot(kt),u=o*l-s*s;if(0===u)return r.set(-2,-1,-1);const h=1/u,p=(l*a-s*c)*h,d=(o*c-s*a)*h;return r.set(1-p-d,d,p)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,zt),zt.x>=0&&zt.y>=0&&zt.x+zt.y<=1}static getUV(e,t,i,n,r,o,s,a){return this.getBarycoord(e,t,i,n,zt),a.set(0,0),a.addScaledVector(r,zt.x),a.addScaledVector(o,zt.y),a.addScaledVector(s,zt.z),a}static isFrontFacing(e,t,i,n){return Pt.subVectors(i,t),Rt.subVectors(e,t),Pt.cross(Rt).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Pt.subVectors(this.c,this.b),Rt.subVectors(this.a,this.b),.5*Pt.cross(Rt).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return jt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,r){return jt.getUV(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return jt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let o,s;Dt.subVectors(n,i),Ot.subVectors(r,i),Bt.subVectors(e,i);const a=Dt.dot(Bt),l=Ot.dot(Bt);if(a<=0&&l<=0)return t.copy(i);Nt.subVectors(e,n);const c=Dt.dot(Nt),u=Ot.dot(Nt);if(c>=0&&u<=c)return t.copy(n);const h=a*u-c*l;if(h<=0&&a>=0&&c<=0)return o=a/(a-c),t.copy(i).addScaledVector(Dt,o);Ut.subVectors(e,r);const p=Dt.dot(Ut),d=Ot.dot(Ut);if(d>=0&&p<=d)return t.copy(r);const f=p*l-a*d;if(f<=0&&l>=0&&d<=0)return s=l/(l-d),t.copy(i).addScaledVector(Ot,s);const m=c*d-p*u;if(m<=0&&u-c>=0&&p-d>=0)return Ft.subVectors(r,n),s=(u-c)/(u-c+(p-d)),t.copy(n).addScaledVector(Ft,s);const g=1/(m+f+h);return o=f*g,s=h*g,t.copy(i).addScaledVector(Dt,o).addScaledVector(Ot,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Vt=0;class Gt extends ne{constructor(){super(),Object.defineProperty(this,"id",{value:Vt++}),this.uuid=le(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.format=E,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=i,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const i=e[t];if(void 0===i){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;continue}const n=this[t];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheenTint&&this.sheenTint.isColor&&(i.sheenTint=this.sheenTint.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularTint&&this.specularTint.isColor&&(i.specularTint=this.specularTint.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularTintMap&&this.specularTintMap.isTexture&&(i.specularTintMap=this.specularTintMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationTint&&(i.attenuationTint=this.attenuationTint.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.format!==E&&(i.format=this.format),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){const t=n(e.textures),r=n(e.images);t.length>0&&(i.textures=t),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.format=e.format,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(null!==t){const e=t.length;i=new Array(e);for(let n=0;n!==e;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}Gt.prototype.isMaterial=!0;const Ht={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},Wt={h:0,s:0,l:0},qt={h:0,s:0,l:0};function $t(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}function Zt(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Xt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class Yt{constructor(e,t,i){return void 0===t&&void 0===i?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,i){return this.r=e,this.g=t,this.b=i,this}setHSL(e,t,i){if(e=ue(e,1),t=ce(t,0,1),i=ce(i,0,1),0===t)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,r=2*i-n;this.r=$t(r,n,e+1/3),this.g=$t(r,n,e),this.b=$t(r,n,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const i=parseFloat(e[1])/360,n=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=i[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=Ht[e.toLowerCase()];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){const i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=Zt(e.r),this.g=Zt(e.g),this.b=Zt(e.b),this}copyLinearToSRGB(e){return this.r=Xt(e.r),this.g=Xt(e.g),this.b=Xt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,i=this.g,n=this.b,r=Math.max(t,i,n),o=Math.min(t,i,n);let s,a;const l=(o+r)/2;if(o===r)s=0,a=0;else{const e=r-o;switch(a=l<=.5?e/(r+o):e/(2-r-o),r){case t:s=(i-n)/e+(it&&(t=e[i]);return t}const pi={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function di(e,t){return new pi[e](t)}let fi=0;const mi=new ot,gi=new It,_i=new Ce,yi=new Pe,vi=new Pe,xi=new Ce;class bi extends ne{constructor(){super(),Object.defineProperty(this,"id",{value:fi++}),this.uuid=le(),this.name="",this.type="BufferGeometry",this.index=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(e){return Array.isArray(e)?this.index=new(hi(e)>65535?ai:oi)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const t=(new _e).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return mi.makeRotationFromQuaternion(e),this.applyMatrix4(mi),this}rotateX(e){return mi.makeRotationX(e),this.applyMatrix4(mi),this}rotateY(e){return mi.makeRotationY(e),this.applyMatrix4(mi),this}rotateZ(e){return mi.makeRotationZ(e),this.applyMatrix4(mi),this}translate(e,t,i){return mi.makeTranslation(e,t,i),this.applyMatrix4(mi),this}scale(e,t,i){return mi.makeScale(e,t,i),this.applyMatrix4(mi),this}lookAt(e){return gi.lookAt(e),gi.updateMatrix(),this.applyMatrix4(gi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_i).negate(),this.translate(_i.x,_i.y,_i.z),this}setFromPoints(e){const t=[];for(let i=0,n=e.length;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const t in i){const n=i[t];e.data.attributes[t]=n.toJSON(e.data)}const n={};let r=!1;for(const t in this.morphAttributes){const i=this.morphAttributes[t],o=[];for(let t=0,n=i.length;t0&&(n[t]=o,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new bi).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;null!==i&&this.setIndex(i.clone(t));const n=e.attributes;for(const e in n){const i=n[e];this.setAttribute(e,i.clone(t))}const r=e.morphAttributes;for(const e in r){const i=[],n=r[e];for(let e=0,r=n.length;e0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),Ti.copy(i.boundingSphere),Ti.applyMatrix4(r),!1===e.ray.intersectsSphere(Ti))return;if(wi.copy(r).invert(),Mi.copy(e.ray).applyMatrix4(wi),null!==i.boundingBox&&!1===Mi.intersectsBox(i.boundingBox))return;let o;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position,a=i.morphAttributes.position,l=i.morphTargetsRelative,c=i.attributes.uv,u=i.attributes.uv2,h=i.groups,p=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,d=h.length;ii.far?null:{distance:c,point:Bi.clone(),object:e}}(e,t,i,n,Si,Ei,Ai,Fi);if(d){a&&(zi.fromBufferAttribute(a,c),Di.fromBufferAttribute(a,u),Oi.fromBufferAttribute(a,h),d.uv=jt.getUV(Fi,Si,Ei,Ai,zi,Di,Oi,new ge)),l&&(zi.fromBufferAttribute(l,c),Di.fromBufferAttribute(l,u),Oi.fromBufferAttribute(l,h),d.uv2=jt.getUV(Fi,Si,Ei,Ai,zi,Di,Oi,new ge));const e={a:c,b:u,c:h,normal:new Ce,materialIndex:0};jt.getNormal(Si,Ei,Ai,e.normal),d.face=e}return d}Ni.prototype.isMesh=!0;class ji extends bi{constructor(e=1,t=1,i=1,n=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:o};const s=this;n=Math.floor(n),r=Math.floor(r),o=Math.floor(o);const a=[],l=[],c=[],u=[];let h=0,p=0;function d(e,t,i,n,r,o,d,f,m,g,_){const y=o/m,v=d/g,x=o/2,b=d/2,w=f/2,M=m+1,T=g+1;let S=0,E=0;const A=new Ce;for(let o=0;o0?1:-1,c.push(A.x,A.y,A.z),u.push(a/m),u.push(1-o/g),S+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}Wi.prototype.isShaderMaterial=!0;class qi extends It{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new ot,this.projectionMatrix=new ot,this.projectionMatrixInverse=new ot}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}qi.prototype.isCamera=!0;class $i extends qi{constructor(e=50,t=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*ae*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*se*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*ae*Math.atan(Math.tan(.5*se*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,n,r,o){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*se*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const o=this.view;if(null!==this.view&&this.view.enabled){const e=o.fullWidth,s=o.fullHeight;r+=o.offsetX*n/e,t-=o.offsetY*i/s,n*=o.width/e,i*=o.height/s}const s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}$i.prototype.isPerspectiveCamera=!0;class Zi extends It{constructor(e,t,i){if(super(),this.type="CubeCamera",!0!==i.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=i;const n=new $i(90,1,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new Ce(1,0,0)),this.add(n);const r=new $i(90,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Ce(-1,0,0)),this.add(r);const o=new $i(90,1,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new Ce(0,1,0)),this.add(o);const s=new $i(90,1,e,t);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(new Ce(0,-1,0)),this.add(s);const a=new $i(90,1,e,t);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new Ce(0,0,1)),this.add(a);const l=new $i(90,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Ce(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget,[n,r,o,s,a,l]=this.children,c=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const h=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,r),e.setRenderTarget(i,2),e.render(t,o),e.setRenderTarget(i,3),e.render(t,s),e.setRenderTarget(i,4),e.render(t,a),i.texture.generateMipmaps=h,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=c}}class Xi extends be{constructor(e,t,i,n,o,s,a,l,c,u){super(e=void 0!==e?e:[],t=void 0!==t?t:r,i,n,o,s,a=void 0!==a?a:S,l,c,u),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}Xi.prototype.isCubeTexture=!0;class Yi extends Te{constructor(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),super(e,e,t),t=t||{},this.texture=new Xi(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:g,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=E,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i=new ji(5,5,5),n=new Wi({name:"CubemapFromEquirect",uniforms:Vi({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 \n\t\t\t\t\t#include \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 \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",side:1,blending:0});n.uniforms.tEquirect.value=t;const r=new Ni(i,n),o=t.minFilter;return t.minFilter===y&&(t.minFilter=g),new Zi(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,i,n){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,i,n);e.setRenderTarget(r)}}Yi.prototype.isWebGLCubeRenderTarget=!0;const Ji=new Ce,Qi=new Ce,Ki=new _e;class en{constructor(e=new Ce(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=Ji.subVectors(i,t).cross(Qi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const i=e.delta(Ji),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(i).multiplyScalar(r).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Ki.getNormalMatrix(e),n=this.coplanarPoint(Ji).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}en.prototype.isPlane=!0;const tn=new Ye,nn=new Ce;class rn{constructor(e=new en,t=new en,i=new en,n=new en,r=new en,o=new en){this.planes=[e,t,i,n,r,o]}set(e,t,i,n,r,o){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(i),s[3].copy(n),s[4].copy(r),s[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){const t=this.planes,i=e.elements,n=i[0],r=i[1],o=i[2],s=i[3],a=i[4],l=i[5],c=i[6],u=i[7],h=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],_=i[14],y=i[15];return t[0].setComponents(s-n,u-a,f-h,y-m).normalize(),t[1].setComponents(s+n,u+a,f+h,y+m).normalize(),t[2].setComponents(s+r,u+l,f+p,y+g).normalize(),t[3].setComponents(s-r,u-l,f-p,y-g).normalize(),t[4].setComponents(s-o,u-c,f-d,y-_).normalize(),t[5].setComponents(s+o,u+c,f+d,y+_).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),tn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(tn)}intersectsSprite(e){return tn.center.set(0,0,0),tn.radius=.7071067811865476,tn.applyMatrix4(e.matrixWorld),this.intersectsSphere(tn)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(i)0?e.max.x:e.min.x,nn.y=n.normal.y>0?e.max.y:e.min.y,nn.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(nn)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function on(){let e=null,t=!1,i=null,n=null;function r(t,o){i(t,o),n=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==i&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function sn(e,t){const i=t.isWebGL2,n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const i=n.get(t);i&&(e.deleteBuffer(i.buffer),n.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=n.get(t);return void((!e||e.version 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}\nfloat 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 IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotVH = saturate( dot( geometry.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}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float NoH ) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\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 NoV, float NoL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( NoL + NoV - NoL * NoV ) ) );\n}\nvec3 BRDF_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\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( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + 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 = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\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#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\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 )\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 )\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",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\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 color ) { return dot( color, vec3( 0.3333 ) ); }\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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\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}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\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}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.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\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\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\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + 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 ), m0, cubeUV_maxMipLevel );\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_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 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, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( 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 LinearTosRGB( 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}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\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 int maxMipLevel;\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 )\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 )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in GeometricContext geometry ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, 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#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, 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#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 texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\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 GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.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\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\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, const in GeometricContext geometry, 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 GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\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 GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\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 GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, 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\n#define Material_LightProbeLOD( material )\t(0)",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 GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, 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\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\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\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularTintFactor = specularTint;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARTINTMAP\n\t\t\tspecularTintFactor *= specularTintMapTexelToLinear( texture2D( specularTintMap, vUv ) ).rgb;\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 specularTintFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularTintFactor, 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, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_SHEEN\n\tmaterial.sheenTint = sheenTint;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\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_SHEEN\n\t\tvec3 sheenTint;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\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}\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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\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(\t\t0, 1,\t\t0 ),\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( material.roughness, directLight.direction, geometry, material.sheenTint );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\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:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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\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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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, geometry, 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\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\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 ], geometry );\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, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\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\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\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, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).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( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\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 OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.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 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( 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( 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 linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( 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 invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - 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_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, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#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 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\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\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 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 shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\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\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.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\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.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 shadow;\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 shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#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 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 mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\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 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:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\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.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.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ 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.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\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\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, vUv );\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 toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( 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(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.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}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationTint, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = transmission.a;\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationTint;\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\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, 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( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \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#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define 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 SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularTint;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARTINTMAP\n\t\tuniform sampler2D specularTintMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenTint;\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \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 \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\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 \n\t#include \n\t#include \n}"},cn={common:{diffuse:{value:new Yt(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new _e},uv2Transform:{value:new _e},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ge(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Yt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 Yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new _e}},sprite:{diffuse:{value:new Yt(16777215)},opacity:{value:1},center:{value:new ge(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new _e}}},un={basic:{uniforms:Gi([cn.common,cn.specularmap,cn.envmap,cn.aomap,cn.lightmap,cn.fog]),vertexShader:ln.meshbasic_vert,fragmentShader:ln.meshbasic_frag},lambert:{uniforms:Gi([cn.common,cn.specularmap,cn.envmap,cn.aomap,cn.lightmap,cn.emissivemap,cn.fog,cn.lights,{emissive:{value:new Yt(0)}}]),vertexShader:ln.meshlambert_vert,fragmentShader:ln.meshlambert_frag},phong:{uniforms:Gi([cn.common,cn.specularmap,cn.envmap,cn.aomap,cn.lightmap,cn.emissivemap,cn.bumpmap,cn.normalmap,cn.displacementmap,cn.fog,cn.lights,{emissive:{value:new Yt(0)},specular:{value:new Yt(1118481)},shininess:{value:30}}]),vertexShader:ln.meshphong_vert,fragmentShader:ln.meshphong_frag},standard:{uniforms:Gi([cn.common,cn.envmap,cn.aomap,cn.lightmap,cn.emissivemap,cn.bumpmap,cn.normalmap,cn.displacementmap,cn.roughnessmap,cn.metalnessmap,cn.fog,cn.lights,{emissive:{value:new Yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag},toon:{uniforms:Gi([cn.common,cn.aomap,cn.lightmap,cn.emissivemap,cn.bumpmap,cn.normalmap,cn.displacementmap,cn.gradientmap,cn.fog,cn.lights,{emissive:{value:new Yt(0)}}]),vertexShader:ln.meshtoon_vert,fragmentShader:ln.meshtoon_frag},matcap:{uniforms:Gi([cn.common,cn.bumpmap,cn.normalmap,cn.displacementmap,cn.fog,{matcap:{value:null}}]),vertexShader:ln.meshmatcap_vert,fragmentShader:ln.meshmatcap_frag},points:{uniforms:Gi([cn.points,cn.fog]),vertexShader:ln.points_vert,fragmentShader:ln.points_frag},dashed:{uniforms:Gi([cn.common,cn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ln.linedashed_vert,fragmentShader:ln.linedashed_frag},depth:{uniforms:Gi([cn.common,cn.displacementmap]),vertexShader:ln.depth_vert,fragmentShader:ln.depth_frag},normal:{uniforms:Gi([cn.common,cn.bumpmap,cn.normalmap,cn.displacementmap,{opacity:{value:1}}]),vertexShader:ln.meshnormal_vert,fragmentShader:ln.meshnormal_frag},sprite:{uniforms:Gi([cn.sprite,cn.fog]),vertexShader:ln.sprite_vert,fragmentShader:ln.sprite_frag},background:{uniforms:{uvTransform:{value:new _e},t2D:{value:null}},vertexShader:ln.background_vert,fragmentShader:ln.background_frag},cube:{uniforms:Gi([cn.envmap,{opacity:{value:1}}]),vertexShader:ln.cube_vert,fragmentShader:ln.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ln.equirect_vert,fragmentShader:ln.equirect_frag},distanceRGBA:{uniforms:Gi([cn.common,cn.displacementmap,{referencePosition:{value:new Ce},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ln.distanceRGBA_vert,fragmentShader:ln.distanceRGBA_frag},shadow:{uniforms:Gi([cn.lights,cn.fog,{color:{value:new Yt(0)},opacity:{value:1}}]),vertexShader:ln.shadow_vert,fragmentShader:ln.shadow_frag}};function hn(e,t,i,n,r){const o=new Yt(0);let s,a,c=0,u=null,h=0,p=null;function d(e,t){i.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),d(o,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){d(o,c=e)},render:function(i,r){let f=!1,m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=t.get(m));const g=e.xr,_=g.getSession&&g.getSession();_&&"additive"===_.environmentBlendMode&&(m=null),null===m?d(o,c):m&&m.isColor&&(d(m,1),f=!0),(e.autoClear||f)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===l)?(void 0===a&&((a=new Ni(new ji(1,1,1),new Wi({name:"BackgroundCubeMaterial",uniforms:Vi(un.cube.uniforms),vertexShader:un.cube.vertexShader,fragmentShader:un.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),a.geometry.deleteAttribute("uv"),a.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(a.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(a)),a.material.uniforms.envMap.value=m,a.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,u===m&&h===m.version&&p===e.toneMapping||(a.material.needsUpdate=!0,u=m,h=m.version,p=e.toneMapping),i.unshift(a,a.geometry,a.material,0,0,null)):m&&m.isTexture&&(void 0===s&&((s=new Ni(new an(2,2),new Wi({name:"BackgroundMaterial",uniforms:Vi(un.background.uniforms),vertexShader:un.background.vertexShader,fragmentShader:un.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(s)),s.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),s.material.uniforms.uvTransform.value.copy(m.matrix),u===m&&h===m.version&&p===e.toneMapping||(s.material.needsUpdate=!0,u=m,h=m.version,p=e.toneMapping),i.unshift(s,s.geometry,s.material,0,0,null))}}}function pn(e,t,i,n){const r=e.getParameter(34921),o=n.isWebGL2?null:t.get("OES_vertex_array_object"),s=n.isWebGL2||null!==o,a={},l=p(null);let c=l;function u(t){return n.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function h(t){return n.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function p(e){const t=[],i=[],n=[];for(let e=0;e=0){let o=l[t];if(void 0===o&&("instanceMatrix"===t&&r.instanceMatrix&&(o=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(o=r.instanceColor)),void 0!==o){const t=o.normalized,s=o.itemSize,l=i.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,h=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const i=o.data,l=i.stride,p=o.offset;if(i&&i.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let s=void 0!==i.precision?i.precision:"highp";const a=r(s);a!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",a,"instead."),s=a);const l=o||t.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,u=e.getParameter(34930),h=e.getParameter(35660),p=e.getParameter(3379),d=e.getParameter(34076),f=e.getParameter(34921),m=e.getParameter(36347),g=e.getParameter(36348),_=e.getParameter(36349),y=h>0,v=o||t.has("OES_texture_float");return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===t.has("EXT_texture_filter_anisotropic")){const i=t.get("EXT_texture_filter_anisotropic");n=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:v,floatVertexTextures:y&&v,maxSamples:o?e.getParameter(36183):0}}function mn(e){const t=this;let i=null,n=0,r=!1,o=!1;const s=new en,a=new _e,l={value:null,needsUpdate:!1};function c(){l.value!==i&&(l.value=i,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(e,i,n,r){const o=null!==e?e.length:0;let c=null;if(0!==o){if(c=l.value,!0!==r||null===c){const t=n+4*o,r=i.matrixWorldInverse;a.getNormalMatrix(r),(null===c||c.length0){const s=e.getRenderTarget(),a=new Yi(o.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),e.setRenderTarget(s),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}un.physical={uniforms:Gi([un.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ge(1,1)},clearcoatNormalMap:{value:null},sheenTint:{value:new Yt(0)},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new ge},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationTint:{value:new Yt(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularTint:{value:new Yt(1,1,1)},specularTintMap:{value:null}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag};class _n extends qi{constructor(e=-1,t=1,i=1,n=-1,r=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,o=i+e,s=n+t,a=n-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o=(r+=e*this.view.offsetX)+e*this.view.width,a=(s-=t*this.view.offsetY)-t*this.view.height}this.projectionMatrix.makeOrthographic(r,o,s,a,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}_n.prototype.isOrthographicCamera=!0;class yn extends Wi{constructor(e){super(e),this.type="RawShaderMaterial"}}yn.prototype.isRawShaderMaterial=!0;const vn=Math.pow(2,8),xn=[.125,.215,.35,.446,.526,.582],bn=5+xn.length,wn={[$]:0,[Z]:1,[Y]:2,[J]:3,[Q]:4,[K]:5,[X]:6},Mn=new _n,{_lodPlanes:Tn,_sizeLods:Sn,_sigmas:En}=function(){const e=[],t=[],i=[];let n=8;for(let r=0;r4?s=xn[r-8+4-1]:0==r&&(s=0),i.push(s);const a=1/(o-1),l=-a/2,c=1+a/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,p=6,d=3,f=2,m=1,g=new Float32Array(d*p*h),_=new Float32Array(f*p*h),y=new Float32Array(m*p*h);for(let e=0;e2?0:-1,n=[t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0];g.set(n,d*p*e),_.set(u,f*p*e);const r=[e,e,e,e,e,e];y.set(r,m*p*e)}const v=new bi;v.setAttribute("position",new ei(g,d)),v.setAttribute("uv",new ei(_,f)),v.setAttribute("faceIndex",new ei(y,m)),e.push(v),n>4&&n--}return{_lodPlanes:e,_sizeLods:t,_sigmas:i}}(),An=new Yt;let Cn=null;const Ln=(1+Math.sqrt(5))/2,In=1/Ln,Pn=[new Ce(1,1,1),new Ce(-1,1,1),new Ce(1,1,-1),new Ce(-1,1,-1),new Ce(0,Ln,In),new Ce(0,Ln,-In),new Ce(In,0,Ln),new Ce(-In,0,Ln),new Ce(Ln,In,0),new Ce(-Ln,In,0)];class Rn{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=function(e){const t=new Float32Array(20),i=new Ce(0,1,0);return new yn({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:wn[3e3]},outputEncoding:{value:wn[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\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",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\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \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\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){Cn=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,i,n,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=Fn(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=On(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e2?vn:0,vn,vn),a.setRenderTarget(n),d&&a.render(p,r),a.render(e,r)}p.geometry.dispose(),p.material.dispose(),a.toneMapping=u,a.outputEncoding=c,a.autoClear=l,e.background=f}_textureToCubeUV(e,t){const i=this._renderer;e.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=Fn()):null==this._equirectShader&&(this._equirectShader=On());const n=e.isCubeTexture?this._cubemapShader:this._equirectShader,r=new Ni(Tn[0],n),o=n.uniforms;o.envMap.value=e,e.isCubeTexture||o.texelSize.value.set(1/e.image.width,1/e.image.height),o.inputEncoding.value=wn[e.encoding],o.outputEncoding.value=wn[t.texture.encoding],Dn(t,0,0,3*vn,2*vn),i.setRenderTarget(t),i.render(r,Mn)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/d,i=Math.exp(-t*t/2);m.push(i),0==e?g+=i:e4?n-8+4:0),3*_,2*_),a.setRenderTarget(t),a.render(c,Mn)}}function kn(e){return void 0!==e&&e.type===v&&(e.encoding===$||e.encoding===Z||e.encoding===X)}function zn(e){const t=new Te(3*vn,3*vn,e);return t.texture.mapping=l,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Dn(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function On(){const e=new ge(1,1);return new yn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:wn[3e3]},outputEncoding:{value:wn[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\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",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 vec2 texelSize;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Fn(){return new yn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:wn[3e3]},outputEncoding:{value:wn[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\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",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 samplerCube envMap;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Bn(e){let t=new WeakMap,i=null;function n(e){const i=e.target;i.removeEventListener("dispose",n);const r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(l){if(l&&l.isTexture&&!1===l.isRenderTargetTexture){const c=l.mapping,u=c===s||c===a,h=c===r||c===o;if(u||h){if(t.has(l))return t.get(l).texture;{const r=l.image;if(u&&r&&r.height>0||h&&r&&function(e){let t=0;for(let i=0;i<6;i++)void 0!==e[i]&&t++;return 6===t}(r)){const r=e.getRenderTarget();null===i&&(i=new Rn(e));const o=u?i.fromEquirectangular(l):i.fromCubemap(l);return t.set(l,o),e.setRenderTarget(r),l.addEventListener("dispose",n),o.texture}return null}}}return l},dispose:function(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Nn(e){const t={};function i(i){if(void 0!==t[i])return t[i];let n;switch(i){case"WEBGL_depth_texture":n=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=e.getExtension(i)}return t[i]=n,n}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(e){const t=i(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Un(e,t,i,n){const r={},o=new WeakMap;function s(e){const a=e.target;null!==a.index&&t.remove(a.index);for(const e in a.attributes)t.remove(a.attributes[e]);a.removeEventListener("dispose",s),delete r[a.id];const l=o.get(a);l&&(t.remove(l),o.delete(a)),n.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,i.memory.geometries--}function a(e){const i=[],n=e.index,r=e.attributes.position;let s=0;if(null!==n){const e=n.array;s=n.version;for(let t=0,n=e.length;t65535?ai:oi)(i,1);a.version=s;const l=o.get(e);l&&t.remove(l),o.set(e,a)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",s),r[t.id]=!0,i.memory.geometries++),t},update:function(e){const i=e.attributes;for(const e in i)t.update(i[e],34962);const n=e.morphAttributes;for(const e in n){const i=n[e];for(let e=0,n=i.length;e0)return e;const r=t*i;let o=Kn[r];if(void 0===o&&(o=new Float32Array(r),Kn[r]=o),0!==t){n.toArray(o,0);for(let n=1,r=0;n!==t;++n)r+=i,e[n].toArray(o,r)}return o}function or(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i/gm;function lo(e){return e.replace(ao,co)}function co(e,t){const i=ln[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return lo(i)}const uo=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,ho=/#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 po(e){return e.replace(ho,mo).replace(uo,fo)}function fo(e,t,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),mo(e,t,i,n)}function mo(e,t,i,n){let r="";for(let e=parseInt(t);e0?e.gammaFactor:1,_=i.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ro).join("\n")}(i),y=function(e){const t=[];for(const i in e){const n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}(a),v=s.createProgram();let x,b,w=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?((x=[y].filter(ro).join("\n")).length>0&&(x+="\n"),(b=[_,y].filter(ro).join("\n")).length>0&&(b+="\n")):(x=[go(i),"#define SHADER_NAME "+i.shaderName,y,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+f:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularTintMap?"#define USE_SPECULARTINTMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+p:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#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_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ro).join("\n"),b=[_,go(i),"#define SHADER_NAME "+i.shaderName,y,"#define GAMMA_FACTOR "+g,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+d:"",i.envMap?"#define "+f:"",i.envMap?"#define "+m:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularTintMap?"#define USE_SPECULARTINTMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheenTint?"#define USE_SHEEN":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+p:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?ln.tonemapping_pars_fragment:"",0!==i.toneMapping?no("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.format===S?"#define OPAQUE":"",ln.encodings_pars_fragment,i.map?to("mapTexelToLinear",i.mapEncoding):"",i.matcap?to("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?to("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?to("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.specularTintMap?to("specularTintMapTexelToLinear",i.specularTintMapEncoding):"",i.lightMap?to("lightMapTexelToLinear",i.lightMapEncoding):"",io("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ro).join("\n")),u=so(u=oo(u=lo(u),i),i),h=so(h=oo(h=lo(h),i),i),u=po(u),h=po(h),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(w="#version 300 es\n",x=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,b=["#define varying in",i.glslVersion===ie?"":"out highp vec4 pc_fragColor;",i.glslVersion===ie?"":"#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"+b);const M=w+b+h,T=Jr(s,35633,w+x+u),E=Jr(s,35632,M);if(s.attachShader(v,T),s.attachShader(v,E),void 0!==i.index0AttributeName?s.bindAttribLocation(v,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v),e.debug.checkShaderErrors){const e=s.getProgramInfoLog(v).trim(),t=s.getShaderInfoLog(T).trim(),i=s.getShaderInfoLog(E).trim();let n=!0,r=!0;if(!1===s.getProgramParameter(v,35714)){n=!1;const t=eo(s,T,"vertex"),i=eo(s,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,35715)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+i)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==i||(r=!1);r&&(this.diagnostics={runnable:n,programLog:e,vertexShader:{log:t,prefix:x},fragmentShader:{log:i,prefix:b}})}let A,C;return s.deleteShader(T),s.deleteShader(E),this.getUniforms=function(){return void 0===A&&(A=new Yr(s,v)),A},this.getAttributes=function(){return void 0===C&&(C=function(e,t){const i={},n=e.getProgramParameter(t,35721);for(let r=0;r0,I=o.clearcoat>0;return{isWebGL2:u,shaderID:T,shaderName:o.type,vertexShader:E,fragmentShader:A,defines:o.defines,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:m,instancing:!0===x.isInstancedMesh,instancingColor:!0===x.isInstancedMesh&&null!==x.instanceColor,supportsVertexTextures:f,outputEncoding:null!==C?y(C.texture):e.outputEncoding,map:!!o.map,mapEncoding:y(o.map),matcap:!!o.matcap,matcapEncoding:y(o.matcap),envMap:!!M,envMapMode:M&&M.mapping,envMapEncoding:y(M),envMapCubeUV:!!M&&(M.mapping===l||M.mapping===c),lightMap:!!o.lightMap,lightMapEncoding:y(o.lightMap),aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,emissiveMapEncoding:y(o.emissiveMap),bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:1===o.normalMapType,tangentSpaceNormalMap:0===o.normalMapType,clearcoat:I,clearcoatMap:I&&!!o.clearcoatMap,clearcoatRoughnessMap:I&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:I&&!!o.clearcoatNormalMap,displacementMap:!!o.displacementMap,roughnessMap:!!o.roughnessMap,metalnessMap:!!o.metalnessMap,specularMap:!!o.specularMap,specularIntensityMap:!!o.specularIntensityMap,specularTintMap:!!o.specularTintMap,specularTintMapEncoding:y(o.specularTintMap),alphaMap:!!o.alphaMap,alphaTest:L,gradientMap:!!o.gradientMap,sheenTint:!!o.sheenTint&&(o.sheenTint.r>0||o.sheenTint.g>0||o.sheenTint.b>0),transmission:o.transmission>0,transmissionMap:!!o.transmissionMap,thicknessMap:!!o.thicknessMap,combine:o.combine,vertexTangents:!!o.normalMap&&!!x.geometry&&!!x.geometry.attributes.tangent,vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!x.geometry&&!!x.geometry.attributes.color&&4===x.geometry.attributes.color.itemSize,vertexUvs:!!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatMap||o.clearcoatRoughnessMap||o.clearcoatNormalMap||o.displacementMap||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularTintMap),uvsVertexOnly:!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatNormalMap||o.transmission>0||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularTintMap||!o.displacementMap),fog:!!b,useFog:o.fog,fogExp2:b&&b.isFogExp2,flatShading:!!o.flatShading,sizeAttenuation:o.sizeAttenuation,logarithmicDepthBuffer:h,skinning:!0===x.isSkinnedMesh&&S>0,maxBones:S,useVertexTexture:p,morphTargets:!!x.geometry&&!!x.geometry.morphAttributes.position,morphNormals:!!x.geometry&&!!x.geometry.morphAttributes.normal,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,format:o.format,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&_.length>0,shadowMapType:e.shadowMap.type,toneMapping:o.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:2===o.side,flipSided:1===o.side,depthPacking:void 0!==o.depthPacking&&o.depthPacking,index0AttributeName:o.index0AttributeName,extensionDerivatives:o.extensions&&o.extensions.derivatives,extensionFragDepth:o.extensions&&o.extensions.fragDepth,extensionDrawBuffers:o.extensions&&o.extensions.drawBuffers,extensionShaderTextureLOD:o.extensions&&o.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(t){const i=[];if(t.shaderID?i.push(t.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(const e in t.defines)i.push(e),i.push(t.defines[e]);if(!1===t.isRawShaderMaterial){for(let e=0;e<_.length;e++)i.push(t[_[e]]);i.push(e.outputEncoding),i.push(e.gammaFactor)}return i.push(t.customProgramCacheKey),i.join()},getUniforms:function(e){const t=g[e.type];let i;if(t){const e=un[t];i=Hi.clone(e.uniforms)}else i=e.uniforms;return i},acquireProgram:function(t,i){let n;for(let e=0,t=a.length;e0?r.push(u):!0===i.transparent?o.push(u):n.push(u)},unshift:function(e,t,i,s,l,c){const u=a(e,t,i,s,l,c);i.transmission>0?r.unshift(u):!0===i.transparent?o.unshift(u):n.unshift(u)},finish:function(){for(let e=i,n=t.length;e1&&n.sort(e||xo),r.length>1&&r.sort(t||bo),o.length>1&&o.sort(t||bo)}}}function Mo(e){let t=new WeakMap;return{get:function(i,n){let r;return!1===t.has(i)?(r=new wo(e),t.set(i,[r])):n>=t.get(i).length?(r=new wo(e),t.get(i).push(r)):r=t.get(i)[n],r},dispose:function(){t=new WeakMap}}}function To(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new Ce,color:new Yt};break;case"SpotLight":i={position:new Ce,direction:new Ce,color:new Yt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ce,color:new Yt,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ce,skyColor:new Yt,groundColor:new Yt};break;case"RectAreaLight":i={color:new Yt,position:new Ce,halfWidth:new Ce,halfHeight:new Ce}}return e[t.id]=i,i}}}let So=0;function Eo(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Ao(e,t){const i=new To,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ge};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ge,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)r.probe.push(new Ce);const o=new Ce,s=new ot,a=new ot;return{setup:function(o,s){let a=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let u=0,h=0,p=0,d=0,f=0,m=0,g=0,_=0;o.sort(Eo);const y=!0!==s?Math.PI:1;for(let e=0,t=o.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=cn.LTC_FLOAT_1,r.rectAreaLTC2=cn.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=cn.LTC_HALF_1,r.rectAreaLTC2=cn.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=a,r.ambient[1]=l,r.ambient[2]=c;const v=r.hash;v.directionalLength===u&&v.pointLength===h&&v.spotLength===p&&v.rectAreaLength===d&&v.hemiLength===f&&v.numDirectionalShadows===m&&v.numPointShadows===g&&v.numSpotShadows===_||(r.directional.length=u,r.spot.length=p,r.rectArea.length=d,r.point.length=h,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotShadowMatrix.length=_,v.directionalLength=u,v.pointLength=h,v.spotLength=p,v.rectAreaLength=d,v.hemiLength=f,v.numDirectionalShadows=m,v.numPointShadows=g,v.numSpotShadows=_,r.version=So++)},setupView:function(e,t){let i=0,n=0,l=0,c=0,u=0;const h=t.matrixWorldInverse;for(let t=0,p=e.length;t=i.get(n).length?(o=new Co(e,t),i.get(n).push(o)):o=i.get(n)[r],o},dispose:function(){i=new WeakMap}}}class Io extends Gt{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}Io.prototype.isMeshDepthMaterial=!0;class Po extends Gt{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Ce,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Ro(e,t,i){let n=new rn;const r=new ge,o=new ge,s=new Me,a=new Io({depthPacking:3201}),l=new Po,c={},u=i.maxTextureSize,h={0:1,1:0,2:2},p=new Wi({uniforms:{shadow_pass:{value:null},resolution:{value:new ge},radius:{value:4},samples:{value:8}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nuniform float samples;\n#include \nvoid main() {\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}"}),f=p.clone();f.defines.HORIZONTAL_PASS=1;const m=new bi;m.setAttribute("position",new ei(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Ni(m,p),y=this;function v(i,n){const r=t.update(_);p.uniforms.shadow_pass.value=i.map.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,p.uniforms.samples.value=i.blurSamples,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(n,null,r,p,_,null),f.uniforms.shadow_pass.value=i.mapPass.texture,f.uniforms.resolution.value=i.mapSize,f.uniforms.radius.value=i.radius,f.uniforms.samples.value=i.blurSamples,e.setRenderTarget(i.map),e.clear(),e.renderBufferDirect(n,null,r,f,_,null)}function x(t,i,n,r,o,s,u){let p=null;const d=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(p=void 0!==d?d:!0===r.isPointLight?l:a,e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const e=p.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=p.clone(),i[t]=r),p=r}return p.visible=n.visible,p.wireframe=n.wireframe,p.side=3===u?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],p.alphaMap=n.alphaMap,p.alphaTest=n.alphaTest,p.clipShadows=n.clipShadows,p.clippingPlanes=n.clippingPlanes,p.clipIntersection=n.clipIntersection,p.displacementMap=n.displacementMap,p.displacementScale=n.displacementScale,p.displacementBias=n.displacementBias,p.wireframeLinewidth=n.wireframeLinewidth,p.linewidth=n.linewidth,!0===r.isPointLight&&!0===p.isMeshDistanceMaterial&&(p.referencePosition.setFromMatrixPosition(r.matrixWorld),p.nearDistance=o,p.farDistance=s),p}function b(i,r,o,s,a){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,i.matrixWorld);const n=t.update(i),r=i.material;if(Array.isArray(r)){const t=n.groups;for(let l=0,c=t.length;lu||r.y>u)&&(r.x>u&&(o.x=Math.floor(u/f.x),r.x=o.x*f.x,h.mapSize.x=o.x),r.y>u&&(o.y=Math.floor(u/f.y),r.y=o.y*f.y,h.mapSize.y=o.y)),null===h.map&&!h.isPointLightShadow&&3===this.type){const e={minFilter:g,magFilter:g,format:E};h.map=new Te(r.x,r.y,e),h.map.texture.name=c.name+".shadowMap",h.mapPass=new Te(r.x,r.y,e),h.camera.updateProjectionMatrix()}if(null===h.map){const e={minFilter:d,magFilter:d,format:E};h.map=new Te(r.x,r.y,e),h.map.texture.name=c.name+".shadowMap",h.camera.updateProjectionMatrix()}e.setRenderTarget(h.map),e.clear();const m=h.getViewportCount();for(let e=0;e=1):-1!==L.indexOf("OpenGL ES")&&(C=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),A=C>=2);let I=null,P={};const R=e.getParameter(3088),k=e.getParameter(2978),z=(new Me).fromArray(R),D=(new Me).fromArray(k);function O(t,i,n){const r=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;tn||e.height>n)&&(r=n/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const n=t?fe:Math.floor,o=n(r*e.width),s=n(r*e.height);void 0===P&&(P=k(o,s));const a=i?k(o,s):P;return a.width=o,a.height=s,a.getContext("2d").drawImage(e,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),a}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function D(e){return pe(e.width)&&pe(e.height)}function O(e,t){return e.generateMipmaps&&t&&e.minFilter!==d&&e.minFilter!==g}function F(t,i,r,o,s=1){e.generateMipmap(t),n.get(i).__maxMipLevel=Math.log2(Math.max(r,o,s))}function B(i,n,r){if(!1===a)return n;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;return 6403===n&&(5126===r&&(o=33326),5131===r&&(o=33325),5121===r&&(o=33321)),6407===n&&(5126===r&&(o=34837),5131===r&&(o=34843),5121===r&&(o=32849)),6408===n&&(5126===r&&(o=34836),5131===r&&(o=34842),5121===r&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||t.get("EXT_color_buffer_float"),o}function N(e){return e===d||e===f||e===m?9728:9729}function U(t){const i=t.target;i.removeEventListener("dispose",U),function(t){const i=n.get(t);void 0!==i.__webglInit&&(e.deleteTexture(i.__webglTexture),n.remove(t))}(i),i.isVideoTexture&&I.delete(i),s.memory.textures--}function j(t){const i=t.target;i.removeEventListener("dispose",j),function(t){const i=t.texture,r=n.get(t),o=n.get(i);if(t){if(void 0!==o.__webglTexture&&(e.deleteTexture(o.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);if(t.isWebGLMultipleRenderTargets)for(let t=0,r=i.length;t0&&r.__version!==e.version){const i=e.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void X(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+t),i.bindTexture(3553,r.__webglTexture)}function H(t,r){const s=n.get(t);t.version>0&&s.__version!==t.version?function(t,n,r){if(6!==n.image.length)return;Z(t,n),i.activeTexture(33984+r),i.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment),e.pixelStorei(37443,0);const s=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),l=n.image[0]&&n.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=s||l?l?n.image[e].image:n.image[e]:z(n.image[e],!1,!0,c);const h=u[0],p=D(h)||a,d=o.convert(n.format),f=o.convert(n.type),m=B(n.internalFormat,d,f);let g;if($(34067,n,p),s){for(let e=0;e<6;e++){g=u[e].mipmaps;for(let t=0;t1||n.get(o).__currentAnisotropy)&&(e.texParameterf(i,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),n.get(o).__currentAnisotropy=o.anisotropy)}}function Z(t,i){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",U),t.__webglTexture=e.createTexture(),s.memory.textures++)}function X(t,n,r){let s=3553;n.isDataTexture2DArray&&(s=35866),n.isDataTexture3D&&(s=32879),Z(t,n),i.activeTexture(33984+r),i.bindTexture(s,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment),e.pixelStorei(37443,0);const l=function(e){return!a&&(e.wrapS!==h||e.wrapT!==h||e.minFilter!==d&&e.minFilter!==g)}(n)&&!1===D(n.image),c=z(n.image,l,!1,v),u=D(c)||a,p=o.convert(n.format);let f,m=o.convert(n.type),_=B(n.internalFormat,p,m);$(s,n,u);const y=n.mipmaps;if(n.isDepthTexture)_=6402,a?_=n.type===w?36012:n.type===b?33190:n.type===T?35056:33189:n.type===w&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===A&&6402===_&&n.type!==x&&n.type!==b&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=x,m=o.convert(n.type)),n.format===C&&6402===_&&(_=34041,n.type!==T&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=T,m=o.convert(n.type))),i.texImage2D(3553,0,_,c.width,c.height,0,p,m,null);else if(n.isDataTexture)if(y.length>0&&u){for(let e=0,t=y.length;e0&&u){for(let e=0,t=y.length;e=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),V+=1,e},this.resetTextureUnits=function(){V=0},this.setTexture2D=G,this.setTexture2DArray=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?X(r,e,t):(i.activeTexture(33984+t),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?X(r,e,t):(i.activeTexture(33984+t),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=H,this.setupRenderTarget=function(t){const l=t.texture,c=n.get(t),u=n.get(l);t.addEventListener("dispose",j),!0!==t.isWebGLMultipleRenderTargets&&(u.__webglTexture=e.createTexture(),u.__version=l.version,s.memory.textures++);const h=!0===t.isWebGLCubeRenderTarget,p=!0===t.isWebGLMultipleRenderTargets,d=!0===t.isWebGLMultisampleRenderTarget,f=l.isDataTexture3D||l.isDataTexture2DArray,m=D(t)||a;if(!a||l.format!==S||l.type!==w&&l.type!==M||(l.format=E,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else if(c.__webglFramebuffer=e.createFramebuffer(),p)if(r.drawBuffers){const i=t.texture;for(let t=0,r=i.length;ta+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=a-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==a&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,i))&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),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);return null!==s&&(s.visible=null!==n),null!==a&&(a.visible=null!==r),null!==l&&(l.visible=null!==o),this}}class Uo extends ne{constructor(e,t){super();const i=this,n=e.state;let r=null,o=1,s=null,a="local-floor",l=null,c=null,u=null,h=null,p=null,d=!1,f=null,m=null,g=null,_=null,y=null,v=null;const x=[],b=new Map,w=new $i;w.layers.enable(1),w.viewport=new Me;const M=new $i;M.layers.enable(2),M.viewport=new Me;const T=[w,M],S=new Oo;S.layers.enable(1),S.layers.enable(2);let E=null,A=null;function C(e){const t=b.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function L(){b.forEach((function(e,t){e.disconnect(t)})),b.clear(),E=null,A=null,n.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),u&&t.deleteFramebuffer(u),f&&t.deleteFramebuffer(f),m&&t.deleteRenderbuffer(m),g&&t.deleteRenderbuffer(g),u=null,f=null,m=null,g=null,p=null,h=null,c=null,r=null,D.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function I(e){const t=r.inputSources;for(let e=0;e0&&(t.alphaTest.value=i.alphaTest);const n=e.get(i).envMap;if(n){t.envMap.value=n,t.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio;const r=e.get(n).__maxMipLevel;void 0!==r&&(t.maxMipLevel.value=r)}let r,o;i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap?r=i.clearcoatRoughnessMap:i.specularIntensityMap?r=i.specularIntensityMap:i.specularTintMap?r=i.specularTintMap:i.transmissionMap?r=i.transmissionMap:i.thicknessMap&&(r=i.thicknessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix)),i.aoMap?o=i.aoMap:i.lightMap&&(o=i.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),t.uv2Transform.value.copy(o.matrix))}function i(t,i){t.roughness.value=i.roughness,t.metalness.value=i.metalness,i.roughnessMap&&(t.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(t.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap),i.bumpMap&&(t.bumpMap.value=i.bumpMap,t.bumpScale.value=i.bumpScale,1===i.side&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,t.normalScale.value.copy(i.normalScale),1===i.side&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),e.get(i).envMap&&(t.envMapIntensity.value=i.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,n,r,o,s){n.isMeshBasicMaterial?t(e,n):n.isMeshLambertMaterial?(t(e,n),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(e,n)):n.isMeshToonMaterial?(t(e,n),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshPhongMaterial?(t(e,n),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshStandardMaterial?(t(e,n),n.isMeshPhysicalMaterial?function(e,t,n){i(e,t),e.ior.value=t.ior,t.sheenTint&&e.sheenTint.value.copy(t.sheenTint),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate())),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationTint.value.copy(t.attenuationTint)),e.specularIntensity.value=t.specularIntensity,e.specularTint.value.copy(t.specularTint),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap),t.specularTintMap&&(e.specularTintMap.value=t.specularTintMap)}(e,n,s):i(e,n)):n.isMeshMatcapMaterial?(t(e,n),function(e,t){t.matcap&&(e.matcap.value=t.matcap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshDepthMaterial?(t(e,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshDistanceMaterial?(t(e,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,n)):n.isMeshNormalMaterial?(t(e,n),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,n),n.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,n)):n.isPointsMaterial?function(e,t,i,n){let r;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*n,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?r=t.map:t.alphaMap&&(r=t.alphaMap),void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}(e,n,r,o):n.isSpriteMaterial?function(e,t){let i;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?i=t.map:t.alphaMap&&(i=t.alphaMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}(e,n):n.isShadowMaterial?(e.color.value.copy(n.color),e.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Vo(e={}){const t=void 0!==e.canvas?e.canvas:function(){const e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.style.display="block",e}(),i=void 0!==e.context?e.context:null,n=void 0!==e.alpha&&e.alpha,r=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,s=void 0!==e.antialias&&e.antialias,a=void 0===e.premultipliedAlpha||e.premultipliedAlpha,l=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,c=void 0!==e.powerPreference?e.powerPreference:"default",u=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let p=null,f=null;const m=[],g=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=$,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const _=this;let x=!1,b=0,T=0,S=null,A=-1,C=null;const L=new Me,I=new Me;let P=null,R=t.width,k=t.height,z=1,D=null,O=null;const F=new Me(0,0,R,k),B=new Me(0,0,R,k);let N=!1;const U=[],j=new rn;let V=!1,G=!1,H=null;const W=new ot,q=new Ce,Z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function X(){return null===S?z:1}let Y,J,Q,K,ee,te,ie,ne,re,oe,se,ae,le,ce,ue,he,pe,de,fe,me,ge,_e,ye,ve=i;function xe(e,i){for(let n=0;n0&&function(e,t,i){if(null===H){const e=!0===s&&!0===J.isWebGL2;H=new(e?Ee:Te)(1024,1024,{generateMipmaps:!0,type:null!==_e.convert(M)?M:v,minFilter:y,magFilter:d,wrapS:h,wrapT:h})}const n=_.getRenderTarget();_.setRenderTarget(H),_.clear();const r=_.toneMapping;_.toneMapping=0,De(e,t,i),_.toneMapping=r,te.updateMultisampleRenderTarget(H),te.updateRenderTargetMipmap(H),_.setRenderTarget(n)}(r,t,i),n&&Q.viewport(L.copy(n)),r.length>0&&De(r,t,i),o.length>0&&De(o,t,i),a.length>0&&De(a,t,i)}function De(e,t,i){const n=!0===t.isScene?t.overrideMaterial:null;for(let r=0,o=e.length;r0?g[g.length-1]:null,m.pop(),p=m.length>0?m[m.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return S},this.setRenderTarget=function(e,t=0,i=0){S=e,b=t,T=i,e&&void 0===ee.get(e).__webglFramebuffer&&te.setupRenderTarget(e);let n=null,r=!1,o=!1;if(e){const i=e.texture;(i.isDataTexture3D||i.isDataTexture2DArray)&&(o=!0);const s=ee.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(n=s[t],r=!0):n=e.isWebGLMultisampleRenderTarget?ee.get(e).__webglMultisampledFramebuffer:s,L.copy(e.viewport),I.copy(e.scissor),P=e.scissorTest}else L.copy(F).multiplyScalar(z).floor(),I.copy(B).multiplyScalar(z).floor(),P=N;if(Q.bindFramebuffer(36160,n)&&J.drawBuffers){let t=!1;if(e)if(e.isWebGLMultipleRenderTargets){const i=e.texture;if(U.length!==i.length||36064!==U[0]){for(let e=0,t=i.length;e=0&&t<=e.width-n&&i>=0&&i<=e.height-r&&ve.readPixels(t,i,n,r,_e.convert(a),_e.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==S?ee.get(S).__webglFramebuffer:null;Q.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),o=Math.floor(t.image.height*n);let s=_e.convert(t.format);J.isWebGL2&&(6407===s&&(s=32849),6408===s&&(s=32856)),te.setTexture2D(t,0),ve.copyTexImage2D(3553,i,s,e.x,e.y,r,o,0),Q.unbindTexture()},this.copyTextureToTexture=function(e,t,i,n=0){const r=t.image.width,o=t.image.height,s=_e.convert(i.format),a=_e.convert(i.type);te.setTexture2D(i,0),ve.pixelStorei(37440,i.flipY),ve.pixelStorei(37441,i.premultiplyAlpha),ve.pixelStorei(3317,i.unpackAlignment),t.isDataTexture?ve.texSubImage2D(3553,n,e.x,e.y,r,o,s,a,t.image.data):t.isCompressedTexture?ve.compressedTexSubImage2D(3553,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):ve.texSubImage2D(3553,n,e.x,e.y,s,a,t.image),0===n&&i.generateMipmaps&&ve.generateMipmap(3553),Q.unbindTexture()},this.copyTextureToTexture3D=function(e,t,i,n,r=0){if(_.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,a=e.max.z-e.min.z+1,l=_e.convert(n.format),c=_e.convert(n.type);let u;if(n.isDataTexture3D)te.setTexture3D(n,0),u=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");te.setTexture2DArray(n,0),u=35866}ve.pixelStorei(37440,n.flipY),ve.pixelStorei(37441,n.premultiplyAlpha),ve.pixelStorei(3317,n.unpackAlignment);const h=ve.getParameter(3314),p=ve.getParameter(32878),d=ve.getParameter(3316),f=ve.getParameter(3315),m=ve.getParameter(32877),g=i.isCompressedTexture?i.mipmaps[0]:i.image;ve.pixelStorei(3314,g.width),ve.pixelStorei(32878,g.height),ve.pixelStorei(3316,e.min.x),ve.pixelStorei(3315,e.min.y),ve.pixelStorei(32877,e.min.z),i.isDataTexture||i.isDataTexture3D?ve.texSubImage3D(u,r,t.x,t.y,t.z,o,s,a,l,c,g.data):i.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ve.compressedTexSubImage3D(u,r,t.x,t.y,t.z,o,s,a,l,g.data)):ve.texSubImage3D(u,r,t.x,t.y,t.z,o,s,a,l,c,g),ve.pixelStorei(3314,h),ve.pixelStorei(32878,p),ve.pixelStorei(3316,d),ve.pixelStorei(3315,f),ve.pixelStorei(32877,m),0===r&&n.generateMipmaps&&ve.generateMipmap(u),Q.unbindTexture()},this.initTexture=function(e){te.setTexture2D(e,0),Q.unbindTexture()},this.resetState=function(){b=0,T=0,S=null,Q.reset(),ye.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Go extends Vo{}Go.prototype.isWebGL1Renderer=!0;class Ho{constructor(e,t=25e-5){this.name="",this.color=new Yt(e),this.density=t}clone(){return new Ho(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Ho.prototype.isFogExp2=!0;class Wo{constructor(e,t=1,i=1e3){this.name="",this.color=new Yt(e),this.near=t,this.far=i}clone(){return new Wo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Wo.prototype.isFog=!0;class qo extends It{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}qo.prototype.isScene=!0;class $o{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=ee,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=le()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;ne.far||t.push({distance:a,point:Qo.clone(),uv:jt.getUV(Qo,rs,os,ss,as,ls,cs,new ge),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function hs(e,t,i,n,r,o){ts.subVectors(e,i).addScalar(.5).multiply(n),void 0!==r?(is.x=o*ts.x-r*ts.y,is.y=r*ts.x+o*ts.y):is.copy(ts),e.copy(t),e.x+=is.x,e.y+=is.y,e.applyMatrix4(ns)}us.prototype.isSprite=!0;const ps=new Ce,ds=new Ce;class fs extends It{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,i=t.length;e0){let i,n;for(i=1,n=t.length;i0){ps.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(ps);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){ps.setFromMatrixPosition(e.matrixWorld),ds.setFromMatrixPosition(this.matrixWorld);const i=ps.distanceTo(ds)/e.zoom;let n,r;for(t[0].object.visible=!0,n=1,r=t.length;n=t[n].distance;n++)t[n-1].object.visible=!1,t[n].object.visible=!0;for(this._currentLevel=n-1;na)continue;h.applyMatrix4(this.matrixWorld);const p=e.ray.origin.distanceTo(h);pe.far||t.push({distance:p,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}else for(let i=Math.max(0,o.start),n=Math.min(r.count,o.start+o.count)-1;ia)continue;h.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(h);ne.far||t.push({distance:n,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Bs.prototype.isLine=!0;const Ns=new Ce,Us=new Ce;class js extends Bs{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[];for(let e=0,n=t.count;e0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function Xs(e,t,i,n,r,o,s){const a=Ws.distanceSqToPoint(e);if(ar.far)return;o.push({distance:l,distanceToRay:Math.sqrt(a),point:i,index:t,face:null,object:s})}}Zs.prototype.isPoints=!0;class Ys extends be{constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s,a,l),this.format=void 0!==s?s:S,this.minFilter=void 0!==o?o:g,this.magFilter=void 0!==r?r:g,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;0=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Ys.prototype.isVideoTexture=!0;class Js extends be{constructor(e,t,i,n,r,o,s,a,l,c,u,h){super(null,o,s,a,l,c,n,r,u,h),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}Js.prototype.isCompressedTexture=!0;class Qs extends be{constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s,a,l),this.needsUpdate=!0}}Qs.prototype.isCanvasTexture=!0;class Ks extends be{constructor(e,t,i,n,r,o,s,a,l,c){if((c=void 0!==c?c:A)!==A&&c!==C)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===A&&(i=x),void 0===i&&c===C&&(i=T),super(null,n,r,o,s,a,c,i,l),this.image={width:e,height:t},this.magFilter=void 0!==s?s:d,this.minFilter=void 0!==a?a:d,this.flipY=!1,this.generateMipmaps=!1}}Ks.prototype.isDepthTexture=!0;class ea extends bi{constructor(e=1,t=8,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const r=[],o=[],s=[],a=[],l=new Ce,c=new ge;o.push(0,0,0),s.push(0,0,1),a.push(.5,.5);for(let r=0,u=3;r<=t;r++,u+=3){const h=i+r/t*n;l.x=e*Math.cos(h),l.y=e*Math.sin(h),o.push(l.x,l.y,l.z),s.push(0,0,1),c.x=(o[u]/e+1)/2,c.y=(o[u+1]/e+1)/2,a.push(c.x,c.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new ci(o,3)),this.setAttribute("normal",new ci(s,3)),this.setAttribute("uv",new ci(a,2))}static fromJSON(e){return new ea(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ta extends bi{constructor(e=1,t=1,i=1,n=8,r=1,o=!1,s=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:s,thetaLength:a};const l=this;n=Math.floor(n),r=Math.floor(r);const c=[],u=[],h=[],p=[];let d=0;const f=[],m=i/2;let g=0;function _(i){const r=d,o=new ge,f=new Ce;let _=0;const y=!0===i?e:t,v=!0===i?1:-1;for(let e=1;e<=n;e++)u.push(0,m*v,0),h.push(0,v,0),p.push(.5,.5),d++;const x=d;for(let e=0;e<=n;e++){const t=e/n*a+s,i=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*v,f.z=y*i,u.push(f.x,f.y,f.z),h.push(0,v,0),o.x=.5*i+.5,o.y=.5*r*v+.5,p.push(o.x,o.y),d++}for(let e=0;e0&&_(!0),t>0&&_(!1)),this.setIndex(c),this.setAttribute("position",new ci(u,3)),this.setAttribute("normal",new ci(h,3)),this.setAttribute("uv",new ci(p,2))}static fromJSON(e){return new ta(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ia extends ta{constructor(e=1,t=1,i=8,n=1,r=!1,o=0,s=2*Math.PI){super(0,e,t,i,n,r,o,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:o,thetaLength:s}}static fromJSON(e){return new ia(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class na extends bi{constructor(e,t,i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};const r=[],o=[];function s(e,t,i,n){const r=n+1,o=[];for(let n=0;n<=r;n++){o[n]=[];const s=e.clone().lerp(i,n/r),a=t.clone().lerp(i,n/r),l=r-n;for(let e=0;e<=l;e++)o[n][e]=0===e&&n===r?s:s.clone().lerp(a,e/l)}for(let e=0;e.9&&s<.1&&(t<.2&&(o[e+0]+=1),i<.2&&(o[e+2]+=1),n<.2&&(o[e+4]+=1))}}()}(),this.setAttribute("position",new ci(r,3)),this.setAttribute("normal",new ci(r.slice(),3)),this.setAttribute("uv",new ci(o,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new na(e.vertices,e.indices,e.radius,e.details)}}class ra extends na{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ra(e.radius,e.detail)}}const oa=new Ce,sa=new Ce,aa=new Ce,la=new jt;class ca extends bi{constructor(e,t){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=void 0!==t?t:1,!0===e.isGeometry)return void console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const i=Math.pow(10,4),n=Math.cos(se*t),r=e.getIndex(),o=e.getAttribute("position"),s=r?r.count:o.count,a=[0,0,0],l=["a","b","c"],c=new Array(3),u={},h=[];for(let e=0;e0)){l=n;break}l=n-1}if(i[n=l]===o)return n/(r-1);const c=i[n];return(n+(o-c)/(i[n+1]-c))/(r-1)}getTangent(e,t){let i=e-1e-4,n=e+1e-4;i<0&&(i=0),n>1&&(n=1);const r=this.getPoint(i),o=this.getPoint(n),s=t||(r.isVector2?new ge:new Ce);return s.copy(o).sub(r).normalize(),s}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new Ce,n=[],r=[],o=[],s=new Ce,a=new ot;for(let t=0;t<=e;t++){const i=t/e;n[t]=this.getTangentAt(i,new Ce),n[t].normalize()}r[0]=new Ce,o[0]=new Ce;let l=Number.MAX_VALUE;const c=Math.abs(n[0].x),u=Math.abs(n[0].y),h=Math.abs(n[0].z);c<=l&&(l=c,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),h<=l&&i.set(0,0,1),s.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],s),o[0].crossVectors(n[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),o[t]=o[t-1].clone(),s.crossVectors(n[t-1],n[t]),s.length()>Number.EPSILON){s.normalize();const e=Math.acos(ce(n[t-1].dot(n[t]),-1,1));r[t].applyMatrix4(a.makeRotationAxis(s,e))}o[t].crossVectors(n[t],r[t])}if(!0===t){let t=Math.acos(ce(r[0].dot(r[e]),-1,1));t/=e,n[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let i=1;i<=e;i++)r[i].applyMatrix4(a.makeRotationAxis(n[i],t*i)),o[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class ha extends ua{constructor(e=0,t=0,i=1,n=1,r=0,o=2*Math.PI,s=!1,a=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=s,this.aRotation=a}getPoint(e,t){const i=t||new ge,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)n;)r-=n;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=n[(l-1)%r]:(fa.subVectors(n[0],n[1]).add(n[0]),s=fa);const u=n[l%r],h=n[(l+1)%r];if(this.closed||l+2n.length-2?n.length-1:o+1],u=n[o>n.length-3?n.length-1:o+2];return i.set(va(s,a.x,l.x,c.x,u.x),va(s,a.y,l.y,c.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t0)for(o=t;o=t;o-=n)s=Ja(o,e[o],e[o+1],s);return s&&Wa(s,s.next)&&(Qa(s),s=s.next),s}function Pa(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Wa(n,n.next)&&0!==Ha(n.prev,n,n.next))n=n.next;else{if(Qa(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function Ra(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{null===r.z&&(r.z=Ua(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i,n,r,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,n=i,a=0,t=0;t0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1)}(r)}(e,n,r,o);let a,l,c=e;for(;e.prev!==e.next;)if(a=e.prev,l=e.next,o?za(e,n,r,o):ka(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),Qa(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?Ra(e=Da(Pa(e),t,i),t,i,n,r,o,2):2===s&&Oa(e,t,i,n,r,o):Ra(Pa(e),t,i,n,r,o,1);break}}function ka(e){const t=e.prev,i=e,n=e.next;if(Ha(t,i,n)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Va(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Ha(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function za(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Ha(r,o,s)>=0)return!1;const a=r.xo.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,u=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,h=Ua(a,l,t,i,n),p=Ua(c,u,t,i,n);let d=e.prevZ,f=e.nextZ;for(;d&&d.z>=h&&f&&f.z<=p;){if(d!==e.prev&&d!==e.next&&Va(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Ha(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==e.prev&&f!==e.next&&Va(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ha(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=h;){if(d!==e.prev&&d!==e.next&&Va(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Ha(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=p;){if(f!==e.prev&&f!==e.next&&Va(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ha(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Da(e,t,i){let n=e;do{const r=n.prev,o=n.next.next;!Wa(r,o)&&qa(r,n,n.next,o)&&Xa(r,o)&&Xa(o,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(o.i/i),Qa(n),Qa(n.next),n=e=o),n=n.next}while(n!==e);return Pa(n)}function Oa(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Ga(s,e)){let a=Ya(s,e);return s=Pa(s,s.next),a=Pa(a,a.next),Ra(s,t,i,n,r,o),void Ra(a,t,i,n,r,o)}e=e.next}s=s.next}while(s!==e)}function Fa(e,t){return e.x-t.x}function Ba(e,t){if(t=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>s){if(s=e,e===n){if(r===i.y)return i;if(r===i.next.y)return i.next}o=i.x=i.x&&i.x>=l&&n!==i.x&&Va(ro.x||i.x===o.x&&Na(o,i)))&&(o=i,h=u)),i=i.next}while(i!==a);return o}(e,t)){const i=Ya(t,e);Pa(t,t.next),Pa(i,i.next)}}function Na(e,t){return Ha(e.prev,e,t.prev)<0&&Ha(t.next,e,e.next)<0}function Ua(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ja(e){let t=e,i=e;do{(t.x=0&&(e-s)*(n-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(r-s)*(n-a)>=0}function Ga(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&qa(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Xa(e,t)&&Xa(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Ha(e.prev,e,t.prev)||Ha(e,t.prev,t))||Wa(e,t)&&Ha(e.prev,e,e.next)>0&&Ha(t.prev,t,t.next)>0)}function Ha(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Wa(e,t){return e.x===t.x&&e.y===t.y}function qa(e,t,i,n){const r=Za(Ha(e,t,i)),o=Za(Ha(e,t,n)),s=Za(Ha(i,n,e)),a=Za(Ha(i,n,t));return r!==o&&s!==a||!(0!==r||!$a(e,i,t))||!(0!==o||!$a(e,n,t))||!(0!==s||!$a(i,e,n))||!(0!==a||!$a(i,t,n))}function $a(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Za(e){return e>0?1:e<0?-1:0}function Xa(e,t){return Ha(e.prev,e,e.next)<0?Ha(e,t,e.next)>=0&&Ha(e,e.prev,t)>=0:Ha(e,t,e.prev)<0||Ha(e,e.next,t)<0}function Ya(e,t){const i=new Ka(e.i,e.x,e.y),n=new Ka(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Ja(e,t,i,n){const r=new Ka(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Qa(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ka(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class el{static area(e){const t=e.length;let i=0;for(let n=t-1,r=0;r80*i){a=c=e[0],l=u=e[1];for(let t=i;tc&&(c=h),p>u&&(u=p);d=0!==(d=Math.max(c-a,u-l))?1/d:0}return Ra(o,s,i,a,l,d),s}(i,n);for(let e=0;e2&&e[t-1].equals(e[0])&&e.pop()}function il(e,t){for(let i=0;iNumber.EPSILON){const h=Math.sqrt(u),p=Math.sqrt(l*l+c*c),d=t.x-a/h,f=t.y+s/h,m=((i.x-c/p-d)*c-(i.y+l/p-f)*l)/(s*c-a*l),g=(n=d+s*m-e.x)*n+(r=f+a*m-e.y)*r;if(g<=2)return new ge(n,r);o=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(a)===Math.sign(c)&&(e=!0),e?(n=-a,r=s,o=Math.sqrt(u)):(n=s,r=a,o=Math.sqrt(u/2))}return new ge(n/o,r/o)}const P=[];for(let e=0,t=E.length,i=t-1,n=e+1;e=0;e--){const t=e/d,i=u*Math.cos(t*Math.PI/2),n=h*Math.sin(t*Math.PI/2)+p;for(let e=0,t=E.length;e=0;){const n=i;let r=i-1;r<0&&(r=e.length-1);for(let e=0,i=a+2*d;e=0?(e(n-a,d,u),h.subVectors(c,u)):(e(n+a,d,u),h.subVectors(u,c)),d-a>=0?(e(n,d-a,u),p.subVectors(c,u)):(e(n,d+a,u),p.subVectors(u,c)),l.crossVectors(h,p).normalize(),o.push(l.x,l.y,l.z),s.push(n,d)}}for(let e=0;e0)&&p.push(t,r,l),(e!==i-1||a0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheenTint.copy(e.sheenTint),this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationTint.copy(e.attenuationTint),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularTint.copy(e.specularTint),this.specularTintMap=e.specularTintMap,this}}wl.prototype.isMeshPhysicalMaterial=!0;class Ml extends Gt{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new Yt(16777215),this.specular=new Yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}Ml.prototype.isMeshPhongMaterial=!0;class Tl extends Gt{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Yt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(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.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Tl.prototype.isMeshToonMaterial=!0;class Sl extends Gt{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}Sl.prototype.isMeshNormalMaterial=!0;class El extends Gt{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new Yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}El.prototype.isMeshLambertMaterial=!0;class Al extends Gt{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Yt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}Al.prototype.isMeshMatcapMaterial=!0;class Cl extends Rs{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}Cl.prototype.isLineDashedMaterial=!0;var Ll=Object.freeze({__proto__:null,ShadowMaterial:xl,SpriteMaterial:Yo,RawShaderMaterial:yn,ShaderMaterial:Wi,PointsMaterial:Gs,MeshPhysicalMaterial:wl,MeshStandardMaterial:bl,MeshPhongMaterial:Ml,MeshToonMaterial:Tl,MeshNormalMaterial:Sl,MeshLambertMaterial:El,MeshDepthMaterial:Io,MeshDistanceMaterial:Po,MeshBasicMaterial:Jt,MeshMatcapMaterial:Al,LineDashedMaterial:Cl,LineBasicMaterial:Rs,Material:Gt});const Il={arraySlice:function(e,t,i){return Il.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){const t=e.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort((function(t,i){return e[t]-e[i]})),i},sortedArray:function(e,t,i){const n=e.length,r=new e.constructor(n);for(let o=0,s=0;s!==n;++o){const n=i[o]*t;for(let i=0;i!==t;++i)r[s++]=e[n+i]}return r},flattenJSON:function(e,t,i,n){let r=1,o=e[0];for(;void 0!==o&&void 0===o[n];)o=e[r++];if(void 0===o)return;let s=o[n];if(void 0!==s)if(Array.isArray(s))do{void 0!==(s=o[n])&&(t.push(o.time),i.push.apply(i,s)),o=e[r++]}while(void 0!==o);else if(void 0!==s.toArray)do{void 0!==(s=o[n])&&(t.push(o.time),s.toArray(i,i.length)),o=e[r++]}while(void 0!==o);else do{void 0!==(s=o[n])&&(t.push(o.time),i.push(s)),o=e[r++]}while(void 0!==o)},subclip:function(e,t,i,n,r=30){const o=e.clone();o.name=t;const s=[];for(let e=0;e=n)){l.push(t.times[e]);for(let i=0;io.tracks[e].times[0]&&(a=o.tracks[e].times[0]);for(let e=0;e=n.times[h]){const e=h*l+a,t=e+l-a;p=Il.arraySlice(n.values,e,t)}else{const e=n.createInterpolant(),t=a,i=l-a;e.evaluate(o),p=Il.arraySlice(e.resultBuffer,t,i)}"quaternion"===r&&(new Ae).fromArray(p).normalize().conjugate().toArray(p);const d=s.times.length;for(let e=0;e=r)break e;{const s=t[1];e=(r=t[--i-1]))break t}o=i,i=0}}for(;i>>1;et;)--o;if(++o,0!==r||o!==n){r>=o&&(r=(o=Math.max(o,1))-1);const e=this.getValueSize();this.times=Il.arraySlice(i,r,o),this.values=Il.arraySlice(this.values,r*e,o*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let t=0;t!==r;t++){const n=i[t];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,n),e=!1;break}if(null!==o&&o>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,n,o),e=!1;break}o=n}if(void 0!==n&&Il.isTypedArray(n))for(let t=0,i=n.length;t!==i;++t){const i=n[t];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,i),e=!1;break}}return e}optimize(){const e=Il.arraySlice(this.times),t=Il.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===j,r=e.length-1;let o=1;for(let s=1;s0){e[o]=e[r];for(let e=r*i,n=o*i,s=0;s!==i;++s)t[n+s]=t[e+s];++o}return o!==e.length?(this.times=Il.arraySlice(e,0,o),this.values=Il.arraySlice(t,0,o*i)):(this.times=e,this.values=t),this}clone(){const e=Il.arraySlice(this.times,0),t=Il.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Dl.prototype.TimeBufferType=Float32Array,Dl.prototype.ValueBufferType=Float32Array,Dl.prototype.DefaultInterpolation=U;class Ol extends Dl{}Ol.prototype.ValueTypeName="bool",Ol.prototype.ValueBufferType=Array,Ol.prototype.DefaultInterpolation=N,Ol.prototype.InterpolantFactoryMethodLinear=void 0,Ol.prototype.InterpolantFactoryMethodSmooth=void 0;class Fl extends Dl{}Fl.prototype.ValueTypeName="color";class Bl extends Dl{}Bl.prototype.ValueTypeName="number";class Nl extends Pl{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(i-t)/(n-t);let l=e*s;for(let e=l+s;l!==e;l+=4)Ae.slerpFlat(r,0,o,l-s,o,l,a);return r}}class Ul extends Dl{InterpolantFactoryMethodLinear(e){return new Nl(this.times,this.values,this.getValueSize(),e)}}Ul.prototype.ValueTypeName="quaternion",Ul.prototype.DefaultInterpolation=U,Ul.prototype.InterpolantFactoryMethodSmooth=void 0;class jl extends Dl{}jl.prototype.ValueTypeName="string",jl.prototype.ValueBufferType=Array,jl.prototype.DefaultInterpolation=N,jl.prototype.InterpolantFactoryMethodLinear=void 0,jl.prototype.InterpolantFactoryMethodSmooth=void 0;class Vl extends Dl{}Vl.prototype.ValueTypeName="vector";class Gl{constructor(e,t=-1,i,n=2500){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=le(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let e=0,r=i.length;e!==r;++e)t.push(Hl(i[e]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,n=i.length;e!==n;++e)t.push(Dl.toJSON(i[e]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,o=[];for(let e=0;e1){const e=o[1];let t=n[e];t||(n[e]=t=[]),t.push(i)}}const o=[];for(const e in n)o.push(this.CreateFromMorphTargetSequence(e,n[e],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(e,t,i,n,r){if(0!==i.length){const o=[],s=[];Il.flattenJSON(i,o,s,n),0!==o.length&&r.push(new e(t,o,s))}},n=[],r=e.name||"default",o=e.fps||30,s=e.blendMode;let a=e.length||-1;const l=e.hierarchy||[];for(let e=0;e0||0===e.search(/^data\:image\/jpeg/);r.format=n?S:E,r.needsUpdate=!0,void 0!==t&&t(r)}),i,n),r}}class tc extends ua{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Ta(t,e))}getPoint(e){const t=e*this.getLength(),i=this.getCurveLengths();let n=0;for(;n=t){const e=i[n]-t,r=this.curves[n],o=r.getLength(),s=0===o?0:1-e/o;return r.getPointAt(s)}n++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class nc extends ic{constructor(e){super(e),this.uuid=le(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,n=this.holes.length;i0:n.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(n.uniforms[t]={},r.type){case"t":n.uniforms[t].value=i(r.value);break;case"c":n.uniforms[t].value=(new Yt).setHex(r.value);break;case"v2":n.uniforms[t].value=(new ge).fromArray(r.value);break;case"v3":n.uniforms[t].value=(new Ce).fromArray(r.value);break;case"v4":n.uniforms[t].value=(new Me).fromArray(r.value);break;case"m3":n.uniforms[t].value=(new _e).fromArray(r.value);break;case"m4":n.uniforms[t].value=(new ot).fromArray(r.value);break;default:n.uniforms[t].value=r.value}}if(void 0!==e.defines&&(n.defines=e.defines),void 0!==e.vertexShader&&(n.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(n.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(const t in e.extensions)n.extensions[t]=e.extensions[t];if(void 0!==e.shading&&(n.flatShading=1===e.shading),void 0!==e.size&&(n.size=e.size),void 0!==e.sizeAttenuation&&(n.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(n.map=i(e.map)),void 0!==e.matcap&&(n.matcap=i(e.matcap)),void 0!==e.alphaMap&&(n.alphaMap=i(e.alphaMap)),void 0!==e.bumpMap&&(n.bumpMap=i(e.bumpMap)),void 0!==e.bumpScale&&(n.bumpScale=e.bumpScale),void 0!==e.normalMap&&(n.normalMap=i(e.normalMap)),void 0!==e.normalMapType&&(n.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),n.normalScale=(new ge).fromArray(t)}return void 0!==e.displacementMap&&(n.displacementMap=i(e.displacementMap)),void 0!==e.displacementScale&&(n.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(n.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(n.roughnessMap=i(e.roughnessMap)),void 0!==e.metalnessMap&&(n.metalnessMap=i(e.metalnessMap)),void 0!==e.emissiveMap&&(n.emissiveMap=i(e.emissiveMap)),void 0!==e.emissiveIntensity&&(n.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(n.specularMap=i(e.specularMap)),void 0!==e.specularIntensityMap&&(n.specularIntensityMap=i(e.specularIntensityMap)),void 0!==e.specularTintMap&&(n.specularTintMap=i(e.specularTintMap)),void 0!==e.envMap&&(n.envMap=i(e.envMap)),void 0!==e.envMapIntensity&&(n.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(n.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(n.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(n.lightMap=i(e.lightMap)),void 0!==e.lightMapIntensity&&(n.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(n.aoMap=i(e.aoMap)),void 0!==e.aoMapIntensity&&(n.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(n.gradientMap=i(e.gradientMap)),void 0!==e.clearcoatMap&&(n.clearcoatMap=i(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(n.clearcoatNormalScale=(new ge).fromArray(e.clearcoatNormalScale)),void 0!==e.transmissionMap&&(n.transmissionMap=i(e.transmissionMap)),void 0!==e.thicknessMap&&(n.thicknessMap=i(e.thicknessMap)),n}setTextures(e){return this.textures=e,this}}class Tc{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,n=e.length;iNumber.EPSILON){if(l<0&&(i=t[o],a=-a,s=t[r],l=-l),e.ys.y)continue;if(e.y===i.y){if(e.x===i.x)return!0}else{const t=l*(e.x-i.x)-a*(e.y-i.y);if(0===t)return!0;if(t<0)continue;n=!n}}else{if(e.y!==i.y)continue;if(s.x<=e.x&&e.x<=i.x||i.x<=e.x&&e.x<=s.x)return!0}}return n}const r=el.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return i(o);let s,a,l;const c=[];if(1===o.length)return a=o[0],(l=new nc).curves=a.curves,c.push(l),c;let u=!r(o[0].getPoints());u=e?!u:u;const h=[],p=[];let d,f,m=[],g=0;p[g]=void 0,m[g]=[];for(let t=0,i=o.length;t1){let e=!1;const t=[];for(let e=0,t=p.length;e0&&(e||(m=h))}for(let e=0,t=p.length;e0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(i[e]!==i[e+t]){s.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let e=i,r=n;e!==r;++e)t[e]=t[n+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let n=0;n!==r;++n)e[t+n]=e[i+n]}_slerp(e,t,i,n){Ae.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const o=this._workIndex*r;Ae.multiplyQuaternionsFlat(e,o,e,t,e,i),Ae.slerpFlat(e,t,e,t,e,o,n)}_lerp(e,t,i,n,r){const o=1-n;for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]*o+e[i+s]*n}}_lerpAdditive(e,t,i,n,r){for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]+e[i+o]*n}}}const eu=new RegExp("[\\[\\]\\.:\\/]","g"),tu="[^\\[\\]\\.:\\/]",iu="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",nu=/((?:WC+[\/:])*)/.source.replace("WC",tu),ru=/(WCOD+)?/.source.replace("WCOD",iu),ou=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",tu),su=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",tu),au=new RegExp("^"+nu+ru+ou+su+"$"),lu=["material","materials","bones"];class cu{constructor(e,t,i){this.path=t,this.parsedPath=i||cu.parseTrackName(t),this.node=cu.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new cu.Composite(e,t,i):new cu(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(eu,"")}static parseTrackName(e){const t=au.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const e=i.nodeName.substring(n+1);-1!==lu.indexOf(e)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=e)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){const i=function(e){for(let n=0;n=r){const o=r++,c=e[o];t[c.uuid]=l,e[l]=c,t[a]=o,e[o]=s;for(let e=0,t=n;e!==t;++e){const t=i[e],n=t[o],r=t[l];t[l]=n,t[o]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=e.length;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s].uuid,l=t[a];if(void 0!==l)if(delete t[a],l0&&(t[s.uuid]=l),e[l]=s,e.pop();for(let e=0,t=n;e!==t;++e){const t=i[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(void 0!==n)return r[n];const o=this._paths,s=this._parsedPaths,a=this._objects,l=a.length,c=this.nCachedObjects_,u=new Array(l);n=r.length,i[e]=n,o.push(e),s.push(t),r.push(u);for(let i=c,n=a.length;i!==n;++i){const n=a[i];u[i]=new cu(n,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(void 0!==i){const n=this._paths,r=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s];t[e[s]]=i,o[i]=a,o.pop(),r[i]=r[s],r.pop(),n[i]=n[s],n.pop()}}}uu.prototype.isAnimationObjectGroup=!0;class hu{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,o=r.length,s=new Array(o),a={endingStart:V,endingEnd:V};for(let e=0;e!==o;++e){const t=r[e].createInterpolant(null);s[e]=t,t.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=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const i=this._clip.duration,n=e._clip.duration,r=n/i,o=i/n;e.warp(1,r,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,o=this.timeScale;let s=this._timeScaleInterpolant;null===s&&(s=n._lendControlInterpolant(),this._timeScaleInterpolant=s);const a=s.parameterPositions,l=s.sampleValues;return a[0]=r,a[1]=r+i,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const n=(e-r)*i;if(n<0||0===i)return;this._startTime=null,t=i*n}t*=this._updateTimeScale(e);const o=this._updateTime(t),s=this._updateWeight(e);if(s>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===q)for(let i=0,n=e.length;i!==n;++i)e[i].evaluate(o),t[i].accumulateAdditive(s);else for(let i=0,r=e.length;i!==r;++i)e[i].evaluate(o),t[i].accumulate(n,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;null!==i&&(t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const o=2202===i;if(0===e)return-1===r?n:o&&1==(1&r)?t-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),n>=t||n<0){const i=Math.floor(n/t);n-=t*i,r+=Math.abs(i);const s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){const t=e<0;this._setEndings(t,!t,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(o&&1==(1&r))return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=G,n.endingEnd=G):(n.endingStart=e?this.zeroSlopeAtStart?G:V:H,n.endingEnd=t?this.zeroSlopeAtEnd?G:V:H)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);const s=o.parameterPositions,a=o.sampleValues;return s[0]=r,a[0]=t,s[1]=r+e,a[1]=i,this}}class pu extends ne{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,o=e._propertyBindings,s=e._interpolants,a=i.uuid,l=this._bindingsByRootAndName;let c=l[a];void 0===c&&(c={},l[a]=c);for(let e=0;e!==r;++e){const r=n[e],l=r.name;let u=c[l];if(void 0!==u)o[e]=u;else{if(void 0!==(u=o[e])){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,a,l));continue}const n=t&&t._propertyBindings[e].binding.parsedPath;++(u=new Kc(cu.create(i,l,n),r.ValueTypeName,r.getValueSize())).referenceCount,this._addInactiveBinding(u,a,l),o[e]=u}s[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,i=e._clip.uuid,n=this._actionsByClip[i];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,i,t)}const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let s=0;s!==i;++s)t[s]._update(n,e,r,o);const s=this._bindings,a=this._nActiveBindings;for(let e=0;e!==a;++e)s[e].apply(o);return this}setTime(e){this.time=0;for(let e=0;ethis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return yu.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}vu.prototype.isBox2=!0;const xu=new Ce,bu=new Ce;class wu{constructor(e=new Ce,t=new Ce){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){xu.subVectors(e,this.start),bu.subVectors(this.end,this.start);const i=bu.dot(bu);let n=bu.dot(xu)/i;return t&&(n=ce(n,0,1)),n}closestPointToPoint(e,t,i){const n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}class Mu extends It{constructor(e){super(),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}}Mu.prototype.isImmediateRenderObject=!0;const Tu=new Ce,Su=new Ce,Eu=new ot,Au=new ot;class Cu extends js{constructor(e){const t=function e(t){const i=[];t&&t.isBone&&i.push(t);for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{ju.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ju,t)}}setLength(e,t=.2*e,i=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}},e.Audio=$c,e.AudioAnalyser=Qc,e.AudioContext=Dc,e.AudioListener=class extends It{constructor(){super(),this.type="AudioListener",this.context=Dc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new jc}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Gc,Hc,Wc),qc.set(0,0,-1).applyQuaternion(Hc),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Gc.x,e),t.positionY.linearRampToValueAtTime(Gc.y,e),t.positionZ.linearRampToValueAtTime(Gc.z,e),t.forwardX.linearRampToValueAtTime(qc.x,e),t.forwardY.linearRampToValueAtTime(qc.y,e),t.forwardZ.linearRampToValueAtTime(qc.z,e),t.upX.linearRampToValueAtTime(i.x,e),t.upY.linearRampToValueAtTime(i.y,e),t.upZ.linearRampToValueAtTime(i.z,e)}else t.setPosition(Gc.x,Gc.y,Gc.z),t.setOrientation(qc.x,qc.y,qc.z,i.x,i.y,i.z)}},e.AudioLoader=Oc,e.AxesHelper=Hu,e.AxisHelper=function(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Hu(e)},e.BackSide=1,e.BasicDepthPacking=3200,e.BasicShadowMap=0,e.BinaryTextureLoader=function(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Kl(e)},e.Bone=bs,e.BooleanKeyframeTrack=Ol,e.BoundingBoxHelper=function(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Uu(e,t)},e.Box2=vu,e.Box3=Pe,e.Box3Helper=class extends js{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new bi;n.setIndex(new ei(i,1)),n.setAttribute("position",new ci([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new Rs({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}},e.BoxBufferGeometry=ji,e.BoxGeometry=ji,e.BoxHelper=Uu,e.BufferAttribute=ei,e.BufferGeometry=bi,e.BufferGeometryLoader=Ec,e.ByteType=1010,e.Cache=Wl,e.Camera=qi,e.CameraHelper=class extends js{constructor(e){const t=new bi,i=new Rs({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],o={},s=new Yt(16755200),a=new Yt(16711680),l=new Yt(43775),c=new Yt(16777215),u=new Yt(3355443);function h(e,t,i){p(e,i),p(t,i)}function p(e,t){n.push(0,0,0),r.push(t.r,t.g,t.b),void 0===o[e]&&(o[e]=[]),o[e].push(n.length/3-1)}h("n1","n2",s),h("n2","n4",s),h("n4","n3",s),h("n3","n1",s),h("f1","f2",s),h("f2","f4",s),h("f4","f3",s),h("f3","f1",s),h("n1","f1",s),h("n2","f2",s),h("n3","f3",s),h("n4","f4",s),h("p","n1",a),h("p","n2",a),h("p","n3",a),h("p","n4",a),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",c),h("p","c",u),h("cn1","cn2",u),h("cn3","cn4",u),h("cf1","cf2",u),h("cf3","cf4",u),t.setAttribute("position",new ci(n,3)),t.setAttribute("color",new ci(r,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){const e=this.geometry,t=this.pointMap;Fu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Bu("c",t,e,Fu,0,0,-1),Bu("t",t,e,Fu,0,0,1),Bu("n1",t,e,Fu,-1,-1,-1),Bu("n2",t,e,Fu,1,-1,-1),Bu("n3",t,e,Fu,-1,1,-1),Bu("n4",t,e,Fu,1,1,-1),Bu("f1",t,e,Fu,-1,-1,1),Bu("f2",t,e,Fu,1,-1,1),Bu("f3",t,e,Fu,-1,1,1),Bu("f4",t,e,Fu,1,1,1),Bu("u1",t,e,Fu,.7,1.1,-1),Bu("u2",t,e,Fu,-.7,1.1,-1),Bu("u3",t,e,Fu,0,2,-1),Bu("cf1",t,e,Fu,-1,0,1),Bu("cf2",t,e,Fu,1,0,1),Bu("cf3",t,e,Fu,0,-1,1),Bu("cf4",t,e,Fu,0,1,1),Bu("cn1",t,e,Fu,-1,0,-1),Bu("cn2",t,e,Fu,1,0,-1),Bu("cn3",t,e,Fu,0,-1,-1),Bu("cn4",t,e,Fu,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},e.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},e.CanvasTexture=Qs,e.CatmullRomCurve3=ya,e.CineonToneMapping=3,e.CircleBufferGeometry=ea,e.CircleGeometry=ea,e.ClampToEdgeWrapping=h,e.Clock=jc,e.Color=Yt,e.ColorKeyframeTrack=Fl,e.CompressedTexture=Js,e.CompressedTextureLoader=class extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=[],s=new Js,a=new Yl(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let l=0;function c(c){a.load(e[c],(function(e){const i=r.parse(e,!0);o[c]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},6===(l+=1)&&(1===i.mipmapCount&&(s.minFilter=g),s.image=o,s.format=i.format,s.needsUpdate=!0,t&&t(s))}),i,n)}if(Array.isArray(e))for(let t=0,i=e.length;t>16&32768,n=t>>12&2047;const r=t>>23&255;return r<103?i:r>142?(i|=31744,i|=(255==r?0:1)&&8388607&t):r<113?i|=((n|=2048)>>114-r)+(n>>113-r&1):(i|=r-112<<10|n>>1,i+=1&n)}},e.DecrementStencilOp=7683,e.DecrementWrapStencilOp=34056,e.DefaultLoadingManager=$l,e.DepthFormat=A,e.DepthStencilFormat=C,e.DepthTexture=Ks,e.DirectionalLight=yc,e.DirectionalLightHelper=class extends It{constructor(e,t,i){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,void 0===t&&(t=1);let n=new bi;n.setAttribute("position",new ci([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Rs({fog:!1,toneMapped:!1});this.lightPlane=new Bs(n,r),this.add(this.lightPlane),(n=new bi).setAttribute("position",new ci([0,0,0,0,0,1],3)),this.targetLine=new Bs(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){ku.setFromMatrixPosition(this.light.matrixWorld),zu.setFromMatrixPosition(this.light.target.matrixWorld),Du.subVectors(zu,ku),this.lightPlane.lookAt(zu),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(zu),this.targetLine.scale.z=Du.length()}},e.DiscreteInterpolant=zl,e.DodecahedronBufferGeometry=ra,e.DodecahedronGeometry=ra,e.DoubleSide=2,e.DstAlphaFactor=206,e.DstColorFactor=208,e.DynamicBufferAttribute=function(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new ei(e,t).setUsage(te)},e.DynamicCopyUsage=35050,e.DynamicDrawUsage=te,e.DynamicReadUsage=35049,e.EdgesGeometry=ca,e.EdgesHelper=function(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new js(new ca(e.geometry),new Rs({color:void 0!==t?t:16777215}))},e.EllipseCurve=ha,e.EqualDepth=4,e.EqualStencilFunc=514,e.EquirectangularReflectionMapping=s,e.EquirectangularRefractionMapping=a,e.Euler=mt,e.EventDispatcher=ne,e.ExtrudeBufferGeometry=nl,e.ExtrudeGeometry=nl,e.FaceColors=1,e.FileLoader=Yl,e.FlatShading=1,e.Float16BufferAttribute=li,e.Float32Attribute=function(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new ci(e,t)},e.Float32BufferAttribute=ci,e.Float64Attribute=function(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new ui(e,t)},e.Float64BufferAttribute=ui,e.FloatType=w,e.Fog=Wo,e.FogExp2=Ho,e.Font=Rc,e.FontLoader=class extends Zl{constructor(e){super(e)}load(e,t,i,n){const r=this,o=new Yl(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(e){let i;try{i=JSON.parse(e)}catch(t){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(e.substring(65,e.length-2))}const n=r.parse(i);t&&t(n)}),i,n)}parse(e){return new Rc(e)}},e.FrontSide=0,e.Frustum=rn,e.GLBufferAttribute=mu,e.GLSL1="100",e.GLSL3=ie,e.GammaEncoding=X,e.GreaterDepth=6,e.GreaterEqualDepth=5,e.GreaterEqualStencilFunc=518,e.GreaterStencilFunc=516,e.GridHelper=Ru,e.Group=Fo,e.HalfFloatType=M,e.HemisphereLight=oc,e.HemisphereLightHelper=class extends It{constructor(e,t,i){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;const n=new al(t);n.rotateY(.5*Math.PI),this.material=new Jt({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),o=new Float32Array(3*r.count);n.setAttribute("color",new ei(o,3)),this.add(new Ni(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Iu.copy(this.light.color),Pu.copy(this.light.groundColor);for(let e=0,i=t.count;e0){const i=new ql(t);(r=new Jl(i)).setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t0){(n=new Jl(this.manager)).setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t90))return e;console.error("Latitude must be between -90 and 90")}else console.error("Coords must be an array")},Line:function(e){if(e.constructor===Array){for(const t of e)if(!this.Coords(t))return void console.error("Each coordinate in a line must be a valid Coords type");return e}console.error("Line must be an array")},Rotation:function(e){if(e.constructor===Number)e={z:e};else{if(e.constructor!==Object)return void console.error("Rotation must be an object or a number");for(const t of Object.keys(e)){if(!["x","y","z"].includes(t))return void console.error("Rotation parameters must be x, y, or z");if(e[t].constructor!==Number)return void console.error("Individual rotation values must be numbers")}}return e},Scale:function(e){if(e.constructor===Number)e={x:e,y:e,z:e};else{if(e.constructor!==Object)return void console.error("Scale must be an object or a number");for(const t of Object.keys(e)){if(!["x","y","z"].includes(t))return void console.error("Scale parameters must be x, y, or z");if(e[t].constructor!==Number)return void console.error("Individual scale values must be numbers")}}return e}},l=l=c;var u={},h={prettyPrintMatrix:function(e){for(var t=0;t<4;t++){var i=[e[t],e[t+4],e[t+8],e[t+12]];console.log(i.map((function(e){return e.toFixed(4)})))}},makePerspectiveMatrix:function(e,t,i,r){var o=new n.Matrix4,s=1/Math.tan(e/2),a=1/(i-r),l=[s/t,0,0,0,0,s,0,0,0,0,(r+i)*a,-1,0,0,2*r*i*a,0];return o.elements=l,o},makeOrthographicMatrix:function(e,t,i,r,o,s){var a=new n.Matrix4;const l=1/(t-e),c=1/(i-r),u=1/(s-o);var h=[2*l,0,0,0,0,2*c,0,0,0,0,-1*u,0,-(t+e)*l,-(i+r)*c,-o*u,1];return a.elements=h,a},radify:function(e){function t(e){return e=e||0,2*Math.PI*e/360}return"object"==typeof e?e.length>0?e.map((function(e){return t(e)})):[t(e.x),t(e.y),t(e.z)]:t(e)},degreeify:function(e){function t(e){return 360*(e=e||0)/(2*Math.PI)}return"object"==typeof e?[t(e.x),t(e.y),t(e.z)]:t(e)},projectToWorld:function(e){var t=[-r.MERCATOR_A*r.DEG2RAD*e[0]*r.PROJECTION_WORLD_SIZE,-r.MERCATOR_A*Math.log(Math.tan(.25*Math.PI+.5*r.DEG2RAD*e[1]))*r.PROJECTION_WORLD_SIZE];if(e[2]){var i=this.projectedUnitsPerMeter(e[1]);t.push(e[2]*i)}else t.push(0);return new n.Vector3(t[0],t[1],t[2])},projectedUnitsPerMeter:function(e){return Math.abs(r.WORLD_SIZE/Math.cos(r.DEG2RAD*e)/r.EARTH_CIRCUMFERENCE)},_circumferenceAtLatitude:function(e){return r.EARTH_CIRCUMFERENCE*Math.cos(e*Math.PI/180)},mercatorZfromAltitude:function(e,t){return e/this._circumferenceAtLatitude(t)},_scaleVerticesToMeters:function(e,t){for(var i=this.projectedUnitsPerMeter(e[1]),n=(this.projectToWorld(e),0);n{let{width:i,color:r}=t,o=(new n.BufferGeometry).setFromPoints(e.getPoints(100)),s=new n.LineBasicMaterial({color:r,linewidth:i});return new n.Line(o,s)},curvesToLines:e=>{var t=[16711680,2031360,2490623];return e.map(((e,i)=>curveToLine(e,{width:3,color:t[i]||"purple"})))},_validate:function(e,t){e=e||{};var i={};h.extend(i,e);for(let n of Object.keys(t))if(void 0===e[n]){if(null===t[n])return void console.error(n+" is required");i[n]=t[n]}else i[n]=e[n];return i},Validator:new l,exposedMethods:["projectToWorld","projectedUnitsPerMeter","extend","unprojectFromWorld"]};u=u=h;var p={};function d(e,t,i){this.map=e,this.camera=t,this.active=!0,this.camera.matrixAutoUpdate=!1,this.world=i||new n.Group,this.world.position.x=this.world.position.y=r.WORLD_SIZE/2,this.world.matrixAutoUpdate=!1,this.state={translateCenter:(new n.Matrix4).makeTranslation(r.WORLD_SIZE/2,-r.WORLD_SIZE/2,0),worldSizeRatio:r.TILE_SIZE/r.WORLD_SIZE,worldSize:r.TILE_SIZE*this.map.transform.scale};let o=this;this.map.on("move",(function(){o.updateCamera()})).on("resize",(function(){o.setupCamera()})),this.setupCamera()}d.prototype={setupCamera:function(){const e=this.map.transform;this.camera.aspect=e.width/e.height,this.halfFov=e._fov/2,this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*e.height;const t=e._maxPitch*Math.PI/180;this.acuteAngle=Math.PI/2-t,this.updateCamera()},updateCamera:function(e){if(!this.camera)return void console.log("nocamera");const t=this.map.transform;this.camera.aspect=t.width/t.height;const i=t.centerOffset||new n.Vector3;let r=0,o=0;this.halfFov=t._fov/2;const s=Math.PI/2+t._pitch,a=Math.cos(Math.PI/2-t._pitch);this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*t.height;let l=1;const c=this.worldSize();if(this.map.tb.mapboxVersion>=2){l=this.mercatorZfromAltitude(1,t.center.lat)*c;const e=t._fov*(.5+t.centerOffset.y/t.height),i=t.elevation?t.elevation.getMinElevationBelowMSL()*l:0,n=(t._camera.position[2]*c-i)/Math.cos(t._pitch);o=a*(Math.sin(e)*n/Math.sin(u.clamp(Math.PI-s-e,.01,Math.PI-.01)))+n;const h=n*(1/t._horizonShift);r=Math.min(1.01*o,h)}else r=1.01*(o=a*(Math.sin(this.halfFov)*this.cameraToCenterDistance/Math.sin(Math.PI-s-this.halfFov))+this.cameraToCenterDistance);this.cameraTranslateZ=(new n.Matrix4).makeTranslation(0,0,this.cameraToCenterDistance);const h=t.height/50,p=Math.max(h*a,h),f=t.height,m=t.width;this.camera instanceof n.OrthographicCamera?this.camera.projectionMatrix=u.makeOrthographicMatrix(m/-2,m/2,f/2,f/-2,p,r):this.camera.projectionMatrix=u.makePerspectiveMatrix(t._fov,m/f,p,r),this.camera.projectionMatrix.elements[8]=2*-i.x/t.width,this.camera.projectionMatrix.elements[9]=2*i.y/t.height;let g=this.calcCameraMatrix(t._pitch,t.angle);t.elevation&&(g.elements[14]=t._camera.position[2]*c),this.camera.matrixWorld.copy(g);let _=t.scale*this.state.worldSizeRatio,y=new n.Matrix4,v=new n.Matrix4,x=new n.Matrix4;y.makeScale(_,_,_);let b=t.x||t.point.x,w=t.y||t.point.y;v.makeTranslation(-b,w,0),x.makeRotationZ(Math.PI),this.world.matrix=(new n.Matrix4).premultiply(x).premultiply(this.state.translateCenter).premultiply(y).premultiply(v),this.map.fire("CameraSynced",{detail:{nearZ:p,farZ:r,pitch:t._pitch,angle:t.angle,furthestDistance:o,cameraToCenterDistance:this.cameraToCenterDistance,t:this.map.transform,tbProjMatrix:this.camera.projectionMatrix.elements,tbWorldMatrix:this.world.matrix.elements,cameraSyn:d}})},worldSize(){let e=this.map.transform;return e.tileSize*e.scale},worldSizeFromZoom(){let e=this.map.transform;return Math.pow(2,e.zoom)*e.tileSize},mercatorZfromAltitude(e,t){return e/this.circumferenceAtLatitude(t)},mercatorZfromZoom(){return this.cameraToCenterDistance/this.worldSizeFromZoom()},circumferenceAtLatitude:e=>r.EARTH_CIRCUMFERENCE*Math.cos(e*Math.PI/180),calcCameraMatrix(e,t,i){const r=this.map.transform,o=void 0===e?r._pitch:e,s=void 0===t?r.angle:t,a=void 0===i?this.cameraTranslateZ:i;return(new n.Matrix4).premultiply(a).premultiply((new n.Matrix4).makeRotationX(o)).premultiply((new n.Matrix4).makeRotationZ(s))},updateCameraState(){let e=this.map.transform;if(!e.height)return;const t=e._camera.forward(),i=e.cameraToCenterDistance,n=e.point,r=(e._cameraZoom?e._cameraZoom:e._zoom,this.mercatorZfromZoom(e)-this.mercatorZfromAltitude(e._centerAltitude,e.center.lat)),o=e.cameraToCenterDistance/r;return[n.x/this.worldSize()-t[0]*i/o,n.y/this.worldSize()-t[1]*i/o,this.mercatorZfromAltitude(e._centerAltitude,e._center.lat)+-t[2]*i/o]},getWorldToCamera(e,t){let i=this.map.transform;const r=new n.Matrix4,o=new n.Matrix4,s=i._camera._orientation,a=i._camera.position,l=new n.Vector3(a[0],a[1],a[2]),c=new n.Quaternion;c.set(s[0],s[1],s[2],s[3]);const u=c.conjugate();return l.multiplyScalar(-e),o.makeTranslation(l.x,l.y,l.z),r.makeRotationFromQuaternion(u).premultiply(o),r.elements[1]*=-1,r.elements[5]*=-1,r.elements[9]*=-1,r.elements[13]*=-1,r.elements[8]*=t,r.elements[9]*=t,r.elements[10]*=t,r.elements[11]*=t,r},translate(e,t,i){let n,r,o,s,a,l,c,u,h,p,d,f,m=i[0]||i.x,g=i[1]||i.y,_=i[2]||i.z;return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=n,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]=p,e[10]=d,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+p*_+t[13],e[14]=o*m+c*g+d*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e}},p=p=d;var f={};!function(){"use strict";var e=Math.PI,t=Math.sin,i=Math.cos,n=Math.tan,r=Math.asin,o=Math.atan2,s=Math.acos,a=e/180;function l(e){return e.valueOf()/864e5-.5+2440588}function c(e){return new Date(864e5*(e+.5-2440588))}function u(e){return l(e)-2451545}var h=23.4397*a;function p(e,r){return o(t(e)*i(h)-n(r)*t(h),i(e))}function d(e,n){return r(t(n)*i(h)+i(n)*t(h)*t(e))}function m(e,r,s){return o(t(e),i(e)*t(r)-n(s)*i(r))}function g(e,n,o){return r(t(n)*t(o)+i(n)*i(o)*i(e))}function _(e,t){return a*(280.16+360.9856235*e)-t}function y(e){return a*(357.5291+.98560028*e)}function v(i){return i+a*(1.9148*t(i)+.02*t(2*i)+3e-4*t(3*i))+102.9372*a+e}function x(e){var t=v(y(e));return{dec:d(t,0),ra:p(t,0)}}var b={getPosition:function(e,t,i){var n=a*-i,r=a*t,o=u(e),s=x(o),l=_(o,n)-s.ra;return{azimuth:m(l,r,s.dec),altitude:g(l,r,s.dec)}},toJulian:function(e){return l(e)}},w=b.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];b.addTime=function(e,t,i){w.push([e,t,i])};function M(t,i,n){return 9e-4+(t+i)/(2*e)+n}function T(e,i,n){return 2451545+e+.0053*t(i)-.0069*t(2*n)}function S(e,n,r,o,a,l,c){return T(M(function(e,n,r){return s((t(e)-t(n)*t(r))/(i(n)*i(r)))}(e,r,o),n,a),l,c)}function E(e){var n=a*(134.963+13.064993*e),r=a*(93.272+13.22935*e),o=a*(218.316+13.176396*e)+6.289*a*t(n),s=5.128*a*t(r),l=385001-20905*i(n);return{ra:p(o,s),dec:d(o,s),dist:l}}function A(e,t){return new Date(e.valueOf()+864e5*t/24)}b.getTimes=function(t,i,n,r){var o,s,l,h,p,f=a*-n,m=a*i,g=function(e){return-2.076*Math.sqrt(e)/60}(r=r||0),_=function(t,i){return Math.round(t-9e-4-i/(2*e))}(u(t),f),x=M(0,f,_),b=y(x),E=v(b),A=d(E,0),C=T(x,b,E),L={solarNoon:c(C),nadir:c(C-.5)};for(o=0,s=w.length;o=0&&(g=p-(y=Math.sqrt(f)/(2*Math.abs(u))),_=p+y,Math.abs(g)<=1&&m++,Math.abs(_)<=1&&m++,g<-1&&(g=_)),1===m?x<0?l=w+g:c=w+g:2===m&&(l=w+(d<0?_:g),c=w+(d<0?g:_)),!l||!c);w+=2)x=s;var M={};return l&&(M.rise=A(r,l)),c&&(M.set=A(r,c)),l||c||(M[d>0?"alwaysUp":"alwaysDown"]=!0),M},f=f=b}();var m={},g={material:"MeshBasicMaterial",color:"black",opacity:1};m=m=function(e){var t;function i(){return new n[g.material]({color:g.color})}return e?((t=(e=u._validate(e,g)).material&&e.material.isMaterial?e.material:e.material||e.color||e.opacity?new n[e.material]({color:e.color,transparent:e.opacity<1}):i()).opacity=e.opacity,e.side&&(t.side=e.side)):t=i(),t};var _={};function y(e){this.map=e,this.enrolledObjects=[],this.previousFrameTime}y.prototype={unenroll:function(e){this.enrolledObjects.splice(this.enrolledObjects.indexOf(e),1)},enroll:function(e){if(e.clock=new n.Clock,e.hasDefaultAnimation=!1,e.defaultAction,e.actions=[],e.mixer,e.animations&&e.animations.length>0){e.hasDefaultAnimation=!0;let i=e.userData.defaultAnimation?e.userData.defaultAnimation:0;e.mixer=new n.AnimationMixer(e),t(i)}function t(t){for(let i=0;ie.animations.length&&console.log("The animation index "+t+" doesn't exist for this object");let n=e.animations[i],r=e.mixer.clipAction(n);e.actions.push(r),t===i?(e.defaultAction=r,r.setEffectiveWeight(1)):r.setEffectiveWeight(0),r.play()}}let i=!1;Object.defineProperty(e,"isPlaying",{get:()=>i,set(t){i!=t&&(i=t,e.dispatchEvent({type:"IsPlayingChanged",detail:e}))}}),this.enrolledObjects.push(e),e.animationQueue=[],e.set=function(t){if(t.duration>0){let i={start:Date.now(),expiration:Date.now()+t.duration,endState:{}};u.extend(t,i);let r=t.coords,o=t.rotation,s=t.scale||t.scaleX||t.scaleY||t.scaleZ;if(o){let i=e.rotation;t.startRotation=[i.x,i.y,i.z],t.endState.rotation=u.types.rotation(t.rotation,t.startRotation),t.rotationPerMs=t.endState.rotation.map((function(e,i){return(e-t.startRotation[i])/t.duration}))}if(s){let i=e.scale;t.startScale=[i.x,i.y,i.z],t.endState.scale=u.types.scale(t.scale,t.startScale),t.scalePerMs=t.endState.scale.map((function(e,i){return(e-t.startScale[i])/t.duration}))}r&&(t.pathCurve=new n.CatmullRomCurve3(u.lnglatsToWorld([e.coordinates,t.coords])));let a={type:"set",parameters:t};this.animationQueue.push(a),tb.map.repaint=!0}else this.stop(),t.rotation=u.radify(t.rotation),this._setObject(t);return this},e.animationMethod=null,e.stop=function(t){return e.mixer&&(e.isPlaying=!1,cancelAnimationFrame(e.animationMethod)),this.animationQueue=[],this},e.followPath=function(e,t){let i={type:"followPath",parameters:u._validate(e,v.followPath)};return u.extend(i.parameters,{pathCurve:new n.CatmullRomCurve3(u.lnglatsToWorld(e.path)),start:Date.now(),expiration:Date.now()+i.parameters.duration,cb:t}),this.animationQueue.push(i),tb.map.repaint=!0,this},e._setObject=function(t){e.setScale();let i=t.position,r=t.rotation,o=t.scale,s=t.worldCoordinates,a=t.quaternion,l=t.translate,c=t.worldTranslate;if(i){this.coordinates=i;let e=u.projectToWorld(i);this.position.copy(e)}if(l){this.coordinates=[this.coordinates[0]+l[0],this.coordinates[1]+l[1],this.coordinates[2]+l[2]];let e=u.projectToWorld(l);this.position.copy(e),t.position=this.coordinates}if(c){this.translateX(c.x),this.translateY(c.y),this.translateZ(c.z);let e=u.unprojectFromWorld(this.position);this.coordinates=t.position=e}if(r&&(this.rotation.set(r[0],r[1],r[2]),t.rotation=new n.Vector3(r[0],r[1],r[2])),o&&(this.scale.set(o[0],o[1],o[2]),t.scale=this.scale),a&&(this.quaternion.setFromAxisAngle(a[0],a[1]),t.rotation=a[0].multiplyScalar(a[1])),s){this.position.copy(s);let e=u.unprojectFromWorld(s);this.coordinates=t.position=e}this.setBoundingBoxShadowFloor(),this.setReceiveShadowFloor(),this.updateMatrixWorld(),tb.map.repaint=!0;let h={type:"ObjectChanged",detail:{object:this,action:{position:t.position,rotation:t.rotation,scale:t.scale}}};this.dispatchEvent(h)},e.playDefault=function(t){if(e.mixer&&e.hasDefaultAnimation){let i={start:Date.now(),expiration:Date.now()+t.duration,endState:{}};u.extend(t,i),e.mixer.timeScale=t.speed||1;let n={type:"playDefault",parameters:t};return this.animationQueue.push(n),tb.map.repaint=!0,this}},e.playAnimation=function(i){e.mixer&&(i.animation&&t(i.animation),e.playDefault(i))},e.pauseAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.paused=!0}))},e.unPauseAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.paused=!1}))},e.deactivateAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.stop()}))},e.activateAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.play()}))},e.idle=function(){return e.mixer&&e.mixer.update(.01),tb.map.repaint=!0,this}},update:function(e){if(void 0===this.previousFrameTime&&(this.previousFrameTime=e),!this.enrolledObjects)return!1;for(let t=this.enrolledObjects.length-1;t>=0;t--){let i=this.enrolledObjects[t];if(i.animationQueue&&0!==i.animationQueue.length)for(let t=i.animationQueue.length-1;t>=0;t--){let r=i.animationQueue[t];if(!r)continue;let o=r.parameters;if(!o.expiration)return i.animationQueue.splice(t,1),void(i.animationQueue[t]&&(i.animationQueue[t].parameters.start=e));if(e>=o.expiration)o.expiration=!1,"playDefault"===r.type?i.stop():(o.endState&&i._setObject(o.endState),void 0!==o.cb&&o.cb());else{let t=(e-o.start)/o.duration;if("set"===r.type){let e={};o.pathCurve&&(e.worldCoordinates=o.pathCurve.getPoint(t)),o.rotationPerMs&&(e.rotation=o.startRotation.map((function(e,i){return e+o.rotationPerMs[i]*t*o.duration}))),o.scalePerMs&&(e.scale=o.startScale.map((function(e,i){return e+o.scalePerMs[i]*t*o.duration}))),i._setObject(e)}if("followPath"===r.type){let e={worldCoordinates:o.pathCurve.getPointAt(t)};if(o.trackHeading){let i=o.pathCurve.getTangentAt(t).normalize(),r=new n.Vector3(0,0,0),s=new n.Vector3(0,1,0);r.crossVectors(s,i).normalize();let a=Math.acos(s.dot(i));e.quaternion=[r,a]}i._setObject(e)}"playDefault"===r.type&&(i.activateAllActions(),i.isPlaying=!0,i.animationMethod=requestAnimationFrame(this.update),i.mixer.update(i.clock.getDelta()),tb.map.repaint=!0)}}}this.previousFrameTime=e}};const v={followPath:{path:null,duration:1e3,trackHeading:!0}};_=_=y;var x={};!function(){class e extends n.Object3D{constructor(e){super(),this.element=e||document.createElement("div"),this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.alwaysVisible=!1,Object.defineProperty(this,"layer",{get(){return this.parent&&this.parent.parent?this.parent.parent.layer:null}}),this.dispose=function(){this.remove(),this.element=null},this.remove=function(){this.element instanceof Element&&null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)},this.addEventListener("removed",(function(){this.remove()}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}}e.prototype.isCSS2DObject=!0;const t=new n.Vector3,i=new n.Matrix4,r=new n.Matrix4,o=new n.Vector3,s=new n.Vector3;n.CSS2DObject=e,n.CSS2DRenderer=class{constructor(){const e=this;let n,a,l,c;const u={objects:new WeakMap,list:new Map};this.cacheList=u.list;const h=document.createElement("div");h.style.overflow="hidden",this.domElement=h,this.getSize=function(){return{width:n,height:a}},this.render=function(n,a){!0===n.autoUpdate&&n.updateMatrixWorld(),null===a.parent&&a.updateMatrixWorld(),i.copy(a.matrixWorldInverse),r.multiplyMatrices(a.projectionMatrix,i),function i(n,a,p){if(n.isCSS2DObject)if(n.visible){n.onBeforeRender(e,a,p),t.setFromMatrixPosition(n.matrixWorld),t.applyMatrix4(r);const i=n.element;var d;d=/apple/i.test(navigator.vendor)?"translate(-50%,-50%) translate("+Math.round(t.x*l+l)+"px,"+Math.round(-t.y*c+c)+"px)":"translate(-50%,-50%) translate("+(t.x*l+l)+"px,"+(-t.y*c+c)+"px)",i.style.WebkitTransform=d,i.style.MozTransform=d,i.style.oTransform=d,i.style.transform=d,i.style.display=n.visible&&t.z>=-1&&t.z<=1?"":"none";const g={distanceToCameraSquared:(f=p,m=n,o.setFromMatrixPosition(f.matrixWorld),s.setFromMatrixPosition(m.matrixWorld),o.distanceToSquared(s))};u.objects.set({key:n.uuid},g),u.list.set(n.uuid,n),i.parentNode!==h&&h.appendChild(i),n.onAfterRender(e,a,p)}else u.objects.delete({key:n.uuid}),u.list.delete(n.uuid),n.remove();var f,m;for(let e=0,t=n.children.length;ee.getObjectByName("model")}),Object.defineProperty(e,"animations",{get(){const t=e.model;return t?t.animations:null}}),i.animationManager.enroll(e),e.setCoords=function(t){return e.userData.topMargin&&e.userData.feature&&(t[2]+=((e.userData.feature.properties.height||0)-(e.userData.feature.properties.base_height||e.userData.feature.properties.min_height||0))*(e.userData.topMargin||0)),e.coordinates=t,e.set({position:t}),e},e.setTranslate=function(t){return e.set({translate:t}),e},e.setRotation=function(t){"number"==typeof t&&(t={z:t});var i={x:u.radify(t.x)||e.rotation.x,y:u.radify(t.y)||e.rotation.y,z:u.radify(t.z)||e.rotation.z};e._setObject({rotation:[i.x,i.y,i.z]})},e.calculateAdjustedPosition=function(t,i,n){let r=t.slice(),o=u.unprojectFromWorld(e.modelSize);return n?(r[0]-=0!=i.x?o[0]/i.x:0,r[1]-=0!=i.y?o[1]/i.y:0,r[2]-=0!=i.z?o[2]/i.z:0):(r[0]+=0!=i.x?o[0]/i.x:0,r[1]+=0!=i.y?o[1]/i.y:0,r[2]+=0!=i.z?o[2]/i.z:0),r},e.setRotationAxis=function(t){"number"==typeof t&&(t={z:t});let i=e.modelBox(),r=new w.Vector3(i.max.x,i.max.y,i.min.z);0!=t.x&&n(e,r,new w.Vector3(0,0,1),t.x),0!=t.y&&n(e,r,new w.Vector3(0,0,1),t.y),0!=t.z&&n(e,r,new w.Vector3(0,0,1),t.z)},Object.defineProperty(e,"scaleGroup",{get:()=>e.getObjectByName("scaleGroup")}),Object.defineProperty(e,"boxGroup",{get:()=>e.getObjectByName("boxGroup")}),Object.defineProperty(e,"boundingBox",{get:()=>e.getObjectByName("boxModel")}),Object.defineProperty(e,"boundingBoxShadow",{get:()=>e.getObjectByName("boxShadow")}),e.drawBoundingBox=function(){let t=e.box3(),i=new w.Group;i.name="boxGroup",i.updateMatrixWorld(!0);let n=new w.Box3Helper(t,M.prototype._defaults.colors.yellow);n.name="boxModel",i.add(n),n.layers.disable(0);let r=t.clone();r.max.z=r.min.z;let o=new w.Box3Helper(r,M.prototype._defaults.colors.black);o.name="boxShadow",i.add(o),o.layers.disable(0),i.visible=!1,e.scaleGroup.add(i),e.setBoundingBoxShadowFloor()},e.setBoundingBoxShadowFloor=function(){if(e.boundingBoxShadow){let t=-e.modelHeight,i=e.rotation,n=e.boundingBoxShadow;n.box.max.z=n.box.min.z=t,n.rotation.y=i.y,n.rotation.x=-i.x}},e.setAnchor=function(t){const i=e.box3(),n=i.getCenter(new w.Vector3);switch(e.none={x:0,y:0,z:0},e.center={x:n.x,y:n.y,z:i.min.z},e.bottom={x:n.x,y:i.max.y,z:i.min.z},e.bottomLeft={x:i.max.x,y:i.max.y,z:i.min.z},e.bottomRight={x:i.min.x,y:i.max.y,z:i.min.z},e.top={x:n.x,y:i.min.y,z:i.min.z},e.topLeft={x:i.max.x,y:i.min.y,z:i.min.z},e.topRight={x:i.min.x,y:i.min.y,z:i.min.z},e.left={x:i.max.x,y:n.y,z:i.min.z},e.right={x:i.min.x,y:n.y,z:i.min.z},t){case"center":e.anchor=e.center;break;case"top":e.anchor=e.top;break;case"top-left":e.anchor=e.topLeft;break;case"top-right":e.anchor=e.topRight;break;case"left":e.anchor=e.left;break;case"right":e.anchor=e.right;break;case"bottom":e.anchor=e.bottom;break;case"bottom-left":default:e.anchor=e.bottomLeft;break;case"bottom-right":e.anchor=e.bottomRight;break;case"auto":case"none":e.anchor=e.none}e.model.position.set(-e.anchor.x,-e.anchor.y,-e.anchor.z)},e.setCenter=function(t){if(t&&(0!=t.x||0!=t.y||0!=t.z)){let i=e.getSize();e.anchor={x:e.anchor.x-i.x*t.x,y:e.anchor.y-i.y*t.y,z:e.anchor.z-i.z*t.z},e.model.position.set(-e.anchor.x,-e.anchor.y,-e.anchor.z)}},Object.defineProperty(e,"label",{get:()=>e.getObjectByName("label")}),Object.defineProperty(e,"tooltip",{get:()=>e.getObjectByName("tooltip")}),Object.defineProperty(e,"help",{get:()=>e.getObjectByName("help")});let o=!1;Object.defineProperty(e,"hidden",{get:()=>o,set(t){o!=t&&(o=t,e.visibility=!o)}}),Object.defineProperty(e,"visibility",{get:()=>e.visible,set(t){let i=t;if("visible"==t||1==t)i=!0,e.label&&(e.label.visible=i);else{if("none"!=t&&0!=t)return;i=!1,e.label&&e.label.alwaysVisible&&(e.label.visible=i),e.tooltip&&(e.tooltip.visible=i)}if(e.visible!=i){if(e.hidden&&i)return;e.visible=i,e.model&&e.model.traverse((function(t){"Mesh"!=t.type&&"SkinnedMesh"!=t.type||(i&&e.raycasted?t.layers.enable(0):t.layers.disable(0)),"LineSegments"==t.type&&t.layers.disableAll()}))}}}),e.addLabel=function(t,i,n,r){t&&e.drawLabelHTML(t,i,n,r)},e.removeLabel=function(){e.removeCSS2D("label")},e.drawLabelHTML=function(t,n=!1,r=e.anchor,o=.5){let s=i.drawLabelHTML(t,M.prototype._defaults.label.cssClass),a=e.addCSS2D(s,"label",r,o);return a.alwaysVisible=n,a.visible=n,a},e.addTooltip=function(t,i,n,r=!0,o=1){let s=e.addHelp(t,"tooltip",i,n,o);s.visible=!1,s.custom=r},e.removeTooltip=function(){e.removeCSS2D("tooltip")},e.addHelp=function(t,n="help",r=!1,o=e.anchor,s=0){let a=i.drawTooltip(t,r),l=e.addCSS2D(a,n,o,s);return l.visible=!0,l},e.removeHelp=function(){e.removeCSS2D("help")},e.addCSS2D=function(t,i,n=e.anchor,r=1){if(t){const o=e.box3(),s=o.getSize(new w.Vector3);let a={x:o.max.x,y:o.max.y,z:o.min.z};e.removeCSS2D(i);let l=new x.CSS2DObject(t);return l.name=i,l.position.set(.5*-s.x-e.model.position.x-n.x+a.x,.5*-s.y-e.model.position.y-n.y+a.y,s.z*r),l.visible=!1,e.scaleGroup.add(l),l}},e.removeCSS2D=function(t){let i=e.getObjectByName(t);if(i){i.dispose();let t=e.scaleGroup.children;t.splice(t.indexOf(i),1)}},Object.defineProperty(e,"shadowPlane",{get:()=>e.getObjectByName("shadowPlane")});let s=!1;Object.defineProperty(e,"castShadow",{get:()=>s,set(t){if(e.model&&s!==t){if(e.model.traverse((function(e){e.isMesh&&(e.castShadow=!0)})),t){const i=e.modelSize,n=[i.x,i.y,i.z,e.modelHeight],r=10*Math.max(...n),o=new w.PlaneBufferGeometry(r,r),s=new w.ShadowMaterial;s.opacity=.5;let a=new w.Mesh(o,s);a.name="shadowPlane",a.layers.enable(1),a.layers.disable(0),a.receiveShadow=t,e.add(a)}else e.traverse((function(t){t.isMesh&&t.material instanceof w.ShadowMaterial&&e.remove(t)}));s=t}}}),e.setReceiveShadowFloor=function(){if(e.castShadow){let t=e.shadowPlane,i=t.position,n=t.rotation;if(i.z=-e.modelHeight,n.y=e.rotation.y,n.x=-e.rotation.x,"meters"===e.userData.units){const n=e.modelSize,r=[n.x,n.y,n.z,-i.z],o=10*Math.max(...r)/t.geometry.parameters.width;t.scale.set(o,o,o)}}};let a=!1;Object.defineProperty(e,"receiveShadow",{get:()=>a,set(t){e.model&&a!==t&&(e.model.traverse((function(e){e.isMesh&&(e.receiveShadow=!0)})),a=t)}});let l=!1;Object.defineProperty(e,"wireframe",{get:()=>l,set(t){e.model&&l!==t&&(e.model.traverse((function(e){if("Mesh"==e.type||"SkinnedMesh"==e.type){let i=[];Array.isArray(e.material)?i=e.material:i.push(e.material);let n=i[0];t?(e.userData.materials=n,e.material=n.clone(),e.material.wireframe=e.material.transparent=t,e.material.opacity=.3):(e.material.dispose(),e.material=e.userData.materials,e.userData.materials.dispose(),e.userData.materials=null),t?(e.layers.disable(0),e.layers.enable(1)):(e.layers.disable(1),e.layers.enable(0))}"LineSegments"==e.type&&e.layers.disableAll()})),l=t,e.dispatchEvent({type:"Wireframed",detail:e}))}});let c=null;Object.defineProperty(e,"color",{get:()=>c,set(t){e.model&&c!==t&&(e.model.traverse((function(e){if("Mesh"==e.type||"SkinnedMesh"==e.type){let i=[];Array.isArray(e.material)?i=e.material:i.push(e.material);let n=i[0];t?(e.userData.materials=n,e.material=new w.MeshStandardMaterial,e.material.color.setHex(t)):(e.material.dispose(),e.material=e.userData.materials,e.userData.materials.dispose(),e.userData.materials=null)}})),c=t)}});let h=!1;Object.defineProperty(e,"selected",{get:()=>h,set(t){t?(e.userData.bbox&&!e.boundingBox&&e.drawBoundingBox(),e.boxGroup&&(e.boundingBox.material=M.prototype._defaults.materials.boxSelectedMaterial,e.boundingBox.parent.visible=!0,e.boundingBox.layers.enable(1),e.boundingBoxShadow.layers.enable(1)),e.label&&!e.label.alwaysVisible&&(e.label.visible=!0)):(e.boxGroup&&e.remove(e.boxGroup),e.label&&!e.label.alwaysVisible&&(e.label.visible=!1),e.removeHelp()),e.tooltip&&(e.tooltip.visible=t),h!=t&&(h=t,e.dispatchEvent({type:"SelectedChange",detail:e}))}});let p=!0;Object.defineProperty(e,"raycasted",{get:()=>p,set(t){e.model&&p!==t&&(e.model.traverse((function(e){"Mesh"!=e.type&&"SkinnedMesh"!=e.type||(t?(e.layers.disable(1),e.layers.enable(0)):(e.layers.disable(0),e.layers.enable(1)))})),p=t)}});let d=!1;Object.defineProperty(e,"over",{get:()=>d,set(t){t?(e.selected||(e.userData.bbox&&!e.boundingBox&&e.drawBoundingBox(),e.userData.tooltip&&!e.tooltip&&e.addTooltip(e.uuid,!0,e.anchor,!1),e.boxGroup&&(e.boundingBox.material=M.prototype._defaults.materials.boxOverMaterial,e.boundingBox.parent.visible=!0,e.boundingBox.layers.enable(1),e.boundingBoxShadow.layers.enable(1))),e.label&&!e.label.alwaysVisible&&(e.label.visible=!0),e.dispatchEvent({type:"ObjectMouseOver",detail:e})):(e.selected||(e.boxGroup&&(e.remove(e.boxGroup),e.tooltip&&!e.tooltip.custom&&e.removeTooltip()),e.label&&!e.label.alwaysVisible&&(e.label.visible=!1)),e.dispatchEvent({type:"ObjectMouseOut",detail:e})),e.tooltip&&(e.tooltip.visible=t||e.selected),d=t}}),e.box3=function(){let t;if(e.updateMatrix(),e.updateMatrixWorld(!0,!0),e.model){let i=e.clone(!0),n=e.model.clone();if(t=(new w.Box3).setFromObject(n),e.parent){let r=new w.Matrix4,o=new w.Matrix4;e.matrix.extractRotation(r),o.copy(r).invert(),i.setRotationFromMatrix(o),t=(new w.Box3).setFromObject(n)}}return t},e.modelBox=function(){return e.box3()},e.getSize=function(){return e.box3().getSize(new w.Vector3(0,0,0))};let f=!1;Object.defineProperty(e,"modelSize",{get:()=>f=e.getSize(),set(e){f!=e&&(f=e)}}),Object.defineProperty(e,"modelHeight",{get(){let t=e.coordinates[2]||0;return"scene"===e.userData.units&&(t*=e.unitsPerMeter/e.scale.x),t}}),Object.defineProperty(e,"unitsPerMeter",{get:()=>Number(u.projectedUnitsPerMeter(e.coordinates[1]).toFixed(7))}),Object.defineProperty(e,"fixedZoom",{get:()=>e.userData.fixedZoom,set(t){e.userData.fixedZoom!==t&&(e.userData.fixedZoom=t,e.userData.units=t?"scene":"meters")}}),e.setFixedZoom=function(t){if(null!=e.fixedZoom&&0!=e.fixedZoom){t||(t=e.userData.mapScale);let n=(i=e.fixedZoom,Math.pow(2,i));if(n>t){let i=n/t;e.scale.set(i,i,i)}else e.scale.set(1,1,1)}var i},e.setScale=function(t){if("scene"!=e.userData.units){let t=e.unitsPerMeter;e.scale.set(t,t,t)}else e.fixedZoom?(t&&(e.userData.mapScale=t),e.setFixedZoom(e.userData.mapScale)):e.scale.set(1,1,1)},e.setObjectScale=function(t){e.setScale(t),e.setBoundingBoxShadowFloor(),e.setReceiveShadowFloor()}}e.add=function(t){return e.scaleGroup.add(t),t.position.z=e.coordinates[2]?-e.coordinates[2]:0,t},e.remove=function(t){t&&(t.traverse((e=>{if(e.geometry&&e.geometry.dispose(),e.material)if(e.material.isMaterial)r(e.material);else for(const t of e.material)r(t);e.dispose&&e.dispose()})),e.scaleGroup.remove(t),tb.map.repaint=!0)},e.duplicate=function(t){let n=e.clone(!0);if(n.getObjectByName("model").animations=e.animations,n.userData.feature&&(t&&t.feature&&(n.userData.feature=t.feature),n.userData.feature.properties.uuid=n.uuid),i._addMethods(n),!t||u.equal(t.scale,e.userData.scale))return n.copyAnchor(e),n;{n.userData=t,n.userData.isGeoGroup=!0,n.remove(n.boxGroup);const e=u.types.rotation(t.rotation,[0,0,0]),i=u.types.scale(t.scale,[1,1,1]);return n.model.position.set(0,0,0),n.model.rotation.set(e[0],e[1],e[2]),n.model.scale.set(i[0],i[1],i[2]),n.setAnchor(t.anchor),n.setCenter(t.adjustment),n}},e.copyAnchor=function(t){e.anchor=t.anchor,e.none={x:0,y:0,z:0},e.center=t.center,e.bottom=t.bottom,e.bottomLeft=t.bottomLeft,e.bottomRight=t.bottomRight,e.top=t.top,e.topLeft=t.topLeft,e.topRight=t.topRight,e.left=t.left,e.right=t.right},e.dispose=function(){M.prototype.unenroll(e),e.traverse((e=>{if((!e.parent||"world"!=e.parent.name)&&"threeboxObject"!==e.name){if(e.geometry&&e.geometry.dispose(),e.material)if(e.material.isMaterial)r(e.material);else for(const t of e.material)r(t);e.dispose&&e.dispose()}})),e.children=[]};const r=e=>{e.dispose();for(const t of Object.keys(e)){const i=e[t];i&&"object"==typeof i&&"minFilter"in i&&i.dispose()}let t=e;(t.map||t.alphaMap||t.aoMap||t.bumpMap||t.displacementMap||t.emissiveMap||t.envMap||t.lightMap||t.metalnessMap||t.normalMap||t.roughnessMap)&&(t.map&&t.map.dispose(),t.alphaMap&&t.alphaMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.displacementMap&&t.displacementMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.envMap&&t.envMap.dispose(),t.lightMap&&t.lightMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose())};return e},_makeGroup:function(e,t){let i=new w.Group;i.name="scaleGroup",i.add(e);var n=new w.Group;if(n.userData=t||{},n.userData.isGeoGroup=!0,n.userData.feature&&(n.userData.feature.properties.uuid=n.uuid),i.length)for(o of i)n.add(o);else n.add(i);return n.name="threeboxObject",n},animationManager:new _,drawTooltip:function(e,t=!1){if(e){let i;if(t){let t=document.createElement("div");t.className="mapboxgl-popup-content";let n=document.createElement("strong");n.innerHTML=e,t.appendChild(n);let r=document.createElement("div");r.className="mapboxgl-popup-tip";let o=document.createElement("div");o.className="marker mapboxgl-popup-anchor-bottom",o.appendChild(r),o.appendChild(t),(i=document.createElement("div")).className+="label3D",i.appendChild(o)}else(i=document.createElement("span")).className=this._defaults.tooltip.cssClass,i.innerHTML=e;return i}},drawLabelHTML:function(e,t){let i=document.createElement("div");return i.className+=t,i.innerHTML="string"==typeof e?e:e.outerHTML,i},_defaults:{colors:{red:new w.Color(16711680),yellow:new w.Color(16776960),green:new w.Color(65280),black:new w.Color(0)},materials:{boxNormalMaterial:new w.LineBasicMaterial({color:new w.Color(16711680)}),boxOverMaterial:new w.LineBasicMaterial({color:new w.Color(16776960)}),boxSelectedMaterial:new w.LineBasicMaterial({color:new w.Color(65280)})},line:{geometry:null,color:"black",width:1,opacity:1},label:{htmlElement:null,cssClass:" label3D",alwaysVisible:!1,topMargin:-.5},tooltip:{text:"",cssClass:"toolTip text-xs",mapboxStyle:!1,topMargin:0},sphere:{position:[0,0,0],radius:1,sides:20,units:"scene",material:"MeshBasicMaterial",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},tube:{geometry:null,radius:1,sides:6,units:"scene",material:"MeshBasicMaterial",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0},loadObj:{type:null,obj:null,units:"scene",scale:1,rotation:0,defaultAnimation:0,anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0,clone:!0},Object3D:{obj:null,units:"scene",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},extrusion:{coordinates:[[[]]],geometryOptions:{},height:100,materials:new w.MeshPhongMaterial({color:6684672,side:w.DoubleSide}),scale:1,rotation:0,units:"scene",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0}},geometries:{line:["LineString"],tube:["LineString"],sphere:["Point"]}},b=b=M;var T={};T=T=function(e){let t=(e=u._validate(e,b.prototype._defaults.Object3D)).obj;const i=u.types.rotation(e.rotation,[0,0,0]),n=u.types.scale(e.scale,[1,1,1]);t.rotation.set(i[0],i[1],i[2]),t.scale.set(n[0],n[1],n[2]),t.name="model";let r=b.prototype._makeGroup(t,e);return e.obj.name="model",b.prototype._addMethods(r),r.setAnchor(e.anchor),r.setCenter(e.adjustment),r.raycasted=e.raycasted,r.visibility=!0,r};var S={};S=S=function(e){e=u._validate(e,b.prototype._defaults.sphere);let t=new n.SphereBufferGeometry(e.radius,e.sides,e.sides),i=m(e),r=new n.Mesh(t,i);return new T({obj:r,units:e.units,anchor:e.anchor,adjustment:e.adjustment,bbox:e.bbox,tooltip:e.tooltip,raycasted:e.raycasted})};var E={};function A(e){e=u._validate(e,b.prototype._defaults.extrusion);let t=A.prototype.buildShape(e.coordinates),i=A.prototype.buildGeometry(t,e.geometryOptions),r=new n.Mesh(i,e.materials);return e.obj=r,new T(e)}A.prototype={buildShape:function(e){if(e[0]instanceof(n.Vector2||n.Vector3))return new n.Shape(e);let t=new n.Shape;for(let i=0;i0?t[t.length-1]:"",smooth:void 0!==i?i.smooth:this.smooth,groupStart:void 0!==i?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){const t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(n),n},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){const t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},i&&i.name&&"function"==typeof i.clone){const e=i.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},parseNormalIndex:function(e,t){const i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},parseUVIndex:function(e,t){const i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)},addVertex:function(e,t,i){const n=this.vertices,r=this.object.geometry.vertices;r.push(n[e+0],n[e+1],n[e+2]),r.push(n[t+0],n[t+1],n[t+2]),r.push(n[i+0],n[i+1],n[i+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,i){const n=this.normals,r=this.object.geometry.normals;r.push(n[e+0],n[e+1],n[e+2]),r.push(n[t+0],n[t+1],n[t+2]),r.push(n[i+0],n[i+1],n[i+2])},addFaceNormal:function(e,t,i){const n=this.vertices,r=this.object.geometry.normals;o.fromArray(n,e),s.fromArray(n,t),a.fromArray(n,i),c.subVectors(a,s),l.subVectors(o,s),c.cross(l),c.normalize(),r.push(c.x,c.y,c.z),r.push(c.x,c.y,c.z),r.push(c.x,c.y,c.z)},addColor:function(e,t,i){const n=this.colors,r=this.object.geometry.colors;void 0!==n[e]&&r.push(n[e+0],n[e+1],n[e+2]),void 0!==n[t]&&r.push(n[t+0],n[t+1],n[t+2]),void 0!==n[i]&&r.push(n[i+0],n[i+1],n[i+2])},addUV:function(e,t,i){const n=this.uvs,r=this.object.geometry.uvs;r.push(n[e+0],n[e+1]),r.push(n[t+0],n[t+1]),r.push(n[i+0],n[i+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,i,n,r,o,s,a,l){const c=this.vertices.length;let u=this.parseVertexIndex(e,c),h=this.parseVertexIndex(t,c),p=this.parseVertexIndex(i,c);if(this.addVertex(u,h,p),this.addColor(u,h,p),void 0!==s&&""!==s){const e=this.normals.length;u=this.parseNormalIndex(s,e),h=this.parseNormalIndex(a,e),p=this.parseNormalIndex(l,e),this.addNormal(u,h,p)}else this.addFaceNormal(u,h,p);if(void 0!==n&&""!==n){const e=this.uvs.length;u=this.parseUVIndex(n,e),h=this.parseUVIndex(r,e),p=this.parseUVIndex(o,e),this.addUV(u,h,p),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let i=0,n=e.length;i=7?s.colors.push(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6])):s.colors.push(void 0,void 0,void 0);break;case"vn":s.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case"vt":s.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if("f"===c){const e=l.substr(1).trim().split(/\s+/),t=[];for(let i=0,n=e.length;i0){const e=n.split("/");t.push(e)}}const i=t[0];for(let e=1,n=t.length-1;e1){const e=p[1].trim().toLowerCase();s.object.smooth="0"!==e&&"off"!==e}else s.object.smooth=!0;const e=s.object.currentMaterial();e&&(e.smooth=s.object.smooth)}else{if("\0"===l)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}s.finalize();const f=new n.Group;if(f.materialLibraries=[].concat(s.materialLibraries),1==!(1===s.objects.length&&0===s.objects[0].geometry.vertices.length))for(let e=0,t=s.objects.length;e0&&c.setAttribute("normal",new n.Float32BufferAttribute(i.normals,3)),i.colors.length>0&&(l=!0,c.setAttribute("color",new n.Float32BufferAttribute(i.colors,3))),!0===i.hasUVIndices&&c.setAttribute("uv",new n.Float32BufferAttribute(i.uvs,2));const u=[];for(let e=0,t=r.length;e1){for(let e=0,t=r.length;e0){const e=new n.PointsMaterial({size:1,sizeAttenuation:!1}),t=new n.BufferGeometry;t.setAttribute("position",new n.Float32BufferAttribute(s.vertices,3)),s.colors.length>0&&void 0!==s.colors[0]&&(t.setAttribute("color",new n.Float32BufferAttribute(s.colors,3)),e.vertexColors=!0);const i=new n.Points(t,e);f.add(i)}return f}}}(),I=I=n.OBJLoader;var P={};!function(){class e{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:n.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:n.RepeatWrapping}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const i in e){const n=e[i],r={};t[i]=r;for(const e in n){let t=!0,i=n[e];const o=e.toLowerCase();switch(o){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(i=[i[0]/255,i[1]/255,i[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===i[0]&&0===i[1]&&0===i[2]&&(t=!1)}t&&(r[o]=i)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,i=this.materialsInfo[e],r={name:e,side:this.side};function o(e,i){if(r[e])return;const n=t.getTextureParams(i,r),o=t.loadTexture((s=t.baseUrl,"string"!=typeof(a=n.url)||""===a?"":/^https?:\/\//i.test(a)?a:s+a));var s,a;o.repeat.copy(n.scale),o.offset.copy(n.offset),o.wrapS=t.wrap,o.wrapT=t.wrap,r[e]=o}for(const e in i){const t=i[e];let s;if(""!==t)switch(e.toLowerCase()){case"kd":r.color=(new n.Color).fromArray(t);break;case"ks":r.specular=(new n.Color).fromArray(t);break;case"ke":r.emissive=(new n.Color).fromArray(t);break;case"map_kd":o("map",t);break;case"map_ks":o("specularMap",t);break;case"map_ke":o("emissiveMap",t);break;case"norm":o("normalMap",t);break;case"map_bump":case"bump":o("bumpMap",t);break;case"map_d":o("alphaMap",t),r.transparent=!0;break;case"ns":r.shininess=parseFloat(t);break;case"d":(s=parseFloat(t))<1&&(r.opacity=s,r.transparent=!0);break;case"tr":s=parseFloat(t),this.options&&this.options.invertTrProperty&&(s=1-s),s>0&&(r.opacity=1-s,r.transparent=!0)}}return this.materials[e]=new n.MeshPhongMaterial(r),this.materials[e]}getTextureParams(e,t){const i={scale:new n.Vector2(1,1),offset:new n.Vector2(0,0)},r=e.split(/\s+/);let o;return(o=r.indexOf("-bm"))>=0&&(t.bumpScale=parseFloat(r[o+1]),r.splice(o,2)),(o=r.indexOf("-s"))>=0&&(i.scale.set(parseFloat(r[o+1]),parseFloat(r[o+2])),r.splice(o,4)),(o=r.indexOf("-o"))>=0&&(i.offset.set(parseFloat(r[o+1]),parseFloat(r[o+2])),r.splice(o,4)),i.url=r.join(" ").trim(),i}loadTexture(e,t,i,r,o){const s=void 0!==this.manager?this.manager:n.DefaultLoadingManager;let a=s.getHandler(e);null===a&&(a=new n.TextureLoader(s)),a.setCrossOrigin&&a.setCrossOrigin(this.crossOrigin);const l=a.load(e,i,r,o);return void 0!==t&&(l.mapping=t),l}}n.MTLLoader=class extends n.Loader{constructor(e){super(e)}load(e,t,i,r){const o=this,s=""===this.path?n.LoaderUtils.extractUrlBase(e||""):this.path,a=new n.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(i){try{t(o.parse(i,s))}catch(t){r?r(t):console.error(t),o.manager.itemError(e)}}),i,r)}setMaterialOptions(e){return this.materialOptions=e,this}parse(t,i){const n=t.split("\n");let r={};const o=/\s+/,s={};for(let e=0;e=0?t.substring(0,i):t;a=a.toLowerCase();let l=i>=0?t.substring(i+1):"";if(l=l.trim(),"newmtl"===a)r={name:l},s[l]=r;else if("ka"===a||"kd"===a||"ks"===a||"ke"===a){const e=l.split(o,3);r[a]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else r[a]=l}const a=new e(this.resourcePath||i,this.materialOptions);return a.setCrossOrigin(this.crossOrigin),a.setManager(this.manager),a.setMaterials(s),a}}}(),P=P=n.MTLLoader;var R,k,z={},D=z={};function O(){throw new Error("setTimeout has not been defined")}function F(){throw new Error("clearTimeout has not been defined")}function B(e){if(R===setTimeout)return setTimeout(e,0);if((R===O||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}!function(){try{R="function"==typeof setTimeout?setTimeout:O}catch(e){R=O}try{k="function"==typeof clearTimeout?clearTimeout:F}catch(e){k=F}}();var N,U=[],j=!1,V=-1;function G(){j&&N&&(j=!1,N.length?U=N.concat(U):V=-1,U.length&&H())}function H(){if(!j){var e=B(G);j=!0;for(var t=U.length;t;){for(N=U,U=[];++V1)for(var i=1;i>>1|(21845&_)<<1;g[_]=((65280&(y=(61680&(y=(52428&y)>>>2|(13107&y)<<2))>>>4|(3855&y)<<4))>>>8|(255&y)<<8)>>>1}var v=function(e,t,i){for(var n=e.length,o=0,s=new r(t);o>>c]=u}else for(a=new r(n),o=0;o>>15-e[o]);return a},x=new n(288);for(_=0;_<144;++_)x[_]=8;for(_=144;_<256;++_)x[_]=9;for(_=256;_<280;++_)x[_]=7;for(_=280;_<288;++_)x[_]=8;var b=new n(32);for(_=0;_<32;++_)b[_]=5;var w=v(x,9,0),M=v(x,9,1),T=v(b,5,0),S=v(b,5,1),E=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},A=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},C=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},L=function(e){return(e/8|0)+(7&e&&1)},I=function(e,t,i){(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof r?r:e instanceof o?o:n)(i-t);return s.set(e.subarray(t,i)),s},P=function(e,t,i){var r=e.length;if(!r||i&&!i.l&&r<5)return t||new n(0);var o=!t||i,c=!i||i.i;i||(i={}),t||(t=new n(3*r));var u=function(e){var i=t.length;if(e>i){var r=new n(Math.max(2*i,e));r.set(t),t=r}},p=i.f||0,d=i.p||0,m=i.b||0,g=i.l,_=i.d,y=i.m,x=i.n,b=8*r;do{if(!g){i.f=p=A(e,d,1);var w=A(e,d+1,3);if(d+=3,!w){var T=e[(j=L(d)+4)-4]|e[j-3]<<8,P=j+T;if(P>r){if(c)throw"unexpected EOF";break}o&&u(m+T),t.set(e.subarray(j,P),m),i.b=m+=T,i.p=d=8*P;continue}if(1==w)g=M,_=S,y=9,x=5;else{if(2!=w)throw"invalid block type";var R=A(e,d,31)+257,k=A(e,d+10,15)+4,z=R+A(e,d+5,31)+1;d+=14;for(var D=new n(z),O=new n(19),F=0;Fb)break;var U=v(O,B,1);for(F=0;F>>4)<16)D[F++]=j;else{var G=0,H=0;for(16==j?(H=3+A(e,d,3),d+=2,G=D[F-1]):17==j?(H=3+A(e,d,7),d+=3):18==j&&(H=11+A(e,d,127),d+=7);H--;)D[F++]=G}}var W=D.subarray(0,R),q=D.subarray(R);y=E(W),x=E(q),g=v(W,y,1),_=v(q,x,1)}if(d>b)throw"unexpected EOF"}o&&u(m+131072);for(var $=(1<>>4;if((d+=15&G)>b)throw"unexpected EOF";if(!G)throw"invalid length/literal";if(Y<256)t[m++]=Y;else{if(256==Y){g=null;break}var J=Y-254;Y>264&&(J=A(e,d,(1<<(ee=s[F=Y-257]))-1)+h[F],d+=ee);var Q=_[C(e,d)&Z],K=Q>>>4;if(!Q)throw"invalid distance";if(d+=15&Q,q=f[K],K>3){var ee=a[K];q+=C(e,d)&(1<b)throw"unexpected EOF";o&&u(m+131072);for(var te=m+J;m>>8},k=function(e,t,i){var n=t/8|0;e[n]|=i<<=7&t,e[n+1]|=i>>>8,e[n+2]|=i>>>16},z=function(e,t){for(var i=[],o=0;of&&(f=a[o].s);var m=new r(f+1),g=D(i[p-1],m,0);if(g>t){o=0;var _=0,y=g-t,v=1<t))break;_+=v-(1<>>=y;_>0;){var b=a[o].s;m[b]=0&&_;--o){var w=a[o].s;m[w]==t&&(--m[w],++_)}g=t}return[new n(m),g]},D=function(e,t,i){return-1==e.s?Math.max(D(e.l,t,i+1),D(e.r,t,i+1)):t[e.s]=i},O=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new r(++t),n=0,o=e[0],s=1,a=function(e){i[n++]=e},l=1;l<=t;++l)if(e[l]==o&&l!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(o),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(o);s=1,o=e[l]}return[i.subarray(0,n),t]},F=function(e,t){for(var i=0,n=0;n>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var o=0;o4&&!j[l[G-1]];--G);var H,W,q,$,Z=d+5<<3,X=F(o,x)+F(c,b)+u,Y=F(o,g)+F(c,M)+u+14+3*G+F(D,j)+(2*D[16]+3*D[17]+7*D[18]);if(Z<=X&&Z<=Y)return B(t,f,e.subarray(p,p+d));if(R(t,f,1+(Y15&&(R(t,f,ee[N]>>>5&127),f+=ee[N]>>>12)}}else H=w,W=x,q=T,$=b;for(N=0;N255){var te;k(t,f,H[257+(te=n[N]>>>18&31)]),f+=W[te+257],te>7&&(R(t,f,n[N]>>>23&31),f+=s[te]);var ie=31&n[N];k(t,f,q[ie]),f+=$[ie],ie>3&&(k(t,f,n[N]>>>5&8191),f+=a[ie])}else k(t,f,H[n[N]]),f+=W[n[N]];return k(t,f,H[256]),f+W[256]},U=new o([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),j=new n(0),V=function(e,t,i,l,c,u){var h=e.length,d=new n(l+h+5*(1+Math.ceil(h/7e3))+c),f=d.subarray(l,d.length-c),g=0;if(!t||h<8)for(var _=0;_<=h;_+=65535){var y=_+65535;y>>13,b=8191&v,w=(1<7e3||D>24576)&&W>423){g=N(e,f,0,C,P,R,z,D,F,_-F,g),D=k=z=0,F=_;for(var q=0;q<286;++q)P[q]=0;for(q=0;q<30;++q)R[q]=0}var $=2,Z=0,X=b,Y=G-H&32767;if(W>2&&V==A(_-Y))for(var J=Math.min(x,W)-1,Q=Math.min(32767,_),K=Math.min(258,W);Y<=Q&&--X&&G!=H;){if(e[_+$]==e[_+$-Y]){for(var ee=0;ee$){if($=ee,Z=Y,ee>J)break;var te=Math.min(Y,ee-2),ie=0;for(q=0;qie&&(ie=re,H=ne)}}}Y+=(G=H)-(H=M[G])+32768&32767}if(Z){C[D++]=268435456|p[$]<<18|m[Z];var oe=31&p[$],se=31&m[Z];z+=s[oe]+a[se],++P[257+oe],++R[se],O=_+$,++k}else C[D++]=e[_],++P[e[_]]}}g=N(e,f,u,C,P,R,z,D,F,_-F,g),!u&&7&g&&(g=B(f,g+1,j))}return I(d,0,l+L(g)+c)},G=function(){for(var e=new o(256),t=0;t<256;++t){for(var i=t,n=9;--n;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),H=function(){var e=-1;return{p:function(t){for(var i=e,n=0;n>>8;e=i},d:function(){return~e}}},W=function(){var e=1,t=0;return{p:function(i){for(var n=e,r=t,o=i.length,s=0;s!=o;){for(var a=Math.min(s+2655,o);s>16),r=(65535&r)+15*(r>>16)}e=n,t=r},d:function(){return((e%=65521)>>>8<<16|(255&(t%=65521))<<8|t>>>8)+2*((255&e)<<23)}}},q=function(e,t,i,n,r){return V(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,n,!r)},Z=function(e,t){var i={};for(var n in e)i[n]=e[n];for(var n in t)i[n]=t[n];return i},X=function(e,t,i){for(var n=e(),r=""+e,o=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/ /g,"").split(","),s=0;s>>=8},fe=function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&de(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var n=0;n<=i.length;++n)e[n+10]=i.charCodeAt(n)}},me=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],i=10;4&t&&(i+=e[10]|2+(e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[i++]);return i+(2&t)},ge=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16)+2*(e[t-1]<<23)},_e=function(e){return 10+(e.filename&&e.filename.length+1||0)},ye=function(e,t){var i=t.level,n=0==i?0:i<6?1:9==i?3:2;e[0]=120,e[1]=n<<6|(n?32-2*n:1)},ve=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function xe(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var be=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(q(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}();t.Deflate=be;var we=function(e,t){ce([ee,function(){return[le,be]}],this,xe.call(this,e,t),(function(e){var t=new be(e.data);onmessage=le(t)}),6)};function Me(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[ee],(function(e){return oe(Te(e.data[0],e.data[1]))}),0,i)}function Te(e,t){return q(e,t||{},0,0)}t.AsyncDeflate=we,t.deflate=Me,t.deflateSync=Te;var Se=function(){function e(e){this.s={},this.p=new n(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,i=new n(t+e.length);i.set(this.p),i.set(e,t),this.p=i},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,i=P(this.p,this.o,this.s);this.ondata(I(i,t,this.s.b),this.d),this.o=I(i,this.s.b-32768),this.s.b=this.o.length,this.p=I(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();t.Inflate=Se;var Ee=function(e){this.ondata=e,ce([K,function(){return[le,Se]}],this,0,(function(){var e=new Se;onmessage=le(e)}),7)};function Ae(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[K],(function(e){return oe(Ce(e.data[0],se(e.data[1])))}),1,i)}function Ce(e,t){return P(e,t)}t.AsyncInflate=Ee,t.inflate=Ae,t.inflateSync=Ce;var Le=function(){function e(e,t){this.c=H(),this.l=0,this.v=1,be.call(this,e,t)}return e.prototype.push=function(e,t){be.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var i=q(e,this.o,this.v&&_e(this.o),t&&8,!t);this.v&&(fe(i,this.o),this.v=0),t&&(de(i,i.length-8,this.c.d()),de(i,i.length-4,this.l)),this.ondata(i,t)},e}();t.Gzip=Le,t.Compress=Le;var Ie=function(e,t){ce([ee,te,function(){return[le,be,Le]}],this,xe.call(this,e,t),(function(e){var t=new Le(e.data);onmessage=le(t)}),8)};function Pe(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[ee,te,function(){return[Re]}],(function(e){return oe(Re(e.data[0],e.data[1]))}),2,i)}function Re(e,t){t||(t={});var i=H(),n=e.length;i.p(e);var r=q(e,t,_e(t),8),o=r.length;return fe(r,t),de(r,o-8,i.d()),de(r,o-4,n),r}t.AsyncGzip=Ie,t.AsyncCompress=Ie,t.gzip=Pe,t.compress=Pe,t.gzipSync=Re,t.compressSync=Re;var ke=function(){function e(e){this.v=1,Se.call(this,e)}return e.prototype.push=function(e,t){if(Se.prototype.e.call(this,e),this.v){var i=this.p.length>3?me(this.p):4;if(i>=this.p.length&&!t)return;this.p=this.p.subarray(i),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Se.prototype.c.call(this,t)},e}();t.Gunzip=ke;var ze=function(e){this.ondata=e,ce([K,ie,function(){return[le,Se,ke]}],this,0,(function(){var e=new ke;onmessage=le(e)}),9)};function De(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[K,ie,function(){return[Oe]}],(function(e){return oe(Oe(e.data[0]))}),3,i)}function Oe(e,t){return P(e.subarray(me(e),-8),t||new n(ge(e)))}t.AsyncGunzip=ze,t.gunzip=De,t.gunzipSync=Oe;var Fe=function(){function e(e,t){this.c=W(),this.v=1,be.call(this,e,t)}return e.prototype.push=function(e,t){be.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var i=q(e,this.o,this.v&&2,t&&4,!t);this.v&&(ye(i,this.o),this.v=0),t&&de(i,i.length-4,this.c.d()),this.ondata(i,t)},e}();t.Zlib=Fe;function Be(e,t){t||(t={});var i=W();i.p(e);var n=q(e,t,2,4);return ye(n,t),de(n,n.length-4,i.d()),n}t.AsyncZlib=function(e,t){ce([ee,ne,function(){return[le,be,Fe]}],this,xe.call(this,e,t),(function(e){var t=new Fe(e.data);onmessage=le(t)}),10)},t.zlib=function(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[ee,ne,function(){return[Be]}],(function(e){return oe(Be(e.data[0],e.data[1]))}),4,i)},t.zlibSync=Be;var Ne=function(){function e(e){this.v=1,Se.call(this,e)}return e.prototype.push=function(e,t){if(Se.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Se.prototype.c.call(this,t)},e}();t.Unzlib=Ne;var Ue=function(e){this.ondata=e,ce([K,re,function(){return[le,Se,Ne]}],this,0,(function(){var e=new Ne;onmessage=le(e)}),11)};function je(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return ae(e,t,[K,re,function(){return[Ve]}],(function(e){return oe(Ve(e.data[0],se(e.data[1])))}),5,i)}function Ve(e,t){return P((ve(e),e.subarray(2,-4)),t)}t.AsyncUnzlib=Ue,t.unzlib=je,t.unzlibSync=Ve;var Ge=function(){function e(e){this.G=ke,this.I=Se,this.Z=Ne,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var i=new n(this.p.length+e.length);i.set(this.p),i.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var r=this,o=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(o):new this.Z(o),this.s.push(this.p,t),this.p=null}}},e}();t.Decompress=Ge;var He=function(){function e(e){this.G=ze,this.I=Ee,this.Z=Ue,this.ondata=e}return e.prototype.push=function(e,t){Ge.prototype.push.call(this,e,t)},e}();t.AsyncDecompress=He,t.decompress=function(e,t,i){if(i||(i=t,t={}),"function"!=typeof i)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?De(e,t,i):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Ae(e,t,i):je(e,t,i)},t.decompressSync=function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?Oe(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Ce(e,t):Ve(e,t)};var We=function(e,t,i,r){for(var o in e){var s=e[o],a=t+o;s instanceof n?i[a]=[s,r]:Array.isArray(s)?i[a]=[s[0],Z(r,s[1])]:We(s,a+"/",i,r)}},qe="undefined"!=typeof TextEncoder&&new TextEncoder,$e="undefined"!=typeof TextDecoder&&new TextDecoder,Ze=0;try{$e.decode(j,{stream:!0}),Ze=1}catch(i){}var Xe=function(e){for(var t="",i=0;;){var n=e[i++],r=(n>127)+(n>223)+(n>239);if(i+r>e.length)return[t,I(e,i-1)];r?3==r?(n=((15&n)<<18|(63&e[i++])<<12|(63&e[i++])<<6|63&e[i++])-65536,t+=String.fromCharCode(55296|n>>10,56320|1023&n)):t+=String.fromCharCode(1&r?(31&n)<<6|63&e[i++]:(15&n)<<12|(63&e[i++])<<6|63&e[i++]):t+=String.fromCharCode(n)}},Ye=function(){function e(e){this.ondata=e,Ze?this.t=new TextDecoder:this.p=j}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t||(t=!1),this.t)return this.ondata(this.t.decode(e,{stream:!t}),t);var i=new n(this.p.length+e.length);i.set(this.p),i.set(e,this.p.length);var r=Xe(i),o=r[0],s=r[1];if(t&&s.length)throw"invalid utf-8 data";this.p=s,this.ondata(o,t)},e}();t.DecodeUTF8=Ye;var Je=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";this.ondata(Qe(e),t||!1)},e}();function Qe(e,t){if(t){for(var i=new n(e.length),r=0;r>1)),a=0,l=function(e){s[a++]=e};for(r=0;rs.length){var c=new n(a+8+(o-r<<1));c.set(s),s=c}var u=e.charCodeAt(r);u<128||t?l(u):u<2048?(l(192|u>>>6),l(128|63&u)):u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++r))>>>18),l(128|u>>>12&63),l(128|u>>>6&63),l(128|63&u)):(l(224|u>>>12),l(128|u>>>6&63),l(128|63&u))}return I(s,0,a)}function Ke(e,t){if(t){for(var i="",n=0;n65535)throw"extra field too long";t+=n+4}return t},ot=function(e,t,i,n,r,o,s,a){var l=n.length,c=i.extra,u=a&&a.length,h=rt(c);de(e,t,null!=s?33639248:67324752),t+=4,null!=s&&(e[t++]=20,e[t++]=i.os),e[t]=20,t+=2,e[t++]=i.flag<<1|(null==o&&8),e[t++]=r&&8,e[t++]=255&i.compression,e[t++]=i.compression>>8;var p=new Date(null==i.mtime?Date.now():i.mtime),d=p.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(de(e,t,2*(d<<24)|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),t+=4,null!=o&&(de(e,t,i.crc),de(e,t+4,o),de(e,t+8,i.size)),de(e,t+12,l),de(e,t+14,h),t+=16,null!=s&&(de(e,t,u),de(e,t+6,i.attrs),de(e,t+10,s),t+=14),e.set(n,t),t+=l,h)for(var f in c){var m=c[f],g=m.length;de(e,t,+f),de(e,t+2,g),e.set(m,t+4),t+=4+g}return u&&(e.set(a,t),t+=u),t},st=function(e,t,i,n,r){de(e,t,101010256),de(e,t+8,i),de(e,t+10,i),de(e,t+12,n),de(e,t+16,r)},at=function(){function e(e){this.filename=e,this.c=H(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();t.ZipPassThrough=at;var lt=function(){function e(e,t){var i=this;t||(t={}),at.call(this,e),this.d=new be(t,(function(e,t){i.ondata(null,e,t)})),this.compression=8,this.flag=et(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){at.prototype.push.call(this,e,t)},e}();t.ZipDeflate=lt;var ct=function(){function e(e,t){var i=this;t||(t={}),at.call(this,e),this.d=new we(t,(function(e,t,n){i.ondata(e,t,n)})),this.compression=8,this.flag=et(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){at.prototype.push.call(this,e,t)},e}();t.AsyncZipDeflate=ct;var ut=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var i=Qe(e.filename),r=i.length,o=e.comment,s=o&&Qe(o),a=r!=e.filename.length||s&&o.length!=s.length,l=r+rt(e.extra)+30;if(r>65535)throw"filename too long";var c=new n(l);ot(c,0,e,i,a);var u=[c],h=function(){for(var e=0,i=u;e65535&&T("filename too long",null),M)if(g<16e4)try{T(null,Te(c,f))}catch(e){T(e,null)}else h.push(Me(c,f,T));else T(null,c)},m=0;m65535)throw"filename too long";var _=h?Te(c,u):c,y=_.length,v=H();v.p(c),r.push(Z(u,{size:c.length,crc:v.d(),c:_,f:T,m:f,u:p!=a.length||f&&d.length!=m,o:o,compression:h})),o+=30+p+g+y,s+=76+2*(p+g)+(m||0)+y}for(var x=new n(s+22),b=o,w=s-o,M=0;M0){var r=Math.min(this.c,e.length),o=e.subarray(0,r);if(this.c-=r,this.d?this.d.push(o,!this.c):this.k[0].push(o),(e=e.subarray(r)).length)return this.push(e,t)}else{var s=0,a=0,l=void 0,c=void 0;this.p.length?e.length?((c=new n(this.p.length+e.length)).set(this.p),c.set(e,this.p.length)):c=this.p:c=e;for(var u=c.length,h=this.c,p=h&&this.d,d=function(){var e,t=he(c,a);if(67324752==t){s=1,l=a,f.d=null,f.c=0;var n=ue(c,a+6),r=ue(c,a+8),o=2048&n,p=8&n,d=ue(c,a+26),m=ue(c,a+28);if(u>a+30+d+m){var g=[];f.k.unshift(g),s=2;var _=he(c,a+18),y=he(c,a+22),v=Ke(c.subarray(a+30,a+=30+d),!o);4294967295==_?(e=p?[-2]:nt(c,a),_=e[0],y=e[1]):p&&(_=-1),a+=m,f.c=_;var x={name:v,compression:r,start:function(){if(!x.ondata)throw"no callback";if(_){var e=i.o[r];if(!e)throw"unknown compression type "+r;var t=_<0?new e(v):new e(v,_,y);t.ondata=function(e,t,i){x.ondata(e,t,i)};for(var n=0,o=g;n=0&&(x.size=_,x.originalSize=y),f.onfile(x)}return"break"}if(h){if(134695760==t)return l=a+=12+(-2==h&&8),s=2,f.c=0,"break";if(33639248==t)return l=a-=4,s=2,f.c=0,"break"}},f=this;a65558)return void t("invalid zip file",null);var a=ue(e,s+8);a||t(null,{});var l=a,c=he(e,s+16),u=4294967295==c;if(u){if(s=he(e,s-12),101075792!=he(e,s))return void t("invalid zip file",null);l=a=he(e,s+32),c=he(e,s+48)}for(var h=function(s){var l=it(e,c,u),h=l[0],p=l[1],d=l[2],f=l[3],m=l[4],g=tt(e,l[5]);c=m;var _=function(e,i){e?(r(),t(e,null)):(o[f]=i,--a||t(null,o))};if(h)if(8==h){var y=e.subarray(g,g+p);if(p<32e4)try{_(null,Ce(y,new n(d)))}catch(e){_(e,null)}else i.push(Ae(y,{size:d},_))}else _("unknown compression type "+h,null);else _(null,I(e,g,g+p))},p=0;p65558)throw"invalid zip file";var r=ue(e,i+8);if(!r)return{};var o=he(e,i+16),s=4294967295==o;if(s){if(i=he(e,i-12),101075792!=he(e,i))throw"invalid zip file";r=he(e,i+32),o=he(e,i+48)}for(var a=0;a0,o="string"==typeof r.Content&&""!==r.Content;if(t||o){const t=this.parseImage(n[e]);i[r.RelativeFilename||r.Filename]=t}}}}for(const e in t){const n=t[e];void 0!==i[n]?t[e]=i[n]:t[e]=t[e].split("\\").pop()}return t}parseImage(e){const t=e.Content,i=e.RelativeFilename||e.Filename,n=i.slice(i.lastIndexOf(".")+1).toLowerCase();let r;switch(n){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),r="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+n+'" is not supported.')}if("string"==typeof t)return"data:"+r+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:r}))}}parseTextures(t){const i=new Map;if("Texture"in e.Objects){const n=e.Objects.Texture;for(const e in n){const r=this.parseTexture(n[e],t);i.set(parseInt(e),r)}}return i}parseTexture(e,t){const i=this.loadTexture(e,t);i.ID=e.id,i.name=e.attrName;const r=e.WrapModeU,o=e.WrapModeV,s=void 0!==r?r.value:0,a=void 0!==o?o.value:0;if(i.wrapS=0===s?n.RepeatWrapping:n.ClampToEdgeWrapping,i.wrapT=0===a?n.RepeatWrapping:n.ClampToEdgeWrapping,"Scaling"in e){const t=e.Scaling.value;i.repeat.x=t[0],i.repeat.y=t[1]}return i}loadTexture(e,i){let r;const o=this.textureLoader.path,s=t.get(e.id).children;let a;void 0!==s&&s.length>0&&void 0!==i[s[0].ID]&&(0!==(r=i[s[0].ID]).indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));const l=e.FileName.slice(-3).toLowerCase();if("tga"===l){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),a=new n.Texture):(t.setPath(this.textureLoader.path),a=t.load(r))}else"psd"===l?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new n.Texture):a=this.textureLoader.load(r);return this.textureLoader.setPath(o),a}parseMaterials(t){const i=new Map;if("Material"in e.Objects){const n=e.Objects.Material;for(const e in n){const r=this.parseMaterial(n[e],t);null!==r&&i.set(parseInt(e),r)}}return i}parseMaterial(e,i){const r=e.id,o=e.attrName;let s=e.ShadingModel;if("object"==typeof s&&(s=s.value),!t.has(r))return null;const a=this.parseParameters(e,i,r);let l;switch(s.toLowerCase()){case"phong":l=new n.MeshPhongMaterial;break;case"lambert":l=new n.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to THREE.MeshPhongMaterial.',s),l=new n.MeshPhongMaterial}return l.setValues(a),l.name=o,l}parseParameters(e,i,r){const o={};e.BumpFactor&&(o.bumpScale=e.BumpFactor.value),e.Diffuse?o.color=(new n.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(o.color=(new n.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(o.displacementScale=e.DisplacementFactor.value),e.Emissive?o.emissive=(new n.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(o.emissive=(new n.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(o.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(o.opacity=parseFloat(e.Opacity.value)),o.opacity<1&&(o.transparent=!0),e.ReflectionFactor&&(o.reflectivity=e.ReflectionFactor.value),e.Shininess&&(o.shininess=e.Shininess.value),e.Specular?o.specular=(new n.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(o.specular=(new n.Color).fromArray(e.SpecularColor.value));const s=this;return t.get(r).children.forEach((function(e){const t=e.relationship;switch(t){case"Bump":o.bumpMap=s.getTexture(i,e.ID);break;case"Maya|TEX_ao_map":o.aoMap=s.getTexture(i,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=s.getTexture(i,e.ID),void 0!==o.map&&(o.map.encoding=n.sRGBEncoding);break;case"DisplacementColor":o.displacementMap=s.getTexture(i,e.ID);break;case"EmissiveColor":o.emissiveMap=s.getTexture(i,e.ID),void 0!==o.emissiveMap&&(o.emissiveMap.encoding=n.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=s.getTexture(i,e.ID);break;case"ReflectionColor":o.envMap=s.getTexture(i,e.ID),void 0!==o.envMap&&(o.envMap.mapping=n.EquirectangularReflectionMapping,o.envMap.encoding=n.sRGBEncoding);break;case"SpecularColor":o.specularMap=s.getTexture(i,e.ID),void 0!==o.specularMap&&(o.specularMap.encoding=n.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=s.getTexture(i,e.ID),o.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",t)}})),o}getTexture(i,n){return"LayeredTexture"in e.Objects&&n in e.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),n=t.get(n).children[0].ID),i.get(n)}parseDeformers(){const i={},n={};if("Deformer"in e.Objects){const r=e.Objects.Deformer;for(const e in r){const o=r[e],s=t.get(parseInt(e));if("Skin"===o.attrType){const t=this.parseSkeleton(s,r);t.ID=e,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,i[e]=t}else if("BlendShape"===o.attrType){const t={id:e};t.rawTargets=this.parseMorphTargets(s,r),t.id=e,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),n[e]=t}}}return{skeletons:i,morphTargets:n}}parseSkeleton(e,t){const i=[];return e.children.forEach((function(e){const r=t[e.ID];if("Cluster"!==r.attrType)return;const o={ID:e.ID,indices:[],weights:[],transformLink:(new n.Matrix4).fromArray(r.TransformLink.a)};"Indexes"in r&&(o.indices=r.Indexes.a,o.weights=r.Weights.a),i.push(o)})),{rawBones:i,bones:[]}}parseMorphTargets(e,i){const n=[];for(let r=0;r1?s=a:a.length>0?s=a[0]:(s=new n.MeshPhongMaterial({color:13421772}),a.push(s)),"color"in o.attributes&&a.forEach((function(e){e.vertexColors=!0})),o.FBX_Deformer?(r=new n.SkinnedMesh(o,s)).normalizeSkinWeights():r=new n.Mesh(o,s),r}createCurve(e,t){const i=e.children.reduce((function(e,i){return t.has(i.ID)&&(e=t.get(i.ID)),e}),null),r=new n.LineBasicMaterial({color:3342591,linewidth:1});return new n.Line(i,r)}getTransformData(e,t){const i={};"InheritType"in t&&(i.inheritType=parseInt(t.InheritType.value)),i.eulerOrder="RotationOrder"in t?y(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(i.translation=t.Lcl_Translation.value),"PreRotation"in t&&(i.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(i.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(i.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(i.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(i.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(i.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(i.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(i.rotationPivot=t.RotationPivot.value),e.userData.transformData=i}setLookAtProperties(r,o){"LookAtProperty"in o&&t.get(r.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const o=e.Objects.Model[t.ID];if("Lcl_Translation"in o){const e=o.Lcl_Translation.value;void 0!==r.target?(r.target.position.fromArray(e),i.add(r.target)):r.lookAt((new n.Vector3).fromArray(e))}}}))}bindSkeleton(e,i,r){const o=this.parsePoseNodes();for(const s in e){const a=e[s];t.get(parseInt(a.ID)).parents.forEach((function(e){if(i.has(e.ID)){const i=e.ID;t.get(i).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new n.Skeleton(a.bones),o[e.ID])}))}}))}}parsePoseNodes(){const t={};if("Pose"in e.Objects){const i=e.Objects.Pose;for(const e in i)if("BindPose"===i[e].attrType){const r=i[e].PoseNode;Array.isArray(r)?r.forEach((function(e){t[e.Node]=(new n.Matrix4).fromArray(e.Matrix.a)})):t[r.Node]=(new n.Matrix4).fromArray(r.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in e&&"AmbientColor"in e.GlobalSettings){const t=e.GlobalSettings.AmbientColor.value,r=t[0],o=t[1],s=t[2];if(0!==r||0!==o||0!==s){const e=new n.Color(r,o,s);i.add(new n.AmbientLight(e,1))}}}}class o{parse(i){const n=new Map;if("Geometry"in e.Objects){const r=e.Objects.Geometry;for(const e in r){const o=t.get(parseInt(e)),s=this.parseGeometry(o,r[e],i);n.set(parseInt(e),s)}}return n}parseGeometry(e,t,i){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,i);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(t,i,n){const r=n.skeletons,o=[],s=t.parents.map((function(t){return e.Objects.Model[t.ID]}));if(0===s.length)return;const a=t.children.reduce((function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e}),null);t.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&o.push(n.morphTargets[e.ID])}));const l=s[0],c={};"RotationOrder"in l&&(c.eulerOrder=y(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const u=_(c);return this.genGeometry(i,a,o,u)}genGeometry(e,t,i,r){const o=new n.BufferGeometry;e.attrName&&(o.name=e.attrName);const s=this.parseGeoNode(e,t),a=this.genBuffers(s),l=new n.Float32BufferAttribute(a.vertex,3);if(l.applyMatrix4(r),o.setAttribute("position",l),a.colors.length>0&&o.setAttribute("color",new n.Float32BufferAttribute(a.colors,3)),t&&(o.setAttribute("skinIndex",new n.Uint16BufferAttribute(a.weightsIndices,4)),o.setAttribute("skinWeight",new n.Float32BufferAttribute(a.vertexWeights,4)),o.FBX_Deformer=t),a.normal.length>0){const e=(new n.Matrix3).getNormalMatrix(r),t=new n.Float32BufferAttribute(a.normal,3);t.applyNormalMatrix(e),o.setAttribute("normal",t)}if(a.uvs.forEach((function(e,t){let i="uv"+(t+1).toString();0===t&&(i="uv"),o.setAttribute(i,new n.Float32BufferAttribute(a.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=a.materialIndex[0],t=0;if(a.materialIndex.forEach((function(i,n){i!==e&&(o.addGroup(t,n-t,e),e=i,t=n)})),o.groups.length>0){const t=o.groups[o.groups.length-1],i=t.start+t.count;i!==a.materialIndex.length&&o.addGroup(i,a.materialIndex.length-i,e)}0===o.groups.length&&o.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(o,e,i,r),o}parseGeoNode(e,t){const i={};if(i.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],i.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(i.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(i.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(i.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){i.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&i.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return i.weightTable={},null!==t&&(i.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(n,r){void 0===i.weightTable[n]&&(i.weightTable[n]=[]),i.weightTable[n].push({id:t,weight:e.weights[r]})}))}))),i}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let i=0,n=0,r=!1,o=[],s=[],a=[],l=[],c=[],u=[];const h=this;return e.vertexIndices.forEach((function(p,d){let m,g=!1;p<0&&(p^=-1,g=!0);let _=[],y=[];if(o.push(3*p,3*p+1,3*p+2),e.color){const t=f(d,i,p,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[p]&&e.weightTable[p].forEach((function(e){y.push(e.weight),_.push(e.id)})),y.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const e=[0,0,0,0],t=[0,0,0,0];y.forEach((function(i,n){let r=i,o=_[n];t.forEach((function(t,i,n){if(r>t){n[i]=r,r=t;const s=e[i];e[i]=o,o=s}}))})),_=e,y=t}for(;y.length<4;)y.push(0),_.push(0);for(let e=0;e<4;++e)c.push(y[e]),u.push(_[e])}if(e.normal){const t=f(d,i,p,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(m=f(d,i,p,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){const n=f(d,i,p,e);void 0===l[t]&&(l[t]=[]),l[t].push(n[0]),l[t].push(n[1])})),n++,g&&(h.genFace(t,e,o,m,s,a,l,c,u,n),i++,n=0,o=[],s=[],a=[],l=[],c=[],u=[])})),t}genFace(e,t,i,n,r,o,s,a,l,c){for(let u=2;u1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=i.get(o[0].ID);r[e]={name:n[e].attrName,layer:s}}return r}addClip(e){let t=[];const i=this;return e.layer.forEach((function(e){t=t.concat(i.generateTracks(e))})),new n.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let i=new n.Vector3,r=new n.Quaternion,o=new n.Vector3;if(e.transform&&e.transform.decompose(i,r,o),i=i.toArray(),r=(new n.Euler).setFromQuaternion(r,e.eulerOrder).toArray(),o=o.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.T.curves,i,"position");void 0!==n&&t.push(n)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const i=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);void 0!==i&&t.push(i)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.S.curves,o,"scale");void 0!==i&&t.push(i)}if(void 0!==e.DeformPercent){const i=this.generateMorphTrack(e);void 0!==i&&t.push(i)}return t}generateVectorTrack(e,t,i,r){const o=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(o,t,i);return new n.VectorKeyframeTrack(e+"."+r,o,s)}generateRotationTrack(e,t,i,r,o,s){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(n.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(n.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(n.MathUtils.degToRad));const a=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(a,t,i);void 0!==r&&((r=r.map(n.MathUtils.degToRad)).push(s),r=(new n.Euler).fromArray(r),r=(new n.Quaternion).setFromEuler(r)),void 0!==o&&((o=o.map(n.MathUtils.degToRad)).push(s),o=(new n.Euler).fromArray(o),o=(new n.Quaternion).setFromEuler(o).invert());const c=new n.Quaternion,u=new n.Euler,h=[];for(let e=0;e1){let e=1,i=t[0];for(let n=1;n=180){const o=r/180,s=n/o;let a=i+s;const l=e.times[t-1],c=(e.times[t]-l)/o;let u=l+c;const h=[],p=[];for(;u1&&(i=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:i,type:n}}parseNodeProperty(e,t,i){let n=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===r&&(r=i.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if("Properties70"!==o.name){if("C"===n){const e=r.split(",").slice(1),t=parseInt(e[0]),i=parseInt(e[1]);let s=r.split(",").slice(3);n="connections",function(e,t){for(let i=0,n=e.length,r=t.length;i=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const i={},n=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),s=e.getString(o);if(0===n)return null;const a=[];for(let t=0;t0?a[0]:"",c=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(i.singleProperty=1===r&&e.getOffset()===n;n>e.getOffset();){const n=this.parseNode(e,t);null!==n&&this.parseSubNode(s,i,n)}return i.propertyList=a,"number"==typeof l&&(i.id=l),""!==c&&(i.attrName=c),""!==u&&(i.attrType=u),""!==s&&(i.name=s),i}parseSubNode(e,t,i){if(!0===i.singleProperty){const e=i.propertyList[0];Array.isArray(e)?(t[i.name]=i,i.a=e):t[i.name]=e}else if("Connections"===e&&"C"===i.name){const e=[];i.propertyList.forEach((function(t,i){0!==i&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===i.name)Object.keys(i).forEach((function(e){t[e]=i[e]}));else if("Properties70"===e&&"P"===i.name){let e=i.propertyList[0],n=i.propertyList[1];const r=i.propertyList[2],o=i.propertyList[3];let s;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===n.indexOf("Lcl ")&&(n=n.replace("Lcl ","Lcl_")),s="Color"===n||"ColorRGB"===n||"Vector"===n||"Vector3D"===n||0===n.indexOf("Lcl_")?[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:i.propertyList[4],t[e]={type:n,type2:r,flag:o,value:s}}else void 0===t[i.name]?"number"==typeof i.id?(t[i.name]={},t[i.name][i.id]=i):t[i.name]=i:"PoseNode"===i.name?(Array.isArray(t[i.name])||(t[i.name]=[t[i.name]]),t[i.name].push(i)):void 0===t[i.name][i.id]&&(t[i.name][i.id]=i)}parseProperty(e){const t=e.getString(1);let i;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return i=e.getUint32(),e.getArrayBuffer(i);case"S":return i=e.getUint32(),e.getString(i);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const n=e.getUint32(),r=e.getUint32(),o=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}void 0===$&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const s=$.unzlibSync(new Uint8Array(e.getArrayBuffer(o))),a=new c(s.buffer);switch(t){case"b":case"c":return a.getBooleanArray(n);case"d":return a.getFloat64Array(n);case"f":return a.getFloat32Array(n);case"i":return a.getInt32Array(n);case"l":return a.getInt64Array(n)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class c{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let i=0;i=0&&(t=t.slice(0,i)),n.LoaderUtils.decodeText(new Uint8Array(t))}}class u{add(e,t){this[e]=t}}function h(e){const t=e.match(/FBXVersion: (\d+)/);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function p(e){return e/46186158e3}const d=[];function f(e,t,i,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=i;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}"IndexToDirect"===n.referenceType&&(r=n.indices[r]);const o=r*n.dataSize,s=o+n.dataSize;return function(e,t,i,n){for(let r=i,o=0;r=t.length&&t===x(e,0,t.length)}(t))e=(new l).parse(t);else{const i=x(t);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let i=0;function n(t){const n=e[t-1];return e=e.slice(i+t),i++,n}for(let e=0;e=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o,s)}}class g{constructor(e){this.parser=e,this.name="EXT_texture_webp",this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],s=n.images[o.source];let a=i.textureLoader;if(s.uri){const e=i.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(e,s,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class _{constructor(e){this.name="EXT_meshopt_compression",this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const e=i.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([n,r.ready]).then((function(t){const i=e.byteOffset||0,n=e.byteLength||0,o=e.count,s=e.byteStride,a=new ArrayBuffer(o*s),l=new Uint8Array(t[0],i,n);return r.decodeGltfBuffer(new Uint8Array(a),o,s,l,e.mode,e.filter),a}))}return null}}class y{constructor(e){this.name=t,this.content=null,this.body=null;const i=new DataView(e,0,12);if(this.header={magic:n.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:i.getUint32(4,!0),length:i.getUint32(8,!0)},"glTF"!==this.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 r=this.header.length-12,o=new DataView(e,12);let s=0;for(;s",t).replace("#include ",i).replace("#include ",r).replace("#include ",o).replace("#include ",s)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class w{constructor(){this.name=r,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return b}extendParams(e,t,i){const r=t.extensions[this.name];e.color=new n.Color(1,1,1),e.opacity=1;const o=[];if(Array.isArray(r.diffuseFactor)){const t=r.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==r.diffuseTexture&&o.push(i.assignTexture(e,"map",r.diffuseTexture)),e.emissive=new n.Color(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new n.Color(1,1,1),Array.isArray(r.specularFactor)&&e.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const t=r.specularGlossinessTexture;o.push(i.assignTexture(e,"glossinessMap",t)),o.push(i.assignTexture(e,"specularMap",t))}return Promise.all(o)}createMaterial(e){const t=new b(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=n.TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}class M{constructor(){this.name=a}}class T extends n.Interpolant{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=i[r+e];return t}}T.prototype.beforeStart_=T.prototype.copySampleValue_,T.prototype.afterEnd_=T.prototype.copySampleValue_,T.prototype.interpolate_=function(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=2*s,l=3*s,c=n-t,u=(i-t)/c,h=u*u,p=h*u,d=e*l,f=d-l,m=-2*p+3*h,g=p-h,_=1-m,y=g-h+u;for(let e=0;e!==s;e++){const t=o[f+e+s],i=o[f+e+a]*c,n=o[d+e+s],l=o[d+e]*c;r[e]=_*t+y*i+m*n+g*l}return r};const S=new n.Quaternion;class E extends T{interpolate_(e,t,i,n){const r=super.interpolate_(e,t,i,n);return S.fromArray(r).normalize().toArray(r),r}}const A={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},C={9728:n.NearestFilter,9729:n.LinearFilter,9984:n.NearestMipmapNearestFilter,9985:n.LinearMipmapNearestFilter,9986:n.NearestMipmapLinearFilter,9987:n.LinearMipmapLinearFilter},L={33071:n.ClampToEdgeWrapping,33648:n.MirroredRepeatWrapping,10497:n.RepeatWrapping},I={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},P={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},R={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},k={CUBICSPLINE:void 0,LINEAR:n.InterpolateLinear,STEP:n.InterpolateDiscrete};function z(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}function D(e,t,i){for(const n in i.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=i.extensions[n])}function O(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function F(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let i=0,n=t.weights.length;i=2&&f.setY(t,h[e*s+1]),s>=3&&f.setZ(t,h[e*s+2]),s>=4&&f.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.")}}return f}))}loadTexture(e){const t=this.json,i=this.options,n=t.textures[e],r=t.images[n.source];let o=this.textureLoader;if(r.uri){const e=i.manager.getHandler(r.uri);null!==e&&(o=e)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,i){const r=this,o=this.json,s=this.options,a=o.textures[e],l=(t.uri||t.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=self.URL||self.webkitURL;let u=t.uri||"",h=!1,p=!0;const d=u.search(/\.jpe?g($|\?)/i)>0||0===u.search(/^data\:image\/jpeg/);if(("image/jpeg"===t.mimeType||d)&&(p=!1),void 0!==t.bufferView)u=r.getDependency("bufferView",t.bufferView).then((function(e){if("image/png"===t.mimeType){const t=new DataView(e,25,1).getUint8(0,!1);p=6===t||4===t||3===t}h=!0;const i=new Blob([e],{type:t.mimeType});return u=c.createObjectURL(i)}));else if(void 0===t.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(u).then((function(e){return new Promise((function(t,r){let o=t;!0===i.isImageBitmapLoader&&(o=function(e){const i=new n.Texture(e);i.needsUpdate=!0,t(i)}),i.load(z(e,s.path),o,void 0,r)}))})).then((function(t){!0===h&&c.revokeObjectURL(u),t.flipY=!1,a.name&&(t.name=a.name),p||(t.format=n.RGBFormat);const i=(o.samplers||{})[a.sampler]||{};return t.magFilter=C[i.magFilter]||n.LinearFilter,t.minFilter=C[i.minFilter]||n.LinearMipmapLinearFilter,t.wrapS=L[i.wrapS]||n.RepeatWrapping,t.wrapT=L[i.wrapT]||n.RepeatWrapping,r.associations.set(t,{type:"textures",index:e}),t})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",u),null}));return this.textureCache[l]=f,f}assignTexture(e,t,i){const n=this;return this.getDependency("texture",i.index).then((function(r){if(void 0===i.texCoord||0==i.texCoord||"aoMap"===t&&1==i.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+i.texCoord+" for texture "+t+" not yet supported."),n.extensions[s]){const e=void 0!==i.extensions?i.extensions[s]:void 0;if(e){const t=n.associations.get(r);r=n.extensions[s].extendTexture(r,e),n.associations.set(r,t)}}return e[t]=r,r}))}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=void 0!==t.attributes.tangent,o=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new n.PointsMaterial,n.Material.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,t.sizeAttenuation=!1,this.cache.add(e,t)),i=t}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new n.LineBasicMaterial,n.Material.prototype.copy.call(t,i),t.color.copy(i.color),this.cache.add(e,t)),i=t}if(r||o||s){let e="ClonedMaterial:"+i.uuid+":";i.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),r&&(e+="vertex-tangents:"),o&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=i.clone(),o&&(t.vertexColors=!0),s&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(i))),i=t}i.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=i}getMaterialType(){return n.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,s=this.extensions,a=i.materials[e];let l;const c={},u=a.extensions||{},h=[];if(u[r]){const e=s[r];l=e.getMaterialType(),h.push(e.extendParams(c,a,t))}else if(u[o]){const e=s[o];l=e.getMaterialType(),h.push(e.extendParams(c,a,t))}else{const i=a.pbrMetallicRoughness||{};if(c.color=new n.Color(1,1,1),c.opacity=1,Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;c.color.fromArray(e),c.opacity=e[3]}void 0!==i.baseColorTexture&&h.push(t.assignTexture(c,"map",i.baseColorTexture)),c.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,c.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(h.push(t.assignTexture(c,"metalnessMap",i.metallicRoughnessTexture)),h.push(t.assignTexture(c,"roughnessMap",i.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),h.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,c)}))))}!0===a.doubleSided&&(c.side=n.DoubleSide);const p=a.alphaMode||"OPAQUE";return"BLEND"===p?(c.transparent=!0,c.depthWrite=!1):(c.format=n.RGBFormat,c.transparent=!1,"MASK"===p&&(c.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&l!==n.MeshBasicMaterial&&(h.push(t.assignTexture(c,"normalMap",a.normalTexture)),c.normalScale=new n.Vector2(1,-1),void 0!==a.normalTexture.scale&&c.normalScale.set(a.normalTexture.scale,-a.normalTexture.scale)),void 0!==a.occlusionTexture&&l!==n.MeshBasicMaterial&&(h.push(t.assignTexture(c,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(c.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&l!==n.MeshBasicMaterial&&(c.emissive=(new n.Color).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&l!==n.MeshBasicMaterial&&h.push(t.assignTexture(c,"emissiveMap",a.emissiveTexture)),Promise.all(h).then((function(){let i;return i=l===b?s[r].createMaterial(c):new l(c),a.name&&(i.name=a.name),i.map&&(i.map.encoding=n.sRGBEncoding),i.emissiveMap&&(i.emissiveMap.encoding=n.sRGBEncoding),O(i,a),t.associations.set(i,{type:"materials",index:e}),a.extensions&&D(s,i,a),i}))}createUniqueName(e){const t=n.PropertyBinding.sanitizeNodeName(e||"");let i=t;for(let e=1;this.nodeNamesUsed[i];++e)i=t+"_"+e;return this.nodeNamesUsed[i]=!0,i}loadGeometries(e){const t=this,r=this.extensions,o=this.primitiveCache;function s(e){return r[i].decodePrimitive(e,t).then((function(i){return G(i,e,t)}))}const a=[];for(let r=0,l=e.length;r0&&F(p,o),p.name=t.createUniqueName(o.name||"mesh_"+e),O(p,o),h.extensions&&D(r,p,h),t.assignFinalMaterial(p),c.push(p)}if(1===c.length)return c[0];const u=new n.Group;for(let e=0,t=c.length;e1?new n.Group:1===t.length?t[0]:new n.Object3D)!==t[0])for(let e=0,i=t.length;e=2.0 are supported.")));const g=new j(m,{path:l||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});g.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===f[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}g.setExtensions(d),g.setPlugins(f),g.parse(u,h)}}}(),X=X=n.GLTFLoader;var Y={};n.ColladaLoader=class extends n.Loader{constructor(e){super(e)}load(e,t,i,r){const o=this,s=""===o.path?n.LoaderUtils.extractUrlBase(e):o.path,a=new n.FileLoader(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,(function(i){try{t(o.parse(i,s))}catch(t){r?r(t):console.error(t),o.manager.itemError(e)}}),i,r)}parse(e,t){function i(e,t){const i=[],n=e.childNodes;for(let e=0,r=n.length;e0&&t.push(new n.VectorKeyframeTrack(r+".position",o,s)),a.length>0&&t.push(new n.QuaternionKeyframeTrack(r+".quaternion",o,a)),l.length>0&&t.push(new n.VectorKeyframeTrack(r+".scale",o,l)),t}function M(e,t,i){let n,r,o,s=!0;for(r=0,o=e.length;r=0;){const n=e[t];if(null!==n.value[i])return n;t--}return null}function S(e,t,i){for(;t>>0));if("tga"===(i=i.toLowerCase()))t=We;else t=He;return t}(r);if(void 0!==t){const i=t.load(r),o=e.extra;if(void 0!==o&&void 0!==o.technique&&!1===l(o.technique)){const e=o.technique;i.wrapS=e.wrapU?n.RepeatWrapping:n.ClampToEdgeWrapping,i.wrapT=e.wrapV?n.RepeatWrapping:n.ClampToEdgeWrapping,i.offset.set(e.offsetU||0,e.offsetV||0),i.repeat.set(e.repeatU||1,e.repeatV||1)}else i.wrapS=n.RepeatWrapping,i.wrapT=n.RepeatWrapping;return i}return console.warn("THREE.ColladaLoader: THREE.Loader for texture %s not found.",r),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}s.name=e.name||"";const c=r.parameters;for(const e in c){const t=c[e];switch(e){case"diffuse":t.color&&s.color.fromArray(t.color),t.texture&&(s.map=a(t.texture));break;case"specular":t.color&&s.specular&&s.specular.fromArray(t.color),t.texture&&(s.specularMap=a(t.texture));break;case"bump":t.texture&&(s.normalMap=a(t.texture));break;case"ambient":t.texture&&(s.lightMap=a(t.texture));break;case"shininess":t.float&&s.shininess&&(s.shininess=t.float);break;case"emission":t.color&&s.emissive&&s.emissive.fromArray(t.color),t.texture&&(s.emissiveMap=a(t.texture))}}let u=c.transparent,h=c.transparency;if(void 0===h&&u&&(h={float:1}),void 0===u&&h&&(u={opaque:"A_ONE",data:{color:[1,1,1,1]}}),u&&h)if(u.data.texture)s.transparent=!0;else{const e=u.data.color;switch(u.opaque){case"A_ONE":s.opacity=e[3]*h.float;break;case"RGB_ZERO":s.opacity=1-e[0]*h.float;break;case"A_ZERO":s.opacity=1-e[3]*h.float;break;case"RGB_ONE":s.opacity=e[0]*h.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',u.opaque)}s.opacity<1&&(s.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(s.side=n.DoubleSide),s}function X(e){return d(Xe.materials[e],Z)}function Y(e){for(let t=0;t0?i+o:i;t.inputs[l]={id:e,offset:r},t.stride=Math.max(t.stride,r+1),"TEXCOORD"===i&&(t.hasUV=!0);break;case"vcount":t.vcount=s(n.textContent);break;case"p":t.p=s(n.textContent)}}return t}function le(e){let t=0;for(let i=0,n=e.length;i0&&t0&&p.setAttribute("position",new n.Float32BufferAttribute(o.array,o.stride)),s.array.length>0&&p.setAttribute("normal",new n.Float32BufferAttribute(s.array,s.stride)),c.array.length>0&&p.setAttribute("color",new n.Float32BufferAttribute(c.array,c.stride)),a.array.length>0&&p.setAttribute("uv",new n.Float32BufferAttribute(a.array,a.stride)),l.array.length>0&&p.setAttribute("uv2",new n.Float32BufferAttribute(l.array,l.stride)),u.length>0&&p.setAttribute("skinIndex",new n.Float32BufferAttribute(u,4)),h.length>0&&p.setAttribute("skinWeight",new n.Float32BufferAttribute(h,4)),r.data=p,r.type=e[0].type,r.materialKeys=d,r}function he(e,t,i,n){const r=e.p,o=e.stride,s=e.vcount;function a(e){let t=r[e+i]*c;const o=t+c;for(;t4)for(let t=1,n=i-2;t<=n;t++){const i=e+o*t,n=e+o*(t+1);a(e+0*o),a(i),a(n)}e+=o*i}}else for(let e=0,t=r.length;e=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function _e(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let i=0;ir.limits.max||t{let r=[];switch(e.type){case"mtl":n=n.children[0];break;case"gltf":case"glb":case"dae":r=n.animations,n=n.scene;break;case"fbx":r=n.animations}n.animations=r;const o=u.types.rotation(e.rotation,[0,0,0]),s=u.types.scale(e.scale,[1,1,1]);n.rotation.set(o[0],o[1],o[2]),n.scale.set(s[0],s[1],s[2]),e.normalize&&n.traverse((function(e){if(e.isMesh){let t;"MeshStandardMaterial"==e.material.type?(e.material.metalness&&(e.material.metalness*=.1),e.material.glossiness&&(e.material.glossiness*=.25),t=new THREE.Color(12,12,12)):"MeshPhongMaterial"==e.material.type&&(e.material.shininess=.1,t=new THREE.Color(20,20,20)),e.material.specular&&e.material.specular.isColor&&(e.material.specular=t)}})),n.name="model";let a=b.prototype._makeGroup(n,e);b.prototype._addMethods(a),a.setAnchor(e.anchor),a.setCenter(e.adjustment),a.raycasted=e.raycasted,i(a),t(a),a.setFixedZoom(e.mapScale),a.idle()}),(()=>null),(t=>{console.error("Could not load model file: "+e.obj+" \n "+t.stack),i("Error loading the model")}))}),(()=>null),(e=>{console.warn("No material file found "+e.stack)}))};var ne={};function re(e){e=u._validate(e,b.prototype._defaults.line);var t=u.lnglatsToWorld(e.geometry),i=u.normalizeVertices(t),r=u.flattenVectors(i.vertices),o=new n.LineGeometry;o.setPositions(r);let s=new n.LineMaterial({color:e.color,linewidth:e.width,dashed:!1,opacity:e.opacity});return s.resolution.set(window.innerWidth,window.innerHeight),s.isMaterial=!0,s.transparent=!0,s.depthWrite=!1,(re=new n.Line2(o,s)).position.copy(i.position),re.computeLineDistances(),re}ne=ne=re,function(){const e=new n.Box3,t=new n.Vector3;class i extends n.InstancedBufferGeometry{constructor(){super(),this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new n.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new n.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),i.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new n.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new n.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceEnd",new n.InterleavedBufferAttribute(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new n.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new n.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceColorEnd",new n.InterleavedBufferAttribute(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new n.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;if(!t.isGeometry)return t.isBufferGeometry&&this.setPositions(t.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new n.Box3);const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;void 0!==t&&void 0!==i&&(this.boundingBox.setFromBufferAttribute(t),e.setFromBufferAttribute(i),this.boundingBox.union(e))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new n.Sphere),null===this.boundingBox&&this.computeBoundingBox();const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;if(void 0!==e&&void 0!==i){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let o=0,s=e.count;o\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\tworldStart = start.xyz;\n\t\t\tworldEnd = end.xyz;\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segements overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include \n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"};class e extends n.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:n.UniformsUtils.clone(n.ShaderLib.line.uniforms),vertexShader:n.ShaderLib.line.vertexShader,fragmentShader:n.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set(e){Boolean(e)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("ALPHA_TO_COVERAGE"in this.defines)},set:function(e){Boolean(e)!==Boolean("ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===e?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}}e.prototype.isLineMaterial=!0,n.LineMaterial=e}(),function(){const e=new n.Vector3,t=new n.Vector3,i=new n.Vector4,r=new n.Vector4,o=new n.Vector4,s=new n.Vector3,a=new n.Matrix4,l=new n.Line3,c=new n.Vector3,u=new n.Box3,h=new n.Sphere,p=new n.Vector4;class d extends n.Mesh{constructor(e=new n.LineSegmentsGeometry,t=new n.LineMaterial({color:16777215*Math.random()})){super(e,t),this.type="LineSegments2"}computeLineDistances(){const i=this.geometry,r=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=new Float32Array(2*r.count);for(let i=0,n=0,a=r.count;iT&&r.z>T)continue;if(i.z>T){const e=i.z-r.z,t=(i.z-T)/e;i.lerp(r,t)}else if(r.z>T){const e=r.z-i.z,t=(r.z-T)/e;r.lerp(i,t)}i.applyMatrix4(g),r.applyMatrix4(g),i.multiplyScalar(1/i.w),r.multiplyScalar(1/r.w),i.x*=x.x/2,i.y*=x.y/2,r.x*=x.x/2,r.y*=x.y/2,l.start.copy(i),l.start.z=0,l.end.copy(r),l.end.z=0;const o=l.closestPointToPointParameter(s,!0);l.at(o,c);const u=n.MathUtils.lerp(i.z,r.z,o),h=u>=-1&&u<=1,p=s.distanceTo(c)<.5*b;if(h&&p){l.start.fromBufferAttribute(w,e),l.end.fromBufferAttribute(M,e),l.start.applyMatrix4(_),l.end.applyMatrix4(_);const i=new n.Vector3,r=new n.Vector3;f.distanceSqToSegment(l.start,l.end,r,i),t.push({point:r,pointOnLine:i,distance:f.origin.distanceTo(r),object:this,face:null,faceIndex:e,uv:null,uv2:null})}}}}}d.prototype.LineSegments2=!0,n.LineSegments2=d}(),function(){class e extends n.LineSegments2{constructor(e=new n.LineGeometry,t=new n.LineMaterial({color:16777215*Math.random()})){super(e,t),this.type="Line2"}}e.prototype.isLine2=!0,n.Line2=e}(),function(){const e=new n.Vector3,t=new n.Vector3;class i extends n.Mesh{constructor(e=new n.LineSegmentsGeometry,t=new n.LineMaterial({color:16777215*Math.random()})){super(e,t),this.type="Wireframe"}computeLineDistances(){const i=this.geometry,r=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=new Float32Array(2*r.count);for(let i=0,n=0,a=r.count;i{i.push(new n.Vector3(e[0],e[1],e[2]))}));const r=new n.CatmullRomCurve3(i);let o=new n.TubeGeometry(r,i.length,e.radius,e.sides,!1),s=m(e),a=new n.Mesh(o,s);return new T({obj:a,units:e.units,anchor:e.anchor,adjustment:e.adjustment,bbox:e.bbox,tooltip:e.tooltip,raycasted:e.raycasted})};var se={};se=se=function(e){this.map=e,this.renderer=new x.CSS2DRenderer,this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight),this.renderer.domElement.style.position="absolute",this.renderer.domElement.id="labelCanvas",this.renderer.domElement.style.top=0,this.renderer.domElement.style.zIndex="0",this.map.getCanvasContainer().appendChild(this.renderer.domElement),this.scene,this.camera,this.dispose=function(){this.map.getCanvasContainer().removeChild(this.renderer.domElement),this.renderer.domElement.remove(),this.renderer={}},this.setSize=function(e,t){this.renderer.setSize(e,t)},this.map.on("resize",function(){this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight)}.bind(this)),this.state={reset:function(){}},this.render=async function(e,t){return this.scene=e,this.camera=t,new Promise((i=>{i(this.renderer.render(e,t))}))},this.toggleLabels=async function(e,t){return new Promise((i=>{i(this.setVisibility(e,t,this.scene,this.camera,this.renderer))}))},this.setVisibility=function(e,t,i,n,r){this.renderer.cacheList.forEach((function(o){o.visible!=t&&o.layer===e&&(t&&o.alwaysVisible||!t)&&(o.visible=t,r.renderObject(o,i,n))}))}};var ae={};ae=ae=class{constructor(e,t){this.id=e.layerId,this.type="custom",this.renderingMode="3d",this.opacity=.5,this.buildingsLayerId=e.buildingsLayerId,this.minAltitude=e.minAltitude||.1,this.tb=t}onAdd(e,t){this.map=e;const i=t.createShader(t.VERTEX_SHADER);t.shaderSource(i,"\n\t\t\tuniform mat4 u_matrix;\n\t\t\tuniform float u_height_factor;\n\t\t\tuniform float u_altitude;\n\t\t\tuniform float u_azimuth;\n\t\t\tattribute vec2 a_pos;\n\t\t\tattribute vec4 a_normal_ed;\n\t\t\tattribute lowp vec2 a_base;\n\t\t\tattribute lowp vec2 a_height;\n\t\t\tvoid main() {\n\t\t\t\tfloat base = max(0.0, a_base.x);\n\t\t\t\tfloat height = max(0.0, a_height.x);\n\t\t\t\tfloat t = mod(a_normal_ed.x, 2.0);\n\t\t\t\tvec4 pos = vec4(a_pos, t > 0.0 ? height : base, 1);\n\t\t\t\tfloat len = pos.z * u_height_factor / tan(u_altitude);\n\t\t\t\tpos.x += cos(u_azimuth) * len;\n\t\t\t\tpos.y += sin(u_azimuth) * len;\n\t\t\t\tpos.z = 0.0;\n\t\t\t\tgl_Position = u_matrix * pos;\n\t\t\t}\n\t\t\t"),t.compileShader(i);const n=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(n,"\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 0.7);\n\t\t\t}\n\t\t\t"),t.compileShader(n),this.program=t.createProgram(),t.attachShader(this.program,i),t.attachShader(this.program,n),t.linkProgram(this.program),t.validateProgram(this.program),this.uMatrix=t.getUniformLocation(this.program,"u_matrix"),this.uHeightFactor=t.getUniformLocation(this.program,"u_height_factor"),this.uAltitude=t.getUniformLocation(this.program,"u_altitude"),this.uAzimuth=t.getUniformLocation(this.program,"u_azimuth"),this.aPos=t.getAttribLocation(this.program,"a_pos"),this.aNormal=t.getAttribLocation(this.program,"a_normal_ed"),this.aBase=t.getAttribLocation(this.program,"a_base"),this.aHeight=t.getAttribLocation(this.program,"a_height")}render(e,t){e.useProgram(this.program);const i=this.map.style.sourceCaches.composite,n=i.getVisibleCoordinates().reverse(),r=this.map.getLayer(this.buildingsLayerId),o=this.map.painter.context,{lng:s,lat:a}=this.map.getCenter(),l=this.tb.getSunPosition(this.tb.lightDateTime,[s,a]);e.uniform1f(this.uAltitude,l.altitude>this.minAltitude?l.altitude:0),e.uniform1f(this.uAzimuth,l.azimuth+3*Math.PI/2),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.getExtension("EXT_blend_minmax"),e.disable(e.DEPTH_TEST);for(const t of n){const n=i.getTile(t),s=n.getBucket(r);if(!s)continue;const[a,l]=s.programConfigurations.programConfigurations[this.buildingsLayerId]._buffers;e.uniformMatrix4fv(this.uMatrix,!1,t.posMatrix),e.uniform1f(this.uHeightFactor,Math.pow(2,t.overscaledZ)/n.tileSize/8);for(const t of s.segments.get()){const i=o.currentNumAttributes||0,n=2;for(let t=n;t{this.tb.setObjectsScale()})),this.tb.options.sky&&(this.tb.sky=!0),this.tb.options.terrain&&(this.tb.terrain=!0),["satellite","mapbox-mapbox-satellite","satelliteLayer"].forEach((e=>{this.getLayer(e)&&(this.tb.terrainLayerName=e)}))})),this.map.on("load",(function(){let t;this.selectedObject,this.selectedFeature,this.draggedObject,this.overedObject,this.overedFeature;let i,n=this.getCanvasContainer();this.getCanvasContainer().style.cursor=this.tb.defaultCursor;let r,o,s,a,l=[];function c(e){var t=n.getBoundingClientRect();return{x:e.originalEvent.clientX-t.left-n.clientLeft,y:e.originalEvent.clientY-t.top-n.clientTop}}this.unselectObject=function(){this.selectedObject.selected=!1,this.selectedObject=null},this.outObject=function(){this.overedObject.over=!1,this.overedObject=null},this.unselectFeature=function(e){void 0!==e.id&&(this.setFeatureState({source:e.source,sourceLayer:e.sourceLayer,id:e.id},{select:!1}),this.removeTooltip(e),(e=this.queryRenderedFeatures({layers:[e.layer.id],filter:["==",["id"],e.id]})[0])&&this.fire("SelectedFeatureChange",{detail:e}),this.selectedFeature=null)},this.selectFeature=function(e){this.selectedFeature=e,this.setFeatureState({source:this.selectedFeature.source,sourceLayer:this.selectedFeature.sourceLayer,id:this.selectedFeature.id},{select:!0}),this.selectedFeature=this.queryRenderedFeatures({layers:[this.selectedFeature.layer.id],filter:["==",["id"],this.selectedFeature.id]})[0],this.addTooltip(this.selectedFeature),this.fire("SelectedFeatureChange",{detail:this.selectedFeature})},this.outFeature=function(t){this.overedFeature&&void 0!==this.overedFeature&&this.overedFeature.id!=t&&(e.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!1}),this.removeTooltip(this.overedFeature),this.overedFeature=null)},this.addTooltip=function(e){if(!this.tb.enableTooltips)return;let t=this.tb.getFeatureCenter(e),i=this.tb.tooltip({text:e.properties.name||e.id||e.type,mapboxStyle:!0,feature:e});i.setCoords(t),this.tb.add(i,e.layer.id),e.tooltip=i,e.tooltip.tooltip.visible=!0},this.removeTooltip=function(e){e.tooltip&&(e.tooltip.visibility=!1,this.tb.remove(e.tooltip),e.tooltip=null)},e.onContextMenu=function(e){alert("contextMenu")},this.onClick=function(t){let i,n=[];if(e.tb.enableSelectingObjects&&(n=this.tb.queryRenderedFeatures(t.point)),i="object"==typeof n[0]){let e=ce.prototype.findParent3DObject(n[0]);if(e){if(this.selectedFeature&&this.unselectFeature(this.selectedFeature),this.selectedObject){if(this.selectedObject.uuid!=e.uuid)this.selectedObject.selected=!1,e.selected=!0,this.selectedObject=e;else if(this.selectedObject.uuid==e.uuid)return void this.unselectObject()}else this.selectedObject=e,this.selectedObject.selected=!0;this.selectedObject.dispatchEvent({type:"Wireframed",detail:this.selectedObject}),this.selectedObject.dispatchEvent({type:"IsPlayingChanged",detail:this.selectedObject}),this.repaint=!0,t.preventDefault()}}else{let i=[];if(e.tb.enableSelectingFeatures&&(i=this.queryRenderedFeatures(t.point)),i.length>0&&"fill-extrusion"==i[0].layer.type&&void 0!==i[0].id)if(this.selectedObject&&this.unselectObject(),this.selectedFeature){if(this.selectedFeature.id!=i[0].id)this.unselectFeature(this.selectedFeature),this.selectFeature(i[0]);else if(this.selectedFeature.id==i[0].id)return void this.unselectFeature(this.selectedFeature)}else this.selectFeature(i[0])}},this.onMouseMove=function(n){let l,u=c(n);if(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,n.originalEvent.altKey&&this.draggedObject){if(!e.tb.enableRotatingObjects)return;t="rotate",this.getCanvasContainer().style.cursor="move",Math.min(i.x,u.x),Math.max(i.x,u.x),Math.min(i.y,u.y),Math.max(i.y,u.y);let n={x:0,y:0,z:Math.round(a[2]+~~((u.x-i.x)/this.tb.rotationStep)%360*this.tb.rotationStep%360)};return this.draggedObject.setRotation(n),void this.draggedObject.addHelp("rot: "+n.z+"°")}if(n.originalEvent.shiftKey&&this.draggedObject){if(!e.tb.enableDraggingObjects)return;t="translate",this.getCanvasContainer().style.cursor="move";let i=n.lngLat,s=[Number((i.lng+r).toFixed(this.tb.gridStep)),Number((i.lat+o).toFixed(this.tb.gridStep)),this.draggedObject.modelHeight];return this.draggedObject.setCoords(s),void this.draggedObject.addHelp("lng: "+s[0]+"°, lat: "+s[1]+"°")}if(n.originalEvent.ctrlKey&&this.draggedObject){if(!e.tb.enableDraggingObjects)return;t="altitude",this.getCanvasContainer().style.cursor="move";let i=n.point.y*this.tb.altitudeStep,r=[this.draggedObject.coordinates[0],this.draggedObject.coordinates[1],Number((-i-s).toFixed(this.tb.gridStep))];return this.draggedObject.setCoords(r),void this.draggedObject.addHelp("alt: "+r[2]+"m")}let h=[];if(e.tb.enableSelectingObjects&&(h=this.tb.queryRenderedFeatures(n.point)),l="object"==typeof h[0]){let e=ce.prototype.findParent3DObject(h[0]);e&&(this.outFeature(this.overedFeature),this.getCanvasContainer().style.cursor="pointer",this.selectedObject&&e.uuid==this.selectedObject.uuid?this.selectedObject&&e.uuid==this.selectedObject.uuid&&(e.over=!0,this.overedObject=e):(this.overedObject&&this.overedObject.uuid!=e.uuid&&this.outObject(),e.over=!0,this.overedObject=e),this.repaint=!0,n.preventDefault())}else{this.overedObject&&this.outObject();let t=[];e.tb.enableSelectingFeatures&&(t=this.queryRenderedFeatures(n.point)),t.length>0&&(this.outFeature(t[0]),"fill-extrusion"==t[0].layer.type&&void 0!==t[0].id&&(this.selectedFeature&&this.selectedFeature.id==t[0].id||(this.getCanvasContainer().style.cursor="pointer",this.overedFeature=t[0],this.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!0}),this.overedFeature=e.queryRenderedFeatures({layers:[this.overedFeature.layer.id],filter:["==",["id"],this.overedFeature.id]})[0],this.addTooltip(this.overedFeature))))}},this.onMouseDown=function(t){(t.originalEvent.shiftKey||t.originalEvent.altKey||t.originalEvent.ctrlKey)&&0===t.originalEvent.button&&this.selectedObject&&(e.tb.enableDraggingObjects||e.tb.enableRotatingObjects)&&(t.preventDefault(),e.getCanvasContainer().style.cursor="move",e.once("mouseup",this.onMouseUp),this.draggedObject=this.selectedObject,i=c(t),l=this.draggedObject.coordinates,a=u.degreeify(this.draggedObject.rotation),r=l[0]-t.lngLat.lng,o=l[1]-t.lngLat.lat,s=-this.draggedObject.modelHeight-t.point.y*this.tb.altitudeStep)},this.onMouseUp=function(e){this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.off("mouseup",this.onMouseUp),this.off("mouseout",this.onMouseUp),this.dragPan.enable(),this.draggedObject&&(this.draggedObject.dispatchEvent({type:"ObjectDragged",detail:{draggedObject:this.draggedObject,draggedAction:t}}),this.draggedObject.removeHelp(),this.draggedObject=null,t=null)},this.onMouseOut=function(e){if(this.overedFeature){let t=this.queryRenderedFeatures(e.point);t.length>0&&this.overedFeature.id!=t[0].id&&(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.outFeature(t[0]))}},this.onZoom=function(e){this.tb.zoomLayers.forEach((e=>{this.tb.toggleLayer(e)})),this.tb.setObjectsScale()};let h=!1,p=!1;this.on("click",this.onClick),this.on("mousemove",this.onMouseMove),this.on("mouseout",this.onMouseOut),this.on("mousedown",this.onMouseDown),this.on("zoom",this.onZoom),this.on("zoomend",this.onZoom),document.addEventListener("keydown",function(e){17!==e.which&&91!==e.which||(h=!0),16===e.which&&(p=!0);let t=this.selectedObject;if(p&&83===e.which&&t){let e=u.toDecimal;if(t.help)t.removeHelp();else{let i=t.modelSize,n=1;"meters"!==t.userData.units&&((n=u.projectedUnitsPerMeter(t.coordinates[1]))||(n=1),n=e(n,7)),t.addHelp("size(m): "+e(i.x/n,3)+" W, "+e(i.y/n,3)+" L, "+e(i.z/n,3)+" H"),this.repaint=!0}return!1}}.bind(this),!0),document.addEventListener("keyup",function(e){17!=e.which&&91!=e.which||(h=!1),16===e.which&&(p=!1)}.bind(this))}))},get sky(){return this.options.sky},set sky(e){e?this.createSkyLayer():this.removeLayer(this.skyLayerName),this.options.sky=e},get terrain(){return this.options.terrain},set terrain(e){if(this.terrainLayerName="",e)this.createTerrainLayer();else{if(this.mapboxVersion<2)return void console.warn("Terrain layer are only supported by Mapbox-gl-js > v2.0");this.map.getTerrain()&&(this.map.setTerrain(null),this.map.removeSource(this.terrainSourceName))}this.options.terrain=e},get fov(){return this.options.fov},set fov(e){this.camera instanceof n.PerspectiveCamera&&this.options.fov!==e&&(this.map.transform.fov=e,this.camera.fov=this.map.transform.fov,this.cameraSync.setupCamera(),this.map.repaint=!0,this.options.fov=e)},get orthographic(){return this.options.orthographic},set orthographic(e){const t=this.map.getCanvas().clientHeight,i=this.map.getCanvas().clientWidth;e?(this.map.transform.fov=0,this.camera=new n.OrthographicCamera(i/-2,i/2,t/2,t/-2,.1,1e21)):(this.map.transform.fov=this.fov,this.camera=new n.PerspectiveCamera(this.map.transform.fov,i/t,.1,1e21)),this.camera.layers.enable(0),this.camera.layers.enable(1),this.cameraSync=new p(this.map,this.camera,this.world),this.map.repaint=!0,this.options.orthographic=e},createSkyLayer:function(){if(this.mapboxVersion<2)return console.warn("Sky layer are only supported by Mapbox-gl-js > v2.0"),void(this.options.sky=!1);this.map.getLayer(this.skyLayerName)||(this.map.addLayer({id:this.skyLayerName,type:"sky",paint:{"sky-opacity":["interpolate",["linear"],["zoom"],0,0,5,.3,8,1],"sky-type":"atmosphere","sky-atmosphere-sun":this.getSunSky(this.lightDateTime),"sky-atmosphere-sun-intensity":10}}),this.map.once("idle",(()=>{this.setSunlight(),this.repaint()})))},createTerrainLayer:function(){if(this.mapboxVersion<2)return console.warn("Terrain layer are only supported by Mapbox-gl-js > v2.0"),void(this.options.terrain=!1);this.map.getTerrain()||(this.map.addSource(this.terrainSourceName,{type:"raster-dem",url:"mapbox://mapbox.mapbox-terrain-dem-v1",tileSize:512,maxzoom:14}),this.map.setTerrain({source:this.terrainSourceName,exaggeration:this.terrainExaggeration}),this.map.once("idle",(()=>{this.cameraSync.updateCamera(),this.repaint()})))},sphere:function(e){return this.setDefaultView(e,this.options),S(e,this.world)},line:ne,label:C,tooltip:L,tube:function(e){return this.setDefaultView(e,this.options),oe(e,this.world)},extrusion:function(e){return this.setDefaultView(e,this.options),E(e)},Object3D:function(e){return this.setDefaultView(e,this.options),T(e)},loadObj:async function(e,t){if(this.setDefaultView(e,this.options),!1===e.clone)return new Promise((async i=>{J(e,t,(async e=>{i(e)}))}));{let i=this.objectsCache.get(e.obj);i?i.promise.then((i=>{t(i.duplicate(e))})).catch((t=>{this.objectsCache.delete(e.obj),console.error("Could not load model file: "+e.obj)})):this.objectsCache.set(e.obj,{promise:new Promise((async(i,n)=>{J(e,t,(async e=>{e.duplicate?i(e.duplicate()):n(e)}))}))})}},material:function(e){return m(e)},initLights:{ambientLight:null,dirLight:null,dirLightBack:null,dirLightHelper:null,hemiLight:null,pointLight:null},utils:u,SunCalc:f,Constants:r,projectToWorld:function(e){return this.utils.projectToWorld(e)},unprojectFromWorld:function(e){return this.utils.unprojectFromWorld(e)},projectedUnitsPerMeter:function(e){return this.utils.projectedUnitsPerMeter(e)},getFeatureCenter:function(e,t,i){return u.getFeatureCenter(e,t,i)},getObjectHeightOnFloor:function(e,t,i){return u.getObjectHeightOnFloor(e,t,i)},queryRenderedFeatures:function(e){let t=new n.Vector2;return t.x=e.x/this.map.transform.width*2-1,t.y=1-e.y/this.map.transform.height*2,this.raycaster.setFromCamera(t,this.camera),this.raycaster.intersectObjects(this.world.children,!0)},findParent3DObject:function(e){var t;return e.object.traverseAncestors((function(e){e.parent&&"Group"==e.parent.type&&e.userData.obj&&(t=e)})),t},setLayoutProperty:function(e,t,i){this.map.setLayoutProperty(e,t,i),null!=i&&"visibility"===t&&this.world.children.filter((t=>t.layer===e)).forEach((e=>{e.visibility=i}))},setLayerZoomRange:function(e,t,i){this.map.getLayer(e)&&(this.map.setLayerZoomRange(e,t,i),this.zoomLayers.includes(e)||this.zoomLayers.push(e),this.toggleLayer(e))},setLayerHeigthProperty:function(e,t){let i=this.map.getLayer(e);if(i)if("fill-extrusion"==i.type){let e=this.map.getStyle().sources[i.source].data;e.features.forEach((function(e){e.properties.level=t})),this.map.getSource(i.source).setData(e)}else"custom"==i.type&&this.world.children.forEach((function(i){let n=i.userData.feature;if(n&&n.layer===e){let e=this.tb.getFeatureCenter(n,i,t);i.setCoords(e)}}))},setObjectsScale:function(){this.world.children.filter((e=>null!=e.fixedZoom)).forEach((e=>{e.setObjectScale(this.map.transform.scale)}))},setStyle:function(e,t){this.clear().then((()=>{this.map.setStyle(e,t)}))},toggleLayer:function(e,t=!0){let i=this.map.getLayer(e);if(i){if(!t)return void this.toggle(i.id,!1);let e=this.map.getZoom();if(i.minzoom&&e=i.maxzoom)return void this.toggle(i.id,!1);this.toggle(i.id,!0)}},toggle:function(e,t){this.setLayoutProperty(e,"visibility",t?"visible":"none"),this.labelRenderer.toggleLabels(e,t)},update:function(){this.map.repaint&&(this.map.repaint=!1);var e=Date.now();this.objects.animationManager.update(e),this.updateLightHelper(),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this.labelRenderer.render(this.scene,this.camera),!1===this.options.passiveRendering&&this.map.triggerRepaint()},add:function(e,t,i){if(!this.enableTooltips&&e.tooltip&&(e.tooltip.visibility=!1),this.world.add(e),t){e.layer=t,e.source=i;let n=this.map.getLayer(t);if(n){let t=n.visibility,i=void 0===t;e.visibility=!(!i&&"visible"!==t)}}},removeByName:function(e){let t=this.world.getObjectByName(e);t&&this.remove(t)},remove:function(e){this.map.selectedObject&&e.uuid==this.map.selectedObject.uuid&&this.map.unselectObject(),this.map.draggedObject&&e.uuid==this.map.draggedObject.uuid&&(this.map.draggedObject=null),e.dispose&&e.dispose(),this.world.remove(e),e=null},clear:async function(e=null,t=!1){return new Promise(((i,n)=>{let r=[];this.world.children.forEach((function(e){r.push(e)}));for(let t=0;t{e.promise.then((e=>{e.dispose(),e=null}))})),i("clear")}))},removeLayer:function(e){this.clear(e,!0).then((()=>{this.map.removeLayer(e)}))},getSunPosition:function(e,t){return f.getPosition(e||Date.now(),t[1],t[0])},getSunTimes:function(e,t){return f.getTimes(e,t[1],t[0],t[2]?t[2]:0)},setBuildingShadows:function(e){if(this.map.getLayer(e.buildingsLayerId)){let t=new ae(e,this);this.map.addLayer(t,e.buildingsLayerId)}else console.warn("The layer '"+e.buildingsLayerId+"' does not exist in the map.")},setSunlight:function(e=new Date,t){if(!this.lights.dirLight||!this.options.realSunlight)return void console.warn("To use setSunlight it's required to set realSunlight : true in Threebox initial options.");var i=new Date(e.getTime());if(t?t.lng&&t.lat?this.mapCenter=t:this.mapCenter={lng:t[0],lat:t[1]}:this.mapCenter=this.map.getCenter(),this.lightDateTime&&this.lightDateTime.getTime()===i.getTime()&&this.lightLng===this.mapCenter.lng&&this.lightLat===this.mapCenter.lat)return;this.lightDateTime=i,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition=this.getSunPosition(i,[this.mapCenter.lng,this.mapCenter.lat]);let n=this.sunPosition.altitude,o=Math.PI+this.sunPosition.azimuth,s=r.WORLD_SIZE/2,a=Math.sin(n),l=Math.cos(n),c=Math.cos(o)*l,u=Math.sin(o)*l;this.lights.dirLight.position.set(u,c,a),this.lights.dirLight.position.multiplyScalar(s),this.lights.dirLight.intensity=Math.max(a,0),this.lights.hemiLight.intensity=Math.max(1*a,.1),this.lights.dirLight.updateMatrixWorld(),this.updateLightHelper(),this.map.loaded()&&(this.updateSunGround(this.sunPosition),this.map.setLight({anchor:"map",position:[3,180+180*this.sunPosition.azimuth/Math.PI,90-180*this.sunPosition.altitude/Math.PI],intensity:Math.cos(this.sunPosition.altitude),color:`hsl(40, ${50*Math.cos(this.sunPosition.altitude)}%, ${Math.max(20,20+96*Math.sin(this.sunPosition.altitude))}%)`},{duration:0}),this.sky&&this.updateSunSky(this.getSunSky(i,this.sunPosition)))},getSunSky:function(e,t){if(!t){var i=this.map.getCenter();t=this.getSunPosition(e||Date.now(),[i.lng,i.lat])}return[180+180*t.azimuth/Math.PI,90-180*t.altitude/Math.PI]},updateSunSky:function(e){this.sky&&this.map.setPaintProperty(this.skyLayerName,"sky-atmosphere-sun",e)},updateSunGround:function(e){""!=this.terrainLayerName&&this.map.setPaintProperty(this.terrainLayerName,"raster-opacity",Math.max(Math.min(1,4*e.altitude),.25))},updateLightHelper:function(){this.lights.dirLightHelper&&(this.lights.dirLightHelper.position.setFromMatrixPosition(this.lights.dirLight.matrixWorld),this.lights.dirLightHelper.updateMatrix(),this.lights.dirLightHelper.update())},dispose:async function(){return console.log(this.memory()),new Promise((e=>{e(this.clear(null,!0).then((e=>(this.map.remove(),this.map={},this.scene.remove(this.world),this.world.children=[],this.world=null,this.objectsCache.clear(),this.labelRenderer.dispose(),console.log(this.memory()),this.renderer.dispose(),e))))}))},defaultLights:function(){this.lights.ambientLight=new n.AmbientLight(new n.Color("hsl(0, 0%, 100%)"),.75),this.scene.add(this.lights.ambientLight),this.lights.dirLightBack=new n.DirectionalLight(new n.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLightBack.position.set(30,100,100),this.scene.add(this.lights.dirLightBack),this.lights.dirLight=new n.DirectionalLight(new n.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLight.position.set(-30,100,-100),this.scene.add(this.lights.dirLight)},realSunlight:function(e=!1){this.renderer.shadowMap.enabled=!0,this.lights.dirLight=new n.DirectionalLight(16777215,1),this.scene.add(this.lights.dirLight),e&&(this.lights.dirLightHelper=new n.DirectionalLightHelper(this.lights.dirLight,5),this.scene.add(this.lights.dirLightHelper)),this.lights.dirLight.castShadow=!0,this.lights.dirLight.shadow.radius=2,this.lights.dirLight.shadow.mapSize.width=8192,this.lights.dirLight.shadow.mapSize.height=8192,this.lights.dirLight.shadow.camera.top=this.lights.dirLight.shadow.camera.right=1e3,this.lights.dirLight.shadow.camera.bottom=this.lights.dirLight.shadow.camera.left=-1e3,this.lights.dirLight.shadow.camera.near=1,this.lights.dirLight.shadow.camera.visible=!0,this.lights.dirLight.shadow.camera.far=4e8,this.lights.hemiLight=new n.HemisphereLight(new n.Color(16777215),new n.Color(16777215),.6),this.lights.hemiLight.color.setHSL(.661,.96,.12),this.lights.hemiLight.groundColor.setHSL(.11,.96,.14),this.lights.hemiLight.position.set(0,0,50),this.scene.add(this.lights.hemiLight),this.setSunlight(),this.map.once("idle",(()=>{this.setSunlight(),this.repaint()}))},setDefaultView:function(e,t){e.bbox=(e.bbox||null==e.bbox)&&t.enableSelectingObjects,e.tooltip=(e.tooltip||null==e.tooltip)&&t.enableTooltips,e.mapScale=this.map.transform.scale},memory:function(){return this.renderer.info.memory},programs:function(){return this.renderer.info.programs.length},version:"2.2.6"};var ue={defaultLights:!1,realSunlight:!1,realSunlightHelper:!1,passiveRendering:!0,preserveDrawingBuffer:!1,enableSelectingFeatures:!1,enableSelectingObjects:!1,enableDraggingObjects:!1,enableRotatingObjects:!1,enableTooltips:!1,multiLayer:!1,orthographic:!1,fov:r.FOV_DEGREES,sky:!1,terrain:!1};le=le=ce,window.Threebox=le,window.THREE=n}();!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).turf=e()}}((function(){return function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s=c&&u===n.length-1);u++){if(c>=t){var h=t-c;if(h){var p=r.default(n[u],n[u-1])-180;return o.default(n[u],h,p,i)}return a.point(n[u])}c+=s.default(n[u],n[u+1],i)}return a.point(n[n.length-1])}},{"@turf/bearing":4,"@turf/destination":8,"@turf/distance":9,"@turf/helpers":11,"@turf/invariant":12}],3:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/meta");function r(e){var t=[1/0,1/0,-1/0,-1/0];n.coordEach(e,(function(e){t[0]>e[0]&&(t[0]=e[0]);t[1]>e[1]&&(t[1]=e[1]);t[2]=e[0]&&t[3]>=e[1]}(o,l))return!1;"Polygon"===a&&(c=[c]);for(var u=!1,h=0;he[1]!=c>e[1]&&e[0]<(l-s)*(e[1]-a)/(c-a)+s&&(n=!n)}return n}},{"@turf/invariant":12}],6:[function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0});var r=n(e("@turf/bbox")),o=e("@turf/helpers");i.default=function(e,t){void 0===t&&(t={});var i=r.default(e),n=(i[0]+i[2])/2,s=(i[1]+i[3])/2;return o.point([n,s],t.properties,t)}},{"@turf/bbox":3,"@turf/helpers":11}],7:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});function n(e){var t={type:"Feature"};Object.keys(e).forEach((function(i){switch(i){case"type":case"properties":case"geometry":return;default:t[i]=e[i]}}));t.properties=r(e.properties);t.geometry=o(e.geometry);return t}function r(e){var t={};if(!e)return t;Object.keys(e).forEach((function(i){var n=e[i];"object"==typeof n?null===n?t[i]=null:Array.isArray(n)?t[i]=n.map((function(e){return e})):t[i]=r(n):t[i]=n}));return t}function o(e){var t={type:e.type};e.bbox&&(t.bbox=e.bbox);if("GeometryCollection"===e.type){t.geometries=e.geometries.map((function(e){return o(e)}));return t}t.coordinates=s(e.coordinates);return t}function s(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map((function(e){return s(e)}))}i.default=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return n(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};Object.keys(e).forEach((function(i){switch(i){case"type":case"features":return;default:t[i]=e[i]}}));t.features=e.features.map((function(e){return n(e)}));return t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return o(e);default:throw new Error("unknown GeoJSON type")}}},{}],8:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers"),r=e("@turf/invariant");i.default=function(e,t,i,o){void 0===o&&(o={});var s=r.getCoord(e),a=n.degreesToRadians(s[0]),l=n.degreesToRadians(s[1]),c=n.degreesToRadians(i),u=n.lengthToRadians(t,o.units),h=Math.asin(Math.sin(l)*Math.cos(u)+Math.cos(l)*Math.sin(u)*Math.cos(c)),p=a+Math.atan2(Math.sin(c)*Math.sin(u)*Math.cos(l),Math.cos(u)-Math.sin(l)*Math.sin(h)),d=n.radiansToDegrees(p),f=n.radiansToDegrees(h);return n.point([d,f],o.properties)}},{"@turf/helpers":11,"@turf/invariant":12}],9:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/invariant"),r=e("@turf/helpers");i.default=function(e,t,i){void 0===i&&(i={});var o=n.getCoord(e),s=n.getCoord(t),a=r.degreesToRadians(s[1]-o[1]),l=r.degreesToRadians(s[0]-o[0]),c=r.degreesToRadians(o[1]),u=r.degreesToRadians(s[1]),h=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(l/2),2)*Math.cos(c)*Math.cos(u);return r.radiansToLength(2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),i.units)}},{"@turf/helpers":11,"@turf/invariant":12}],10:[function(e,t,i){"use strict";var n=e("@turf/meta"),r=e("@turf/helpers");function o(e){var t=[];"FeatureCollection"===e.type?n.featureEach(e,(function(e){n.coordEach(e,(function(i){t.push(r.point(i,e.properties))}))})):n.coordEach(e,(function(i){t.push(r.point(i,e.properties))}));return r.featureCollection(t)}t.exports=o;t.exports.default=o},{"@turf/helpers":11,"@turf/meta":16}],11:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.earthRadius=6371008.8;i.factors={centimeters:100*i.earthRadius,centimetres:100*i.earthRadius,degrees:i.earthRadius/111325,feet:3.28084*i.earthRadius,inches:39.37*i.earthRadius,kilometers:i.earthRadius/1e3,kilometres:i.earthRadius/1e3,meters:i.earthRadius,metres:i.earthRadius,miles:i.earthRadius/1609.344,millimeters:1e3*i.earthRadius,millimetres:1e3*i.earthRadius,nauticalmiles:i.earthRadius/1852,radians:1,yards:1.0936*i.earthRadius};i.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/i.earthRadius,yards:1.0936133};i.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function n(e,t,i){void 0===i&&(i={});var n={type:"Feature"};(0===i.id||i.id)&&(n.id=i.id);i.bbox&&(n.bbox=i.bbox);n.properties=t||{};n.geometry=e;return n}i.feature=n;i.geometry=function(e,t,i){void 0===i&&(i={});switch(e){case"Point":return r(t).geometry;case"LineString":return s(t).geometry;case"Polygon":return o(t).geometry;case"MultiPoint":return c(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return u(t).geometry;default:throw new Error(e+" is invalid")}};function r(e,t,i){void 0===i&&(i={});if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(e[0])||!f(e[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:e},t,i)}i.point=r;i.points=function(e,t,i){void 0===i&&(i={});return a(e.map((function(e){return r(e,t)})),i)};function o(e,t,i){void 0===i&&(i={});for(var r=0,o=e;r=0))throw new Error("precision must be a positive number");var i=Math.pow(10,t||0);return Math.round(e*i)/i};function h(e,t){void 0===t&&(t="kilometers");var n=i.factors[t];if(!n)throw new Error(t+" units is invalid");return e*n}i.radiansToLength=h;function p(e,t){void 0===t&&(t="kilometers");var n=i.factors[t];if(!n)throw new Error(t+" units is invalid");return e/n}i.lengthToRadians=p;i.lengthToDegrees=function(e,t){return d(p(e,t))};i.bearingToAzimuth=function(e){var t=e%360;t<0&&(t+=360);return t};function d(e){return 180*(e%(2*Math.PI))/Math.PI}i.radiansToDegrees=d;i.degreesToRadians=function(e){return e%360*Math.PI/180};i.convertLength=function(e,t,i){void 0===t&&(t="kilometers");void 0===i&&(i="kilometers");if(!(e>=0))throw new Error("length must be a positive number");return h(p(e,t),i)};i.convertArea=function(e,t,n){void 0===t&&(t="meters");void 0===n&&(n="kilometers");if(!(e>=0))throw new Error("area must be a positive number");var r=i.areaFactors[t];if(!r)throw new Error("invalid original units");var o=i.areaFactors[n];if(!o)throw new Error("invalid final units");return e/r*o};function f(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}i.isNumber=f;i.isObject=function(e){return!!e&&e.constructor===Object};i.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach((function(e){if(!f(e))throw new Error("bbox must only contain numbers")}))};i.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},{}],12:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers");i.getCoord=function(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")};i.getCoords=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")};i.containsNumber=function e(t){if(t.length>1&&n.isNumber(t[0])&&n.isNumber(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return e(t[0]);throw new Error("coordinates must only contain numbers")};i.geojsonType=function(e,t,i){if(!t||!i)throw new Error("type and name required");if(!e||e.type!==t)throw new Error("Invalid input to "+i+": must be a "+t+", given "+e.type)};i.featureOf=function(e,t,i){if(!e)throw new Error("No feature passed");if(!i)throw new Error(".featureOf() requires a name");if(!e||"Feature"!==e.type||!e.geometry)throw new Error("Invalid input to "+i+", Feature with geometry required");if(!e.geometry||e.geometry.type!==t)throw new Error("Invalid input to "+i+": must be a "+t+", given "+e.geometry.type)};i.collectionOf=function(e,t,i){if(!e)throw new Error("No featureCollection passed");if(!i)throw new Error(".collectionOf() requires a name");if(!e||"FeatureCollection"!==e.type)throw new Error("Invalid input to "+i+", FeatureCollection required");for(var n=0,r=e.features;n line1 must only contain 2 coordinates");if(2!==n.length)throw new Error(" line2 must only contain 2 coordinates");var s=i[0][0],a=i[0][1],l=i[1][0],c=i[1][1],u=n[0][0],h=n[0][1],p=n[1][0],d=n[1][1],f=(d-h)*(l-s)-(p-u)*(c-a),m=(p-u)*(a-h)-(d-h)*(s-u),g=(l-s)*(a-h)-(c-a)*(s-u);if(0===f)return null;var _=m/f,y=g/f;if(_>=0&&_<=1&&y>=0&&y<=1){var v=s+_*(l-s),x=a+_*(c-a);return r.point([v,x])}return null}i.default=function(e,t){var i={},n=[];"LineString"===e.type&&(e=r.feature(e));"LineString"===t.type&&(t=r.feature(t));if("Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var u=c(e,t);u&&n.push(u);return r.featureCollection(n)}var h=l.default();h.load(s.default(t));a.featureEach(s.default(e),(function(e){a.featureEach(h.search(e),(function(t){var r=c(e,t);if(r){var s=o.getCoords(r).join(",");if(!i[s]){i[s]=!0;n.push(r)}}}))}));return r.featureCollection(n)}},{"@turf/helpers":11,"@turf/invariant":12,"@turf/line-segment":15,"@turf/meta":16,"geojson-rbush":20}],15:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers"),r=e("@turf/invariant"),o=e("@turf/meta");i.default=function(e){if(!e)throw new Error("geojson is required");var t=[];o.flattenEach(e,(function(e){!function(e,t){var i=[],o=e.geometry;if(null!==o){switch(o.type){case"Polygon":i=r.getCoords(o);break;case"LineString":i=[r.getCoords(o)]}i.forEach((function(i){var r=function(e,t){var i=[];e.reduce((function(e,r){var o,s,a,l,c,u,h=n.lineString([e,r],t);h.bbox=(s=r,a=(o=e)[0],l=o[1],c=s[0],u=s[1],[ac?a:c,l>u?l:u]);i.push(h);return r}));return i}(i,e.properties);r.forEach((function(e){e.id=t.length;t.push(e)}))}))}}(e,t)}));return n.featureCollection(t)}},{"@turf/helpers":11,"@turf/invariant":12,"@turf/meta":16}],16:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("@turf/helpers");function r(e,t,i){if(null!==e)for(var n,o,s,a,l,c,u,h,p=0,d=0,f=e.type,m="FeatureCollection"===f,g="Feature"===f,_=m?e.features.length:1,y=0;y<_;y++){l=(h=!!(u=m?e.features[y].geometry:g?e.geometry:e)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var v=0;vc||d>u||f>h){l=r;c=i;u=d;h=f;s=0}else{var m=n.lineString([l,r],e.properties);if(!1===t(m,i,o,f,s))return!1;s++;l=r}}))&&void 0}}}))}function u(e,t){if(!e)throw new Error("geojson is required");l(e,(function(e,i,r){if(null!==e.geometry){var o=e.geometry.type,s=e.geometry.coordinates;switch(o){case"LineString":if(!1===t(e,i,r,0,0))return!1;break;case"Polygon":for(var a=0;a0){(b=x.features[0]).properties.dist=o.default(t,b,i);b.properties.location=h+o.default(d,b,i)}if(d.properties.distr;){if(o-r>600){var a=o-r+1,l=n-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);e(i,n,Math.max(r,Math.floor(n-l*u/a+h)),Math.min(o,Math.floor(n+(a-l)*u/a+h)),s)}var p=i[n],d=r,f=o;for(t(i,r,n),s(i[o],p)>0&&t(i,r,o);d0;)f--}0===s(i[r],p)?t(i,r,f):t(i,++f,o),f<=n&&(r=f+1),n<=f&&(o=f-1)}}(e,n,r||0,o||e.length-1,s||i)}function t(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function i(e,t){return et?1:0}var n=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(e,t,i){if(!i)return t.indexOf(e);for(var n=0;n=e.minX&&t.maxY>=e.minY}function f(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,i,n,r,o){for(var s=[i,n];s.length;)if(!((n=s.pop())-(i=s.pop())<=r)){var a=i+Math.ceil((n-i)/r/2)*r;e(t,a,i,n,o),s.push(i,a,a,n)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(e){var t=this.data,i=[];if(!d(e,t))return i;for(var n=this.toBBox,r=[];t;){for(var o=0;o=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(n,r,t)},n.prototype._split=function(e,t){var i=e[t],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);var s=this._chooseSplitIndex(i,r,n),a=f(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)},n.prototype._splitRoot=function(e,t){this.data=f([e,t]),this.data.height=e.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(e,t,i){for(var n,r,o,a,l,c,h,p=1/0,d=1/0,f=t;f<=i-t;f++){var m=s(e,0,f,this.toBBox),g=s(e,f,i,this.toBBox),_=(r=m,o=g,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);_=t;d--){var f=e.children[d];a(l,e.leaf?r(f):f),c+=h(l)}return c},n.prototype._adjustParentBBoxes=function(e,t,i){for(var n=i;n>=0;n--)a(t[n],e)},n.prototype._condense=function(e){for(var t=e.length-1,i=void 0;t>=0;t--)0===e[t].children.length?t>0?(i=e[t-1].children).splice(i.indexOf(e[t]),1):this.clear():o(e[t],this.toBBox)},n},"object"==typeof i&&void 0!==t?t.exports=r():(n=n||self).RBush=r();var n,r},{}]},{},[1])(1)}));class CustomHTMLControl{constructor(e){this.custom_html=e.custom_html}onAdd(e){this.map=e;this._container=document.createElement("div");this._container.innerHTML=this.custom_html;return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class DownloadControl{constructor(e,t,i,n){this.interact_with_filters=e.interact_with_filters;this.notify_on_download=e.notify_on_download;this.included_fields=e.included_fields;this.features=t.concat(i.concat(n))}addListeners(){jQuery(document).on("click",".mapster-data-download",(()=>{this.downloadFeatures()}))}downloadFeatures(){let e=this.processFeatures();e.length>0?this.downloadCSV(e):alert("No features selected for download.")}processFeatures(e){let t=[];this.features.forEach((e=>{if(this.interact_with_filters&&window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.indexOf(e.id)>-1)return;let i=e.data.location?e.data.location:e.data.line?e.data.line:e.data.polygon?e.data.polygon:null,n={};n.title=e.title;n.permalink=e.permalink;n.categories=e.categories.map((e=>e.name)).join(",");this.getRecursivePropertyValue(n,e.data.additional_details,"");n.geography=JSON.stringify(i);if(this.included_fields&&""!==this.included_fields){let e={};this.included_fields.split(",").forEach((t=>{let i=t.trim();n[i]&&(e[i]=n[i])}));n=e}t.push(n)}));return t}getRecursivePropertyValue(e,t,i){for(let n in t)Array.isArray(t[n])?e[i+n]=t[n].join(","):"object"==typeof t[n]?this.getRecursivePropertyValue(e,t[n],i+n+"_"):e[i+n]=JSON.stringify(t[n])}downloadCSV(e){const t=(e,t)=>null===t?"":t;let i=[];e.forEach((e=>{for(let t in e)-1===i.indexOf(t)&&i.push(t)}));e.forEach((e=>{i.forEach((t=>{e[t]||(e[t]="")}))}));let n=e.map((e=>i.map((i=>JSON.stringify(e[i],t).replace(/\\"/g,'""'))).join(",")));n.unshift(i.join(","));n=n.join("\r\n");var r=document.createElement("a"),o=new Blob(["\ufeff",n]),s=URL.createObjectURL(o);r.href=s;r.download="map-data-download.csv";document.body.appendChild(r);r.click();document.body.removeChild(r);if(this.notify_on_download){let e=[];jQuery(".mapster-category-control input").each((function(){jQuery(this).is(":checked")&&e.push(jQuery(this).closest("li").text().trim())}));fetch(`${window.mapster_params.rest_url}mapster-wp-maps/send-email`,{method:"POST",body:JSON.stringify({users:this.notify_on_download,active_filters:e})})}}onAdd(e){this.map=e;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");if(window.mapster_params.public){this._container.className="mapboxgl-ctrl mapster-download-control";this._container.innerHTML='\n
\n \n
\n ';this.addListeners()}return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class ListControl{constructor(e,t,i,n,r,o){this.sort_by_distance=e.sort_by_distance;this.show_distance=e.show_distance;this.units=e.units;this.markers=r;this.mapLibrary=o;this.listing_type=e.listing_type;this.number_of_locations=e.number_of_locations;this.store_locator=e.store_locator_options.enable;this.sort_hours_by_day=e.store_locator_options.sort_hours_by_day;this.features=t.concat(i.concat(n));this.currentPage=1;this.storedBounds=null}storeLocatorHTML(e){return"
Upgrade to Mapster Pro to enable this functionality.
"}setHTML(e){const t=new MapsterHelpers;var i="
    ",n=[];this.features.forEach(((e,i)=>{if(!(window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.indexOf(e.id)>-1)){var r=t.makeFeatureJSON(e.data);if(this.show_distance||this.sort_by_distance){var o=turf.distance(turf.center(r).geometry.coordinates,this.getCenter());e.distance=o*("imperial"===this.units?.621371:1)}n.push(e)}}));this.sort_by_distance&&(n=n.sort(((e,t)=>e.distance>t.distance?1:-1)));var r=[];n.forEach(((e,t)=>{"paginate"===this.listing_type?this.number_of_locations*(this.currentPage-1)<=t&&this.number_of_locations*this.currentPage>t&&r.push(e):r=n}));this.store_locator?i=this.storeLocatorHTML(i,r):r.forEach((e=>{i+=`\n
  • \n ${e.title}\n ${e.distance?e.distance.toFixed(2)+("imperial"===this.units?" miles":" km"):""}\n
  • \n `}));i+="
";if("paginate"===this.listing_type){i+='
';this.currentPage>1&&(i+='');this.number_of_locations*this.currentPage');i+="
"}if(e)return i;jQuery(".mapster-list-control-content").html(i)}getStoreHTML(e){return""}getCenter(){return[this.map.getCenter().lng,this.map.getCenter().lat]}addListeners(){var e=this;const t=new MapsterHelpers;jQuery(document).on("click",".mapster-list-control li",(function(i){if(!i.isTrigger){var n=e.features.find((e=>parseInt(e.id)==jQuery(this).data("id"))),r=t.makeFeatureJSON(n.data).features[0];if("Point"===r.geometry.type){const t=e.markers.find((e=>e.mapsterProperties.id===n.id));t&&n.data.enable_popup&&e.openPopup(t,n);!t&&n.data.enable_popup&&e.openPopupNonMarker(n);e.centerMap(r.geometry.coordinates,15)}else{var o=turf.bbox(r);e.fitBounds(o,{padding:20})}if(e.store_locator){jQuery(".mapster-list-control-content").hide();jQuery(".mapster-list-control-single-content").show();jQuery(".mapster-list-control-single-content").html(e.getStoreHTML(n))}}}));jQuery(document).on("click",".mapster-next",(()=>{this.currentPage=this.currentPage+1;this.setHTML()}));jQuery(document).on("click",".mapster-back",(()=>{this.currentPage=this.currentPage-1;this.setHTML()}));jQuery(document).on("click",".mapster-store-locator-results",(()=>{jQuery(".mapster-list-control-content").show();jQuery(".mapster-list-control-single-content").hide();jQuery(".mapster-list-control-single-content").empty();this.fitBounds(this.storedBounds)}));jQuery(document).on("change",".mapster-cat-toggle",(()=>{this.setHTML()}))}openPopup(e,t){const i=new MapsterHelpers;e.setPopup(new this.mapLibrary.Popup(i.returnPopupOptions(t.data)).setHTML(i.getPopupHTML(t.id,t.data))).togglePopup()}openPopupNonMarker(e){let t=this;const i=setInterval((()=>{if(t.map.getBounds().contains(e.data.location.coordinates)){t.map.fire("click",{lngLat:e.data.location.coordinates,originalEvent:{}});clearInterval(i)}}),100)}centerMap(e,t){this.map.flyTo({center:e,zoom:t})}fitBounds(e,t){this.map.fitBounds(e,t)}onAdd(e){this.map=e;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-list-control"+(this.store_locator?" mapster-store-locator":"")+(window.innerWidth<768?" mapster-mobile":"");this._container.innerHTML=`
`+this.setHTML(!0)+`
`;if(window.innerWidth<768&&this.store_locator){jQuery(this.map._container).css("overflow","visible");this._container.style.marginTop=`${jQuery(this.map._container).height()}px`;jQuery(this.map._container).after(`
`);jQuery(".maplibregl-control-container > div, .mapboxgl-control-container > div").width("100%");jQuery(".mapboxgl-ctrl-geocoder").width("100%")}this.addListeners();this.map.on("moveend",(()=>{this.setHTML()}));setTimeout((()=>{this.store_locator&&!jQuery(".mapster-store-locator .mapboxgl-ctrl-geocoder").length&&jQuery(".mapboxgl-ctrl-geocoder").prependTo(".mapster-store-locator")}),100);return this._container}onAddGoogleMap(e){this.map=e;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-list-control mapster-list-control-google"+(this.store_locator?" mapster-store-locator":"")+(window.innerWidth<768?" mapster-mobile":"");this._container.innerHTML=`
`+this.setHTML(!0)+`
`;this.addListeners();this.map.addListener("dragend",(()=>{this.setHTML()}));google.maps.event.addListenerOnce(this.map,"idle",(()=>{this.store_locator&&setTimeout((()=>{jQuery(".mapster-google-geocoder-input").addClass("geocoder-google-store-locator");jQuery(".mapster-google-geocoder-input").prependTo(".mapster-store-locator")}),1e3);const e=this.map.getBounds();this.storedBounds=[e.getSouthWest().lng(),e.getSouthWest().lat(),e.getNorthEast().lng(),e.getNorthEast().lat()]}));return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}} ;class PitchToggle{constructor(e=-20,t=70,i=null){this._bearing=-20;this._pitch=70;this._minpitchzoom=i}onAdd(e){this._map=e;let t=this;this._btn=document.createElement("button");this._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-3d";this._btn.type="button";this._btn["aria-label"]="Toggle Pitch";this._btn.onclick=function(){if(0===e.getPitch()){let i={pitch:t._pitch,bearing:t._bearing};t._minpitchzoom&&e.getZoom()>t._minpitchzoom&&(i.zoom=t._minpitchzoom);e.easeTo(i);t._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-2d"}else{e.easeTo({pitch:0,bearing:0});t._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-3d"}};this._container=document.createElement("div");this._container.className="mapboxgl-ctrl-group mapboxgl-ctrl";this._container.appendChild(this._btn);return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class CategoryControl{constructor(e,t,i,n,r,o,s,a,l,c,u){this.displayMode=e.category_display;this.checkboxMode=e.checkbox_display;this.initialVisibility=e.initial_visibility;this.preSelectedCategories=e.pre_selected_categories;this.independentChildren=e.independent_children;this.excludedCategories=e.excluded_categories;this.functionality=e.functionality;this.additional_filters=e.additional_filters;this.accordion_layout=e.accordion_layout;this.show_number_of_features=e.show_number_of_features;this.did_one_accordion=!1;this.markers=i;this.map_provider=a;this.circle_clustering=l;this.label_icon_clustering=c;this.marker_clustering=u;this.cluster_options=t;this.features=r.concat(o.concat(s));this.dataLayers=n;this.locations=r;this.lines=o;this.polygons=s}setMarkers(e){this.markers=e}organizeCategories(){var e=[];this.features.forEach((t=>{t.categories.forEach((t=>{-1===e.findIndex((e=>e.id===t.id))&&e.push(t)}))}));return e=this.filterCategories(e)}returnHTML(){return`\n
\n ${this.returnCategoryHTML(this.organizeCategories())}\n
\n `}returnCategoryHTML(e){var t="
    ";e.filter((e=>0===e.parent)).forEach(((i,n)=>{var r=e.filter((e=>e.parent===i.id));t+=this.returnInputHTML(i,r);t+=this.returnChildrenHTML(i,e)}));return t+="
"}returnChildrenHTML(e,t){var i="
    ",n=t.filter((t=>t.parent===e.id));n.forEach((e=>{i+=this.returnInputHTML(e,[]);i+=this.returnChildrenHTML(e,t)}));i+="
";0===n.length&&(i="");return i}returnInputHTML(e,t){var i=!0;!this.initialVisibility&&this.preSelectedCategories&&-1===this.preSelectedCategories.indexOf(e.id)&&(i=!1);return this.returnAccordionHTML(`\n
  • \n ${"checkbox"===this.checkboxMode?`\n \n `:`\n \n `}\n ${"colors"===this.displayMode?`
    `:""}\n ${"icons"===this.displayMode?`
    `:""}\n \n
  • \n `,e,t)}setToggles(e){var t=jQuery(e).data("term"),i=jQuery(e).data("parent"),n=jQuery(e).is(":checked");if(!this.independentChildren)if(0===i)n?jQuery(`.mapster-cat-toggle[data-parent="${t}"]`).prop("checked",!0):jQuery(`.mapster-cat-toggle[data-parent="${t}"]`).prop("checked",!1);else if(n)jQuery(`.mapster-cat-toggle[data-term="${i}"]`).prop("checked",!0);else{var r=!0;jQuery(`.mapster-cat-toggle[data-parent="${i}"]`).each((function(){jQuery(this).is(":checked")&&(r=!1)}));r&&jQuery(`.mapster-cat-toggle[data-term="${i}"]`).prop("checked",!1)}}returnIDsToHideFeatures(e){let t=[];this.features.forEach((i=>{if(i.categories.length>0)if("exclusive"===this.functionality)i.categories.find((t=>e.indexOf(t.id)>-1))&&t.push(i.id);else if("inclusive"===this.functionality){var n=!0;i.categories.forEach((t=>{-1===e.indexOf(t.id)&&(n=!1)}));n&&t.push(i.id)}}));return t}returnNumberOfFeatures(){return!1}adjustMarkers(e){let t=[];this.markers.forEach((i=>{const n=this.returnMarkerProperties(i);if(n.categories.length>0)if("exclusive"===this.functionality)if(n.categories.find((t=>e.indexOf(t.id)>-1))){this.changeMarker("hide",i);t.push(i.mapsterProperties.id)}else this.changeMarker("show",i);else if("inclusive"===this.functionality){var r=!0;if(n.categories.length>0){n.categories.forEach((t=>{-1===e.indexOf(t.id)&&(r=!1)}));if(r){this.changeMarker("hide",i);t.push(i.mapsterProperties.id)}else this.changeMarker("show",i)}}}));this.adjustMarkerClusters(t)}adjustMarkerClusters(e){if(this.marker_clustering){let t=["marker"];(new MapsterHelpers).makeClusters(this.map,this.map_provider,this.cluster_options,t,this.locations,[],[],e)}}returnAccordionHTML(e,t,i){return e}filterCategories(e){return e}changeMarker(e,t){"hide"===e?t.remove():"show"===e&&t.addTo(this.map)}changeLayerVisibility(){var e=[];jQuery(".mapster-cat-toggle").each((function(){jQuery(this).is(":checked")||e.push(jQuery(this).data("term"))}));var t=this.returnIDsToHideFeatures(e);this.setHiddenFeatures(t);this.adjustMarkers(e)}setHiddenFeatures(e){if(this.map.getLayer("symbol")){this.map.getLayer("symbol-clusters")&&(new MapsterHelpers).setClustering(this.map,this.map_provider,this.cluster_options,this.circle_clustering,this.label_icon_clustering,this.marker_clustering,this.markers,this.locations,this.lines,this.polygons,e);this.map.setLayoutProperty("symbol","text-size",["case",["in",["get","post_id"],["literal",e]],0,["==",!1,["get","label_label_on"]],0,["has","label_text_properties_text-size"],["to-number",["get","label_text_properties_text-size"]],16]);this.map.setLayoutProperty("symbol","icon-size",["case",["in",["get","post_id"],["literal",e]],0,["==",!1,["get","icon_icon_on"]],0,["has","icon_icon_properties_icon-size"],["/",["to-number",["get","icon_icon_properties_icon-size"]],100],1])}if(this.map.getLayer("circle")){this.map.setPaintProperty("circle","circle-radius",["case",["in",["get","post_id"],["literal",e]],0,["has","circle_radius"],["to-number",["get","circle_radius"]],0]);this.map.setPaintProperty("circle","circle-stroke-width",["case",["in",["get","post_id"],["literal",e]],0,["has","circle_radius"],["to-number",["get","circle_radius"]],0])}this.map.getLayer("line")&&this.map.setPaintProperty("line","line-width",["case",["in",["get","post_id"],["literal",e]],0,["has","width"],["to-number",["get","width"]],2]);if(this.map.getLayer("fill")){const t=new MapsterHelpers;let i=this.polygons.filter((t=>-1===e.indexOf(t.id))),n=t.createLayerGeoJSON(this.map,"polygon","fill",[],[],i);this.map.getSource("fill").setData(n)}}returnMarkerProperties(e){return e.mapsterProperties}addListeners(){var e=this;jQuery(document).on("change",".mapster-cat-toggle",(function(){e.setToggles(this);e.changeLayerVisibility()}));jQuery(document).on("click",".mapster-accordion-indicator",(function(){let e=!1;jQuery(this).parent().hasClass("mapster-accordion-indicator-open")&&(e=!0);jQuery(".mapster-accordion-indicator").each((function(){if(jQuery(this).parent().next("ul").is(":visible")){jQuery(this).parent().next("ul").slideToggle(400,(()=>jQuery(this).parent().addClass("mapster-accordion-indicator-closed")));jQuery(this).parent().removeClass("mapster-accordion-indicator-open")}}));if(e)jQuery(this).parent().addClass("mapster-accordion-indicator-closed");else{jQuery(this).parent().addClass("mapster-accordion-indicator-open");jQuery(this).parent().next("ul").slideToggle()}}))}onAdd(e){this.map=e;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-category-control";this._container.innerHTML=this.returnHTML();this.initialVisibility||setTimeout((()=>{this.changeLayerVisibility()}),10);this.addListeners();return this._container}onAddGoogleMap(e){this.map=e;this._container=document.createElement("div");this._container.className="mapster-category-control mapster-google-category-control";this._container.innerHTML=this.returnHTML();this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this.map=void 0}} ;class LayerControl{constructor(e){this.toggleable_layers=e.toggleable_layers;this.toggleable_layer_titles=e.toggleable_layer_titles;this.checkbox_type=e.checkbox_type}returnHTML(){let e='
      ';const t=this.toggleable_layers.replace("\r","").split("\n"),i=this.toggleable_layer_titles.replace("\r","").split("\n");t.forEach(((t,n)=>{e+="
    • ";const r=t.split(",");let o=!0,s=!0;r.forEach((e=>{if(""!==e){this.map.getLayer(e.trim())||(o=!1);"hidden"!==this.map.getLayoutProperty(e.trim(),"visibility")&&void 0===this.map.getLayoutProperty(e.trim(),"visibility")||(s=!1)}}));o?"checkbox"===this.checkbox_type?e+=` ${i[n]}`:"radio"===this.checkbox_type?e+=` ${i[n]}`:"switch"===this.checkbox_type&&(e+=` ${i[n]}`):alert("Please double check the layers you've set for the layer control: some don't exist in the style!");e+="
    • "}));e+="
    ";return e}changeLayerVisibility(){let e=this;jQuery(".mapster-layer-toggle").each((function(){jQuery(this).data("layers").split(",").forEach((t=>{jQuery(this).is(":checked")?e.map.setLayoutProperty(t.trim(),"visibility","visible"):e.map.setLayoutProperty(t.trim(),"visibility","none")}))}))}addListeners(){var e=this;jQuery(document).on("change",".mapster-layer-toggle",(function(){e.changeLayerVisibility()}))}onAdd(e){this.map=e;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-layer-control";const t=setInterval((()=>{if(this.map.isStyleLoaded()){this._container.innerHTML=this.returnHTML();clearInterval(t)}}),100);this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class StyleControl{constructor(e){this.toggleable_styles=e.toggleable_styles;this.toggleable_styles_titles=e.toggleable_styles_titles;this.initial_style_title=e.initial_style_title;this.default_style=!1}returnHTML(){let e='
      ';this.default_style=this.map.getStyle();e+=`
    • ${this.initial_style_title}`;const t=this.toggleable_styles.replace("\r","").split("\n"),i=this.toggleable_styles_titles.replace("\r","").split("\n");t.forEach(((t,n)=>{if(""!==t){e+="
    • ";e+=` ${i[n]}`;e+="
    • "}}));e+="
    ";return e}addListeners(){var e=this;new MapsterHelpers;jQuery(document).on("change",".mapster-style-toggle",(function(){const t=jQuery(this).data("index");if("default"!==t){const i=e.toggleable_styles.split("\n");i[t].indexOf("{")>-1?e.map.setStyle(JSON.parse(i[t])):e.map.setStyle(i[t]);e.map.fire("mapster_custom_style_load")}else{e.map.setStyle(e.default_style);e.map.fire("mapster_custom_style_load")}}))}onAdd(e){this.map=e;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-style-control";const t=setInterval((()=>{if(this.map.isStyleLoaded()){this._container.innerHTML=this.returnHTML();clearInterval(t)}}),100);this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class ElevationControl{constructor(e){this.lines=e.lines;this.post_id=e.post_id;this.single_line=e.single_line;this.open_on_load=e.open_on_load;this.profile_color=e.profile_color;this.units=e.units;this.show_line_length=e.show_line_length;this.profile_displayed=!1;this.last_line_displayed=!1}addListeners(){jQuery(document).on("click",".mapster-elevation-control-content",(()=>{if(this.profile_displayed){this.removeElevation();this.profile_displayed=!1;jQuery(".mapster-elevation-control-content").removeClass("mapster-elevation-control-active")}else{jQuery(".mapster-elevation-control-content");if(this.map.getSource("mapbox-dem"))this.addElevation(this.last_line_displayed);else{this.loadElevationData();this.map.once("idle",(()=>{this.addElevation(this.last_line_displayed)}))}this.profile_displayed=!0;jQuery(".mapster-elevation-control-content").addClass("mapster-elevation-control-active")}}));this.single_line&&this.open_on_load&&setTimeout((()=>{this.last_line_displayed=this.lines[0];jQuery(".mapster-elevation-control-content").click()}),1e3);this.single_line||this.map.on("click","line",(e=>{this.last_line_displayed=this.lines.find((t=>t.id===e.features[0].properties.post_id));this.profile_displayed&&jQuery(".mapster-elevation-control-content").click();jQuery(".mapster-elevation-control-content").click()}));this.map.on("mousemove",(()=>{this.map.getLayer("elevation-point-along-layer")&&this.map.setLayoutProperty("elevation-point-along-layer","visibility","none")}))}loadElevationData(){this.map.addSource("mapbox-dem",{type:"raster-dem",url:"mapbox://mapbox.terrain-rgb",tileSize:512,maxzoom:14});this.map.setTerrain({source:"mapbox-dem",exaggeration:1.5})}removeElevation(){document.getElementById("mapster-chartjs-container").remove()}addElevation(e){let t=[],i=turf.length(e.data.line);for(let n=0;n""));if(this.show_line_length){s=[];t.forEach(((e,t)=>{let n=i/50;"feet"===this.units&&(n*=.621371);let r=parseInt(t*n*10)/10;s.push(r)}))}new Chart(document.getElementById("mapster-chartjs"),{type:"line",data:{labels:s,datasets:[{label:"Elevation",data:t,fill:!1,borderColor:this.profile_color,pointRadius:0,tension:.2}]},options:o.returnElevationChartOptions(this.units,this.show_line_length),plugins:[o.returnElevationChartPlugin(this.map,e)]})}onAdd(e){this.map=e;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");if(window.mapster_params.public){this._container.className="mapboxgl-ctrl mapster-elevation-control";this._container.innerHTML='\n
    \n \n
    \n ';this.addListeners()}return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class MapsterConstants{returnElevationChartPlugin(e,t){return{id:"corsair",afterInit:e=>{e.corsair={x:0,y:0}},afterEvent:(e,t)=>{const{chartArea:{top:i,bottom:n,left:r,right:o}}=e,{event:{x:s,y:a}}=t;if(so||an){e.corsair={x:s,y:a,draw:!1};e.draw()}else{e.corsair={x:s,y:a,draw:!0};e.draw()}},afterDatasetsDraw:(i,n,r)=>{const{ctx:o,chartArea:{top:s,bottom:a,left:l,right:c}}=i,{x:u,y:h,draw:p}=i.corsair;if(!p)return;o.lineWidth=r.width||0;o.setLineDash(r.dash||[]);o.strokeStyle=r.color||"black";o.save();o.beginPath();o.moveTo(u,a);o.lineTo(u,s);o.stroke();o.restore();const d=(u-l)/(c-l);let f=turf.length(t.data.line),m=turf.along(t.data.line,f*d);if(e.getSource("elevation-point-along")&&e.getLayer("elevation-point-along-layer")){e.getSource("elevation-point-along").setData(m);e.setLayoutProperty("elevation-point-along-layer","visibility","visible")}else{e.addSource("elevation-point-along",{type:"geojson",data:m});e.addLayer({id:"elevation-point-along-layer",type:"circle",source:"elevation-point-along"})}}}}returnElevationChartOptions(e,t){return{interaction:{intersect:!1,mode:"index"},scales:{x:{title:{display:!!t,text:"meters"===e?"KM":"Miles",font:{style:"italic",size:10}},grid:{display:!0},ticks:{font:{size:10}}}},maintainAspectRatio:!1,plugins:{legend:{display:!1},title:{display:!0,text:`Elevation (${"meters"===e?"m":"ft"})`},tooltip:{displayColors:!1,callbacks:{label:function(t){return parseInt(10*t.parsed.y)/10+" "+("meters"===e?"m":"ft")}}},corsair:{color:"#333",width:1}}}}returnStyleProviders(){return[{id:"streets",style:"mapbox://styles/mapbox/streets-v12"},{id:"outdoors",style:"mapbox://styles/mapbox/outdoors-v12"},{id:"light",style:"mapbox://styles/mapbox/light-v11"},{id:"dark",style:"mapbox://styles/mapbox/dark-v11"},{id:"satellite",style:"mapbox://styles/mapbox/satellite-v9"},{id:"satellite-streets",style:"mapbox://styles/mapbox/satellite-streets-v12"},{id:"custom-image",style:{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(255,255,255,1)"}}]}},{id:"empty",style:{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(255,255,255,1)"}}]}},{id:"open-street-map",style:this.returnJsonStyle("https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",'© OpenStreetMap contributors')},{id:"open-topo-map",style:this.returnJsonStyle("https://a.tile.opentopomap.org/{z}/{x}/{y}.png",'Map data: © OpenStreetMap contributors, SRTM | Map style: © OpenTopoMap (CC-BY-SA)')},{id:"cyclo-osm",style:this.returnJsonStyle("https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",'CyclOSM | Map data: © OpenStreetMap contributors')},{id:"toner-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png",'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors')},{id:"watercolor-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png",'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors')},{id:"terrain-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png",'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors')},{id:"esri-satellite",style:this.returnJsonStyle("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}","Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community")},{id:"blank-map",style:this.returnJsonStyle("https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",'© OpenStreetMap contributors')}]}returnJsonStyle(e,t){return{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{"raster-tiles":{type:"raster",tiles:[e],tileSize:256,attribution:t}},layers:[{id:"simple-tiles",type:"raster",source:"raster-tiles",minzoom:0,maxzoom:22}]}}loaderHTML(){return'\n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t'}markerAsSVG(e){return"data:image/svg+xml;charset=UTF-8,"+encodeURIComponent(`\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n `)}}class MapsterHelpers{constructor(){this.queuedImages=[]}isMobile(){let e=!1;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!0);return e}changeCursor(e,t,i){t.data.enable_popup&&(e.getCanvas().style.cursor="on"===i?"pointer":"grab")}formatResponse(e){["location","line","polygon"].forEach((t=>{e[t+"s"].forEach((i=>{this.setObjectProperties(i,e[t+"_template"]);this.setPopupStyles(i,e.popup_styles)}))}));return new Promise((t=>{t(e)}))}getDefaultCenter(){let e=[0,0];"1"===window.mapster_params.activated&&window.mapster_params.mapster_default_lat&&window.mapster_params.mapster_default_lng&&(e=[parseFloat(window.mapster_params.mapster_default_lng),parseFloat(window.mapster_params.mapster_default_lat)]);return e}getDefaultZoom(){let e=2;"1"===window.mapster_params.activated&&window.mapster_params.mapster_default_zoom&&(e=parseFloat(window.mapster_params.mapster_default_zoom));return e}doHover(e,t){let i=t.data.line?"line":t.data.symbol?"symbol":t.data.circle?"circle":t.data.polygon?"fill":[],n="line"===i||"fill"===i?t.data:"circle"===i?t.data.circle:t.data.symbol;if(n.hover_effects&&n.hover_effects.hover_enabled){e.removeFeatureState({source:i});e.setFeatureState({source:i,id:t.id},{hover:!0})}}doHoverOut(e,t){let i=t.data.line?"line":t.data.symbol?"symbol":t.data.circle?"circle":t.data.polygon?"fill":[],n="line"===i||"fill"===i?t.data:"circle"===i?t.data.circle:t.data.symbol;n.hover_effects&&n.hover_effects.hover_enabled&&e.setFeatureState({source:i,id:t.id},{hover:!1})}doMarkerHover(e,t,i){let n=i.mapsterProperties.data;if(n.marker.hover_effects.hover_enabled){const r=new t.Marker({color:n.marker.hover_effects.hover_color,scale:parseFloat(n.marker.hover_effects.hover_scale)/100,rotation:parseFloat(n.marker.hover_effects.hover_rotation),anchor:n.marker.anchor});-1===r._element.className.indexOf("mapster-remove-hover")&&(r._element.className+=" mapster-remove-hover");-1===i._element.className.indexOf("mapster-hide-original")&&(i._element.className+=" mapster-hide-original");r.setLngLat([i._lngLat.lng,i._lngLat.lat]).addTo(e);return r}return!1}doMarkerHoverOut(e,t){t._element.className.indexOf("mapster-hide-original")>-1&&(t._element.className=t._element.className.replace(" mapster-hide-original",""));e.remove()}setMapCompare(e,t,i,n){ }applyProSearchFilter(e,t){ return t}setGeolocationOnLoad(e){ }setMapBreakpointSizes(e,t){ }async getImageData(e){return wp.media.attachment(e).fetch().then((e=>e))}async setCustomImageMap(e,t,i){ }loadModalSteps(e,t,i,n,r,o){const s=new MapsterConstants;let a=!1,l=[];if("create_point"===n){if(r)if(1===r.length){a=r[0].term_id;if(o.submission_interface.include_address_search){c(e);u()}else{u();h()}}else{c(e);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n
    \n ${r.map((e=>`\n
    \n ${e.icon?`
    `:""}\n ${e.name?`

    ${e.name}

    `:""}\n ${e.description?`

    ${e.description}

    `:""}\n
    \n `)).join("")}\n
    \n `)}else{c(e);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n
    \n
    ${o.custom_texts.add_point_text}
    \n
    \n `)}jQuery(document).on("click",`#mapster-submission-modal-${e} .mapster-category-tile.mapster-cat-set`,(function(){"none"!==jQuery(this).data("category")&&(a=jQuery(this).data("category"));u()}))}if("edit_point"===n){const t=window.mapster_params.user_submission_permalink;c(e);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n ${s.loaderHTML()}\n \n \n `)}window.onmessage=function(e){if(e.data&&e.data.indexOf){e.data.indexOf("set_point")>-1&&u(e.data.replace("set_point-",""));if(e.data.indexOf("close_modal")>-1){jQuery(".mapster-submission-modal-overlay").fadeOut(50);jQuery(".mapster-submission-modal").fadeOut(100)}}};function c(e){jQuery(`.mapster-submit-${e} #mapster-submission-modal-overlay-${e}`).fadeIn(100);jQuery(`.mapster-submit-${e} #mapster-submission-modal-${e}`).fadeIn(150)}function u(n){o.submission_interface.include_address_search?jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n

    ${o.custom_texts.choose_how}

    \n
    \n ${o.submission_interface.include_address_search?`

    ${o.custom_texts.address_search}

    `:""}\n

    ${o.custom_texts.map_click}

    \n
    \n `):h();jQuery(document).on("click",`#mapster-submission-modal-${e} .mapster-category-tile.mapster-method-set`,(function(){if("address"===jQuery(this).data("method")){const n=new MapboxGeocoder({accessToken:o.submission_interface.mapbox_geocoder_access_token,mapboxgl:i,marker:!1});jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`

    ${o.custom_texts.search_location}

    `);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`)[0].appendChild(n.onAdd(t));n.on("result",(function(){h()}))}"click"===jQuery(this).data("method")&&h()}));jQuery(document).on("click",`#mapster-wp-maps-${e} .mapster-selection-instructions button`,(function(i){const n=t.getCenter();let r=!0;if(o.administration.allowed_area){const e=JSON.parse(o.administration.allowed_area);turf.booleanPointInPolygon([n.lng,n.lat],e.features[0])||(r=!1)}jQuery(".mapboxgl-ctrl").show();jQuery(".mapster-selection-overlay").remove();l=[n.lng,n.lat];jQuery(`#mapster-submission-modal-overlay-${e}`).fadeIn(100);jQuery(`#mapster-submission-modal-${e}`).fadeIn(150);jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n

    ${r?o.custom_texts.selection_saved:o.custom_texts.selection_error}

    \n
    \n

    ${o.custom_texts.try_again}

    \n ${r?`

    ${o.custom_texts.confirm}

    `:""}\n
    \n `)}));jQuery(document).on("click",`#mapster-submission-modal-${e} .mapster-category-tile.mapster-coords-set`,(function(){const t=window.mapster_params.user_submission_permalink;let i=!!o.administration.template_post&&o.administration.template_post.ID;if(o.administration.multiple_templates){let e=o.submission_interface.categories.indexOf(a);i=o.administration.template_posts[e]}let r=n?"&type=edit&post_id="+n:"";jQuery(`#mapster-submission-modal-${e} .mapster-submission-modal-content`).html(`\n ${s.loaderHTML()}\n \n \n `)}))}function h(){jQuery(".mapster-submission-modal-close").trigger("click");jQuery(".mapboxgl-ctrl").hide();jQuery(t._container).append(`\n
    \n
    \n

    ${o.custom_texts.drag_zoom}

    \n \n
    \n \n \n \n \n
    \n `)}}setProjectionGlobe(e,t){ }create3DModels(e,t){ }setPopupStyles(e,t){if(e.data.popup_style){let i=e.data.popup_style,n=t.find((e=>e.id===i));e.data.popup_style=n}}setObjectProperties(e,t){for(var i in t)if(this.isObject(t[i])){null==e[i]&&(e[i]={});this.setObjectProperties(e[i],t[i])}else null==e[i]&&(e[i]=t[i])}isObject(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}makeFeatureJSON(e){let t=e.line?e.line:e.location?e.location:!!e.polygon&&e.polygon;return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:t.type,coordinates:t.coordinates}}]}}getStyle(e){const t=new MapsterConstants;if(""!==e.custom_mapbox_style)return e.custom_mapbox_style;if("custom-image"===e.map_provider)return t.returnStyleProviders().find((e=>"custom-image"===e.id)).style;if(""!==e.access_token){var i=e.map_tile_style_access_token;return t.returnStyleProviders().find((e=>e.id===i)).style}i=e.map_tile_style_no_access_token;return t.returnStyleProviders().find((e=>e.id===i)).style}addMapControl(e,t,i,n,r,o={}){t&&e.removeControl(t);if(i){const t=new r(o);e.addControl(t,n);return t}return!1}searchLocalFeatures(e,t,i,n,r){var o={type:"FeatureCollection",features:[]};i.concat(n.concat(r)).forEach((e=>{var t=this.makeFeatureJSON(e.data);o.features.push(this.makeGeocoderResult(e,t))}));let s=this.localFeaturesTextMatch(e,t,o.features);s.sort(((e,t)=>e.place_name>t.place_name?1:-1));return s}localFeaturesTextMatch(e,t,i){let n=[];const r=t.split(" ").filter((e=>""!==e));i.forEach((i=>{var o=!1;i.properties.searchableTexts.forEach((s=>{var a={type:"Feature",id:i.properties.id,place_name:jQuery("
    ").html(i.properties.place_name).text()};if(!(window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.length>0&&-1!==window.mapster_categories_hidden_features.indexOf(i.properties.id))){if("exact-match"===e&&s&&(s.toLowerCase().indexOf(t.toLowerCase())>-1||" "===t)&&!o){a.center=turf.center(i).geometry.coordinates;"Point"!==i.geometry.type&&(a.bbox=turf.bbox(i));n.push(a);o=!0} }}))}));return n}initializeSlider(e,t){const i=e=>{jQuery("#mapster-slider ul").animate({left:jQuery("#mapster-slider ul li").width()*("right"===e?-1:1)},200,(()=>{jQuery("#mapster-slider ul li:first-child").appendTo("#mapster-slider ul");jQuery("#mapster-slider ul").css("left","")}))};if(!window.sliderClicksInitialized){jQuery(document).on("click","#mapster-slider .mapster-slider-control_prev",(function(){i("left")}));jQuery(document).on("click","#mapster-slider .mapster-slider-control_next",(function(){i("right")}));window.sliderClicksInitialized=!0}}makeHeatmap(e,t,i,n){ }createHeatmapProperties(e,t,i,n){ }fadeHeatmapFeatures(e,t){ }setClustering(e,t,i,n,r,o,s,a,l,c,u){if(r||n)return this.doSymbolClustering(e,t,i,n,r,a,l,c,u);o&&this.doMarkerClustering(e,t,i,o,s,a,u);return[]}doMarkerClustering(e,t,i,n,r,o,s){let a=i.cluster_by_category?i.categories_to_cluster.map((e=>"marker-"+e)):["marker"];this.makeClusters(e,t,i,a,o,[],[],s);e.on("render",(()=>{let t=[];a.forEach((i=>{if(!e.isSourceLoaded(i))return;const n=e.querySourceFeatures(i);t=t.concat(n.filter((e=>e.properties.id)).map((e=>e.properties.id)))}));r.forEach((i=>{-1===t.indexOf(i.mapsterProperties.id)?i.remove():(!i._popup||i._popup&&!i._popup.isOpen())&&i.addTo(e)}))}))}doSymbolClustering(e,t,i,n,r,o,s,a,l){var c=[];r&&(i.cluster_by_category?i.categories_to_cluster.forEach((e=>{c.push("symbol-"+e)})):c.push("symbol"));n&&(i.cluster_by_category?i.categories_to_cluster.forEach((e=>{c.push("circle-"+e)})):c.push("circle"));this.makeClusters(e,t,i,c,o,s,a,l);return c}makeClusters(e,t,i,n,r,o,s,a){n.forEach((t=>{e.getLayer(`${t}-cluster-count`)&&e.removeLayer(`${t}-cluster-count`);e.getLayer(`${t}-clusters`)&&e.removeLayer(`${t}-clusters`);e.getLayer(`${t}-clusters-border`)&&e.removeLayer(`${t}-clusters-border`);e.getLayer(t)&&e.removeLayer(t);if(e.getSource(t))try{e.removeSource(t)}catch(e){}}));n.forEach(((n,l)=>{let c,u=n.split("-")[0];if(e.getLayer(u)&&e.getSource(u)){e.removeLayer(u);e.removeSource(u)}c=n.indexOf("marker")>-1?this.createMarkerGeoJSON(r,n):this.createLayerGeoJSON(e,"location",n,r,o,s);a=a||[];var h=c.features.filter((e=>-1===a.indexOf(e.properties.post_id)));let p=!1;if(i.show_category_name){let e=r.concat(o.concat(s)),t=parseInt(n.split("-")[1]);e.forEach((e=>{p||(p=e.categories.find((e=>e.id===t)))}))}e.addSource(n,{type:"geojson",data:{type:"FeatureCollection",features:h},cluster:!0,clusterMaxZoom:14,clusterRadius:50});if(n.indexOf("marker")>-1)e.addLayer({id:n,source:n,type:"circle",filter:["!",["has","point_count"]],paint:{"circle-radius":0}});else{var d=this.getLayerExpressions("location",n.indexOf("symbol")>-1?"symbol":"circle",t);e.addLayer({id:n,source:n,type:n.split("-")[0],filter:["!",["has","point_count"]],paint:d.paint,layout:d.layout})}this.addIcons(e,n,c);let f="#51bbd6",m=100,g=20,_="#f1f075",y=750,v=30,x="#f28cb1",b=40; e.addLayer({id:`${n}-clusters`,type:"circle",source:n,filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],f,m,_,y,x],"circle-radius":["step",["get","point_count"],g,m,v,y,b]}});e.addLayer({id:`${n}-cluster-count`,type:"symbol",source:n,filter:["has","point_count"],layout:{"text-field":p?p.name:"{point_count_abbreviated}","text-font":"mapbox"===t?["DIN Offc Pro Medium","Arial Unicode MS Bold"]:["Open Sans Regular"],"text-size":12}});setTimeout((()=>{e.on("click",`${n}-clusters`,(t=>{const i=e.queryRenderedFeatures(t.point,{layers:[`${n}-clusters`]}),r=i[0].properties.cluster_id;e.getSource(n).getClusterExpansionZoom(r,((t,n)=>{e.easeTo({center:i[0].geometry.coordinates,zoom:n+1})}))}))}),500)}))}makeGeocoderResult(e,t){var i=t.features[0];i.properties={searchableTexts:[e.data.popup?e.data.popup.header_text:"",e.data.popup?e.data.popup.body_text:"",e.title,e.content],id:e.id,place_name:e.title};return i}modifyDropdown(e){e.container.classList.add("mapster-maps-dropdown");jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--icon.mapboxgl-ctrl-geocoder--icon-search").replaceWith('');jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--input").wrap('
    ');jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--input").attr("disabled",!0);jQuery(document).on("click",".mapster-maps-dropdown .input-wrapper",(()=>{e.setInput("");jQuery(".suggestions-wrapper .suggestions li").removeClass("active")}));jQuery(document).on("click",".mapboxgl-ctrl-geocoder--icon.mapboxgl-ctrl-geocoder--icon-close",(()=>{e.clear();jQuery(".suggestions-wrapper .suggestions").hide()}))}openExternalLink(e){e&&e.data.open_link_on_click&&e.data.click_link&&e.data.click_link.url&&(e.data.click_link.open_link_in_new_tab?window.open(e.data.click_link.url):window.open(e.data.click_link.url,"_self"))}getMapBounds(e,t,i){var n={type:"FeatureCollection",features:[]};[["location",e],["line",t],["polygon",i]].forEach((e=>{e[1].forEach((e=>{var t=this.makeFeatureJSON(e.data);n.features.push(t.features[0])}))}));return n.features.length>0?turf.bbox(n):null}openStoreLocatorClick(e,t){e.enable&&jQuery(`.mapster-store-locator-list[data-id="${t}"]`).click()}openSidebarClick(e,t,i,n,r,o){!e.enable&&t&&this.setSidebarHTML(i.data,n,r,o)}openPopup(e,t,i,n,r,o,s){if(!o.enable&&!s){i&&i.remove();if(n.data.popup_style){n.data.location&&"Point"===n.data.location.type&&(r=n.data.location.coordinates);let i=new t.Popup(this.returnPopupOptions(n.data)).setLngLat(r).setHTML(this.getPopupHTML(n.id,n.data));this.centerPopup(e,i,n);i.addTo(e);return i}}}centerPopup(e,t,i){ }mouseIsNear(e,t,i){if(e&&e.offset()){var n=e.offset().left-t,r=e.offset().top-t,o=n+e.width()+2*t,s=r+e.height()+2*t,a=i.pageX,l=i.pageY;return a>n&&ar&&l{this.initializeSlider(`mapster-popup-${t.popup_style.id}`,o.images.length+1)}),400);return`\n \n ${r.use_custom_css?``:""}\n ${r.use_custom_html?this.replaceHTMLValues(s.html_editor,o):`
    \n ${r.enable_header?`
    \n

    ${o.header_text}

    \n
    `:""}\n ${r.enable_image&&"feature-image"===o.image_type?'
    ':""}\n ${r.enable_image&&"gallery"===o.image_type?``:""}\n ${r.enable_body?`
    \n

    ${o.body_text}

    \n
    `:""}\n ${r.enable_footer?``:""}\n
    `}\n `}getPopupStyle(e){var t=this.returnPopupCSS(e),i=this.returnPopupLayout(e),n=this.returnPopupContent(e),r=e.popup_style.id;return`\n .mapboxgl-popup .mapboxgl-popup-content, .maplibregl-popup .maplibregl-popup-content {\n padding: 0px;\n background: none;\n border: none;\n border-radius: none;\n box-shadow: none;\n }\n #mapster-popup-${r}.map-popup-background {\n background : ${t.background};\n text-align : ${t.align};\n border-radius: 3px;\n box-shadow: 0 1px 2px rgb(0 0 0 / 10%);\n }\n #mapster-popup-${r} .map-popup-header {\n background : ${t.header};\n padding: 10px;\n }\n #mapster-popup-${r} .map-popup-header h2 {\n all : revert;\n color : ${t.header_text};\n font-weight: bold;\n margin: 0;\n padding: 0;\n }\n #mapster-popup-${r} .map-popup-image {\n background-image : url("${n.featured_image?n.featured_image.url:""}");\n background-position : center center;\n background-size: cover;\n height : ${t.image_height}px;\n width: 100%;\n }\n #mapster-popup-${r} .map-popup-body {\n margin-top: -1px;\n background : ${t.body};\n padding: 10px;\n color : ${t.body_text};\n }\n #mapster-popup-${r} .map-popup-body p {\n padding: 0px;\n margin: 0px;\n }\n #mapster-popup-${r} .map-popup-footer {\n margin-top: -1px;\n background : ${t.footer};\n padding: 10px;\n }\n #mapster-popup-${r} .map-popup-footer .map-popup-footer-button {\n all : revert;\n background : ${t.button};\n border-color: ${t.button};\n color : ${t.button_text};\n padding: 5px;\n text-decoration: none;\n text-shadow: none;\n }\n #mapster-popup-${r} .map-popup-footer .map-popup-footer-button:hover {\n cursor: pointer;\n filter: brightness(1.15);\n }\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color : ${t.pointer};\n display : ${i.enable_pointer?"block":"none"};\n }\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip {\n\t\t\t\tborder-left-color : ${t.pointer};\n display : ${i.enable_pointer?"block":"none"};\n\t\t\t}\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip {\n\t\t\t\tborder-right-color : ${t.pointer};\n display : ${i.enable_pointer?"block":"none"};\n\t\t\t}\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color : ${t.pointer};\n display : ${i.enable_pointer?"block":"none"};\n }\n `}setSidebarHTML(e,t,i,n){var r="#mapster-wp-maps-"+n;jQuery(".mapster-sidebar-popup").remove();var o=jQuery(r).height(),s=(jQuery(r).width(),this.getPopupStyle(e)),a=this.returnPopupCSS(e),l=this.returnPopupLayout(e),c=this.returnPopupContent(e);l.enable_image&&"gallery"===c.image_type&&setTimeout((()=>{this.initializeSlider(`mapster-sidebar-popup-${e.popup_style.id}`,c.images.length+1)}),400);jQuery(document).on("click",".mapster-sidebar-popup-exit",(()=>{jQuery(".mapster-sidebar-popup").remove()}));const u=parseFloat(t),h=parseFloat(i),p=`\n \n ${l.use_custom_css?``:""}\n
    \n
    \n ${l.enable_header?`
    \n

    ${c.header_text}

    \n
    `:""}\n ${l.enable_image&&"feature-image"===c.image_type?'
    ':""}\n ${l.enable_image&&"gallery"===c.image_type?``:""}\n ${l.enable_body?`
    \n

    ${c.body_text}

    \n
    `:""}\n ${l.enable_footer?``:""}\n
    \n `;jQuery(r).append(p)}replaceHTMLValues(e,t){let i; return i}returnPopupHTML(e){return{html_editor:e.popup_style.html_editor}}returnPopupContent(e){return{header_text:e.popup.header_text,image_type:e.popup.image_type,featured_image:e.popup.featured_image,images:e.popup.images,body_text:e.popup.body_text,button_text:e.popup.button_text,button_action:e.popup.button_action,button_url:e.popup.button_url,modal_details:e.popup.modal_details,additional_details:e.additional_details,open_link_in_new_tab:e.popup.open_link_in_new_tab}}returnPopupLayout(e){return{enable_header:e.popup_style.enable_header,enable_image:e.popup_style.enable_image,enable_body:e.popup_style.enable_body,enable_footer:e.popup_style.enable_footer,enable_pointer:e.popup_style.enable_pointer,use_custom_css:e.popup_style.use_custom_css,use_custom_html:e.popup_style.use_custom_html,popup_class:e.popup_style.popup_class}}returnPopupOptions(e){return{className:"hover"===e.interaction?"mapster-hover-popup":"",closeButton:e.popup_style.close_button,closeOnClick:e.popup_style.close_on_click,closeMapMove:e.popup_style.close_on_map_move,maxWidth:e.popup_style.max_width+"px"}}returnPopupCSS(e){return{background:e.popup_style.background,header:e.popup_style.header,image_height:e.popup_style.image_height,body:e.popup_style.body,footer:e.popup_style.footer,button:e.popup_style.button,pointer:e.popup_style.pointer,header_text:e.popup_style.header_text,body_text:e.popup_style.body_text,button_text:e.popup_style.button_text,align:e.popup_style.align,css_editor:e.popup_style.css_editor,max_width:e.popup_style.max_width}}getMarkerStyles(e){var t=e.data;return{color:t.marker.color,scale:parseFloat(t.marker.scale)/100,rotation:parseFloat(t.marker.rotation),anchor:t.marker.anchor}}getLayerExpressions(e,t,i){if("line"===e)return{layout:{},paint:{"line-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"line-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","hover_effects_hover_opacity"]],100],["has","opacity"],["/",["to-number",["get","opacity"]],100],1],"line-width":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","hover_effects_hover_width"]],["has","width"],["to-number",["get","width"]],2],"line-dasharray":"mapbox"===i?["case",["==",!0,["to-boolean",["get","dashed_line"]]],["get","dash_properties_line_dash_array"],["literal",[1,0]]]:[1,0]}};if("polygon"===e){if("fill"===t)return{layout:{},paint:{"fill-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"fill-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","hover_effects_opacity"]],100],["has","opacity"],["/",["to-number",["get","opacity"]],100],1],"fill-outline-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_outline-color"],["has","outline-color"],["get","outline-color"],"rgba(0,0,0,0)"]}};if("fill-extrusion"===t)return"1"===window.mapster_params.activated?{layout:{},paint:{"fill-extrusion-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"fill-extrusion-opacity":.75,"fill-extrusion-base":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","3d_polygon_base"]],100],["has","3d_polygon_base"],["to-number",["get","3d_polygon_base"]],0],"fill-extrusion-height":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","3d_polygon_height"]],["has","3d_polygon_height"],["to-number",["get","3d_polygon_height"]],0]}}:{layout:{},paint:{}}}if("location"===e){if("circle"===t)return{layout:{},paint:{"circle-color":["case",["boolean",["feature-state","hover"],!1],["get","circle_hover_effects_hover_color"],["has","circle_color"],["get","circle_color"],"#000"],"circle-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","circle_hover_effects_hover_opacity"]],100],["has","circle_opacity"],["/",["to-number",["get","circle_opacity"]],100],1],"circle-radius":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","circle_hover_effects_hover_radius"]],["has","circle_radius"],["to-number",["get","circle_radius"]],0],"circle-stroke-width":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","circle_hover_effects_hover_stroke-width"]],["has","circle_stroke-width"],["to-number",["get","circle_stroke-width"]],0],"circle-stroke-color":["case",["boolean",["feature-state","hover"],!1],["get","circle_hover_effects_hover_stroke-color"],["has","circle_stroke-color"],["get","circle_stroke-color"],"#000"],"circle-stroke-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","circle_hover_effects_hover_stroke-opacity"]],100],["has","circle_stroke-opacity"],["/",["to-number",["get","circle_stroke-opacity"]],100],1]}};if("symbol"===t)return{layout:{"text-field":["case",["has","label_text_properties_text-field"],["get","label_text_properties_text-field"],"New Text"],"text-font":["case",["==","Open Sans Regular",["get","label_text_properties_text-font"]],["literal",["Open Sans Regular"]],["==","Open Sans Bold",["get","label_text_properties_text-font"]],["literal",["Open Sans Bold"]],["==","Open Sans Italic",["get","label_text_properties_text-font"]],["literal",["Open Sans Italic"]],["==","Klokantech Noto Sans Regular",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Regular"]],["==","Klokantech Noto Sans Bold",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Bold"]],["==","Klokantech Noto Sans Italic",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Italic"]],["==","Metropolis",["get","label_text_properties_text-font"]],["literal",["Metropolis"]],["==","Metropolis Bold",["get","label_text_properties_text-font"]],["literal",["Metropolis Bold"]],["==","Metropolis Regular Italic",["get","label_text_properties_text-font"]],["literal",["Metropolis Regular Italic"]],["literal",["Open Sans Regular"]]],"text-rotate":["case",["has","label_text_properties_text-rotate"],["to-number",["get","label_text_properties_text-rotate"]],0],"text-size":["case",["==",!1,["get","label_label_on"]],0,["has","label_text_properties_text-size"],["to-number",["get","label_text_properties_text-size"]],16],"icon-size":["case",["==",!1,["get","icon_icon_on"]],0,["has","icon_icon_properties_icon-size"],["/",["to-number",["get","icon_icon_properties_icon-size"]],100],1],"icon-rotate":["case",["has","icon_icon_properties_icon-rotate"],["to-number",["get","icon_icon_properties_icon-rotate"]],0],"icon-allow-overlap":!0,"icon-ignore-placement":!0,"icon-anchor":["case",["has","icon_icon_properties_icon-anchor"],["get","icon_icon_properties_icon-anchor"],"center"],"icon-offset":["case",["has","icon_icon_properties_offset_array"],["get","icon_icon_properties_offset_array"],["literal",[0,0]]],"text-offset":["case",["has","label_text_properties_offset_array"],["get","label_text_properties_offset_array"],["literal",[0,0]]]},paint:{"text-color":["case",["has","label_text_properties_text-color"],["get","label_text_properties_text-color"],"#000000"],"text-halo-width":["case",["has","label_text_properties_text-halo-width"],["to-number",["get","label_text_properties_text-halo-width"]],1],"text-halo-color":["case",["has","label_text_properties_text-halo-color"],["get","label_text_properties_text-halo-color"],"#FFFFFF"],"text-halo-blur":["case",["has","label_text_properties_text-halo-blur"],["/",["to-number",["get","label_text_properties_text-halo-blur"]],100],1],"text-opacity":["case",["has","label_text_properties_text-opacity"],["/",["to-number",["get","label_text_properties_text-opacity"]],100],1],"icon-opacity":["case",["has","icon_icon_properties_icon-opacity"],["/",["to-number",["get","icon_icon_properties_icon-opacity"]],100],1]}}}}addIcons(e,t,i){t.indexOf("symbol")>-1&&i.features.forEach((i=>{i.properties.icon_icon_on&&i.properties["icon_icon_properties_icon-image_url"]&&this.addNewIcon(e,i.properties["icon_icon_properties_icon-image_url"],i.properties["icon_icon_properties_icon-image_id"],(()=>{e.getLayer(t)&&e.setLayoutProperty(t,"icon-image",["case",["has","icon_icon_properties_icon-image_id"],["concat","icon-image-",["get","icon_icon_properties_icon-image_id"]],"none"])}))}))}addNewIcon(e,t,i,n){if(this.queuedImages.indexOf(`icon-image-${i}`)>-1)n();else{this.queuedImages.push(`icon-image-${i}`);t||n();"https:"===window.location.protocol&&t.indexOf("http://")>-1&&(t=t.replace("http","https"));var r=new Image;r.src=t;r.crossOrigin="";r.onload=function(){if(e.loaded()){e.hasImage(`icon-image-${i}`)?e.updateImage(`icon-image-${i}`,r):e.addImage(`icon-image-${i}`,r);n()}else e.once("idle",(()=>{e.hasImage(`icon-image-${i}`)?e.updateImage(`icon-image-${i}`,r):e.addImage(`icon-image-${i}`,r);n()}))}}}createLayerGeoJSON(e,t,i,n,r,o){var s={type:"FeatureCollection",features:[]};let a="line"===t?r:"location"===t?n:"polygon"===t?o:[],l=i.indexOf("-")>-1&&i.split("-")[1],c=i.indexOf("-")>-1?i.split("-")[0]:i;if("fill-extrusion"===i){c=i;l=!1}a.forEach((n=>{if(n.data[t]&&c===this.getLayerType(t,n.data)&&(!l||n.categories.find((e=>e.id===parseFloat(l))))){var r=this.makeFeatureJSON(n.data);if(r.features[0]){var o=this.makeFeatureWithProperties(n,r.features[0]);s.features.push(o)}n.data.open_popup_on_load&&-1===i.indexOf("-")&&setTimeout((()=>{if(e){const t=turf.pointOnFeature(r);e.fire("click",{lngLat:t.geometry.coordinates})}}),500)}}));return s}createMarkerGeoJSON(e,t){let i=!!t.indexOf("-")&&t.split("-")[1];var n={type:"FeatureCollection",features:[]};n.features=e.filter((e=>!i&&"marker"===e.data.location_style||!(!i||"marker"!==e.data.location_style||!e.categories.find((e=>e.id===parseFloat(i)))))).map((e=>{e.post_id=e.id;return{type:"Feature",properties:e,geometry:e.data.location}}));return n}makeFeatureWithProperties(e,t){var i=JSON.parse(JSON.stringify(t));i.id=e.id;i.properties.post_id=e.id;for(var n in e.data)-1===["polygon","line","location","popup","popup_style"].indexOf(n)&&this.assignToProperty(i,e.data,n);i.properties.dashed_line&&i.properties.dash_properties_dash_length&&(i.properties.dash_properties_line_dash_array=[parseFloat(i.properties.dash_properties_dash_length),parseFloat(i.properties.dash_properties_gap_length)]);(i.properties["label_text_properties_text-translate-x"]||i.properties["label_text_properties_text-translate-y"])&&(i.properties.label_text_properties_offset_array=[parseFloat(i.properties["label_text_properties_text-translate-x"]),parseFloat(i.properties["label_text_properties_text-translate-y"])]);(i.properties["icon_icon_properties_icon-translate-x"]||i.properties["icon_icon_properties_icon-translate-y"])&&(i.properties.icon_icon_properties_offset_array=[parseFloat(i.properties["icon_icon_properties_icon-translate-x"]),parseFloat(i.properties["icon_icon_properties_icon-translate-y"])]);return i}assignToProperty(e,t,i,n){if("object"==typeof t[i])for(var r in t[i])this.assignToProperty(e,t[i],r,n?n+"_"+i:i);else{var o=n?n+"_"+i:i;e.properties[o]=t[i]}}getLayerType(e,t){if("line"===e)return"line";if("polygon"===e){if(!t.polygon_style||"fill"===t.polygon_style)return"fill";if("fill-extrusion"===t.polygon_style)return"fill-extrusion"}if("location"===e){if("circle"===t.location_style)return"circle";if("label"===t.location_style)return"symbol"}}}class MapsterCore{constructor(){}setDataLayers(){}getPostData({post_id:e,single_feature_id:t}){const i=new MapsterHelpers;let n=t?`&single_feature_id=${t}`:"";return fetch(`${window.mapster_params.rest_url}mapster-wp-maps/map${window.mapster_params.qd}id=${e}${n}`).then((e=>e.json())).then((e=>i.formatResponse(e)))}getFeaturesAdmin({locations_ids:e,lines_ids:t,polygons_ids:i,cats:n}){const r=e.concat(t.concat(i));return fetch(`${window.mapster_params.rest_url}mapster-wp-maps/features${window.mapster_params.qd}ids=${JSON.stringify(r)}&categories=${JSON.stringify(n)}`).then((e=>e.json()))}sortLocations({adminFeatures:e}){return e.filter((e=>e.data.location))}sortLines({adminFeatures:e}){return e.filter((e=>e.data.line))}sortPolygons({adminFeatures:e}){return e.filter((e=>e.data.polygon))}doClustering({map:e,map_provider:t,cluster_options:i,circle_clustering:n,label_icon_clustering:r,marker_clustering:o,markers:s,locations:a,lines:l,polygons:c,idsToHide:u}){return(new MapsterHelpers).setClustering(e,t,i,n,r,o,s,a,l,c,u)}loadCustomScripts({map:e,javascript:t,locations:i,lines:n,polygons:r}){t&&window[t]&&(0,window[t])(e,i.concat(n.concat(r)))}setMapStyle({map:e,map_type:t}){const i=new MapsterHelpers;"custom-image"===t.map_provider?i.setCustomImageMap(e,t,!0):t.custom_style_json&&""!==t.custom_style_json?e.setStyle(JSON.parse(t.custom_style_json)):e.setStyle(i.getStyle(t))}loadProjection({map:e,map_provider:t,projection:i}){"mapbox"===t&&e.setProjection({name:i,center:[0,30],parallels:[30,30]})}loadTerrain({map:e,map_provider:t,terrain:i}){if("mapbox"===t)if(i){if(!e.getSource("mapbox-mapster-dem")){e.addSource("mapbox-mapster-dem",{type:"raster-dem",url:"mapbox://mapbox.mapbox-terrain-dem-v1",tileSize:512,maxzoom:14});e.setTerrain({source:"mapbox-mapster-dem",exaggeration:1.5});e.addLayer({id:"sky",type:"sky",paint:{"sky-type":"atmosphere","sky-atmosphere-sun":[0,0],"sky-atmosphere-sun-intensity":15}})}}else{e.getLayer("sky")&&e.removeLayer("sky");e.setTerrain(null);e.getSource("mapbox-mapster-dem")&&e.removeSource("mapbox-mapster-dem")}}layerClick({map:e,interactivity:t,clickedEvent:i,locations:n,lines:r,polygons:o}){if(t){let t=i.point?i.point:e.project(i.lngLat);var s=e.queryRenderedFeatures(t).filter((e=>["symbol","line","fill","circle"].indexOf(e.source.split("-")[0])>-1));return!(!s[0]||"fill"===s[0].layer.id&&("fill"!==s[0].layer.id||0===s[0].layer.paint["fill-opacity"]))&&n.concat(r.concat(o)).find((e=>e.id===s[0].properties.post_id))}return!1}storeLocatorClick({clickedFeature:e,store_locator_options:t}){const i=new MapsterHelpers;e&&e.data.enable_popup&&("click"===e.data.interaction||i.isMobile()&&e.data.click_on_mobile)&&i.openStoreLocatorClick(t,e.id)}sidebarClick({post_id:e,clickedFeature:t,minimum_sidebar_width:i,maximum_sidebar_width:n,store_locator_options:r,open_popups_in_sidebar:o}){const s=new MapsterHelpers;t&&t.data.enable_popup&&("click"===t.data.interaction||s.isMobile()&&t.data.click_on_mobile)&&s.openSidebarClick(r,o,t,i,n,e)}externalClickLayer({clickedFeature:e}){(new MapsterHelpers).openExternalLink(e)}externalClickMarker({clickedMarker:e}){(new MapsterHelpers).openExternalLink(e)}popupClick({map:e,mapLibrary:t,clickedPopup:i,clickedFeature:n,clickedEvent:r,store_locator_options:o,open_popups_in_sidebar:s}){const a=new MapsterHelpers;if(n&&n.data.enable_popup&&("click"===n.data.interaction||a.isMobile()&&n.data.click_on_mobile))return a.openPopup(e,t,i,n,r.lngLat,o,s)}layerHover({map:e,interactivity:t,hoveredEvent:i,locations:n,lines:r,polygons:o}){if(t){var s=e.queryRenderedFeatures(i.point).filter((e=>["symbol","line","fill","circle"].indexOf(e.source.split("-")[0])>-1));return!(!s[0]||"fill"===s[0].layer.id&&("fill"!==s[0].layer.id||0===s[0].layer.paint["fill-opacity"]))&&n.concat(r.concat(o)).find((e=>e.id===s[0].properties.post_id))}return!1}layerHoverEffect({map:e,interactivity:t,hoveredFeature:i}){const n=new MapsterHelpers;n.changeCursor(e,i,"on"); }popupHover({map:e,mapLibrary:t,hoveredPopup:i,hoveredFeature:n,hoveredEvent:r,store_locator_options:o}){const s=new MapsterHelpers;if(n&&n.data.enable_popup&&"hover"===n.data.interaction&&(!s.isMobile()||s.isMobile()&&n.data.click_on_mobile))return s.openPopup(e,t,i,n,r.lngLat,o)}markerClick({interactivity:e,clickedMarker:t}){return!!e&&t.mapsterProperties}markerHover({interactivity:e,hoveredMarker:t}){return!!e&&t.mapsterProperties}markerHoverEffect({map:e,mapLibrary:t,interactivity:i,hoveredMarker:n}){ }openMarkerClickPopup({map:e,mapLibrary:t,clickedMarker:i,clickedFeature:n,clickedPopup:r,store_locator_options:o,open_popups_in_sidebar:s}){const a=new MapsterHelpers;if(!o.enable&&!s&&n&&n.data.enable_popup&&("click"===n.data.interaction||a.isMobile()&&n.data.click_on_mobile)&&n.data.popup_style){const r=new t.Popup(a.returnPopupOptions(n.data));r.setHTML(a.getPopupHTML(n.id,n.data));a.centerPopup(e,r,n);i.setPopup(r)}}openMarkerHoverPopup({map:e,mapLibrary:t,hoveredMarker:i,hoveredFeature:n}){const r=new MapsterHelpers;if(n&&n.data.enable_popup&&"hover"===n.data.interaction&&!r.isMobile()&&n.data.popup_style&&!i.getPopup()){const o=new t.Popup(r.returnPopupOptions(n.data));o.setHTML(r.getPopupHTML(n.id,n.data));r.centerPopup(e,o,n);i.setPopup(o).togglePopup()}}markerHoverEffectOff({tempHoverMarker:e,hoveredMarker:t}){ }removeMarkerHoverPopup({hoveredMarker:e,hoveredFeature:t}){const i=new MapsterHelpers;t&&t.data.enable_popup&&"hover"===t.data.interaction&&!i.isMobile()&&(e&&!t.data.keep_popup_open_on_hover?e.setPopup(null):e&&t.data.keep_popup_open_on_hover&&jQuery(document).on("mousemove.mapster",(function(e){let n=jQuery(`.mapster-feature-popup-${t.id}`).closest(".mapboxgl-popup");i.mouseIsNear(n,2,e)?n.one("mouseleave",(function(){jQuery(document).off("mousemove.mapster")})):jQuery(document).off("mousemove.mapster")})))}layerHoverEffectOff({map:e,interactivity:t,hoveredFeature:i}){const n=new MapsterHelpers;n.changeCursor(e,i,"off"); }removePopupHover({hoveredFeature:e,hoveredPopup:t}){t&&!e.data.keep_popup_open_on_hover?t.remove():t&&e.data.keep_popup_open_on_hover&&jQuery(document).one("mousemove",(function(i){let n=jQuery(`.mapster-feature-popup-${e.id}`).closest(".mapboxgl-popup:hover");n.length?n.one("mouseleave",(function(){t.remove()})):t.remove()}))}setInteractivity({map:e,zoom_on_scroll:t,interactivity:i,allow_rotation_and_pitch:n}){t||e.scrollZoom.disable();if(!i){e.scrollZoom.disable();e.boxZoom.disable();e.dragRotate.disable();e.dragPan.disable();e.keyboard.disable();e.doubleClickZoom.disable();e.touchZoomRotate.disable()}if(i&&!n){e.dragRotate.disable();e.touchZoomRotate.disable()}}setFeaturesToMap({map:e,map_provider:t,locations:i,lines:n,polygons:r}){const o=new MapsterHelpers;[["line","line"],["polygon","fill"],["polygon","fill-extrusion"],["location","circle"],["location","symbol"],["location","3d-model"]].forEach((s=>{var a=o.createLayerGeoJSON(e,s[0],s[1],i,n,r);if("3d-model"!==s[1])if(e.getSource(s[1])){e.getSource(s[1]).setData(a);o.addIcons(e,s[1],a)}else{e.addSource(s[1],{type:"geojson",data:a});var l=o.getLayerExpressions(s[0],s[1],t);e.addLayer({id:s[1],source:s[1],type:s[1],paint:l.paint,layout:l.layout});o.addIcons(e,s[1],a)}else o.create3DModels(e,i)}))}setMarkersToMap({map:e,markers:t,mapLibrary:i,locations:n,marker_clustering:r}){const o=new MapsterHelpers;let s=[];t.forEach((e=>{n.find((t=>t.id===e.id))?s.push(e):e.remove()}));let a=[];a=a.concat(s);const l=n.filter((e=>"marker"===e.data.location_style));let c=[];l.sort(((e,t)=>{if(e.data.location.coordinates&&t.data.location.coordinates)return e.data.location.coordinates[1]>t.data.location.coordinates[1]?-1:1;if(!e.data.location.coordinates&&-1===c.indexOf(e.title)){alert(`A point is missing coordinates. See ${e.title}.`);c.push(e.title)}if(!t.data.location.coordinates&&-1===c.indexOf(t.title)){alert(`A point is missing coordinates. See ${t.title}.`);c.push(t.title)}}));l.forEach((t=>{if(!s.find((e=>e.mapsterProperties.id===t.id))){var n=o.getMarkerStyles(t),l=o.makeFeatureJSON(t.data).features[0].geometry.coordinates,c=new i.Marker(n).setLngLat(l);c.mapsterProperties=t;r||c.addTo(e);a.push(c);t.data.open_popup_on_load&&setTimeout((()=>{jQuery(c.getElement()).click()}),100)}}));return a}setHeatmap({map:e,mapLibrary:t,markers:i,locations:n,heatmap:r}){ }setMapSize({post_id:e,layout:t}){var i="#mapster-wp-maps-"+e;const n=new MapsterHelpers;if(!t.full_page){jQuery(i).height(t.height+t.height_units);jQuery(i).width(t.width+t.width_units);n.setMapBreakpointSizes(e,t)}if(t.full_page){jQuery(i).height(window.innerHeight+t.height_units);jQuery(i).width("100%")}if(t.full_page&&t.ignore_container){jQuery(`
    `).insertAfter(i);jQuery(i).css("marginLeft",-1*jQuery(i).offset().left+"px");jQuery(i).width(window.innerWidth+"px");jQuery(i).css("position","absolute")}}setMapMoveEndVariables({map:e}){jQuery('.acf-field[data-name="manual_pitch"]').find(".acf-label label").html(`Manual Pitch (currently: ${e.getPitch()})`);jQuery('.acf-field[data-name="manual_zoom"]').find(".acf-label label").html(`Manual Zoom (currently: ${e.getZoom()})`);jQuery('.acf-field[data-name="manual_rotation"]').find(".acf-label label").html(`Manual Rotation (currently: ${e.getBearing()})`);const{lng:t,lat:i}=e.getCenter();jQuery('.acf-field[data-name="manual_latitude"]').find(".acf-label label").html(`Manual Latitude (currently: ${i})`);jQuery('.acf-field[data-name="manual_longitude"]').find(".acf-label label").html(`Manual Longitude (currently: ${t})`)}setDefaultAccessToken(){""===jQuery('.acf-field[data-name="access_token"]').find(":input").val()&&jQuery('.acf-field[data-name="access_token"]').find(":input").val(window.mapster_params.mapbox_access_token)}setMapType({map_type:e}){if("mapbox"!==e.map_provider){""!==e.access_token&&(maplibregl.accessToken=e.access_token);return maplibregl}if(""!==e.access_token){mapboxgl.accessToken=e.access_token;return mapboxgl}window.alert(window.mapster_params.strings["Mapbox Token Warning"])}setSubmissionModal({post_id:e,map:t,mapLibrary:i,submission:n}){const r=new MapsterHelpers;jQuery(document).on("click",`#mapster-submit-${e}`,(function(){const o=jQuery(this).data("type"),s=jQuery(this).data("header");jQuery(`.mapster-submit-${e} .mapster-submission-modal-title`).text(s);jQuery(`.mapster-submit-${e} #mapster-submission-modal-overlay-${e}`).parent().detach().appendTo("body");jQuery(`.mapster-submit-${e} #mapster-submission-modal-${e}`).parent().detach().appendTo("body");n.submission_interface.categories.length>0?fetch(`${window.mapster_params.rest_url}mapster-wp-maps/submission-info${window.mapster_params.qd}categories=${n.submission_interface.categories.join(",")}`).then((e=>e.json())).then((s=>{r.loadModalSteps(e,t,i,o,s,n)})):r.loadModalSteps(e,t,i,o,!1,n)}));jQuery(document).on("click",".mapster-submission-modal-close",(function(){jQuery(".mapster-submission-modal-overlay").fadeOut(50);jQuery(".mapster-submission-modal").fadeOut(100)}))}setMap({post_id:e,mapLibrary:t,map:i,locations:n,lines:r,polygons:o}){var s="mapster-wp-maps-"+e;const a=new MapsterHelpers;let l=!0,c="manual"===i.view.initial_load?[parseFloat(i.view.manual_longitude),parseFloat(i.view.manual_latitude)]:a.getDefaultCenter();if(jQuery(`#${s}`).data("latitude")&&"null"!==jQuery(`#${s}`).data("latitude")&&jQuery(`#${s}`).data("longitude")&&"null"!==jQuery(`#${s}`).data("longitude")){c=[parseFloat(jQuery(`#${s}`).data("longitude")),parseFloat(jQuery(`#${s}`).data("latitude"))];l=!1}let u="manual"===i.view.initial_load?parseFloat(i.view.manual_zoom):a.getDefaultZoom();if(jQuery(`#${s}`).data("zoom")&&"null"!==jQuery(`#${s}`).data("zoom")){u=parseFloat(jQuery(`#${s}`).data("zoom"));l=!1}const h={renderWorldCopies:i.layout.duplicate_horizontally,style:a.getStyle(i.map_type),container:s,fitBoundsOptions:{padding:20,maxZoom:18},projection:{name:i.map_type.projection?i.map_type.projection:"mercator",center:[0,30],parallels:[30,30]},bounds:"fit-features"===i.view.initial_load&&l?a.getMapBounds(n,r,o):null,center:c,zoom:u,pitch:i.view.manual_pitch?parseFloat(i.view.manual_pitch):0,bearing:i.view.manual_rotation?parseFloat(i.view.manual_rotation):0,attributionControl:!1,logoPosition:i.logo_control?i.logo_control.position:"bottom-left"};if("1"===window.mapster_params.activated&&i.restricted_movement.restrict_movement){let e=i.restricted_movement.allowed_bounds.southwest_longitude,t=i.restricted_movement.allowed_bounds.southwest_latitude,n=i.restricted_movement.allowed_bounds.northeast_longitude,r=i.restricted_movement.allowed_bounds.northeast_latitude;if(""!==e&&""!==t&&""!==n&&""!==r){let i=[[parseFloat(e),parseFloat(t)],[parseFloat(n),parseFloat(r)]];h.maxBounds=i}let o=i.restricted_movement.allowed_zoom.min_zoom;""!==o&&(h.minZoom=parseFloat(o));let s=i.restricted_movement.allowed_zoom.max_zoom;""!==s&&(h.maxZoom=parseFloat(s))}const p=new t.Map(h);i.map_type.custom_style_json&&""!==i.map_type.custom_style_json&&p.setStyle(JSON.parse(i.map_type.custom_style_json));"custom-image"===i.map_type.map_provider&&a.setCustomImageMap(p,i.map_type);i.map_compare&&i.map_compare.enable_map_slider&&i.map_compare.compared_map&&a.setMapCompare(t,p,e,i.map_compare);window[`mapsterMap${e}`]=p;a.setProjectionGlobe(p,i.map_type);jQuery(".mapster-wp-maps-loader-container").hide();return p}setLoader({post_id:e}){const t=new MapsterConstants;jQuery("#mapster-wp-maps-"+e).append(t.loaderHTML())}setLoaderDone({post_id:e}){jQuery("#mapster-wp-maps-"+e+" .mapster-map-loader").fadeOut()}setMapResize({map:e}){e.resize()}setStreetViewControl(){}setMapTypeControl(){}setZoomControl({map:e,mapLibrary:t,controls:i,zoom_control:n}){return(new MapsterHelpers).addMapControl(e,i.zoomControl,n.enable,n.position,t.NavigationControl)}setAttributionControl({map:e,mapLibrary:t,controls:i,attribution_control:n,map_type:r}){}setElevationControl({map:e,mapLibrary:t,controls:i,elevation_line_chart:n,post_id:r,lines:o}){ }set3DControl(e){const{map:t,mapLibrary:i,controls:n}=e;return(new MapsterHelpers).addMapControl(t,n["3dControl"],e["3d_control"].enable,e["3d_control"].position,PitchToggle)}setScaleControl({map:e,mapLibrary:t,controls:i,scale_control:n}){return(new MapsterHelpers).addMapControl(e,i.scaleControl,n.enable,n.position,t.ScaleControl)}setGeolocationControl({map:e,mapLibrary:t,controls:i,geolocation_control:n}){const r=new MapsterHelpers,o={showAccuracyCircle:n.show_accuracy_circle,showUserHeading:n.show_user_heading,trackUserLocation:n.show_user_heading||n.track_user_location},s=r.addMapControl(e,i.geolocationControl,n.enable,n.position,t.GeolocateControl,o);r.setGeolocationOnLoad(n);return s}setFullscreenControl({map:e,mapLibrary:t,controls:i,fullscreen_control:n}){return(new MapsterHelpers).addMapControl(e,i.fullscreenControl,n.enable,n.position,t.FullscreenControl)}setGeocoderControl({map:e,mapLibrary:t,controls:i,geocoder_control:n}){const r=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var o={accessToken:t.accessToken,mapboxgl:t,placeholder:n.placeholder};return r.addMapControl(e,i.geocoderControl,n.enable,n.position,MapboxGeocoder,o)}}setDirectionsControl({map:e,mapLibrary:t,controls:i,directions_control:n}){if("undefined"!=typeof MapboxDirections){const o=new MapsterHelpers;var r={accessToken:t.accessToken,mapboxgl:t,unit:n.unit,profile:n.profile,placeholderOrigin:n.placeholderOrigin};return o.addMapControl(e,i.directionsControl,n.enable,n.position,MapboxDirections,r)}}setCustomSearchFilterControl({map:e,mapLibrary:t,controls:i,custom_search_filter:n,locations:r,lines:o,polygons:s,markers:a}){const l=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var c={mapboxgl:t,marker:!1,placeholder:n.placeholder};n.include_geocoder?c.accessToken=t.accessToken:c.localGeocoderOnly=!0;""!==n.limit_results&&(c.countries=n.limit_results);(c=l.applyProSearchFilter(n,c)).localGeocoder=e=>l.searchLocalFeatures(n.search_type,e,r,o,s);const u=l.addMapControl(e,i.customSearchControl,n.enable,n.position,MapboxGeocoder,c);if(u){u.on("result",(({result:e})=>{var i=document.createElement("div");i.innerHTML=e.place_name;jQuery(u._inputEl).val(i.innerHTML);const n=a.find((t=>t.mapsterProperties.id===e.id));n&&n.mapsterProperties.data.enable_popup&&n.setPopup(new t.Popup(l.returnPopupOptions(n.mapsterProperties.data)).setHTML(l.getPopupHTML(n.mapsterProperties.id,n.mapsterProperties.data))).togglePopup()}));return u}}}setFilterDropdownControl({map:e,mapLibrary:t,controls:i,filter_dropdown:n,locations:r,lines:o,polygons:s,markers:a}){const l=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var c={mapboxgl:t,localGeocoderOnly:!0,marker:!1,placeholder:n.placeholder,minLength:0,limit:1e3,localGeocoder:e=>l.searchLocalFeatures("exact-match",e,r,o,s)};const u=l.addMapControl(e,i.filterDropdownControl,n.enable,n.position,MapboxGeocoder,c);if(u){n.enable&&l.modifyDropdown(u);u.on("result",(e=>{const i=a.find((t=>t.mapsterProperties.id===e.result.id));i&&i.mapsterProperties.data.enable_popup&&i.setPopup(new t.Popup(l.returnPopupOptions(i.mapsterProperties.data)).setHTML(l.getPopupHTML(i.mapsterProperties.id,i.mapsterProperties.data))).togglePopup()}))}return u}}setCategoryFilterControl({map:e,mapLibrary:t,controls:i,cluster_options:n,category_filter:r,markers:o,dataLayers:s,locations:a,lines:l,polygons:c,map_provider:u,label_icon_clustering:h,circle_clustering:p,marker_clustering:d}){new MapsterHelpers;const f={functionality:r.functionality,independent_children:r.independent_children,initial_visibility:r.initial_visibility,category_display:r.category_display,checkbox_display:r.checkbox_display,pre_selected_categories:r.pre_selected_categories,additional_filters:r.additional_filters,accordion_layout:r.accordion_layout,excluded_categories:r.excluded_categories,show_number_of_features:r.show_number_of_features};i.categoryFilterControl&&e.removeControl(i.categoryFilterControl);if(r.enable){const t=new CategoryControl(f,n,o,s,a,l,c,u,p,h,d);""!==r.render_in_external_div&&document.getElementById(r.render_in_external_div)?document.getElementById(r.render_in_external_div).appendChild(t.onAdd(e)):e.addControl(t,r.position);return t}return!1}setListControl({map:e,mapLibrary:t,controls:i,list:n,locations:r,lines:o,polygons:s,markers:a}){new MapsterHelpers;i.listControl&&e.removeControl(i.listControl);if(n.enable){const i=new ListControl(n,r,o,s,a,t);e.addControl(i,n.position);return i}return!1}setDownloadControl({map:e,mapLibrary:t,controls:i,download_control:n,locations:r,lines:o,polygons:s}){ }setCustomHTMLControl({map:e,mapLibrary:t,controls:i,custom_html_control:n}){ }setLayerControl({map:e,mapLibrary:t,controls:i,layer_control:n}){ }setStyleControl({map:e,mapLibrary:t,controls:i,style_control:n}){ }setListingPosts({post_id:e,map:t,listing_page:i,locations:n,lines:r,polygons:o}){ }setJqueryEvents(){ }}class MapsterContainer{constructor(e,t,i){this.core={};this.MapsterMap=i;this.post_id=e;this.single_feature_id=t;this.postResponse;this.mapLibrary;this.markers=[];this.controls=[];this.clusterLayers=[];this.clickedEvent;this.clickedFeature;this.clickedPopup;this.clickedMarker;this.hoveredEvent;this.hoveredFeature;this.hoveredPopup;this.hoveredMarker;this.tempHoverMarker;this.map;this.postResponseAdmin;this.adminFeatures;this.dataLayers;this.defineCore()}defineCore(){const e=new MapsterCore;this.core.set_accesstokendefault={args:[],hook:"access_token_set",func:e.setDefaultAccessToken};this.core.define_postResponse={args:["post_id","single_feature_id"],hook:"data_fetched",func:e.getPostData,promise:!0};this.core.set_mapSize={args:["post_id","postResponse.map.layout"],hook:"map_size_set",func:e.setMapSize};this.core.define_mapLibrary={args:["postResponse.map.map_type"],hook:"map_library_set",func:e.setMapType};this.core.set_submissionModal={args:["post_id","map","mapLibrary","postResponse.map.submission"],hook:"submission_modal_initialized",func:e.setSubmissionModal};this.core.define_map={args:["post_id","mapLibrary","postResponse.map","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_set",func:e.setMap};this.core.set_moveendVariables={args:["map"],hook:"map_moveend",func:e.setMapMoveEndVariables};this.core.set_jquery_events={args:[],hook:"jquery_events_set",func:e.setJqueryEvents};this.core.set_loader={args:["post_id"],hook:"loading_icon_started",func:e.setLoader};this.core.set_loaderdone={args:["post_id"],hook:"loading_icon_done",func:e.setLoaderDone};this.core.set_mapresize={args:["map"],hook:"map_resize_set",func:e.setMapResize};this.core.set_listingposts={args:["post_id","map","postResponse.map.listing_page","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_set_listing_posts",func:e.setListingPosts};this.core.define_dataLayers={args:["map","postResponse.map.map_type.map_provider","dataLayers","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_datalayers_set",func:e.setDataLayers,callback:this.MapsterMap.setDataLayerEvents};this.core.set_mapfeatures={args:["map","postResponse.map.map_type.map_provider","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_features_set",func:e.setFeaturesToMap,callback:this.MapsterMap.setLayerEvents};this.core.define_markers={args:["map","markers","mapLibrary","postResponse.locations","postResponse.map.marker_clustering"],hook:"map_markers_set",func:e.setMarkersToMap,callback:this.MapsterMap.setMarkerEvents};this.core.set_heatmap={args:["map","markers","postResponse.locations","postResponse.map.heatmap"],hook:"map_heatmap_set",func:e.setHeatmap};this.core["define_controls.elevationControl"]={args:["map","mapLibrary","controls","postResponse.map.elevation_line_chart","post_id","postResponse.lines"],hook:"elevation_control_set",func:e.setElevationControl};this.core["define_controls.zoomControl"]={args:["map","mapLibrary","controls","postResponse.map.zoom_control"],hook:"zoom_control_set",func:e.setZoomControl};this.core["define_controls.attributionControl"]={args:["map","mapLibrary","controls","postResponse.map.attribution_control","postResponse.map.map_type"],hook:"attribution_control_set",func:e.setAttributionControl};this.core["define_controls.streetViewControl"]={args:["map","mapLibrary","controls","postResponse.map.street_view_control"],hook:"street_view_control_set",func:e.setStreetViewControl};this.core["define_controls.mapTypeControl"]={args:["map","mapLibrary","controls","postResponse.map.map_type_control"],hook:"map_type_control_set",func:e.setMapTypeControl};this.core["define_controls.geocoderControl"]={args:["map","mapLibrary","controls","postResponse.map.geocoder_control"],hook:"geocoder_control_set",func:e.setGeocoderControl};this.core["define_controls.directionsControl"]={args:["map","mapLibrary","controls","postResponse.map.directions_control"],hook:"directions_control_set",func:e.setDirectionsControl};this.core["define_controls.3dControl"]={args:["map","mapLibrary","controls","postResponse.map.3d_control"],hook:"3d_control_set",func:e.set3DControl};this.core["define_controls.scaleControl"]={args:["map","mapLibrary","controls","postResponse.map.scale_control"],hook:"scale_control_set",func:e.setScaleControl};this.core["define_controls.geolocationControl"]={args:["map","mapLibrary","controls","postResponse.map.geolocation_control"],hook:"geolocation_control_set",func:e.setGeolocationControl};this.core["define_controls.fullscreenControl"]={args:["map","mapLibrary","controls","postResponse.map.fullscreen_control"],hook:"fullscreen_control_set",func:e.setFullscreenControl};this.core["define_controls.downloadControl"]={args:["map","mapLibrary","controls","postResponse.map.download_control","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"download_control_set",func:e.setDownloadControl};this.core["define_controls.customHTMLControl"]={args:["map","mapLibrary","controls","postResponse.map.custom_html_control"],hook:"custom_html_control_set",func:e.setCustomHTMLControl};this.core["define_controls.layerControl"]={args:["map","mapLibrary","controls","postResponse.map.layer_control"],hook:"layer_control_set",func:e.setLayerControl};this.core["define_controls.styleControl"]={args:["map","mapLibrary","controls","postResponse.map.style_control"],hook:"style_control_set",func:e.setStyleControl};this.core["define_controls.customSearchControl"]={args:["map","mapLibrary","controls","postResponse.map.filter.custom_search_filter","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"customSearch_control_set",func:e.setCustomSearchFilterControl};this.core["define_controls.filterDropdownControl"]={args:["map","mapLibrary","controls","postResponse.map.filter.filter_dropdown","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"filterDropdown_control_set",func:e.setFilterDropdownControl};this.core["define_controls.categoryFilterControl"]={args:["map","mapLibrary","controls","postResponse.map.cluster_options","postResponse.map.filter.category_filter","markers","dataLayers","postResponse.locations","postResponse.lines","postResponse.polygons","postResponse.map.map_type.map_provider","postResponse.map.circle_clustering","postResponse.map.label_icon_clustering","postResponse.map.marker_clustering"],hook:"categoryFilter_control_set",func:e.setCategoryFilterControl};this.core["define_controls.listControl"]={args:["map","mapLibrary","controls","postResponse.map.list","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"list_control_set",func:e.setListControl};this.core.define_clusterLayers={args:["map","postResponse.map.map_type.map_provider","postResponse.map.cluster_options","postResponse.map.circle_clustering","postResponse.map.label_icon_clustering","postResponse.map.marker_clustering","markers","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_clustering_set",func:e.doClustering,callback:this.MapsterMap.setDynamicLayerEvents};this.core.set_customscripts={args:["map","postResponse.map.javascript","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"custom_scripts_set",func:e.loadCustomScripts};this.core.set_interactivity={args:["map","postResponse.map.zoom_on_scroll","postResponse.map.interactivity","postResponse.map.allow_rotation_and_pitch"],hook:"interactivity_set",func:e.setInteractivity};this.core.set_mapstyle={args:["map","postResponse.map.map_type"],hook:"map_style_set",func:e.setMapStyle,callback:this.MapsterMap.idleReload};this.core.set_terrain={args:["map","postResponse.map.map_type.map_provider","postResponse.map.map_type.terrain"],hook:"map_terrain_set",func:e.loadTerrain};this.core.set_projection={args:["map","postResponse.map.map_type.map_provider","postResponse.map.map_type.projection"],hook:"map_projection_set",func:e.loadProjection};this.core.define_clickedFeature={args:["map","postResponse.map.interactivity","clickedEvent","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"layer_feature_clicked",func:e.layerClick};this.core.set_storelocatorclick={args:["clickedFeature","postResponse.map.list.store_locator_options"],hook:"",func:e.storeLocatorClick};this.core.set_sidebarclick={args:["post_id","clickedFeature","postResponse.map.minimum_sidebar_width","postResponse.map.maximum_sidebar_width","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"",func:e.sidebarClick};this.core.define_clickedPopup={args:["map","mapLibrary","clickedPopup","clickedFeature","clickedEvent","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_layer_click",func:e.popupClick};this.core.define_hoveredFeature={args:["map","postResponse.map.interactivity","hoveredEvent","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"layer_feature_hovered",func:e.layerHover};this.core.set_hoverEffects={args:["map","postResponse.map.interactivity","hoveredFeature","dataLayers"],hook:"",func:e.layerHoverEffect};this.core.define_hoveredPopup={args:["map","mapLibrary","hoveredPopup","hoveredFeature","hoveredEvent","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_layer_hover",func:e.popupHover};this.core.set_hoverEffectsOff={args:["map","postResponse.map.interactivity","hoveredFeature","dataLayers"],hook:"",func:e.layerHoverEffectOff};this.core.set_hoveredPopupOff={args:["hoveredFeature","hoveredPopup"],hook:"popup_closed_from_layer_hover",func:e.removePopupHover};this.core.set_externallink={args:["clickedFeature"],hook:"external_link_opened",func:e.externalClickLayer};this.core.define_clickedFeature_fromMarker={args:["clickedMarker","postResponse.map.interactivity"],hook:"marker_feature_clicked",func:e.markerClick};this.core.define_hoveredFeature_fromMarker={args:["hoveredMarker","postResponse.map.interactivity"],hook:"marker_feature_hovered",func:e.markerHover};this.core.define_tempHoverMarker={args:["map","mapLibrary","postResponse.map.interactivity","hoveredMarker"],hook:"",func:e.markerHoverEffect};this.core.define_clickedPopup_fromMarker={args:["map","mapLibrary","clickedMarker","clickedFeature","clickedPopup","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_marker_click",func:e.openMarkerClickPopup};this.core.define_hoveredPopup_fromMarker={args:["map","mapLibrary","hoveredMarker","hoveredFeature","hoveredPopup"],hook:"popup_opened_from_marker_hover",func:e.openMarkerHoverPopup};this.core.set_hoverEffectsOff_fromMarker={args:["tempHoverMarker","hoveredMarker"],hook:"",func:e.markerHoverEffectOff};this.core.set_hoveredPopupOff_fromMarker={args:["hoveredMarker","hoveredFeature","hoveredPopup"],hook:"popup_closed_from_marker_hover",func:e.removeMarkerHoverPopup};this.core.define_adminFeatures={args:["postResponseAdmin.locations_ids","postResponseAdmin.lines_ids","postResponseAdmin.polygons_ids","postResponse.cats"],hook:"",func:e.getFeaturesAdmin,promise:!0};this.core["define_postResponse.locations"]={args:["adminFeatures"],hook:"locations_fetched",func:e.sortLocations};this.core["define_postResponse.lines"]={args:["adminFeatures"],hook:"lines_fetched",func:e.sortLines};this.core["define_postResponse.polygons"]={args:["adminFeatures"],hook:"polygons_fetched",func:e.sortPolygons}}doCore(e){let t=this.core[e].args,i=this.core[e].func,n={};for(var r=0;r{this.defineThisObject(e,t);this.core[e].callback&&this.core[e].callback(this,this.MapsterMap);this.core[e].hook&&this.MapsterMap.runHookActions(e,t)}));{const t=i(n);this.defineThisObject(e,t);this.core[e].callback&&this.core[e].callback(this,this.MapsterMap);this.core[e].hook&&this.MapsterMap.runHookActions(e,t);return t}}registerListener(e,t,i,n){this.setStarterValue(e,t,i);jQuery(document).on("change","select"!==t?e:e.replace("select",":input"),(()=>{"check"===t&&this.setObjectProperty(this,i,jQuery(e).is(":checked"));"val"===t&&this.setObjectProperty(this,i,jQuery(e).val());"select"===t&&this.setObjectProperty(this,i,jQuery(e).select2("data").map((e=>e.id)));if(n&&n.length>0)for(var r=0;r{for(var e=r+1;ee.id)))}defineThisObject(e,t){e.indexOf("define_")>-1&&this.setObjectProperty(this,e.split("_")[1],t)}getObjectProperty(e,t){return t.split(".").reduce(((e,t)=>e?.[t]),e)}setObjectProperty(e,t,i){t.split(".").reduce(((e,n)=>{n===t.split(".")[t.split(".").length-1]&&(e[n]=i);void 0===e[n]&&(n===t.split(".")[t.split(".").length-1]?e[n]="":e[n]={});return e?.[n]}),e)}}class MapsterMap{constructor(e,t,i){this.MapsterContainer=new MapsterContainer(e,i,this);this.post_id=e;this.isPublic=t;this.dynamicLayerListenersSet=!1;this.isPublic||this.registerAdminEventListeners()}preInitMap(){return this.isPublic?this.doCoreAndRunActions("define_postResponse"):this.doCoreAndRunActions("define_adminFeatures")}init(){this.preInitMap().then((()=>{if(!this.isPublic){this.doCoreAndRunActions("set_accesstokendefault");this.doCoreAndRunActions("define_postResponse.locations");this.doCoreAndRunActions("define_postResponse.lines");this.doCoreAndRunActions("define_postResponse.polygons")}this.initMap();this.MapsterContainer.map.on("load",(()=>{this.postLoad();this.setMoveEvents(this.MapsterContainer.map)}));this.MapsterContainer.map.on("mapster_custom_style_load",(()=>{this.postStyleSwitch(this.MapsterContainer,this)}))}))}initMap(){this.isPublic&&this.doCoreAndRunActions("set_mapSize");this.doCoreAndRunActions("define_mapLibrary");this.doCoreAndRunActions("define_map");this.doCoreAndRunActions("set_jquery_events");this.doCoreAndRunActions("set_loader");if(this.isPublic){this.doCoreAndRunActions("set_submissionModal");this.doCoreAndRunActions("set_interactivity");this.doCoreAndRunActions("set_listingposts")}}postLoad(){this.doCoreAndRunActions("set_mapresize");this.doCoreAndRunActions("set_terrain");this.doCoreAndRunActions("set_mapfeatures");this.doCoreAndRunActions("define_dataLayers");this.doCoreAndRunActions("define_markers");this.doCoreAndRunActions("set_heatmap");this.setControls();this.isPublic&&this.doCoreAndRunActions("define_clusterLayers");this.doCoreAndRunActions("set_loaderdone");this.doCoreAndRunActions("set_customscripts")}setControls(){this.doCoreAndRunActions("define_controls.zoomControl");this.doCoreAndRunActions("define_controls.mapTypeControl");this.doCoreAndRunActions("define_controls.streetViewControl");this.doCoreAndRunActions("define_controls.attributionControl");this.doCoreAndRunActions("define_controls.geocoderControl");this.doCoreAndRunActions("define_controls.directionsControl");this.doCoreAndRunActions("define_controls.3dControl");this.doCoreAndRunActions("define_controls.scaleControl");this.doCoreAndRunActions("define_controls.geolocationControl");this.doCoreAndRunActions("define_controls.fullscreenControl");this.doCoreAndRunActions("define_controls.downloadControl");this.doCoreAndRunActions("define_controls.customHTMLControl");this.doCoreAndRunActions("define_controls.layerControl");this.doCoreAndRunActions("define_controls.styleControl");this.doCoreAndRunActions("define_controls.customSearchControl");this.doCoreAndRunActions("define_controls.filterDropdownControl");this.doCoreAndRunActions("define_controls.categoryFilterControl");this.doCoreAndRunActions("define_controls.elevationControl");this.doCoreAndRunActions("define_controls.listControl")}idleReload(e,t){e.map.once("idle",(()=>{t.doCoreAndRunActions("set_loader");t.doCoreAndRunActions("set_terrain");t.doCoreAndRunActions("set_mapfeatures");t.doCoreAndRunActions("define_dataLayers");t.doCoreAndRunActions("define_markers");t.doCoreAndRunActions("define_clusterLayers");t.doCoreAndRunActions("set_loaderdone")}))}postStyleSwitch(e,t){e.map.once("idle",(()=>{t.doCoreAndRunActions("set_terrain");t.doCoreAndRunActions("set_mapfeatures");t.doCoreAndRunActions("define_dataLayers");t.doCoreAndRunActions("define_markers");t.doCoreAndRunActions("define_clusterLayers")}))}setLayerEvents(e,t){["symbol","circle","line","fill"].forEach((i=>{e.map.on("click",i,(i=>{e.clickedEvent=i;t.doCoreAndRunActions("define_clickedFeature");t.doCoreAndRunActions("set_storelocatorclick");t.doCoreAndRunActions("set_sidebarclick");t.doCoreAndRunActions("set_externallink");t.doCoreAndRunActions("define_clickedPopup")}));e.map.on("mousemove",i,(i=>{e.hoveredEvent=i;t.doCoreAndRunActions("define_hoveredFeature");t.doCoreAndRunActions("set_hoverEffects");t.doCoreAndRunActions("define_hoveredPopup")}));e.map.on("mouseout",i,(e=>{t.doCoreAndRunActions("set_hoverEffectsOff");t.doCoreAndRunActions("set_hoveredPopupOff")}))}))}setDynamicLayerEvents(e,t){if(e.clusterLayers.length>0&&!this.dynamicLayerListenersSet){e.clusterLayers.forEach((i=>{if(i.indexOf("-")>-1){e.map.on("click",i,(i=>{e.clickedEvent=i;t.doCoreAndRunActions("define_clickedFeature");t.doCoreAndRunActions("set_storelocatorclick");t.doCoreAndRunActions("set_sidebarclick");t.doCoreAndRunActions("set_externallink");t.doCoreAndRunActions("define_clickedPopup")}));e.map.on("mousemove",i,(i=>{e.hoveredEvent=i;t.doCoreAndRunActions("define_hoveredFeature");t.doCoreAndRunActions("set_hoverEffects");t.doCoreAndRunActions("define_hoveredPopup")}));e.map.on("mouseout",i,(e=>{t.doCoreAndRunActions("set_hoverEffectsOff");t.doCoreAndRunActions("set_hoveredPopupOff")}))}}));this.dynamicLayerListenersSet=!0}}setDataLayerEvents(e,t){}setMarkerEvents(e,t){e.markers.forEach((i=>{i.getElement().addEventListener("click",(()=>{e.clickedMarker=i;t.doCoreAndRunActions("define_clickedFeature_fromMarker");t.doCoreAndRunActions("set_storelocatorclick");t.doCoreAndRunActions("set_sidebarclick");t.doCoreAndRunActions("set_externallink");t.doCoreAndRunActions("define_clickedPopup_fromMarker")}));i.getElement().addEventListener("mouseenter",(n=>{e.hoveredMarker=i;t.doCoreAndRunActions("define_hoveredFeature_fromMarker");t.doCoreAndRunActions("define_tempHoverMarker");t.doCoreAndRunActions("define_hoveredPopup_fromMarker")}));i.getElement().addEventListener("mouseleave",(e=>{t.doCoreAndRunActions("set_hoverEffectsOff_fromMarker");t.doCoreAndRunActions("set_hoveredPopupOff_fromMarker")}))}))}setMoveEvents(e){if(!this.isPublic){e.once("idle",(e=>{this.doCoreAndRunActions("set_moveendVariables")}));e.on("moveend",(e=>{this.doCoreAndRunActions("set_moveendVariables")}))}}doCoreAndRunActions(e){return this.MapsterContainer.doCore(e)}runHookActions(e,t){if(window.mwm){let n=this.MapsterContainer.core[e].hook;const r=`${n}/mapster-${this.isPublic?this.post_id:"admin"}`;if(window.mwm.actions[r]){window.mwm.actions[r].funcs;if(window.mwm.actions[r].funcs.length>0)for(var i=0;i0)for(i=0;i{if(document.querySelector(o))return e(document.querySelector(o));const t=new MutationObserver((i=>{if(document.querySelector(o)){e(document.querySelector(o));t.disconnect()}}));t.observe(document.body,{childList:!0,subtree:!0})}))).then((t=>{e(".mapster-wp-maps").each((function(){const t=e(this).attr("id").replace("mapster-wp-maps-",""),i=""!==e(this).data("single_feature_id")&&e(this).data("single_feature_id");new MapsterMap(t,window.mapster_params.public,i).init()}))}));else{let s="Publish this post to generate an embed code.";const a=new URLSearchParams(window.location.search);if(a.has("post")){let c=window.mapster_params.directory.replace("/admin/","/admin/includes/mapster-embed-map.php");c=c+window.mapster_params.qd+"map_id="+a.get("post");s=``}let l="Publish this post to generate an listing code.";a.has("post")&&(l=`[mapster_listing_posts id="${a.get("post")}"]`);if(document.body.classList.contains("block-editor-page")){e("#mapster-wp-maps-preview").prependTo("#normal-sortables");e(".acf-field-625df5ebf4ecc .acf-input").text(s);e(".acf-field-6507ba6e3053a .acf-input").text(l)}else{e("#mapster-wp-maps-preview").prependTo("#acf_after_title-sortables");e(".acf-field-625df5ebf4ecc .acf-input").text(s);e(".acf-field-6507ba6e3053a .acf-input").text(l)}if(a.has("post")){let u=`\n [mapster_wp_map_submit map_id="${a.get("post")}" type="create_point"]
    \n [mapster_wp_map_submit map_id="${a.get("post")}" type="edit_point" button_text="Edit Point" header_text="Edit Point"]\n `;e(".acf-field-62bf86b094491 .acf-input").append(u)}var t=acf.getFields().length,i=0,n=0;function r(e){"select"!==e&&(i+=1);i===t&&4===n&&new MapsterMap("map",window.mapster_params.public,!1).init()}acf.add_action("ready_field",r);acf.addAction("select2_init",(function(e,t,i,o){n+=1;r("select")}))}var o}(jQuery);