!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).maplibregl=e()}(this,(function(){"use strict";var t,e,n;function r(r,i){if(t)if(e){var o="var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk);",a={};t(a);n=i(a);"undefined"!=typeof window&&(n.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=i;else t=i}r(0,(function(t){function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=r;function r(t,e,n,r){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=n,this.p2y=r}r.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},r.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},r.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},r.prototype.solveCurveX=function(t,e){var n,r,i,o,a;for(void 0===e&&(e=1e-6),i=t,a=0;a<8;a++){if(o=this.sampleCurveX(i)-t,Math.abs(o)(r=1))return r;for(;no?n=i:r=i,i=.5*(r-n)+n}return i},r.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var i=o;function o(t,e){this.x=t,this.y=e}o.prototype={clone:function(){return new o(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=n*this.x+e*this.y;return this.x=e*this.x-n*this.y,this.y=r,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=e.x+n*(this.x-e.x)-r*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(t){return t instanceof o?t:Array.isArray(t)?new o(t[0],t[1]):t};var a="undefined"!=typeof self?self:{},s=Math.pow(2,53)-1;function l(t,e,r,i){var o=new n(t,e,r,i);return function(t){return o.solve(t)}}var c=l(.25,.1,.25,1);function u(t,e,n){return Math.min(n,Math.max(e,t))}function p(t,e,n){var r=n-e,i=((t-e)%r+r)%r+e;return i===e?n:i}function h(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function g(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function y(t,e){t.forEach((function(t){e[t]&&(e[t]=e[t].bind(e))}))}function v(t,e){return-1!==t.indexOf(e,t.length-e.length)}function _(t,e,n){var r={};for(var i in t)r[i]=e.call(n||this,t[i],i,t);return r}function x(t,e,n){var r={};for(var i in t)e.call(n||this,t[i],i,t)&&(r[i]=t[i]);return r}function b(t){return Array.isArray(t)?t.map(b):"object"==typeof t&&t?_(t,b):t}var w={};function M(t){w[t]||("undefined"!=typeof console&&console.warn(t),w[t]=!0)}function S(t,e,n){return(n.y-t.y)*(e.x-t.x)>(e.y-t.y)*(n.x-t.x)}function T(t){for(var e=0,n=0,r=t.length,i=r-1,o=void 0,a=void 0;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(function(t,n,r,i){var o=r||i;return e[n]=!o||o.toLowerCase(),""})),e["max-age"]){var n=parseInt(e["max-age"],10);isNaN(n)?delete e["max-age"]:e["max-age"]=n}return e}var C=null;function L(t){if(null==C){var e=t.navigator?t.navigator.userAgent:null;C=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return C}function P(t){try{var e=a[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}var I,R,k,z,D=a.performance&&a.performance.now?a.performance.now.bind(a.performance):Date.now.bind(Date),O=a.requestAnimationFrame||a.mozRequestAnimationFrame||a.webkitRequestAnimationFrame||a.msRequestAnimationFrame,F=a.cancelAnimationFrame||a.mozCancelAnimationFrame||a.webkitCancelAnimationFrame||a.msCancelAnimationFrame,B={now:D,frame:function(t){var e=O(t);return{cancel:function(){return F(e)}}},getImageData:function(t,e){void 0===e&&(e=0);var n=a.document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return n.width=t.width,n.height=t.height,r.drawImage(t,0,0,t.width,t.height),r.getImageData(-e,-e,t.width+2*e,t.height+2*e)},resolveURL:function(t){return I||(I=a.document.createElement("a")),I.href=t,I.href},hardwareConcurrency:a.navigator&&a.navigator.hardwareConcurrency||4,get devicePixelRatio(){return a.devicePixelRatio},get prefersReducedMotion(){return!!a.matchMedia&&(null==R&&(R=a.matchMedia("(prefers-reduced-motion: reduce)")),R.matches)}},N={API_URL:"https://api.mapbox.com",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},FEEDBACK_URL:"https://apps.mapbox.com/feedback",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16,REGISTERED_PROTOCOLS:{}},U={supported:!1,testSupport:function(t){!j&&z&&(V?G(t):k=t)}},j=!1,V=!1;function G(t){var e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,z),t.isContextLost())return;U.supported=!0}catch(t){}t.deleteTexture(e),j=!0}a.document&&((z=a.document.createElement("img")).onload=function(){k&&G(k),k=null,V=!0},z.onerror=function(){j=!0,k=null},z.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");var H="01",W=function(t,e){this._transformRequestFn=t,this._customAccessToken=e,this._createSkuToken()};function q(t){return 0===t.indexOf("mapbox:")}W.prototype._createSkuToken=function(){var t=function(){for(var t="",e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",H,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt},W.prototype._isSkuTokenExpired=function(){return Date.now()>this._skuTokenExpiresAt},W.prototype.transformRequest=function(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}},W.prototype.normalizeStyleURL=function(t,e){if(!q(t))return t;var n=J(t);return n.path="/styles/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||e)},W.prototype.normalizeGlyphsURL=function(t,e){if(!q(t))return t;var n=J(t);return n.path="/fonts/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||e)},W.prototype.normalizeSourceURL=function(t,e){if(!q(t))return t;var n=J(t);return n.path="/v4/"+n.authority+".json",n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||e)},W.prototype.normalizeSpriteURL=function(t,e,n,r){var i=J(t);return q(t)?(i.path="/styles/v1"+i.path+"/sprite"+e+n,this._makeAPIURL(i,this._customAccessToken||r)):(i.path+=""+e+n,Y(i))},W.prototype.normalizeTileURL=function(t,e){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!q(t))return t;var n=J(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,(B.devicePixelRatio>=2||512===e?"@2x":"")+(U.supported?".webp":"$1")),n.path=n.path.replace(/^.+\/v4\//,"/"),n.path="/v4"+n.path;var r=this._customAccessToken||function(t){for(var e=0,n=t;e=0&&t.params.splice(i,1)}if("/"!==r.path&&(t.path=""+r.path+t.path),!N.REQUIRE_ACCESS_TOKEN)return Y(t);if(!(e=e||N.ACCESS_TOKEN))throw new Error("An API access token is required to use Mapbox GL. "+n);if("s"===e[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+n);return t.params=t.params.filter((function(t){return-1===t.indexOf("access_token")})),t.params.push("access_token="+e),Y(t)},W.prototype.setTransformRequest=function(t){this._transformRequestFn=t};var Z=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;function X(t){return Z.test(t)}var $=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function J(t){var e=t.match($);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function Y(t){var e=t.params.length?"?"+t.params.join("&"):"";return t.protocol+"://"+t.authority+t.path+e}function Q(t){if(!t)return null;var e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(a.atob(e[1]).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return null}}var K=function(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null};K.prototype.getStorageKey=function(t){var e,n=Q(N.ACCESS_TOKEN);return e=n&&n.u?a.btoa(encodeURIComponent(n.u).replace(/%([0-9A-F]{2})/g,(function(t,e){return String.fromCharCode(Number("0x"+e))}))):N.ACCESS_TOKEN||"",t?"mapbox.eventData."+t+":"+e:"mapbox.eventData:"+e},K.prototype.fetchEventData=function(){var t=P("localStorage"),e=this.getStorageKey(),n=this.getStorageKey("uuid");if(t)try{var r=a.localStorage.getItem(e);r&&(this.eventData=JSON.parse(r));var i=a.localStorage.getItem(n);i&&(this.anonId=i)}catch(t){M("Unable to read from LocalStorage")}},K.prototype.saveEventData=function(){var t=P("localStorage"),e=this.getStorageKey(),n=this.getStorageKey("uuid");if(t)try{a.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&a.localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){M("Unable to write to LocalStorage")}},K.prototype.processRequests=function(t){},K.prototype.postEvent=function(t,e,n,r){var i=this;if(N.EVENTS_URL){var o=J(N.EVENTS_URL);o.params.push("access_token="+(r||N.ACCESS_TOKEN||""));var a={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:"1.15.2",skuId:H,userId:this.anonId},s=e?h(a,e):a,l={url:Y(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=wt(l,(function(t){i.pendingRequest=null,n(t),i.saveEventData(),i.processRequests(r)}))}},K.prototype.queueRequest=function(t,e){this.queue.push(t),this.processRequests(e)};var tt,et,nt=function(t){function e(){t.call(this,"map.load"),this.success={},this.skuToken=""}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.postMapLoadEvent=function(t,e,n,r){this.skuToken=n,(N.EVENTS_URL&&r||N.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return q(t)||X(t)})))&&this.queueRequest({id:e,timestamp:Date.now()},r)},e.prototype.processRequests=function(t){var e=this;if(!this.pendingRequest&&0!==this.queue.length){var n=this.queue.shift(),r=n.id,i=n.timestamp;r&&this.success[r]||(this.anonId||this.fetchEventData(),g(this.anonId)||(this.anonId=m()),this.postEvent(i,{skuToken:this.skuToken},(function(t){t||r&&(e.success[r]=!0)}),t))}},e}(K),rt=new(function(t){function e(e){t.call(this,"appUserTurnstile"),this._customAccessToken=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.postTurnstileEvent=function(t,e){N.EVENTS_URL&&N.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return q(t)||X(t)}))&&this.queueRequest(Date.now(),e)},e.prototype.processRequests=function(t){var e=this;if(!this.pendingRequest&&0!==this.queue.length){this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();var n=Q(N.ACCESS_TOKEN),r=n?n.u:N.ACCESS_TOKEN,i=r!==this.eventData.tokenU;g(this.anonId)||(this.anonId=m(),i=!0);var o=this.queue.shift();if(this.eventData.lastSuccess){var a=new Date(this.eventData.lastSuccess),s=new Date(o),l=(o-this.eventData.lastSuccess)/864e5;i=i||l>=1||l<-1||a.getDate()!==s.getDate()}else i=!0;if(!i)return this.processRequests();this.postEvent(o,{"enabled.telemetry":!1},(function(t){t||(e.eventData.lastSuccess=o,e.eventData.tokenU=r)}),t)}},e}(K)),it=rt.postTurnstileEvent.bind(rt),ot=new nt,at=ot.postMapLoadEvent.bind(ot),st=500,lt=50;function ct(){a.caches&&!tt&&(tt=a.caches.open("mapbox-tiles"))}function ut(t){var e=t.indexOf("?");return e<0?t:t.slice(0,e)}var pt,ht=1/0;function dt(){return null==pt&&(pt=a.OffscreenCanvas&&new a.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.createImageBitmap),pt}var ft={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(ft);var mt=function(t){function e(e,n,r){401===n&&X(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),t.call(this,e),this.status=n,this.url=r,this.name=this.constructor.name,this.message=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.toString=function(){return this.name+": "+this.message+" ("+this.status+"): "+this.url},e}(Error),gt=E()?function(){return self.worker&&self.worker.referrer}:function(){return("blob:"===a.location.protocol?a.parent:a).location.href};function yt(t,e){var n,r=new a.AbortController,i=new a.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:gt(),signal:r.signal}),o=!1,s=!1,l=(n=i.url).indexOf("sku=")>0&&X(n);"json"===t.type&&i.headers.set("Accept","application/json");var c=function(n,r,o){if(!s){if(n&&"SecurityError"!==n.message&&M(n),r&&o)return u(r);var c=Date.now();a.fetch(i).then((function(n){if(n.ok){var r=l?n.clone():null;return u(n,r,c)}return e(new mt(n.statusText,n.status,t.url))})).catch((function(t){20!==t.code&&e(new Error(t.message))}))}},u=function(n,r,l){("arrayBuffer"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text()).then((function(t){s||(r&&l&&function(t,e,n){if(ct(),tt){var r={status:e.status,statusText:e.statusText,headers:new a.Headers};e.headers.forEach((function(t,e){return r.headers.set(e,t)}));var i=A(e.headers.get("Cache-Control")||"");i["no-store"]||(i["max-age"]&&r.headers.set("Expires",new Date(n+1e3*i["max-age"]).toUTCString()),new Date(r.headers.get("Expires")).getTime()-n<42e4||function(t,e){if(void 0===et)try{new Response(new ReadableStream),et=!0}catch(t){et=!1}et?e(t.body):t.blob().then(e)}(e,(function(e){var n=new a.Response(e,r);ct(),tt&&tt.then((function(e){return e.put(ut(t.url),n)})).catch((function(t){return M(t.message)}))})))}}(i,r,l),o=!0,e(null,t,n.headers.get("Cache-Control"),n.headers.get("Expires")))})).catch((function(t){s||e(new Error(t.message))}))};return l?function(t,e){if(ct(),!tt)return e(null);var n=ut(t.url);tt.then((function(t){t.match(n).then((function(r){var i=function(t){if(!t)return!1;var e=new Date(t.headers.get("Expires")||0),n=A(t.headers.get("Cache-Control")||"");return e>Date.now()&&!n["no-cache"]}(r);t.delete(n),i&&t.put(n,r.clone()),e(null,r,i)})).catch(e)})).catch(e)}(i,c):c(null,null),{cancel:function(){s=!0,o||r.abort()}}}var vt,_t,xt=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(E()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!E()){var n=t.url.substring(0,t.url.indexOf("://"));return(N.REGISTERED_PROTOCOLS[n]||yt)(t,e)}}if(!(/^file:/.test(r=t.url)||/^file:/.test(gt())&&!/^\w+:/.test(r))){if(a.fetch&&a.Request&&a.AbortController&&a.Request.prototype.hasOwnProperty("signal"))return yt(t,e);if(E()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(t,e){var n=new a.XMLHttpRequest;for(var r in n.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(n.responseType="arraybuffer"),t.headers)n.setRequestHeader(r,t.headers[r]);return"json"===t.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===t.credentials,n.onerror=function(){e(new Error(n.statusText))},n.onload=function(){if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){var r=n.response;if("json"===t.type)try{r=JSON.parse(n.response)}catch(t){return e(t)}e(null,r,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else e(new mt(n.statusText,n.status,t.url))},n.send(t.body),{cancel:function(){return n.abort()}}}(t,e)},bt=function(t,e){return xt(h(t,{type:"arrayBuffer"}),e)},wt=function(t,e){return xt(h(t,{method:"POST"}),e)},Mt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";vt=[],_t=0;var St=function(t,e){if(U.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),_t>=N.MAX_PARALLEL_IMAGE_REQUESTS){var n={requestParameters:t,callback:e,cancelled:!1,cancel:function(){this.cancelled=!0}};return vt.push(n),n}_t++;var r=!1,i=function(){if(!r)for(r=!0,_t--;vt.length&&_t0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)},Lt.prototype.setEventedParent=function(t,e){return this._eventedParent=t,this._eventedParentData=e,this};var Pt={$version:8,$root:{version:{required:!0,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"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,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:!0,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:!1},"*":{type:"*"}},source_raster:{type:{required:!0,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:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,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:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,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:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},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_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,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:!1,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:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,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:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,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:!0,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:!1,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:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,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:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,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:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,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:!0,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:!1,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:!1,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:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,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:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,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_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:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,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"}}},It=function(t,e,n,r){this.message=(t?t+": ":"")+n,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)};function Rt(t){var e=t.value;return e?[new It(t.key,e,"constants have been deprecated as of v8")]:[]}function kt(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var Jt=[Bt,Nt,Ut,jt,Vt,qt,Gt,Xt(Ht),Zt];function Yt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Yt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(var n=0,r=Jt;n255?255:t}function i(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function o(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function a(t,e,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?t+(e-t)*n*6:2*n<1?e:3*n<2?t+(e-t)*(2/3-n)*6:t}try{e.parseCSSColor=function(t){var e,s=t.replace(/ /g,"").toLowerCase();if(s in n)return n[s].slice();if("#"===s[0])return 4===s.length?(e=parseInt(s.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===s.length&&(e=parseInt(s.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=s.indexOf("("),c=s.indexOf(")");if(-1!==l&&c+1===s.length){var u=s.substr(0,l),p=s.substr(l+1,c-(l+1)).split(","),h=1;switch(u){case"rgba":if(4!==p.length)return null;h=o(p.pop());case"rgb":return 3!==p.length?null:[i(p[0]),i(p[1]),i(p[2]),h];case"hsla":if(4!==p.length)return null;h=o(p.pop());case"hsl":if(3!==p.length)return null;var d=(parseFloat(p[0])%360+360)%360/360,f=o(p[1]),m=o(p[2]),g=m<=.5?m*(f+1):m+f-m*f,y=2*m-g;return[r(255*a(y,g,d+1/3)),r(255*a(y,g,d)),r(255*a(y,g,d-1/3)),h];default:return null}}return null}}catch(t){}})).parseCSSColor,ee=function(t,e,n,r){void 0===r&&(r=1),this.r=t,this.g=e,this.b=n,this.a=r};ee.parse=function(t){if(t){if(t instanceof ee)return t;if("string"==typeof t){var e=te(t);if(e)return new ee(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},ee.prototype.toString=function(){var t=this.toArray(),e=t[1],n=t[2],r=t[3];return"rgba("+Math.round(t[0])+","+Math.round(e)+","+Math.round(n)+","+r+")"},ee.prototype.toArray=function(){var t=this.a;return 0===t?[0,0,0,0]:[255*this.r/t,255*this.g/t,255*this.b/t,t]},ee.black=new ee(0,0,0,1),ee.white=new ee(1,1,1,1),ee.transparent=new ee(0,0,0,0),ee.red=new ee(1,0,0,1);var ne=function(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})};ne.prototype.compare=function(t,e){return this.collator.compare(t,e)},ne.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var re=function(t,e,n,r,i){this.text=t,this.image=e,this.scale=n,this.fontStack=r,this.textColor=i},ie=function(t){this.sections=t};ie.fromString=function(t){return new ie([new re(t,null,null,null,null)])},ie.prototype.isEmpty=function(){return 0===this.sections.length||!this.sections.some((function(t){return 0!==t.text.length||t.image&&0!==t.image.name.length}))},ie.factory=function(t){return t instanceof ie?t:ie.fromString(t)},ie.prototype.toString=function(){return 0===this.sections.length?"":this.sections.map((function(t){return t.text})).join("")},ie.prototype.serialize=function(){for(var t=["format"],e=0,n=this.sections;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:"Invalid rgba value ["+[t,e,n,r].join(", ")+"]: 'a' must be between 0 and 1.":"Invalid rgba value ["+("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")+"]: 'r', 'g', and 'b' must be between 0 and 255."}function se(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof ee)return!0;if(t instanceof ne)return!0;if(t instanceof ie)return!0;if(t instanceof oe)return!0;if(Array.isArray(t)){for(var e=0,n=t;e2){var s=t[1];if("string"!=typeof s||!(s in he)||"object"===s)return e.error('The item type argument of "array" must be one of string, number, boolean',1);o=he[s],r++}else o=Ht;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);a=t[2],r++}n=Xt(o,a)}else n=he[i];for(var l=[];r1)&&e.push(r)}}return e.concat(this.args.map((function(t){return t.serialize()})))};var fe=function(t){this.type=qt,this.sections=t};fe.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var n=t[1];if(!Array.isArray(n)&&"object"==typeof n)return e.error("First argument must be an image or text section.");for(var r=[],i=!1,o=1;o<=t.length-1;++o){var a=t[o];if(i&&"object"==typeof a&&!Array.isArray(a)){i=!1;var s=null;if(a["font-scale"]&&!(s=e.parse(a["font-scale"],1,Nt)))return null;var l=null;if(a["text-font"]&&!(l=e.parse(a["text-font"],1,Xt(Ut))))return null;var c=null;if(a["text-color"]&&!(c=e.parse(a["text-color"],1,Vt)))return null;var u=r[r.length-1];u.scale=s,u.font=l,u.textColor=c}else{var p=e.parse(t[o],1,Ht);if(!p)return null;var h=p.type.kind;if("string"!==h&&"value"!==h&&"null"!==h&&"resolvedImage"!==h)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:p,scale:null,font:null,textColor:null})}}return new fe(r)},fe.prototype.evaluate=function(t){return new ie(this.sections.map((function(e){var n=e.content.evaluate(t);return le(n)===Zt?new re("",n,null,null,null):new re(ce(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))},fe.prototype.eachChild=function(t){for(var e=0,n=this.sections;e-1),n},me.prototype.eachChild=function(t){t(this.input)},me.prototype.outputDefined=function(){return!1},me.prototype.serialize=function(){return["image",this.input.serialize()]};var ge={"to-boolean":jt,"to-color":Vt,"to-number":Nt,"to-string":Ut},ye=function(t,e){this.type=t,this.args=e};ye.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var n=t[0];if(("to-boolean"===n||"to-string"===n)&&2!==t.length)return e.error("Expected one argument.");for(var r=ge[n],i=[],o=1;o4?"Invalid rbga value "+JSON.stringify(e)+": expected an array containing either three or four numeric values.":ae(e[0],e[1],e[2],e[3])))return new ee(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new pe(n||"Could not parse color from value '"+("string"==typeof e?e:String(JSON.stringify(e)))+"'")}if("number"===this.type.kind){for(var a=null,s=0,l=this.args;s=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Se(t,e){var n=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return[Math.round(n*i*8192),Math.round(r*i*8192)]}function Te(t,e,n){return e[1]>t[1]!=n[1]>t[1]&&t[0]<(n[0]-e[0])*(t[1]-e[1])/(n[1]-e[1])+e[0]}function Ee(t,e){for(var n,r,i,o,a,s,l,c=!1,u=0,p=e.length;u0&&s<0||a<0&&s>0}function Le(t,e,n){for(var r=0,i=n;rn[2]){var i=.5*r,o=t[0]-n[0]>i?-r:n[0]-t[0]>i?r:0;0===o&&(o=t[0]-n[2]>i?-r:n[2]-t[0]>i?r:0),t[0]+=o}we(e,t)}function De(t,e,n,r){for(var i=8192*Math.pow(2,r.z),o=[8192*r.x,8192*r.y],a=[],s=0,l=t;s=0)return!1;var n=!0;return t.eachChild((function(t){n&&!Ue(t,e)&&(n=!1)})),n}Fe.parse=function(t,e){if(2!==t.length)return e.error("'within' expression requires exactly one argument, but found "+(t.length-1)+" instead.");if(se(t[1])){var n=t[1];if("FeatureCollection"===n.type)for(var r=0;re))throw new pe("Input is not a number.");o=a-1}return 0}Ve.prototype.parse=function(t,e,n,r,i){return void 0===i&&(i={}),e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)},Ve.prototype._parse=function(t,e){function n(t,e,n){return"assert"===n?new de(e,[t]):"coerce"===n?new ye(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var r=t[0];if("string"!=typeof r)return this.error("Expression name must be a string, but found "+typeof r+' instead. If you wanted a literal array, use ["literal", [...]].',0),null;var i=this.registry[r];if(i){var o=i.parse(t,this);if(!o)return null;if(this.expectedType){var a=this.expectedType,s=o.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind&&"array"!==a.kind||"value"!==s.kind)if("color"!==a.kind&&"formatted"!==a.kind&&"resolvedImage"!==a.kind||"value"!==s.kind&&"string"!==s.kind){if(this.checkSubtype(a,s))return null}else o=n(o,a,e.typeAnnotation||"coerce");else o=n(o,a,e.typeAnnotation||"assert")}if(!(o instanceof ue)&&"resolvedImage"!==o.type.kind&&function t(e){if(e instanceof je)return t(e.boundExpression);if(e instanceof xe&&"error"===e.name)return!1;if(e instanceof be)return!1;if(e instanceof Fe)return!1;var n=e instanceof ye||e instanceof de,r=!0;return e.eachChild((function(e){r=n?r&&t(e):r&&e instanceof ue})),!!r&&Be(e)&&Ue(e,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}(o)){var l=new _e;try{o=new ue(o.type,o.evaluate(l))}catch(t){return this.error(t.message),null}}return o}return this.error('Unknown expression "'+r+'". If you wanted a literal array, use ["literal", [...]].',0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':"Expected an array, but found "+typeof t+" instead.")},Ve.prototype.concat=function(t,e,n){var r="number"==typeof t?this.path.concat(t):this.path,i=n?this.scope.concat(n):this.scope;return new Ve(this.registry,r,e||null,i,this.errors)},Ve.prototype.error=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var r=""+this.key+e.map((function(t){return"["+t+"]"})).join("");this.errors.push(new Ot(r,t))},Ve.prototype.checkSubtype=function(t,e){var n=Yt(t,e);return n&&this.error(n),n};var He=function(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var r=0,i=n;r=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',l);var u=e.parse(s,c,i);if(!u)return null;i=i||u.type,r.push([a,u])}return new He(i,n,r)},He.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[Ge(e,r)].evaluate(t)},He.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var qe=Object.freeze({__proto__:null,number:We,color:function(t,e,n){return new ee(We(t.r,e.r,n),We(t.g,e.g,n),We(t.b,e.b,n),We(t.a,e.a,n))},array:function(t,e,n){return t.map((function(t,r){return We(t,e[r],n)}))}}),Ze=6/29*3*(6/29),Xe=Math.PI/180,$e=180/Math.PI;function Je(t){return t>.008856451679035631?Math.pow(t,1/3):t/Ze+4/29}function Ye(t){return t>6/29?t*t*t:Ze*(t-4/29)}function Qe(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ke(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function tn(t){var e=Ke(t.r),n=Ke(t.g),r=Ke(t.b),i=Je((.4124564*e+.3575761*n+.1804375*r)/.95047),o=Je((.2126729*e+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-Je((.0193339*e+.119192*n+.9503041*r)/1.08883)),alpha:t.a}}function en(t){var e=(t.l+16)/116,n=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Ye(e),n=.95047*Ye(n),r=1.08883*Ye(r),new ee(Qe(3.2404542*n-1.5371385*e-.4985314*r),Qe(-.969266*n+1.8760108*e+.041556*r),Qe(.0556434*n-.2040259*e+1.0572252*r),t.alpha)}function nn(t,e,n){var r=e-t;return t+n*(r>180||r<-180?r-360*Math.round(r/360):r)}var rn={forward:tn,reverse:en,interpolate:function(t,e,n){return{l:We(t.l,e.l,n),a:We(t.a,e.a,n),b:We(t.b,e.b,n),alpha:We(t.alpha,e.alpha,n)}}},on={forward:function(t){var e=tn(t),n=e.l,r=e.a,i=e.b,o=Math.atan2(i,r)*$e;return{h:o<0?o+360:o,c:Math.sqrt(r*r+i*i),l:n,alpha:t.a}},reverse:function(t){var e=t.h*Xe,n=t.c;return en({l:t.l,a:Math.cos(e)*n,b:Math.sin(e)*n,alpha:t.alpha})},interpolate:function(t,e,n){return{h:nn(t.h,e.h,n),c:We(t.c,e.c,n),l:We(t.l,e.l,n),alpha:We(t.alpha,e.alpha,n)}}},an=Object.freeze({__proto__:null,lab:rn,hcl:on}),sn=function(t,e,n,r,i){this.type=t,this.operator=e,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(var o=0,a=i;o1})))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:s}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(i=e.parse(i,2,Nt)))return null;var l=[],c=null;"interpolate-hcl"===n||"interpolate-lab"===n?c=Vt:e.expectedType&&"value"!==e.expectedType.kind&&(c=e.expectedType);for(var u=0;u=p)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);var m=e.parse(h,f,c);if(!m)return null;c=c||m.type,l.push([p,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new sn(c,n,r,i,l):e.error("Type "+$t(c)+" is not interpolatable.")},sn.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;if(r>=e[i-1])return n[i-1].evaluate(t);var o=Ge(e,r),a=sn.interpolationFactor(this.interpolation,r,e[o],e[o+1]),s=n[o].evaluate(t),l=n[o+1].evaluate(t);return"interpolate"===this.operator?qe[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?on.reverse(on.interpolate(on.forward(s),on.forward(l),a)):rn.reverse(rn.interpolate(rn.forward(s),rn.forward(l),a))},sn.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e=n.length)throw new pe("Array index out of bounds: "+e+" > "+(n.length-1)+".");if(e!==Math.floor(e))throw new pe("Array index must be an integer, but found "+e+" instead.");return n[e]},pn.prototype.eachChild=function(t){t(this.index),t(this.input)},pn.prototype.outputDefined=function(){return!1},pn.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var hn=function(t,e){this.type=jt,this.needle=t,this.haystack=e};hn.parse=function(t,e){if(3!==t.length)return e.error("Expected 2 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Ht);return n&&r?Qt(n.type,[jt,Ut,Nt,Bt,Ht])?new hn(n,r):e.error("Expected first argument to be of type boolean, string, number or null, but found "+$t(n.type)+" instead"):null},hn.prototype.evaluate=function(t){var e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!n)return!1;if(!Kt(e,["boolean","string","number","null"]))throw new pe("Expected first argument to be of type boolean, string, number or null, but found "+$t(le(e))+" instead.");if(!Kt(n,["string","array"]))throw new pe("Expected second argument to be of type array or string, but found "+$t(le(n))+" instead.");return n.indexOf(e)>=0},hn.prototype.eachChild=function(t){t(this.needle),t(this.haystack)},hn.prototype.outputDefined=function(){return!0},hn.prototype.serialize=function(){return["in",this.needle.serialize(),this.haystack.serialize()]};var dn=function(t,e,n){this.type=Nt,this.needle=t,this.haystack=e,this.fromIndex=n};dn.parse=function(t,e){if(t.length<=2||t.length>=5)return e.error("Expected 3 or 4 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Ht);if(!n||!r)return null;if(!Qt(n.type,[jt,Ut,Nt,Bt,Ht]))return e.error("Expected first argument to be of type boolean, string, number or null, but found "+$t(n.type)+" instead");if(4===t.length){var i=e.parse(t[3],3,Nt);return i?new dn(n,r,i):null}return new dn(n,r)},dn.prototype.evaluate=function(t){var e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!Kt(e,["boolean","string","number","null"]))throw new pe("Expected first argument to be of type boolean, string, number or null, but found "+$t(le(e))+" instead.");if(!Kt(n,["string","array"]))throw new pe("Expected second argument to be of type array or string, but found "+$t(le(n))+" instead.");if(this.fromIndex){var r=this.fromIndex.evaluate(t);return n.indexOf(e,r)}return n.indexOf(e)},dn.prototype.eachChild=function(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)},dn.prototype.outputDefined=function(){return!1},dn.prototype.serialize=function(){if(null!=this.fromIndex&&void 0!==this.fromIndex){var t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]};var fn=function(t,e,n,r,i,o){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=o};fn.parse=function(t,e){if(t.length<5)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if(t.length%2!=1)return e.error("Expected an even number of arguments.");var n,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);for(var i={},o=[],a=2;aNumber.MAX_SAFE_INTEGER)return c.error("Branch labels must be integers no larger than "+Number.MAX_SAFE_INTEGER+".");if("number"==typeof h&&Math.floor(h)!==h)return c.error("Numeric branch labels must be integer values.");if(n){if(c.checkSubtype(n,le(h)))return null}else n=le(h);if(void 0!==i[String(h)])return c.error("Branch labels must be unique.");i[String(h)]=o.length}var d=e.parse(l,a,r);if(!d)return null;r=r||d.type,o.push(d)}var f=e.parse(t[1],1,Ht);if(!f)return null;var m=e.parse(t[t.length-1],t.length-1,r);return m?"value"!==f.type.kind&&e.concat(1).checkSubtype(n,f.type)?null:new fn(n,r,f,i,o,m):null},fn.prototype.evaluate=function(t){var e=this.input.evaluate(t);return(le(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)},fn.prototype.eachChild=function(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)},fn.prototype.outputDefined=function(){return this.outputs.every((function(t){return t.outputDefined()}))&&this.otherwise.outputDefined()},fn.prototype.serialize=function(){for(var t=this,e=["match",this.input.serialize()],n=[],r={},i=0,o=Object.keys(this.cases).sort();i=5)return e.error("Expected 3 or 4 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Nt);if(!n||!r)return null;if(!Qt(n.type,[Xt(Ht),Ut,Ht]))return e.error("Expected first argument to be of type array or string, but found "+$t(n.type)+" instead");if(4===t.length){var i=e.parse(t[3],3,Nt);return i?new gn(n.type,n,r,i):null}return new gn(n.type,n,r)},gn.prototype.evaluate=function(t){var e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);if(!Kt(e,["string","array"]))throw new pe("Expected first argument to be of type array or string, but found "+$t(le(e))+" instead.");if(this.endIndex){var r=this.endIndex.evaluate(t);return e.slice(n,r)}return e.slice(n)},gn.prototype.eachChild=function(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)},gn.prototype.outputDefined=function(){return!1},gn.prototype.serialize=function(){if(null!=this.endIndex&&void 0!==this.endIndex){var t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]};var xn=_n("==",(function(t,e,n){return e===n}),vn),bn=_n("!=",(function(t,e,n){return e!==n}),(function(t,e,n,r){return!vn(0,e,n,r)})),wn=_n("<",(function(t,e,n){return e",(function(t,e,n){return e>n}),(function(t,e,n,r){return r.compare(e,n)>0})),Sn=_n("<=",(function(t,e,n){return e<=n}),(function(t,e,n,r){return r.compare(e,n)<=0})),Tn=_n(">=",(function(t,e,n){return e>=n}),(function(t,e,n,r){return r.compare(e,n)>=0})),En=function(t,e,n,r,i){this.type=Ut,this.number=t,this.locale=e,this.currency=n,this.minFractionDigits=r,this.maxFractionDigits=i};En.parse=function(t,e){if(3!==t.length)return e.error("Expected two arguments.");var n=e.parse(t[1],1,Nt);if(!n)return null;var r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");var i=null;if(r.locale&&!(i=e.parse(r.locale,1,Ut)))return null;var o=null;if(r.currency&&!(o=e.parse(r.currency,1,Ut)))return null;var a=null;if(r["min-fraction-digits"]&&!(a=e.parse(r["min-fraction-digits"],1,Nt)))return null;var s=null;return r["max-fraction-digits"]&&!(s=e.parse(r["max-fraction-digits"],1,Nt))?null:new En(n,i,o,a,s)},En.prototype.evaluate=function(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))},En.prototype.eachChild=function(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)},En.prototype.outputDefined=function(){return!1},En.prototype.serialize=function(){var t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]};var An=function(t){this.type=Nt,this.input=t};An.parse=function(t,e){if(2!==t.length)return e.error("Expected 1 argument, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?e.error("Expected argument of type string or array, but found "+$t(n.type)+" instead."):new An(n):null},An.prototype.evaluate=function(t){var e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new pe("Expected value to be of type string or array, but found "+$t(le(e))+" instead.")},An.prototype.eachChild=function(t){t(this.input)},An.prototype.outputDefined=function(){return!1},An.prototype.serialize=function(){var t=["length"];return this.eachChild((function(e){t.push(e.serialize())})),t};var Cn={"==":xn,"!=":bn,">":Mn,"<":wn,">=":Tn,"<=":Sn,array:de,at:pn,boolean:de,case:mn,coalesce:cn,collator:be,format:fe,image:me,in:hn,"index-of":dn,interpolate:sn,"interpolate-hcl":sn,"interpolate-lab":sn,length:An,let:un,literal:ue,match:fn,number:de,"number-format":En,object:de,slice:gn,step:He,string:de,"to-boolean":ye,"to-color":ye,"to-number":ye,"to-string":ye,var:je,within:Fe};function Ln(t,e){var n=e[0],r=e[1],i=e[2],o=e[3];n=n.evaluate(t),r=r.evaluate(t),i=i.evaluate(t);var a=o?o.evaluate(t):1,s=ae(n,r,i,a);if(s)throw new pe(s);return new ee(n/255*a,r/255*a,i/255*a,a)}function Pn(t,e){return t in e}function In(t,e){var n=e[t];return void 0===n?null:n}function Rn(t){return{type:t}}function kn(t){return{result:"success",value:t}}function zn(t){return{result:"error",value:t}}function Dn(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function On(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Fn(t){return!!t.expression&&t.expression.interpolated}function Bn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Nn(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Un(t){return t}function jn(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:void 0}function Vn(t,e,n,r,i){return jn(typeof n===i?r[n]:void 0,t.default,e.default)}function Gn(t,e,n){if("number"!==Bn(n))return jn(t.default,e.default);var r=t.stops.length;if(1===r)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[r-1][0])return t.stops[r-1][1];var i=Ge(t.stops.map((function(t){return t[0]})),n);return t.stops[i][1]}function Hn(t,e,n){var r=void 0!==t.base?t.base:1;if("number"!==Bn(n))return jn(t.default,e.default);var i=t.stops.length;if(1===i)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[i-1][0])return t.stops[i-1][1];var o=Ge(t.stops.map((function(t){return t[0]})),n),a=function(t,e,n,r){var i=r-n,o=t-n;return 0===i?0:1===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}(n,r,t.stops[o][0],t.stops[o+1][0]),s=t.stops[o][1],l=t.stops[o+1][1],c=qe[e.type]||Un;if(t.colorSpace&&"rgb"!==t.colorSpace){var u=an[t.colorSpace];c=function(t,e){return u.reverse(u.interpolate(u.forward(t),u.forward(e),a))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=s.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==n&&void 0!==r)return c(n,r,a)}}:c(s,l,a)}function Wn(t,e,n){return"color"===e.type?n=ee.parse(n):"formatted"===e.type?n=ie.fromString(n.toString()):"resolvedImage"===e.type?n=oe.fromString(n.toString()):Bn(n)===e.type||"enum"===e.type&&e.values[n]||(n=void 0),jn(n,t.default,e.default)}xe.register(Cn,{error:[{kind:"error"},[Ut],function(t,e){throw new pe(e[0].evaluate(t))}],typeof:[Ut,[Ht],function(t,e){return $t(le(e[0].evaluate(t)))}],"to-rgba":[Xt(Nt,4),[Vt],function(t,e){return e[0].evaluate(t).toArray()}],rgb:[Vt,[Nt,Nt,Nt],Ln],rgba:[Vt,[Nt,Nt,Nt,Nt],Ln],has:{type:jt,overloads:[[[Ut],function(t,e){return Pn(e[0].evaluate(t),t.properties())}],[[Ut,Gt],function(t,e){var n=e[1];return Pn(e[0].evaluate(t),n.evaluate(t))}]]},get:{type:Ht,overloads:[[[Ut],function(t,e){return In(e[0].evaluate(t),t.properties())}],[[Ut,Gt],function(t,e){var n=e[1];return In(e[0].evaluate(t),n.evaluate(t))}]]},"feature-state":[Ht,[Ut],function(t,e){return In(e[0].evaluate(t),t.featureState||{})}],properties:[Gt,[],function(t){return t.properties()}],"geometry-type":[Ut,[],function(t){return t.geometryType()}],id:[Ht,[],function(t){return t.id()}],zoom:[Nt,[],function(t){return t.globals.zoom}],"heatmap-density":[Nt,[],function(t){return t.globals.heatmapDensity||0}],"line-progress":[Nt,[],function(t){return t.globals.lineProgress||0}],accumulated:[Ht,[],function(t){return void 0===t.globals.accumulated?null:t.globals.accumulated}],"+":[Nt,Rn(Nt),function(t,e){for(var n=0,r=0,i=e;r":[jt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i>o}],"filter-id->":[jt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>i}],"filter-<=":[jt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i<=o}],"filter-id-<=":[jt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r<=i}],"filter->=":[jt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i>=o}],"filter-id->=":[jt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>=i}],"filter-has":[jt,[Ht],function(t,e){return e[0].value in t.properties()}],"filter-has-id":[jt,[],function(t){return null!==t.id()&&void 0!==t.id()}],"filter-type-in":[jt,[Xt(Ut)],function(t,e){return e[0].value.indexOf(t.geometryType())>=0}],"filter-id-in":[jt,[Xt(Ht)],function(t,e){return e[0].value.indexOf(t.id())>=0}],"filter-in-small":[jt,[Ut,Xt(Ht)],function(t,e){var n=e[0];return e[1].value.indexOf(t.properties()[n.value])>=0}],"filter-in-large":[jt,[Ut,Xt(Ht)],function(t,e){var n=e[0],r=e[1];return function(t,e,n,r){for(;n<=r;){var i=n+r>>1;if(e[i]===t)return!0;e[i]>t?r=i-1:n=i+1}return!1}(t.properties()[n.value],r.value,0,r.value.length-1)}],all:{type:jt,overloads:[[[jt,jt],function(t,e){var n=e[1];return e[0].evaluate(t)&&n.evaluate(t)}],[Rn(jt),function(t,e){for(var n=0,r=e;n0&&"string"==typeof t[0]&&t[0]in Cn}function Xn(t,e){var n=new Ve(Cn,[],e?function(t){var e={color:Vt,string:Ut,number:Nt,enum:Ut,boolean:jt,formatted:qt,resolvedImage:Zt};return"array"===t.type?Xt(e[t.value]||Ht,t.length):e[t.type]}(e):void 0),r=n.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?kn(new qn(r,e)):zn(n.errors)}qn.prototype.evaluateWithoutErrorHandling=function(t,e,n,r,i,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)},qn.prototype.evaluate=function(t,e,n,r,i,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o||null;try{var a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new pe("Expected value to be one of "+Object.keys(this._enumValues).map((function(t){return JSON.stringify(t)})).join(", ")+", but found "+JSON.stringify(a)+" instead.");return a}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}};var $n=function(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Ne(e.expression)};$n.prototype.evaluateWithoutErrorHandling=function(t,e,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,o)},$n.prototype.evaluate=function(t,e,n,r,i,o){return this._styleExpression.evaluate(t,e,n,r,i,o)};var Jn=function(t,e,n,r){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Ne(e.expression),this.interpolationType=r};function Yn(t,e){if("error"===(t=Xn(t,e)).result)return t;var n=t.value.expression,r=Be(n);if(!r&&!Dn(e))return zn([new Ot("","data expressions not supported")]);var i=Ue(n,["zoom"]);if(!i&&!On(e))return zn([new Ot("","zoom expressions not supported")]);var o=function t(e){var n=null;if(e instanceof un)n=t(e.result);else if(e instanceof cn)for(var r=0,i=e.args;rr.maximum?[new It(e,n,n+" is greater than the maximum value "+r.maximum)]:[]}function nr(t){var e,n,r,i=t.valueSpec,o=zt(t.value.type),a={},s="categorical"!==o&&void 0===t.value.property,l=!s,c="array"===Bn(t.value.stops)&&"array"===Bn(t.value.stops[0])&&"object"===Bn(t.value.stops[0][0]),u=Kn({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return[new It(t.key,t.value,'identity function may not have a "stops" property')];var e=[],n=t.value;return e=e.concat(tr({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:p})),"array"===Bn(n)&&0===n.length&&e.push(new It(t.key,n,"array must have at least one stop")),e},default:function(t){return Sr({key:t.key,value:t.value,valueSpec:i,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===o&&s&&u.push(new It(t.key,t.value,'missing required property "property"')),"identity"===o||t.value.stops||u.push(new It(t.key,t.value,'missing required property "stops"')),"exponential"===o&&t.valueSpec.expression&&!Fn(t.valueSpec)&&u.push(new It(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Dn(t.valueSpec)?u.push(new It(t.key,t.value,"property functions not supported")):s&&!On(t.valueSpec)&&u.push(new It(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!c||void 0!==t.value.property||u.push(new It(t.key,t.value,'"property" property is required')),u;function p(t){var e=[],o=t.value,s=t.key;if("array"!==Bn(o))return[new It(s,o,"array expected, "+Bn(o)+" found")];if(2!==o.length)return[new It(s,o,"array length 2 expected, length "+o.length+" found")];if(c){if("object"!==Bn(o[0]))return[new It(s,o,"object expected, "+Bn(o[0])+" found")];if(void 0===o[0].zoom)return[new It(s,o,"object stop key must have zoom")];if(void 0===o[0].value)return[new It(s,o,"object stop key must have value")];if(r&&r>zt(o[0].zoom))return[new It(s,o[0].zoom,"stop zoom values must appear in ascending order")];zt(o[0].zoom)!==r&&(r=zt(o[0].zoom),n=void 0,a={}),e=e.concat(Kn({key:s+"[0]",value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:er,value:h}}))}else e=e.concat(h({key:s+"[0]",value:o[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},o));return Zn(Dt(o[1]))?e.concat([new It(s+"[1]",o[1],"expressions are not allowed in function stops.")]):e.concat(Sr({key:s+"[1]",value:o[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function h(t,r){var s=Bn(t.value),l=zt(t.value),c=null!==t.value?t.value:r;if(e){if(s!==e)return[new It(t.key,c,s+" stop domain type must match previous stop domain type "+e)]}else e=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new It(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==o){var u="number expected, "+s+" found";return Dn(i)&&void 0===o&&(u+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new It(t.key,c,u)]}return"categorical"!==o||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==o&&"number"===s&&void 0!==n&&l=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(var e=0,n=t.slice(1);ee?1:0}function cr(t){if(!t)return!0;var e,n=t[0];return t.length<=1?"any"!==n:"=="===n?ur(t[1],t[2],"=="):"!="===n?dr(ur(t[1],t[2],"==")):"<"===n||">"===n||"<="===n||">="===n?ur(t[1],t[2],n):"any"===n?(e=t.slice(1),["any"].concat(e.map(cr))):"all"===n?["all"].concat(t.slice(1).map(cr)):"none"===n?["all"].concat(t.slice(1).map(cr).map(dr)):"in"===n?pr(t[1],t.slice(2)):"!in"===n?dr(pr(t[1],t.slice(2))):"has"===n?hr(t[1]):"!has"===n?dr(hr(t[1])):"within"!==n||t}function ur(t,e,n){switch(t){case"$type":return["filter-type-"+n,e];case"$id":return["filter-id-"+n,e];default:return["filter-"+n,t,e]}}function pr(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((function(t){return typeof t!=typeof e[0]}))?["filter-in-large",t,["literal",e.sort(lr)]]:["filter-in-small",t,["literal",e]]}}function hr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function dr(t){return["!",t]}function fr(t){return or(Dt(t.value))?rr(kt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):function t(e){var n=e.value,r=e.key;if("array"!==Bn(n))return[new It(r,n,"array expected, "+Bn(n)+" found")];var i,o=e.styleSpec,a=[];if(n.length<1)return[new It(r,n,"filter array must have at least 1 element")];switch(a=a.concat(ir({key:r+"[0]",value:n[0],valueSpec:o.filter_operator,style:e.style,styleSpec:e.styleSpec})),zt(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===zt(n[1])&&a.push(new It(r,n,'"$type" cannot be use with operator "'+n[0]+'"'));case"==":case"!=":3!==n.length&&a.push(new It(r,n,'filter array for operator "'+n[0]+'" must have 3 elements'));case"in":case"!in":n.length>=2&&"string"!==(i=Bn(n[1]))&&a.push(new It(r+"[1]",n[1],"string expected, "+i+" found"));for(var s=2;s=u[d+0]&&r>=u[d+1])?(a[h]=!0,o.push(c[h])):a[h]=!1}}},Dr.prototype._forEachCell=function(t,e,n,r,i,o,a,s){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(n),p=this._convertToCellCoord(r),h=l;h<=u;h++)for(var d=c;d<=p;d++){var f=this.d*d+h;if((!s||s(this._convertFromCellCoord(h),this._convertFromCellCoord(d),this._convertFromCellCoord(h+1),this._convertFromCellCoord(d+1)))&&i.call(this,t,e,n,r,f,o,a,s))return}},Dr.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Dr.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Dr.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,n=0,r=0;r=0)){var u=t[c];l[c]=Br[s].shallow.indexOf(c)>=0?u:Gr(u,e)}t instanceof Error&&(l.message=t.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==s&&(l.$name=s),l}throw new Error("can't serialize object of type "+typeof t)}function Hr(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||jr(t)||Vr(t)||ArrayBuffer.isView(t)||t instanceof Or)return t;if(Array.isArray(t))return t.map(Hr);if("object"==typeof t){var e=t.$name||"Object",n=Br[e].klass;if(!n)throw new Error("can't deserialize unregistered class "+e);if(n.deserialize)return n.deserialize(t);for(var r=Object.create(n.prototype),i=0,o=Object.keys(t);i=0?s:Hr(s)}}return r}throw new Error("can't deserialize object of type "+typeof t)}var Wr=function(){this.first=!0};Wr.prototype.update=function(t,e){var n=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=e):this.lastFloorZoom=128&&t<=255},Arabic:function(t){return t>=1536&&t<=1791},"Arabic Supplement":function(t){return t>=1872&&t<=1919},"Arabic Extended-A":function(t){return t>=2208&&t<=2303},"Hangul Jamo":function(t){return t>=4352&&t<=4607},"Unified Canadian Aboriginal Syllabics":function(t){return t>=5120&&t<=5759},Khmer:function(t){return t>=6016&&t<=6143},"Unified Canadian Aboriginal Syllabics Extended":function(t){return t>=6320&&t<=6399},"General Punctuation":function(t){return t>=8192&&t<=8303},"Letterlike Symbols":function(t){return t>=8448&&t<=8527},"Number Forms":function(t){return t>=8528&&t<=8591},"Miscellaneous Technical":function(t){return t>=8960&&t<=9215},"Control Pictures":function(t){return t>=9216&&t<=9279},"Optical Character Recognition":function(t){return t>=9280&&t<=9311},"Enclosed Alphanumerics":function(t){return t>=9312&&t<=9471},"Geometric Shapes":function(t){return t>=9632&&t<=9727},"Miscellaneous Symbols":function(t){return t>=9728&&t<=9983},"Miscellaneous Symbols and Arrows":function(t){return t>=11008&&t<=11263},"CJK Radicals Supplement":function(t){return t>=11904&&t<=12031},"Kangxi Radicals":function(t){return t>=12032&&t<=12255},"Ideographic Description Characters":function(t){return t>=12272&&t<=12287},"CJK Symbols and Punctuation":function(t){return t>=12288&&t<=12351},Hiragana:function(t){return t>=12352&&t<=12447},Katakana:function(t){return t>=12448&&t<=12543},Bopomofo:function(t){return t>=12544&&t<=12591},"Hangul Compatibility Jamo":function(t){return t>=12592&&t<=12687},Kanbun:function(t){return t>=12688&&t<=12703},"Bopomofo Extended":function(t){return t>=12704&&t<=12735},"CJK Strokes":function(t){return t>=12736&&t<=12783},"Katakana Phonetic Extensions":function(t){return t>=12784&&t<=12799},"Enclosed CJK Letters and Months":function(t){return t>=12800&&t<=13055},"CJK Compatibility":function(t){return t>=13056&&t<=13311},"CJK Unified Ideographs Extension A":function(t){return t>=13312&&t<=19903},"Yijing Hexagram Symbols":function(t){return t>=19904&&t<=19967},"CJK Unified Ideographs":function(t){return t>=19968&&t<=40959},"Yi Syllables":function(t){return t>=40960&&t<=42127},"Yi Radicals":function(t){return t>=42128&&t<=42191},"Hangul Jamo Extended-A":function(t){return t>=43360&&t<=43391},"Hangul Syllables":function(t){return t>=44032&&t<=55215},"Hangul Jamo Extended-B":function(t){return t>=55216&&t<=55295},"Private Use Area":function(t){return t>=57344&&t<=63743},"CJK Compatibility Ideographs":function(t){return t>=63744&&t<=64255},"Arabic Presentation Forms-A":function(t){return t>=64336&&t<=65023},"Vertical Forms":function(t){return t>=65040&&t<=65055},"CJK Compatibility Forms":function(t){return t>=65072&&t<=65103},"Small Form Variants":function(t){return t>=65104&&t<=65135},"Arabic Presentation Forms-B":function(t){return t>=65136&&t<=65279},"Halfwidth and Fullwidth Forms":function(t){return t>=65280&&t<=65519}};function Zr(t){for(var e=0,n=t;e=65097&&t<=65103)||qr["CJK Compatibility Ideographs"](t)||qr["CJK Compatibility"](t)||qr["CJK Radicals Supplement"](t)||qr["CJK Strokes"](t)||!(!qr["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||qr["CJK Unified Ideographs Extension A"](t)||qr["CJK Unified Ideographs"](t)||qr["Enclosed CJK Letters and Months"](t)||qr["Hangul Compatibility Jamo"](t)||qr["Hangul Jamo Extended-A"](t)||qr["Hangul Jamo Extended-B"](t)||qr["Hangul Jamo"](t)||qr["Hangul Syllables"](t)||qr.Hiragana(t)||qr["Ideographic Description Characters"](t)||qr.Kanbun(t)||qr["Kangxi Radicals"](t)||qr["Katakana Phonetic Extensions"](t)||qr.Katakana(t)&&12540!==t||!(!qr["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!qr["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||qr["Unified Canadian Aboriginal Syllabics"](t)||qr["Unified Canadian Aboriginal Syllabics Extended"](t)||qr["Vertical Forms"](t)||qr["Yijing Hexagram Symbols"](t)||qr["Yi Syllables"](t)||qr["Yi Radicals"](t))))}function $r(t){return!(Xr(t)||function(t){return!!(qr["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||qr["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||qr["Letterlike Symbols"](t)||qr["Number Forms"](t)||qr["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||qr["Control Pictures"](t)&&9251!==t||qr["Optical Character Recognition"](t)||qr["Enclosed Alphanumerics"](t)||qr["Geometric Shapes"](t)||qr["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||qr["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||qr["CJK Symbols and Punctuation"](t)||qr.Katakana(t)||qr["Private Use Area"](t)||qr["CJK Compatibility Forms"](t)||qr["Small Form Variants"](t)||qr["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Jr(t){return t>=1424&&t<=2303||qr["Arabic Presentation Forms-A"](t)||qr["Arabic Presentation Forms-B"](t)}function Yr(t,e){return!(!e&&Jr(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||qr.Khmer(t))}function Qr(t){for(var e=0,n=t;e-1&&(ti="error"),Kr&&Kr(t)};function ri(){ii.fire(new At("pluginStateChange",{pluginStatus:ti,pluginURL:ei}))}var ii=new Lt,oi=function(){return ti},ai=function(){if("deferred"!==ti||!ei)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");ti="loading",ri(),ei&&bt({url:ei},(function(t){t?ni(t):(ti="loaded",ri())}))},si={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:function(){return"loaded"===ti||null!=si.applyArabicShaping},isLoading:function(){return"loading"===ti},setState:function(t){ti=t.pluginStatus,ei=t.pluginURL},isParsed:function(){return null!=si.applyArabicShaping&&null!=si.processBidirectionalText&&null!=si.processStyledBidirectionalText},getPluginURL:function(){return ei}},li=function(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Wr,this.transition={})};li.prototype.isSupportedScript=function(t){return function(t,e){for(var n=0,r=t;nthis.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*e}};var ci=function(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Nn(t))return new Qn(t,e);if(Zn(t)){var n=Yn(t,e);if("error"===n.result)throw new Error(n.value.map((function(t){return t.key+": "+t.message})).join(", "));return n.value}var r=t;return"string"==typeof t&&"color"===e.type&&(r=ee.parse(t)),{kind:"constant",evaluate:function(){return r}}}(void 0===e?t.specification.default:e,t.specification)};ci.prototype.isDataDriven=function(){return"source"===this.expression.kind||"composite"===this.expression.kind},ci.prototype.possiblyEvaluate=function(t,e,n){return this.property.possiblyEvaluate(this,t,e,n)};var ui=function(t){this.property=t,this.value=new ci(t,void 0)};ui.prototype.transitioned=function(t,e){return new hi(this.property,this.value,e,h({},t.transition,this.transition),t.now)},ui.prototype.untransitioned=function(){return new hi(this.property,this.value,null,{},0)};var pi=function(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)};pi.prototype.getValue=function(t){return b(this._values[t].value.value)},pi.prototype.setValue=function(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ui(this._values[t].property)),this._values[t].value=new ci(this._values[t].property,null===e?void 0:b(e))},pi.prototype.getTransition=function(t){return b(this._values[t].transition)},pi.prototype.setTransition=function(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ui(this._values[t].property)),this._values[t].transition=b(e)||void 0},pi.prototype.serialize=function(){for(var t={},e=0,n=Object.keys(this._values);ethis.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(r=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}(a))}return i};var di=function(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)};di.prototype.possiblyEvaluate=function(t,e,n){for(var r=new gi(this._properties),i=0,o=Object.keys(this._values);ir.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:n,to:e}},e.prototype.interpolate=function(t){return t},e}(vi),xi=function(t){this.specification=t};xi.prototype.possiblyEvaluate=function(t,e,n,r){if(void 0!==t.value){if("constant"===t.expression.kind){var i=t.expression.evaluate(e,null,{},n,r);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new li(Math.floor(e.zoom-1),e)),t.expression.evaluate(new li(Math.floor(e.zoom),e)),t.expression.evaluate(new li(Math.floor(e.zoom+1),e)),e)}},xi.prototype._calculate=function(t,e,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:n,to:e}},xi.prototype.interpolate=function(t){return t};var bi=function(t){this.specification=t};bi.prototype.possiblyEvaluate=function(t,e,n,r){return!!t.expression.evaluate(e,null,{},n,r)},bi.prototype.interpolate=function(){return!1};var wi=function(t){for(var e in this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],t){var n=t[e];n.specification.overridable&&this.overridableProperties.push(e);var r=this.defaultPropertyValues[e]=new ci(n,void 0),i=this.defaultTransitionablePropertyValues[e]=new ui(n);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}};Nr("DataDrivenProperty",vi),Nr("DataConstantProperty",yi),Nr("CrossFadedDataDrivenProperty",_i),Nr("CrossFadedProperty",xi),Nr("ColorRampProperty",bi);var Mi=function(t){function e(e,n){if(t.call(this),this.id=e.id,this.type=e.type,this._featureFilter={filter:function(){return!0},needGeometry:!1},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),n.layout&&(this._unevaluatedLayout=new fi(n.layout)),n.paint)){for(var r in this._transitionablePaint=new pi(n.paint),e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(var i in e.layout)this.setLayoutProperty(i,e.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new gi(n.paint)}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getCrossfadeParameters=function(){return this._crossfadeParameters},e.prototype.getLayoutProperty=function(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)},e.prototype.setLayoutProperty=function(t,e,n){void 0===n&&(n={}),null!=e&&this._validate(Rr,"layers."+this.id+".layout."+t,t,e,n)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)},e.prototype.getPaintProperty=function(t){return v(t,"-transition")?this._transitionablePaint.getTransition(t.slice(0,-"-transition".length)):this._transitionablePaint.getValue(t)},e.prototype.setPaintProperty=function(t,e,n){if(void 0===n&&(n={}),null!=e&&this._validate(Ir,"layers."+this.id+".paint."+t,t,e,n))return!1;if(v(t,"-transition"))return this._transitionablePaint.setTransition(t.slice(0,-"-transition".length),e||void 0),!1;var r=this._transitionablePaint._values[t],i="cross-faded-data-driven"===r.property.specification["property-type"],o=r.value.isDataDriven(),a=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);var s=this._transitionablePaint._values[t].value;return s.isDataDriven()||o||i||this._handleOverridablePaintPropertyUpdate(t,a,s)},e.prototype._handleSpecialPaintPropertyUpdate=function(t){},e.prototype._handleOverridablePaintPropertyUpdate=function(t,e,n){return!1},e.prototype.isHidden=function(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility},e.prototype.updateTransitions=function(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)},e.prototype.hasTransition=function(){return this._transitioningPaint.hasTransition()},e.prototype.recalculate=function(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)},e.prototype.serialize=function(){var t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),x(t,(function(t,e){return!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)}))},e.prototype._validate=function(t,e,n,r,i){return void 0===i&&(i={}),(!i||!1!==i.validate)&&kr(this,t.call(Lr,{key:e,layerType:this.type,objectKey:n,value:r,styleSpec:Pt,style:{glyphs:!0,sprite:!0}}))},e.prototype.is3D=function(){return!1},e.prototype.isTileClipped=function(){return!1},e.prototype.hasOffscreenPass=function(){return!1},e.prototype.resize=function(){},e.prototype.isStateDependent=function(){for(var t in this.paint._values){var e=this.paint.get(t);if(e instanceof mi&&Dn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1},e}(Lt),Si={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},Ti=function(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8},Ei=function(){this.isTransferred=!1,this.capacity=-1,this.resize(0)};function Ai(t,e){void 0===e&&(e=1);var n=0,r=0;return{members:t.map((function(t){var i=Si[t.type].BYTES_PER_ELEMENT,o=n=Ci(n,Math.max(e,i)),a=t.components||1;return r=Math.max(r,i),n+=i*a,{name:t.name,type:t.type,components:a,offset:o}})),size:Ci(n,Math.max(r,e)),alignment:e}}function Ci(t,e){return Math.ceil(t/e)*e}Ei.serialize=function(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}},Ei.deserialize=function(t){var e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e},Ei.prototype._trim=function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())},Ei.prototype.clear=function(){this.length=0},Ei.prototype.resize=function(t){this.reserve(t),this.length=t},Ei.prototype.reserve=function(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},Ei.prototype._refreshViews=function(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")};var Li=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.int16[r+0]=e,this.int16[r+1]=n,t},e}(Ei);Li.prototype.bytesPerElement=4,Nr("StructArrayLayout2i4",Li);var Pi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=4*t;return this.int16[o+0]=e,this.int16[o+1]=n,this.int16[o+2]=r,this.int16[o+3]=i,t},e}(Ei);Pi.prototype.bytesPerElement=8,Nr("StructArrayLayout4i8",Pi);var Ii=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=6*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,t},e}(Ei);Ii.prototype.bytesPerElement=12,Nr("StructArrayLayout2i4i12",Ii);var Ri=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=4*t,l=8*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.uint8[l+4]=r,this.uint8[l+5]=i,this.uint8[l+6]=o,this.uint8[l+7]=a,t},e}(Ei);Ri.prototype.bytesPerElement=8,Nr("StructArrayLayout2i4ub8",Ri);var ki=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.float32[r+0]=e,this.float32[r+1]=n,t},e}(Ei);ki.prototype.bytesPerElement=8,Nr("StructArrayLayout2f8",ki);var zi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,c){var u=this.length;return this.resize(u+1),this.emplace(u,t,e,n,r,i,o,a,s,l,c)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,c,u){var p=10*t;return this.uint16[p+0]=e,this.uint16[p+1]=n,this.uint16[p+2]=r,this.uint16[p+3]=i,this.uint16[p+4]=o,this.uint16[p+5]=a,this.uint16[p+6]=s,this.uint16[p+7]=l,this.uint16[p+8]=c,this.uint16[p+9]=u,t},e}(Ei);zi.prototype.bytesPerElement=20,Nr("StructArrayLayout10ui20",zi);var Di=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,c,u,p){var h=this.length;return this.resize(h+1),this.emplace(h,t,e,n,r,i,o,a,s,l,c,u,p)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,c,u,p,h){var d=12*t;return this.int16[d+0]=e,this.int16[d+1]=n,this.int16[d+2]=r,this.int16[d+3]=i,this.uint16[d+4]=o,this.uint16[d+5]=a,this.uint16[d+6]=s,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=p,this.int16[d+11]=h,t},e}(Ei);Di.prototype.bytesPerElement=24,Nr("StructArrayLayout4i4ui4i24",Di);var Oi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.float32[i+0]=e,this.float32[i+1]=n,this.float32[i+2]=r,t},e}(Ei);Oi.prototype.bytesPerElement=12,Nr("StructArrayLayout3f12",Oi);var Fi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.uint32[1*t+0]=e,t},e}(Ei);Fi.prototype.bytesPerElement=4,Nr("StructArrayLayout1ul4",Fi);var Bi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l){var c=this.length;return this.resize(c+1),this.emplace(c,t,e,n,r,i,o,a,s,l)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,c){var u=10*t,p=5*t;return this.int16[u+0]=e,this.int16[u+1]=n,this.int16[u+2]=r,this.int16[u+3]=i,this.int16[u+4]=o,this.int16[u+5]=a,this.uint32[p+3]=s,this.uint16[u+8]=l,this.uint16[u+9]=c,t},e}(Ei);Bi.prototype.bytesPerElement=20,Nr("StructArrayLayout6i1ul2ui20",Bi);var Ni=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=6*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,t},e}(Ei);Ni.prototype.bytesPerElement=12,Nr("StructArrayLayout2i2i2i12",Ni);var Ui=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i){var o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,r,i)},e.prototype.emplace=function(t,e,n,r,i,o){var a=4*t,s=8*t;return this.float32[a+0]=e,this.float32[a+1]=n,this.float32[a+2]=r,this.int16[s+6]=i,this.int16[s+7]=o,t},e}(Ei);Ui.prototype.bytesPerElement=16,Nr("StructArrayLayout2f1f2i16",Ui);var ji=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=12*t,a=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=n,this.float32[a+1]=r,this.float32[a+2]=i,t},e}(Ei);ji.prototype.bytesPerElement=12,Nr("StructArrayLayout2ub2f12",ji);var Vi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=n,this.uint16[i+2]=r,t},e}(Ei);Vi.prototype.bytesPerElement=6,Nr("StructArrayLayout3ui6",Vi);var Gi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m,g){var y=this.length;return this.resize(y+1),this.emplace(y,t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m,g)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m,g,y){var v=24*t,_=12*t,x=48*t;return this.int16[v+0]=e,this.int16[v+1]=n,this.uint16[v+2]=r,this.uint16[v+3]=i,this.uint32[_+2]=o,this.uint32[_+3]=a,this.uint32[_+4]=s,this.uint16[v+10]=l,this.uint16[v+11]=c,this.uint16[v+12]=u,this.float32[_+7]=p,this.float32[_+8]=h,this.uint8[x+36]=d,this.uint8[x+37]=f,this.uint8[x+38]=m,this.uint32[_+10]=g,this.int16[v+22]=y,t},e}(Ei);Gi.prototype.bytesPerElement=48,Nr("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Gi);var Hi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m,g,y,v,_,x,b,w,M,S,T,E,A){var C=this.length;return this.resize(C+1),this.emplace(C,t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m,g,y,v,_,x,b,w,M,S,T,E,A)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m,g,y,v,_,x,b,w,M,S,T,E,A,C){var L=34*t,P=17*t;return this.int16[L+0]=e,this.int16[L+1]=n,this.int16[L+2]=r,this.int16[L+3]=i,this.int16[L+4]=o,this.int16[L+5]=a,this.int16[L+6]=s,this.int16[L+7]=l,this.uint16[L+8]=c,this.uint16[L+9]=u,this.uint16[L+10]=p,this.uint16[L+11]=h,this.uint16[L+12]=d,this.uint16[L+13]=f,this.uint16[L+14]=m,this.uint16[L+15]=g,this.uint16[L+16]=y,this.uint16[L+17]=v,this.uint16[L+18]=_,this.uint16[L+19]=x,this.uint16[L+20]=b,this.uint16[L+21]=w,this.uint16[L+22]=M,this.uint32[P+12]=S,this.float32[P+13]=T,this.float32[P+14]=E,this.float32[P+15]=A,this.float32[P+16]=C,t},e}(Ei);Hi.prototype.bytesPerElement=68,Nr("StructArrayLayout8i15ui1ul4f68",Hi);var Wi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.float32[1*t+0]=e,t},e}(Ei);Wi.prototype.bytesPerElement=4,Nr("StructArrayLayout1f4",Wi);var qi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.int16[i+0]=e,this.int16[i+1]=n,this.int16[i+2]=r,t},e}(Ei);qi.prototype.bytesPerElement=6,Nr("StructArrayLayout3i6",qi);var Zi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=n,this.uint16[i+3]=r,t},e}(Ei);Zi.prototype.bytesPerElement=8,Nr("StructArrayLayout1ul2ui8",Zi);var Xi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=n,t},e}(Ei);Xi.prototype.bytesPerElement=4,Nr("StructArrayLayout2ui4",Xi);var $i=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.uint16[1*t+0]=e,t},e}(Ei);$i.prototype.bytesPerElement=2,Nr("StructArrayLayout1ui2",$i);var Ji=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=4*t;return this.float32[o+0]=e,this.float32[o+1]=n,this.float32[o+2]=r,this.float32[o+3]=i,t},e}(Ei);Ji.prototype.bytesPerElement=16,Nr("StructArrayLayout4f16",Ji);var Yi=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorPointX:{configurable:!0},anchorPointY:{configurable:!0},x1:{configurable:!0},y1:{configurable:!0},x2:{configurable:!0},y2:{configurable:!0},featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0},anchorPoint:{configurable:!0}};return n.anchorPointX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorPointY.get=function(){return this._structArray.int16[this._pos2+1]},n.x1.get=function(){return this._structArray.int16[this._pos2+2]},n.y1.get=function(){return this._structArray.int16[this._pos2+3]},n.x2.get=function(){return this._structArray.int16[this._pos2+4]},n.y2.get=function(){return this._structArray.int16[this._pos2+5]},n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+8]},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+9]},n.anchorPoint.get=function(){return new i(this.anchorPointX,this.anchorPointY)},Object.defineProperties(e.prototype,n),e}(Ti);Yi.prototype.size=20;var Qi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new Yi(this,t)},e}(Bi);Nr("CollisionBoxArray",Qi);var Ki=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorX:{configurable:!0},anchorY:{configurable:!0},glyphStartIndex:{configurable:!0},numGlyphs:{configurable:!0},vertexStartIndex:{configurable:!0},lineStartIndex:{configurable:!0},lineLength:{configurable:!0},segment:{configurable:!0},lowerSize:{configurable:!0},upperSize:{configurable:!0},lineOffsetX:{configurable:!0},lineOffsetY:{configurable:!0},writingMode:{configurable:!0},placedOrientation:{configurable:!0},hidden:{configurable:!0},crossTileID:{configurable:!0},associatedIconIndex:{configurable:!0}};return n.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},n.glyphStartIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.numGlyphs.get=function(){return this._structArray.uint16[this._pos2+3]},n.vertexStartIndex.get=function(){return this._structArray.uint32[this._pos4+2]},n.lineStartIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.lineLength.get=function(){return this._structArray.uint32[this._pos4+4]},n.segment.get=function(){return this._structArray.uint16[this._pos2+10]},n.lowerSize.get=function(){return this._structArray.uint16[this._pos2+11]},n.upperSize.get=function(){return this._structArray.uint16[this._pos2+12]},n.lineOffsetX.get=function(){return this._structArray.float32[this._pos4+7]},n.lineOffsetY.get=function(){return this._structArray.float32[this._pos4+8]},n.writingMode.get=function(){return this._structArray.uint8[this._pos1+36]},n.placedOrientation.get=function(){return this._structArray.uint8[this._pos1+37]},n.placedOrientation.set=function(t){this._structArray.uint8[this._pos1+37]=t},n.hidden.get=function(){return this._structArray.uint8[this._pos1+38]},n.hidden.set=function(t){this._structArray.uint8[this._pos1+38]=t},n.crossTileID.get=function(){return this._structArray.uint32[this._pos4+10]},n.crossTileID.set=function(t){this._structArray.uint32[this._pos4+10]=t},n.associatedIconIndex.get=function(){return this._structArray.int16[this._pos2+22]},Object.defineProperties(e.prototype,n),e}(Ti);Ki.prototype.size=48;var to=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new Ki(this,t)},e}(Gi);Nr("PlacedSymbolArray",to);var eo=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorX:{configurable:!0},anchorY:{configurable:!0},rightJustifiedTextSymbolIndex:{configurable:!0},centerJustifiedTextSymbolIndex:{configurable:!0},leftJustifiedTextSymbolIndex:{configurable:!0},verticalPlacedTextSymbolIndex:{configurable:!0},placedIconSymbolIndex:{configurable:!0},verticalPlacedIconSymbolIndex:{configurable:!0},key:{configurable:!0},textBoxStartIndex:{configurable:!0},textBoxEndIndex:{configurable:!0},verticalTextBoxStartIndex:{configurable:!0},verticalTextBoxEndIndex:{configurable:!0},iconBoxStartIndex:{configurable:!0},iconBoxEndIndex:{configurable:!0},verticalIconBoxStartIndex:{configurable:!0},verticalIconBoxEndIndex:{configurable:!0},featureIndex:{configurable:!0},numHorizontalGlyphVertices:{configurable:!0},numVerticalGlyphVertices:{configurable:!0},numIconVertices:{configurable:!0},numVerticalIconVertices:{configurable:!0},useRuntimeCollisionCircles:{configurable:!0},crossTileID:{configurable:!0},textBoxScale:{configurable:!0},textOffset0:{configurable:!0},textOffset1:{configurable:!0},collisionCircleDiameter:{configurable:!0}};return n.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},n.rightJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+2]},n.centerJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+3]},n.leftJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+4]},n.verticalPlacedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+5]},n.placedIconSymbolIndex.get=function(){return this._structArray.int16[this._pos2+6]},n.verticalPlacedIconSymbolIndex.get=function(){return this._structArray.int16[this._pos2+7]},n.key.get=function(){return this._structArray.uint16[this._pos2+8]},n.textBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+9]},n.textBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+10]},n.verticalTextBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+11]},n.verticalTextBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+12]},n.iconBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+13]},n.iconBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+14]},n.verticalIconBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+15]},n.verticalIconBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+16]},n.featureIndex.get=function(){return this._structArray.uint16[this._pos2+17]},n.numHorizontalGlyphVertices.get=function(){return this._structArray.uint16[this._pos2+18]},n.numVerticalGlyphVertices.get=function(){return this._structArray.uint16[this._pos2+19]},n.numIconVertices.get=function(){return this._structArray.uint16[this._pos2+20]},n.numVerticalIconVertices.get=function(){return this._structArray.uint16[this._pos2+21]},n.useRuntimeCollisionCircles.get=function(){return this._structArray.uint16[this._pos2+22]},n.crossTileID.get=function(){return this._structArray.uint32[this._pos4+12]},n.crossTileID.set=function(t){this._structArray.uint32[this._pos4+12]=t},n.textBoxScale.get=function(){return this._structArray.float32[this._pos4+13]},n.textOffset0.get=function(){return this._structArray.float32[this._pos4+14]},n.textOffset1.get=function(){return this._structArray.float32[this._pos4+15]},n.collisionCircleDiameter.get=function(){return this._structArray.float32[this._pos4+16]},Object.defineProperties(e.prototype,n),e}(Ti);eo.prototype.size=68;var no=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new eo(this,t)},e}(Hi);Nr("SymbolInstanceArray",no);var ro=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getoffsetX=function(t){return this.float32[1*t+0]},e}(Wi);Nr("GlyphOffsetArray",ro);var io=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getx=function(t){return this.int16[3*t+0]},e.prototype.gety=function(t){return this.int16[3*t+1]},e.prototype.gettileUnitDistanceFromAnchor=function(t){return this.int16[3*t+2]},e}(qi);Nr("SymbolLineVertexArray",io);var oo=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0}};return n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+0]},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+3]},Object.defineProperties(e.prototype,n),e}(Ti);oo.prototype.size=8;var ao=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new oo(this,t)},e}(Zi);Nr("FeatureIndexArray",ao);var so=Ai([{name:"a_pos",components:2,type:"Int16"}],4).members,lo=function(t){void 0===t&&(t=[]),this.segments=t};function co(t,e){return 256*(t=u(Math.floor(t),0,255))+u(Math.floor(e),0,255)}lo.prototype.prepareSegment=function(t,e,n,r){var i=this.segments[this.segments.length-1];return t>lo.MAX_VERTEX_ARRAY_LENGTH&&M("Max vertices per segment is "+lo.MAX_VERTEX_ARRAY_LENGTH+": bucket requested "+t),(!i||i.vertexLength+t>lo.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:e.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i},lo.prototype.get=function(){return this.segments},lo.prototype.destroy=function(){for(var t=0,e=this.segments;t>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}})),ho=e((function(t){t.exports=function(t,e){for(var n,r=t.length,i=e^r,o=0;r>=4;)n=1540483477*(65535&(n=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:i^=(255&t.charCodeAt(o+2))<<16;case 2:i^=(255&t.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}})),fo=po,mo=ho;fo.murmur3=po,fo.murmur2=mo;var go=function(){this.ids=[],this.positions=[],this.indexed=!1};go.prototype.add=function(t,e,n,r){this.ids.push(vo(t)),this.positions.push(e,n,r)},go.prototype.getPositions=function(t){for(var e=vo(t),n=0,r=this.ids.length-1;n>1;this.ids[i]>=e?r=i:n=i+1}for(var o=[];this.ids[n]===e;)o.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return o},go.serialize=function(t,e){var n=new Float64Array(t.ids),r=new Uint32Array(t.positions);return function t(e,n,r,i){for(;r>1],a=r-1,s=i+1;;){do{a++}while(e[a]o);if(a>=s)break;_o(e,a,s),_o(n,3*a,3*s),_o(n,3*a+1,3*s+1),_o(n,3*a+2,3*s+2)}s-ra.x+1||la.y+1)&&M("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return n}function Vo(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?jo(t):[]}}function Go(t,e,n,r,i){t.emplaceBack(2*e+(r+1)/2,2*n+(i+1)/2)}var Ho=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Li,this.indexArray=new Vi,this.segments=new lo,this.programConfigurations=new Oo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};function Wo(t,e){for(var n=0;n1){if($o(t,e))return!0;for(var r=0;r1?n:n.sub(e)._mult(i)._add(e))}function Ko(t,e){for(var n,r,i,o=!1,a=0;ae.y!=(i=n[l]).y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(o=!o);return o}function ta(t,e){for(var n=!1,r=0,i=t.length-1;re.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function ea(t,e,n){var r=n[0],i=n[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return!1;var o=S(t,e,n[0]);return o!==S(t,e,n[1])||o!==S(t,e,n[2])||o!==S(t,e,n[3])}function na(t,e,n){var r=e.paint.get(t).value;return"constant"===r.kind?r.value:n.programConfigurations.get(e.id).getMaxValue(t)}function ra(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ia(t,e,n,r,o){if(!e[0]&&!e[1])return t;var a=i.convert(e)._mult(o);"viewport"===n&&a._rotate(-r);for(var s=[],l=0;l=8192||u<0||u>=8192)){var p=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),h=p.vertexLength;Go(this.layoutVertexArray,c,u,-1,-1),Go(this.layoutVertexArray,c,u,1,-1),Go(this.layoutVertexArray,c,u,1,1),Go(this.layoutVertexArray,c,u,-1,1),this.indexArray.emplaceBack(h,h+1,h+2),this.indexArray.emplaceBack(h,h+3,h+2),p.vertexLength+=4,p.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,{},r)},Nr("CircleBucket",Ho,{omit:["layers"]});var oa=new wi({"circle-sort-key":new vi(Pt.layout_circle["circle-sort-key"])}),aa={paint:new wi({"circle-radius":new vi(Pt.paint_circle["circle-radius"]),"circle-color":new vi(Pt.paint_circle["circle-color"]),"circle-blur":new vi(Pt.paint_circle["circle-blur"]),"circle-opacity":new vi(Pt.paint_circle["circle-opacity"]),"circle-translate":new yi(Pt.paint_circle["circle-translate"]),"circle-translate-anchor":new yi(Pt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new yi(Pt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new yi(Pt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new vi(Pt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new vi(Pt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new vi(Pt.paint_circle["circle-stroke-opacity"])}),layout:oa},sa="undefined"!=typeof Float32Array?Float32Array:Array;function la(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ca(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],p=e[8],h=e[9],d=e[10],f=e[11],m=e[12],g=e[13],y=e[14],v=e[15],_=n[0],x=n[1],b=n[2],w=n[3];return t[0]=_*r+x*s+b*p+w*m,t[1]=_*i+x*l+b*h+w*g,t[2]=_*o+x*c+b*d+w*y,t[3]=_*a+x*u+b*f+w*v,t[4]=(_=n[4])*r+(x=n[5])*s+(b=n[6])*p+(w=n[7])*m,t[5]=_*i+x*l+b*h+w*g,t[6]=_*o+x*c+b*d+w*y,t[7]=_*a+x*u+b*f+w*v,t[8]=(_=n[8])*r+(x=n[9])*s+(b=n[10])*p+(w=n[11])*m,t[9]=_*i+x*l+b*h+w*g,t[10]=_*o+x*c+b*d+w*y,t[11]=_*a+x*u+b*f+w*v,t[12]=(_=n[12])*r+(x=n[13])*s+(b=n[14])*p+(w=n[15])*m,t[13]=_*i+x*l+b*h+w*g,t[14]=_*o+x*c+b*d+w*y,t[15]=_*a+x*u+b*f+w*v,t}Math.hypot||(Math.hypot=function(){for(var t=arguments,e=0,n=arguments.length;n--;)e+=t[n]*t[n];return Math.sqrt(e)});var ua,pa=ca;function ha(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}ua=new sa(3),sa!=Float32Array&&(ua[0]=0,ua[1]=0,ua[2]=0),function(){var t=new sa(4);sa!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var da=(function(){var t=new sa(2);sa!=Float32Array&&(t[0]=0,t[1]=0)}(),function(t){function e(e){t.call(this,e,aa)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.createBucket=function(t){return new Ho(t)},e.prototype.queryRadius=function(t){var e=t;return na("circle-radius",this,e)+na("circle-stroke-width",this,e)+ra(this.paint.get("circle-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,i,o,a,s){for(var l=ia(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,a),c=this.paint.get("circle-radius").evaluate(e,n)+this.paint.get("circle-stroke-width").evaluate(e,n),u="map"===this.paint.get("circle-pitch-alignment"),p=u?l:function(t,e){return t.map((function(t){return fa(t,e)}))}(l,s),h=u?c*a:c,d=0,f=r;dt.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=t.data,s=e.data,l=0;l80*n){r=o=t[0],i=a=t[1];for(var f=n;fo&&(o=s),l>a&&(a=l);c=0!==(c=Math.max(o-r,a-i))?1/c:0}return Ra(h,d,n,r,i,c),d}function Pa(t,e,n,r,i){var o,a;if(i===ts(t,e,n,r)>0)for(o=e;o=e;o-=r)a=Ya(o,t[o],t[o+1],a);return a&&Wa(a,a.next)&&(Qa(a),a=a.next),a}function Ia(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Wa(r,r.next)&&0!==Ha(r.prev,r,r.next))r=r.next;else{if(Qa(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Ra(t,e,n,r,i,o,a){if(t){!a&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Ua(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,a,s,l,c=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,c*=2}while(a>1)}(i)}(t,r,i,o);for(var s,l,c=t;t.prev!==t.next;)if(s=t.prev,l=t.next,o?za(t,r,i,o):ka(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Qa(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Ra(t=Da(Ia(t),e,n),e,n,r,i,o,2):2===a&&Oa(t,e,n,r,i,o):Ra(Ia(t),e,n,r,i,o,1);break}}}function ka(t){var e=t.prev,n=t,r=t.next;if(Ha(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Va(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Ha(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function za(t,e,n,r){var i=t.prev,o=t,a=t.next;if(Ha(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,c=Ua(i.x=c&&h&&h.z<=u;){if(p!==t.prev&&p!==t.next&&Va(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Ha(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,h!==t.prev&&h!==t.next&&Va(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&Ha(h.prev,h,h.next)>=0)return!1;h=h.nextZ}for(;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&Va(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Ha(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;h&&h.z<=u;){if(h!==t.prev&&h!==t.next&&Va(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&Ha(h.prev,h,h.next)>=0)return!1;h=h.nextZ}return!0}function Da(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!Wa(i,o)&&qa(i,r,r.next,o)&&$a(i,o)&&$a(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Qa(r),Qa(r.next),r=t=o),r=r.next}while(r!==t);return Ia(r)}function Oa(t,e,n,r,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Ga(a,s)){var l=Ja(a,s);return a=Ia(a,a.next),l=Ia(l,l.next),Ra(a,e,n,r,i,o),void Ra(l,e,n,r,i,o)}s=s.next}a=a.next}while(a!==t)}function Fa(t,e){return t.x-e.x}function Ba(t,e){if(e=function(t,e){var n,r=e,i=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x=r.x&&r.x>=u&&i!==r.x&&Va(on.x||r.x===n.x&&Na(n,r)))&&(n=r,h=l)),r=r.next}while(r!==c);return n}(t,e)){var n=Ja(e,t);Ia(e,e.next),Ia(n,n.next)}}function Na(t,e){return Ha(t.prev,t,e.prev)<0&&Ha(e.next,t,t.next)<0}function Ua(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ja(t){var e=t,n=t;do{(e.x=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function Ga(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&qa(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&($a(t,e)&&$a(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(Ha(t.prev,t,e.prev)||Ha(t,e.prev,e))||Wa(t,e)&&Ha(t.prev,t,t.next)>0&&Ha(e.prev,e,e.next)>0)}function Ha(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Wa(t,e){return t.x===e.x&&t.y===e.y}function qa(t,e,n,r){var i=Xa(Ha(t,e,n)),o=Xa(Ha(t,e,r)),a=Xa(Ha(n,r,t)),s=Xa(Ha(n,r,e));return i!==o&&a!==s||!(0!==i||!Za(t,n,e))||!(0!==o||!Za(t,r,e))||!(0!==a||!Za(n,t,r))||!(0!==s||!Za(n,e,r))}function Za(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Xa(t){return t>0?1:t<0?-1:0}function $a(t,e){return Ha(t.prev,t,t.next)<0?Ha(t,e,t.next)>=0&&Ha(t,t.prev,e)>=0:Ha(t,e,t.prev)<0||Ha(t,t.next,e)<0}function Ja(t,e){var n=new Ka(t.i,t.x,t.y),r=new Ka(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Ya(t,e,n,r){var i=new Ka(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Qa(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ka(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ts(t,e,n,r){for(var i=0,o=e,a=n-r;or;){if(i-r>600){var a=i-r+1,s=n-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);t(e,n,Math.max(r,Math.floor(n-s*c/a+u)),Math.min(i,Math.floor(n+(a-s)*c/a+u)),o)}var p=e[n],h=r,d=i;for(ns(e,r,n),o(e[i],p)>0&&ns(e,r,i);h0;)d--}0===o(e[r],p)?ns(e,r,d):ns(e,++d,i),d<=n&&(r=d+1),n<=d&&(i=d-1)}}(t,e,n||0,r||t.length-1,i||rs)}function ns(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function rs(t,e){return te?1:0}function is(t,e){var n=t.length;if(n<=1)return[t];for(var r,i,o=[],a=0;a1)for(var l=0;l0&&n.holes.push(r+=t[i-1].length)}return n},Aa.default=Ca;var ls=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Li,this.indexArray=new Vi,this.indexArray2=new Xi,this.programConfigurations=new Oo(t.layers,t.zoom),this.segments=new lo,this.segments2=new lo,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};ls.prototype.populate=function(t,e,n){this.hasPattern=as("fill",this.layers,e);for(var r=this.layers[0].layout.get("fill-sort-key"),i=!r.isConstant(),o=[],a=0,s=t;a>3}if(o--,1===r||2===r)a+=t.readSVarint(),s+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new i(a,s));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},fs.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,n=1,r=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,c=-1/0;t.pos>3}if(r--,1===n||2===n)(i+=t.readSVarint())s&&(s=i),(o+=t.readSVarint())c&&(c=o);else if(7!==n)throw new Error("unknown command "+n)}return[a,l,s,c]},fs.prototype.toGeoJSON=function(t,e,n){var r,i,o=this.extent*Math.pow(2,n),a=this.extent*t,s=this.extent*e,l=this.loadGeometry(),c=fs.types[this.type];function u(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(n))}function xs(t,e,n){if(3===t){var r=new ys(n,n.readVarint()+n.pos);r.length&&(e[r.name]=r)}}vs.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new ds(this._pbf,e,this.extent,this._keys,this._values)};var bs={VectorTile:function(t,e){this.layers=t.readFields(xs,{},e)},VectorTileFeature:ds,VectorTileLayer:ys},ws=bs.VectorTileFeature.types,Ms=Math.pow(2,13);function Ss(t,e,n,r,i,o,a,s){t.emplaceBack(e,n,2*Math.floor(r*Ms)+a,i*Ms*2,o*Ms*2,Math.round(s))}var Ts=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ii,this.indexArray=new Vi,this.programConfigurations=new Oo(t.layers,t.zoom),this.segments=new lo,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};function Es(t,e){return t.x===e.x&&(t.x<0||t.x>8192)||t.y===e.y&&(t.y<0||t.y>8192)}Ts.prototype.populate=function(t,e,n){this.features=[],this.hasPattern=as("fill-extrusion",this.layers,e);for(var r=0,i=t;r8192}))||R.every((function(t){return t.y<0}))||R.every((function(t){return t.y>8192}))))for(var m=0,g=0;g=1){var v=f[g-1];if(!Es(y,v)){p.vertexLength+4>lo.MAX_VERTEX_ARRAY_LENGTH&&(p=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));var _=y.sub(v)._perp()._unit(),x=v.dist(y);m+x>32768&&(m=0),Ss(this.layoutVertexArray,y.x,y.y,_.x,_.y,0,0,m),Ss(this.layoutVertexArray,y.x,y.y,_.x,_.y,0,1,m),Ss(this.layoutVertexArray,v.x,v.y,_.x,_.y,0,0,m+=x),Ss(this.layoutVertexArray,v.x,v.y,_.x,_.y,0,1,m);var b=p.vertexLength;this.indexArray.emplaceBack(b,b+2,b+1),this.indexArray.emplaceBack(b+1,b+2,b+3),p.vertexLength+=4,p.primitiveLength+=2}}}}if(p.vertexLength+l>lo.MAX_VERTEX_ARRAY_LENGTH&&(p=this.segments.prepareSegment(l,this.layoutVertexArray,this.indexArray)),"Polygon"===ws[t.type]){for(var w=[],M=[],S=p.vertexLength,T=0,E=s;T=2&&t[l-1].equals(t[l-2]);)l--;for(var c=0;c0;if(M&&y>c){var T=u.dist(d);if(T>2*p){var E=u.sub(u.sub(d)._mult(p/T)._round());this.updateDistance(d,E),this.addCurrentVertex(E,m,0,0,h),d=E}}var A=d&&f,C=A?n:s?"butt":r;if(A&&"round"===C&&(bi&&(C="bevel"),"bevel"===C&&(b>2&&(C="flipbevel"),b100)v=g.mult(-1);else{var L=b*m.add(g).mag()/m.sub(g).mag();v._perp()._mult(L*(S?-1:1))}this.addCurrentVertex(u,v,0,0,h),this.addCurrentVertex(u,v.mult(-1),0,0,h)}else if("bevel"===C||"fakeround"===C){var P=-Math.sqrt(b*b-1),I=S?P:0,R=S?0:P;if(d&&this.addCurrentVertex(u,m,I,R,h),"fakeround"===C)for(var k=Math.round(180*w/Math.PI/20),z=1;z2*p){var U=u.add(f.sub(u)._mult(p/N)._round());this.updateDistance(u,U),this.addCurrentVertex(U,g,0,0,h),u=U}}}}},Os.prototype.addCurrentVertex=function(t,e,n,r,i,o){void 0===o&&(o=!1);var a=e.y*r-e.x,s=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*n,e.y-e.x*n,o,!1,n,i),this.addHalfVertex(t,a,s,o,!0,-r,i),this.distance>Ds/2&&0===this.totalDistance&&(this.distance=0,this.addCurrentVertex(t,e,n,r,i,o))},Os.prototype.addHalfVertex=function(t,e,n,r,i,o,a){var s=.5*(this.lineClips?this.scaledDistance*(Ds-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t.x<<1)+(r?1:0),(t.y<<1)+(i?1:0),Math.round(63*e)+128,Math.round(63*n)+128,1+(0===o?0:o<0?-1:1)|(63&s)<<2,s>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);var l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),i?this.e2=l:this.e1=l},Os.prototype.updateScaledDistance=function(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance},Os.prototype.updateDistance=function(t,e){this.distance+=t.dist(e),this.updateScaledDistance()},Nr("LineBucket",Os,{omit:["layers","patternFeatures"]});var Fs=new wi({"line-cap":new yi(Pt.layout_line["line-cap"]),"line-join":new vi(Pt.layout_line["line-join"]),"line-miter-limit":new yi(Pt.layout_line["line-miter-limit"]),"line-round-limit":new yi(Pt.layout_line["line-round-limit"]),"line-sort-key":new vi(Pt.layout_line["line-sort-key"])}),Bs={paint:new wi({"line-opacity":new vi(Pt.paint_line["line-opacity"]),"line-color":new vi(Pt.paint_line["line-color"]),"line-translate":new yi(Pt.paint_line["line-translate"]),"line-translate-anchor":new yi(Pt.paint_line["line-translate-anchor"]),"line-width":new vi(Pt.paint_line["line-width"]),"line-gap-width":new vi(Pt.paint_line["line-gap-width"]),"line-offset":new vi(Pt.paint_line["line-offset"]),"line-blur":new vi(Pt.paint_line["line-blur"]),"line-dasharray":new xi(Pt.paint_line["line-dasharray"]),"line-pattern":new _i(Pt.paint_line["line-pattern"]),"line-gradient":new bi(Pt.paint_line["line-gradient"])}),layout:Fs},Ns=new(function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.possiblyEvaluate=function(e,n){return n=new li(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),t.prototype.possiblyEvaluate.call(this,e,n)},e.prototype.evaluate=function(e,n,r,i){return n=h({},n,{zoom:Math.floor(n.zoom)}),t.prototype.evaluate.call(this,e,n,r,i)},e}(vi))(Bs.paint.properties["line-width"].specification);Ns.useIntegerZoom=!0;var Us=function(t){function e(e){t.call(this,e,Bs),this.gradientVersion=0}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._handleSpecialPaintPropertyUpdate=function(t){"line-gradient"===t&&(this.stepInterpolant=this._transitionablePaint._values["line-gradient"].value.expression._styleExpression.expression instanceof He,this.gradientVersion=(this.gradientVersion+1)%s)},e.prototype.gradientExpression=function(){return this._transitionablePaint._values["line-gradient"].value.expression},e.prototype.recalculate=function(e,n){t.prototype.recalculate.call(this,e,n),this.paint._values["line-floorwidth"]=Ns.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)},e.prototype.createBucket=function(t){return new Os(t)},e.prototype.queryRadius=function(t){var e=t,n=js(na("line-width",this,e),na("line-gap-width",this,e)),r=na("line-offset",this,e);return n/2+Math.abs(r)+ra(this.paint.get("line-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,o,a,s){var l=ia(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,s),c=s/2*js(this.paint.get("line-width").evaluate(e,n),this.paint.get("line-gap-width").evaluate(e,n)),u=this.paint.get("line-offset").evaluate(e,n);return u&&(r=function(t,e){for(var n=[],r=new i(0,0),o=0;o=3)for(var o=0;o0?e+2*t:t}var Vs=Ai([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Gs=Ai([{name:"a_projected_pos",components:3,type:"Float32"}],4),Hs=(Ai([{name:"a_fade_opacity",components:1,type:"Uint32"}],4),Ai([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}])),Ws=(Ai([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]),Ai([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4)),qs=Ai([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Zs(t,e,n){return t.sections.forEach((function(t){t.text=function(t,e,n){var r=e.layout.get("text-transform").evaluate(n,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),si.applyArabicShaping&&(t=si.applyArabicShaping(t)),t}(t.text,e,n)})),t}Ai([{name:"triangle",components:3,type:"Uint16"}]),Ai([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),Ai([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Ai([{type:"Float32",name:"offsetX"}]),Ai([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Xs={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},$s=function(t,e,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,u=-7,p=n?i-1:0,h=n?-1:1,d=t[e+p];for(p+=h,o=d&(1<<-u)-1,d>>=-u,u+=s;u>0;o=256*o+t[e+p],p+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+t[e+p],p+=h,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),o-=c}return(d?-1:1)*a*Math.pow(2,o-r)},Js=function(t,e,n,r,i,o){var a,s,l,c=8*o-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+p>=1?h/l:h*Math.pow(2,1-p))*l>=2&&(a++,l/=2),a+p>=u?(s=0,a=u):a+p>=1?(s=(e*l-1)*Math.pow(2,i),a+=p):(s=e*Math.pow(2,p-1)*Math.pow(2,i),a=0));i>=8;t[n+d]=255&s,d+=f,s/=256,i-=8);for(a=a<0;t[n+d]=255&a,d+=f,a/=256,c-=8);t[n+d-f]|=128*m},Ys=Qs;function Qs(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Qs.Varint=0,Qs.Fixed64=1,Qs.Bytes=2,Qs.Fixed32=5;var Ks="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function tl(t){return t.type===Qs.Bytes?t.readVarint()+t.pos:t.pos+1}function el(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function nl(t,e,n){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=t;i--)n.buf[i+r]=n.buf[i]}function rl(t,e){for(var n=0;n>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function fl(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function ml(t,e,n){1===t&&n.readMessage(gl,e)}function gl(t,e,n){if(3===t){var r=n.readMessage(yl,{}),i=r.width,o=r.height,a=r.left,s=r.top,l=r.advance;e.push({id:r.id,bitmap:new _a({width:i+6,height:o+6},r.bitmap),metrics:{width:i,height:o,left:a,top:s,advance:l}})}}function yl(t,e,n){1===t?e.id=n.readVarint():2===t?e.bitmap=n.readBytes():3===t?e.width=n.readVarint():4===t?e.height=n.readVarint():5===t?e.left=n.readSVarint():6===t?e.top=n.readSVarint():7===t&&(e.advance=n.readVarint())}function vl(t){for(var e=0,n=0,r=0,i=t;r=0;h--){var d=a[h];if(!(p.w>d.w||p.h>d.h)){if(p.x=d.x,p.y=d.y,l=Math.max(l,p.y+p.h),s=Math.max(s,p.x+p.w),p.w===d.w&&p.h===d.h){var f=a.pop();h>3,o=this.pos;this.type=7&r,t(i,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=hl(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=fl(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=hl(this.buf,this.pos)+4294967296*hl(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=hl(this.buf,this.pos)+4294967296*fl(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=$s(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=$s(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,n,r=this.buf;return e=127&(n=r[this.pos++]),n<128?e:(e|=(127&(n=r[this.pos++]))<<7,n<128?e:(e|=(127&(n=r[this.pos++]))<<14,n<128?e:(e|=(127&(n=r[this.pos++]))<<21,n<128?e:function(t,e,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return el(t,r,e);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return el(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Ks?function(t,e,n){return Ks.decode(t.subarray(e,n))}(this.buf,e,t):function(t,e,n){for(var r="",i=e;i239?4:l>223?3:l>191?2:1;if(i+u>n)break;1===u?l<128&&(c=l):2===u?128==(192&(o=t[i+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(a=t[i+2],128==(192&(o=t[i+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&o)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=t[i+2],s=t[i+3],128==(192&(o=t[i+1]))&&128==(192&a)&&128==(192&s)&&((c=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),i+=u}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Qs.Bytes)return t.push(this.readVarint(e));var n=tl(this);for(t=t||[];this.pos127;);else if(e===Qs.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Qs.Fixed32)this.pos+=4;else{if(e!==Qs.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var n,r;if(t>=0?(n=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,n.buf[n.pos]=127&(t>>>=7)}(n,0,e),function(t,e){var n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,n){for(var r,i,o=0;o55295&&r<57344){if(!i){r>56319||o+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):i=r;continue}if(r<56320){t[n++]=239,t[n++]=191,t[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[n++]=239,t[n++]=191,t[n++]=189,i=null);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:(r<65536?t[n++]=r>>12|224:(t[n++]=r>>18|240,t[n++]=r>>12&63|128),t[n++]=r>>6&63|128),t[n++]=63&r|128)}return n}(this.buf,t,this.pos);var n=this.pos-e;n>=128&&nl(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),Js(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Js(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var n=0;n=128&&nl(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,n){this.writeTag(t,Qs.Bytes),this.writeRawMessage(e,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,rl,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,il,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,sl,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,ol,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,al,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,ll,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,cl,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,ul,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,pl,e)},writeBytesField:function(t,e){this.writeTag(t,Qs.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Qs.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Qs.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Qs.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var _l=function(t,e){var n=e.pixelRatio,r=e.version,i=e.stretchX,o=e.stretchY,a=e.content;this.paddedRect=t,this.pixelRatio=n,this.stretchX=i,this.stretchY=o,this.content=a,this.version=r},xl={tl:{configurable:!0},br:{configurable:!0},tlbr:{configurable:!0},displaySize:{configurable:!0}};xl.tl.get=function(){return[this.paddedRect.x+1,this.paddedRect.y+1]},xl.br.get=function(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]},xl.tlbr.get=function(){return this.tl.concat(this.br)},xl.displaySize.get=function(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]},Object.defineProperties(_l.prototype,xl);var bl=function(t,e){var n={},r={};this.haveRenderCallbacks=[];var i=[];this.addImages(t,n,i),this.addImages(e,r,i);var o=vl(i),a=new xa({width:o.w||1,height:o.h||1});for(var s in t){var l=t[s],c=n[s].paddedRect;xa.copy(l.data,a,{x:0,y:0},{x:c.x+1,y:c.y+1},l.data)}for(var u in e){var p=e[u],h=r[u].paddedRect,d=h.x+1,f=h.y+1,m=p.data.width,g=p.data.height;xa.copy(p.data,a,{x:0,y:0},{x:d,y:f},p.data),xa.copy(p.data,a,{x:0,y:g-1},{x:d,y:f-1},{width:m,height:1}),xa.copy(p.data,a,{x:0,y:0},{x:d,y:f+g},{width:m,height:1}),xa.copy(p.data,a,{x:m-1,y:0},{x:d-1,y:f},{width:1,height:g}),xa.copy(p.data,a,{x:0,y:0},{x:d+m,y:f},{width:1,height:g})}this.image=a,this.iconPositions=n,this.patternPositions=r};bl.prototype.addImages=function(t,e,n){for(var r in t){var i=t[r],o={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(o),e[r]=new _l(o,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r)}},bl.prototype.patchUpdatedImages=function(t,e){for(var n in t.dispatchRenderCallbacks(this.haveRenderCallbacks),t.updatedImages)this.patchUpdatedImage(this.iconPositions[n],t.getImage(n),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n),e)},bl.prototype.patchUpdatedImage=function(t,e,n){if(t&&e&&t.version!==e.version){t.version=e.version;var r=t.tl;n.update(e.data,void 0,{x:r[0],y:r[1]})}},Nr("ImagePosition",_l),Nr("ImageAtlas",bl);var wl={horizontal:1,vertical:2,horizontalOnly:3},Ml=function(){this.scale=1,this.fontStack="",this.imageName=null};Ml.forText=function(t,e){var n=new Ml;return n.scale=t||1,n.fontStack=e,n},Ml.forImage=function(t){var e=new Ml;return e.imageName=t,e};var Sl=function(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null};function Tl(t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m){var g,y=Sl.fromFeature(t,i);p===wl.vertical&&y.verticalizePunctuation();var v=si.processBidirectionalText,_=si.processStyledBidirectionalText;if(v&&1===y.sections.length){g=[];for(var x=0,b=v(y.toString(),Rl(y,c,o,e,r,d,f));x0&&B>T&&(T=B)}else{var N=n[A.fontStack],U=N&&N[L];if(U&&U.rect)R=U.rect,I=U.metrics;else{var j=e[A.fontStack],V=j&&j[L];if(!V)continue;I=V.metrics}P=24*(b-A.scale)}D?(t.verticalizable=!0,S.push({glyph:L,imageName:k,x:h,y:d+P,vertical:D,scale:A.scale,fontStack:A.fontStack,sectionIndex:C,metrics:I,rect:R}),h+=z*A.scale+c):(S.push({glyph:L,imageName:k,x:h,y:d+P,vertical:D,scale:A.scale,fontStack:A.fontStack,sectionIndex:C,metrics:I,rect:R}),h+=I.advance*A.scale+c)}0!==S.length&&(f=Math.max(h-c,f),zl(S,0,S.length-1,g,T)),h=0;var G=o*b+T;M.lineOffset=Math.max(T,w),d+=G,m=Math.max(G,m),++y}else d+=o,++y}var H,W=d- -17,q=kl(a),Z=q.horizontalAlign,X=q.verticalAlign;(function(t,e,n,r,i,o,a,s,l){var c,u=(e-n)*i;c=o!==a?-s*r- -17:(-r*l+.5)*a;for(var p=0,h=t;p=0&&r>=t&&El[this.text.charCodeAt(r)];r--)n--;this.text=this.text.substring(t,n),this.sectionIndex=this.sectionIndex.slice(t,n)},Sl.prototype.substring=function(t,e){var n=new Sl;return n.text=this.text.substring(t,e),n.sectionIndex=this.sectionIndex.slice(t,e),n.sections=this.sections,n},Sl.prototype.toString=function(){return this.text},Sl.prototype.getMaxScale=function(){var t=this;return this.sectionIndex.reduce((function(e,n){return Math.max(e,t.sections[n].scale)}),0)},Sl.prototype.addTextSection=function(t,e){this.text+=t.text,this.sections.push(Ml.forText(t.scale,t.fontStack||e));for(var n=this.sections.length-1,r=0;r=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)};var El={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Al={};function Cl(t,e,n,r,i,o){if(e.imageName){var a=r[e.imageName];return a?a.displaySize[0]*e.scale*24/o+i:0}var s=n[e.fontStack],l=s&&s[t];return l?l.metrics.advance*e.scale+i:0}function Ll(t,e,n,r){var i=Math.pow(t-e,2);return r?t=0,p=0,h=0;h-n/2;){if(--a<0)return!1;s-=t[a].dist(o),o=t[a]}s+=t[a].dist(t[a+1]),a++;for(var l=[],c=0;sr;)c-=l.shift().angleDelta;if(c>i)return!1;a++,s+=u.dist(p)}return!0}function Vl(t){for(var e=0,n=0;nc){var f=(c-l)/d,m=We(p.x,h.x,f),g=We(p.y,h.y,f),y=new Ol(m,g,h.angleTo(p),u);return y._round(),!a||jl(t,y,s,a,e)?y:void 0}l+=d}}function ql(t,e,n,r,i,o,a,s,l){var c=Gl(r,o,a),u=Hl(r,i),p=u*a,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-p=0&&b=0&&w=0&&d+u<=p){var M=new Ol(b,w,_,m);M._round(),i&&!jl(e,M,a,i,o)||f.push(M)}}h+=v}return l||f.length||s||(f=t(e,h/2,r,i,o,a,s,!0,c)),f}(t,h?e/2*s%e:(u/2+2*o)*a*s%e,e,c,n,p,h,!1,l)}function Zl(t,e,n,r,o){for(var a=[],s=0;s=r&&h.x>=r||(p.x>=r?p=new i(r,p.y+(r-p.x)/(h.x-p.x)*(h.y-p.y))._round():h.x>=r&&(h=new i(r,p.y+(r-p.x)/(h.x-p.x)*(h.y-p.y))._round()),p.y>=o&&h.y>=o||(p.y>=o?p=new i(p.x+(o-p.y)/(h.y-p.y)*(h.x-p.x),o)._round():h.y>=o&&(h=new i(p.x+(o-p.y)/(h.y-p.y)*(h.x-p.x),o)._round()),c&&p.equals(c[c.length-1])||a.push(c=[p]),c.push(h)))))}return a}function Xl(t,e,n,r){var o=[],a=t.image,s=a.pixelRatio,l=a.paddedRect.w-2,c=a.paddedRect.h-2,u=t.right-t.left,p=t.bottom-t.top,h=a.stretchX||[[0,l]],d=a.stretchY||[[0,c]],f=function(t,e){return t+e[1]-e[0]},m=h.reduce(f,0),g=d.reduce(f,0),y=l-m,v=c-g,_=0,x=m,b=0,w=g,M=0,S=y,T=0,E=v;if(a.content&&r){var A=a.content;_=$l(h,0,A[0]),b=$l(d,0,A[1]),x=$l(h,A[0],A[2]),w=$l(d,A[1],A[3]),M=A[0]-_,T=A[1]-b,S=A[2]-A[0]-x,E=A[3]-A[1]-w}var C=function(r,o,l,c){var h=Yl(r.stretch-_,x,u,t.left),d=Ql(r.fixed-M,S,r.stretch,m),f=Yl(o.stretch-b,w,p,t.top),y=Ql(o.fixed-T,E,o.stretch,g),v=Yl(l.stretch-_,x,u,t.left),A=Ql(l.fixed-M,S,l.stretch,m),C=Yl(c.stretch-b,w,p,t.top),L=Ql(c.fixed-T,E,c.stretch,g),P=new i(h,f),I=new i(v,f),R=new i(v,C),k=new i(h,C),z=new i(d/s,y/s),D=new i(A/s,L/s),O=e*Math.PI/180;if(O){var F=Math.sin(O),B=Math.cos(O),N=[B,-F,F,B];P._matMult(N),I._matMult(N),k._matMult(N),R._matMult(N)}var U=r.stretch+r.fixed,j=o.stretch+o.fixed;return{tl:P,tr:I,bl:k,br:R,tex:{x:a.paddedRect.x+1+U,y:a.paddedRect.y+1+j,w:l.stretch+l.fixed-U,h:c.stretch+c.fixed-j},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:z,pixelOffsetBR:D,minFontScaleX:S/s/u,minFontScaleY:E/s/p,isSDF:n}};if(r&&(a.stretchX||a.stretchY))for(var L=Jl(h,y,m),P=Jl(d,v,g),I=0;I0&&(f=Math.max(10,f),this.circleDiameter=f)}else{var m=a.top*s-l,g=a.bottom*s+l,y=a.left*s-l,v=a.right*s+l,_=a.collisionPadding;if(_&&(y-=_[0]*s,m-=_[1]*s,v+=_[2]*s,g+=_[3]*s),u){var x=new i(y,m),b=new i(v,m),w=new i(y,g),M=new i(v,g),S=u*Math.PI/180;x._rotate(S),b._rotate(S),w._rotate(S),M._rotate(S),y=Math.min(x.x,b.x,w.x,M.x),v=Math.max(x.x,b.x,w.x,M.x),m=Math.min(x.y,b.y,w.y,M.y),g=Math.max(x.y,b.y,w.y,M.y)}t.emplaceBack(e.x,e.y,y,m,v,g,n,r,o)}this.boxEndIndex=t.length},tc=function(t,e){if(void 0===t&&(t=[]),void 0===e&&(e=ec),this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)};function ec(t,e){return te?1:0}function nc(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=1/0,o=1/0,a=-1/0,s=-1/0,l=t[0],c=0;ca)&&(a=u.x),(!c||u.y>s)&&(s=u.y)}var p=Math.min(a-r,s-o),h=p/2,d=new tc([],rc);if(0===p)return new i(r,o);for(var f=r;fg.d||!g.d)&&(g=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,y)),v.max-g.d<=e||(d.push(new ic(v.p.x-(h=v.h/2),v.p.y-h,h,t)),d.push(new ic(v.p.x+h,v.p.y-h,h,t)),d.push(new ic(v.p.x-h,v.p.y+h,h,t)),d.push(new ic(v.p.x+h,v.p.y+h,h,t)),y+=4)}return n&&(console.log("num probes: "+y),console.log("best distance: "+g.d)),g.p}function rc(t,e){return e.max-t.max}function ic(t,e,n,r){this.p=new i(t,e),this.h=n,this.d=function(t,e){for(var n=!1,r=1/0,i=0;it.y!=u.y>t.y&&t.x<(u.x-c.x)*(t.y-c.y)/(u.y-c.y)+c.x&&(n=!n),r=Math.min(r,Qo(t,c,u))}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}tc.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1)},tc.prototype.pop=function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}},tc.prototype.peek=function(){return this.data[0]},tc.prototype._up=function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r},tc.prototype._down=function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=a,t=o}e[t]=i};var oc=Number.POSITIVE_INFINITY;function ac(t,e){return e[1]!==oc?function(t,e,n){var r=0,i=0;switch(e=Math.abs(e),n=Math.abs(n),t){case"top-right":case"top-left":case"top":i=n-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-n}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,i]}(t,e[0],e[1]):function(t,e){var n=0,r=0;e<0&&(e=0);var i=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":r=i-7;break;case"bottom-right":case"bottom-left":r=7-i;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":n=-i;break;case"top-left":case"bottom-left":n=i;break;case"left":n=e;break;case"right":n=-e}return[n,r]}(t,e[0])}function sc(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lc(t,e,n,r,o,a,s,l,c,u,p,h,d,f,m){var g=function(t,e,n,r,o,a,s,l){for(var c=r.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,u=[],p=0,h=e.positionedLines;p32640&&M(t.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".'):"composite"===y.kind&&((v=[128*f.compositeTextSizes[0].evaluate(s,{},m),128*f.compositeTextSizes[1].evaluate(s,{},m)])[0]>32640||v[1]>32640)&&M(t.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".'),t.addSymbols(t.text,g,v,l,a,s,u,e,c.lineStartIndex,c.lineLength,d,m);for(var _=0,x=p;_=0;a--)if(r.dist(o[a])0)&&("constant"!==o.value.kind||o.value.value.length>0),c="constant"!==s.value.kind||!!s.value.value||Object.keys(s.parameters).length>0,u=i.get("symbol-sort-key");if(this.features=[],l||c){for(var p=e.iconDependencies,h=e.glyphDependencies,d=e.availableImages,f=new li(this.zoom),m=0,g=t;m=0;for(var R=0,k=S.sections;R=0;s--)o[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s>0&&(i+=e[s-1].dist(e[s]));for(var l=0;l0},vc.prototype.hasIconData=function(){return this.icon.segments.get().length>0},vc.prototype.hasDebugData=function(){return this.textCollisionBox&&this.iconCollisionBox},vc.prototype.hasTextCollisionBoxData=function(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0},vc.prototype.hasIconCollisionBoxData=function(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0},vc.prototype.addIndicesForPlacedSymbol=function(t,e){for(var n=t.placedSymbolArray.get(e),r=n.vertexStartIndex+4*n.numGlyphs,i=n.vertexStartIndex;i1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(var n=0,r=this.symbolInstanceIndexes;n=0&&r.indexOf(t)===n&&e.addIndicesForPlacedSymbol(e.text,t)})),i.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,i.verticalPlacedTextSymbolIndex),i.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.placedIconSymbolIndex),i.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}},Nr("SymbolBucket",vc,{omit:["layers","collisionBoxArray","features","compareText"]}),vc.MAX_GLYPHS=65535,vc.addDynamicAttributes=fc;var _c=new wi({"symbol-placement":new yi(Pt.layout_symbol["symbol-placement"]),"symbol-spacing":new yi(Pt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new yi(Pt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new vi(Pt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new yi(Pt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new yi(Pt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new yi(Pt.layout_symbol["icon-ignore-placement"]),"icon-optional":new yi(Pt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new yi(Pt.layout_symbol["icon-rotation-alignment"]),"icon-size":new vi(Pt.layout_symbol["icon-size"]),"icon-text-fit":new yi(Pt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new yi(Pt.layout_symbol["icon-text-fit-padding"]),"icon-image":new vi(Pt.layout_symbol["icon-image"]),"icon-rotate":new vi(Pt.layout_symbol["icon-rotate"]),"icon-padding":new yi(Pt.layout_symbol["icon-padding"]),"icon-keep-upright":new yi(Pt.layout_symbol["icon-keep-upright"]),"icon-offset":new vi(Pt.layout_symbol["icon-offset"]),"icon-anchor":new vi(Pt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new yi(Pt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new yi(Pt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new yi(Pt.layout_symbol["text-rotation-alignment"]),"text-field":new vi(Pt.layout_symbol["text-field"]),"text-font":new vi(Pt.layout_symbol["text-font"]),"text-size":new vi(Pt.layout_symbol["text-size"]),"text-max-width":new vi(Pt.layout_symbol["text-max-width"]),"text-line-height":new yi(Pt.layout_symbol["text-line-height"]),"text-letter-spacing":new vi(Pt.layout_symbol["text-letter-spacing"]),"text-justify":new vi(Pt.layout_symbol["text-justify"]),"text-radial-offset":new vi(Pt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new yi(Pt.layout_symbol["text-variable-anchor"]),"text-anchor":new vi(Pt.layout_symbol["text-anchor"]),"text-max-angle":new yi(Pt.layout_symbol["text-max-angle"]),"text-writing-mode":new yi(Pt.layout_symbol["text-writing-mode"]),"text-rotate":new vi(Pt.layout_symbol["text-rotate"]),"text-padding":new yi(Pt.layout_symbol["text-padding"]),"text-keep-upright":new yi(Pt.layout_symbol["text-keep-upright"]),"text-transform":new vi(Pt.layout_symbol["text-transform"]),"text-offset":new vi(Pt.layout_symbol["text-offset"]),"text-allow-overlap":new yi(Pt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new yi(Pt.layout_symbol["text-ignore-placement"]),"text-optional":new yi(Pt.layout_symbol["text-optional"])}),xc={paint:new wi({"icon-opacity":new vi(Pt.paint_symbol["icon-opacity"]),"icon-color":new vi(Pt.paint_symbol["icon-color"]),"icon-halo-color":new vi(Pt.paint_symbol["icon-halo-color"]),"icon-halo-width":new vi(Pt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new vi(Pt.paint_symbol["icon-halo-blur"]),"icon-translate":new yi(Pt.paint_symbol["icon-translate"]),"icon-translate-anchor":new yi(Pt.paint_symbol["icon-translate-anchor"]),"text-opacity":new vi(Pt.paint_symbol["text-opacity"]),"text-color":new vi(Pt.paint_symbol["text-color"],{runtimeType:Vt,getOverride:function(t){return t.textColor},hasOverride:function(t){return!!t.textColor}}),"text-halo-color":new vi(Pt.paint_symbol["text-halo-color"]),"text-halo-width":new vi(Pt.paint_symbol["text-halo-width"]),"text-halo-blur":new vi(Pt.paint_symbol["text-halo-blur"]),"text-translate":new yi(Pt.paint_symbol["text-translate"]),"text-translate-anchor":new yi(Pt.paint_symbol["text-translate-anchor"])}),layout:_c},bc=function(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Bt,this.defaultValue=t};bc.prototype.evaluate=function(t){if(t.formattedSection){var e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default},bc.prototype.eachChild=function(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)},bc.prototype.outputDefined=function(){return!1},bc.prototype.serialize=function(){return null},Nr("FormatSectionOverride",bc,{omit:["defaultValue"]});var wc=function(t){function e(e){t.call(this,e,xc)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.recalculate=function(e,n){if(t.prototype.recalculate.call(this,e,n),"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")),"point"===this.layout.get("symbol-placement")){var r=this.layout.get("text-writing-mode");if(r){for(var i=[],o=0,a=r;o",targetMapId:r,sourceMapId:o.mapId})}}},Oc.prototype.receive=function(t){var e=t.data,n=e.id;if(n&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){delete this.tasks[n];var r=this.cancelCallbacks[n];delete this.cancelCallbacks[n],r&&r()}else E()||e.mustQueue?(this.tasks[n]=e,this.taskQueue.push(n),this.invoker.trigger()):this.processTask(n,e)},Oc.prototype.process=function(){if(this.taskQueue.length){var t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)}},Oc.prototype.processTask=function(t,e){var n=this;if(""===e.type){var r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(Hr(e.error)):r(null,Hr(e.data)))}else{var i=!1,o=L(this.globalScope)?void 0:[],a=e.hasCallback?function(e,r){i=!0,delete n.cancelCallbacks[t],n.target.postMessage({id:t,type:"",sourceMapId:n.mapId,error:e?Gr(e):null,data:Gr(r,o)},o)}:function(t){i=!0},s=null,l=Hr(e.data);if(this.parent[e.type])s=this.parent[e.type](e.sourceMapId,l,a);else if(this.parent.getWorkerSource){var c=e.type.split(".");s=this.parent.getWorkerSource(e.sourceMapId,c[0],l.source)[c[1]](l,a)}else a(new Error("Could not find function "+e.type));!i&&s&&s.cancel&&(this.cancelCallbacks[t]=s.cancel)}},Oc.prototype.remove=function(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)};var Bc=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};Bc.prototype.setNorthEast=function(t){return this._ne=t instanceof Nc?new Nc(t.lng,t.lat):Nc.convert(t),this},Bc.prototype.setSouthWest=function(t){return this._sw=t instanceof Nc?new Nc(t.lng,t.lat):Nc.convert(t),this},Bc.prototype.extend=function(t){var e,n,r=this._sw,i=this._ne;if(t instanceof Nc)e=t,n=t;else{if(!(t instanceof Bc))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Bc.convert(t)):this.extend(Nc.convert(t)):this;if(n=t._ne,!(e=t._sw)||!n)return this}return r||i?(r.lng=Math.min(e.lng,r.lng),r.lat=Math.min(e.lat,r.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Nc(e.lng,e.lat),this._ne=new Nc(n.lng,n.lat)),this},Bc.prototype.getCenter=function(){return new Nc((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},Bc.prototype.getSouthWest=function(){return this._sw},Bc.prototype.getNorthEast=function(){return this._ne},Bc.prototype.getNorthWest=function(){return new Nc(this.getWest(),this.getNorth())},Bc.prototype.getSouthEast=function(){return new Nc(this.getEast(),this.getSouth())},Bc.prototype.getWest=function(){return this._sw.lng},Bc.prototype.getSouth=function(){return this._sw.lat},Bc.prototype.getEast=function(){return this._ne.lng},Bc.prototype.getNorth=function(){return this._ne.lat},Bc.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},Bc.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},Bc.prototype.isEmpty=function(){return!(this._sw&&this._ne)},Bc.prototype.contains=function(t){var e=Nc.convert(t),n=e.lng,r=e.lat,i=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&i},Bc.convert=function(t){return!t||t instanceof Bc?t:new Bc(t)};var Nc=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid LngLat object: ("+t+", "+e+")");if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};Nc.prototype.wrap=function(){return new Nc(p(this.lng,-180,180),this.lat)},Nc.prototype.toArray=function(){return[this.lng,this.lat]},Nc.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},Nc.prototype.distanceTo=function(t){var e=Math.PI/180,n=this.lat*e,r=t.lat*e,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return 6371008.8*Math.acos(Math.min(i,1))},Nc.prototype.toBounds=function(t){void 0===t&&(t=0);var e=360*t/40075017,n=e/Math.cos(Math.PI/180*this.lat);return new Bc(new Nc(this.lng-n,this.lat-e),new Nc(this.lng+n,this.lat+e))},Nc.convert=function(t){if(t instanceof Nc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Nc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Nc(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")};var Uc=2*Math.PI*6371008.8;function jc(t){return Uc*Math.cos(t*Math.PI/180)}function Vc(t){return(180+t)/360}function Gc(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Hc(t,e){return t/jc(e)}function Wc(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}var qc=function(t,e,n){void 0===n&&(n=0),this.x=+t,this.y=+e,this.z=+n};qc.fromLngLat=function(t,e){void 0===e&&(e=0);var n=Nc.convert(t);return new qc(Vc(n.lng),Gc(n.lat),Hc(e,n.lat))},qc.prototype.toLngLat=function(){return new Nc(360*this.x-180,Wc(this.y))},qc.prototype.toAltitude=function(){return this.z*jc(Wc(this.y))},qc.prototype.meterInMercatorCoordinateUnits=function(){return 1/Uc*(t=Wc(this.y),1/Math.cos(t*Math.PI/180));var t};var Zc=function(t,e,n){this.z=t,this.x=e,this.y=n,this.key=Jc(0,t,t,e,n)};Zc.prototype.equals=function(t){return this.z===t.z&&this.x===t.x&&this.y===t.y},Zc.prototype.url=function(t,e){var n,r,i,o,a,s=(r=this.y,i=this.z,o=Fc(256*(n=this.x),256*(r=Math.pow(2,i)-r-1),i),a=Fc(256*(n+1),256*(r+1),i),o[0]+","+o[1]+","+a[0]+","+a[1]),l=function(t,e,n){for(var r,i="",o=t;o>0;o--)i+=(e&(r=1<this.canonical.z?new $c(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new $c(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)},$c.prototype.calculateScaledKey=function(t,e){var n=this.canonical.z-t;return t>this.canonical.z?Jc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Jc(this.wrap*+e,t,t,this.canonical.x>>n,this.canonical.y>>n)},$c.prototype.isChildOf=function(t){if(t.wrap!==this.wrap)return!1;var e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e},$c.prototype.children=function(t){if(this.overscaledZ>=t)return[new $c(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var e=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new $c(e,this.wrap,e,n,r),new $c(e,this.wrap,e,n+1,r),new $c(e,this.wrap,e,n,r+1),new $c(e,this.wrap,e,n+1,r+1)]},$c.prototype.isLessThan=function(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)},Yc.prototype._unpackMapbox=function(t,e,n){return(256*t*256+256*e+n)/10-1e4},Yc.prototype._unpackTerrarium=function(t,e,n){return 256*t+e+n/256-32768},Yc.prototype.getPixels=function(){return new xa({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))},Yc.prototype.backfillBorder=function(t,e,n){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");var r=e*this.dim,i=e*this.dim+this.dim,o=n*this.dim,a=n*this.dim+this.dim;switch(e){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:o=a-1;break;case 1:a=o+1}for(var s=-e*this.dim,l=-n*this.dim,c=o;c=0&&u[3]>=0&&s.insert(a,u[0],u[1],u[2],u[3])}},nu.prototype.loadVTLayers=function(){return this.vtLayers||(this.vtLayers=new bs.VectorTile(new Ys(this.rawTileData)).layers,this.sourceLayerCoder=new Qc(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers},nu.prototype.query=function(t,e,n,r){var o=this;this.loadVTLayers();for(var a=t.params||{},s=8192/t.tileSize/t.scale,l=sr(a.filter),c=t.queryGeometry,u=t.queryPadding*s,p=iu(c),h=this.grid.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u),d=iu(t.cameraQueryGeometry),f=this.grid3D.query(d.minX-u,d.minY-u,d.maxX+u,d.maxY+u,(function(e,n,r,o){return function(t,e,n,r,o){for(var a=0,s=t;a=l.x&&o>=l.y)return!0}var c=[new i(e,n),new i(e,o),new i(r,o),new i(r,n)];if(t.length>2)for(var u=0,p=c;u=0)return!0;return!1}(o,p)){var d=this.sourceLayerCoder.decode(n),f=this.vtLayers[d].feature(r);if(i.needGeometry){var m=Vo(f,!0);if(!i.filter(new li(this.tileID.overscaledZ),m,this.tileID.canonical))return}else if(!i.filter(new li(this.tileID.overscaledZ),f))return;for(var g=this.getId(f,d),y=0;yr)i=!1;else if(e)if(this.expirationTimelt&&(t.getActor().send("enforceCacheSizeLimit",st),ht=0)},t.clamp=u,t.clearTileCache=function(t){var e=a.caches.delete("mapbox-tiles");t&&e.catch(t).then((function(){return t()}))},t.clipLine=Zl,t.clone=function(t){var e=new sa(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=b,t.clone$2=function(t){var e=new sa(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.collisionCircleLayout=qs,t.config=N,t.create=function(){var t=new sa(16);return sa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=function(){var t=new sa(9);return sa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t},t.create$2=function(){var t=new sa(4);return sa!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},t.createCommonjsModule=e,t.createExpression=Xn,t.createLayout=Ai,t.createStyleLayer=function(t){return"custom"===t.type?new Ac(t):new Cc[t.type](t)},t.cross=function(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],l=n[2];return t[0]=i*l-o*s,t[1]=o*a-r*l,t[2]=r*s-i*a,t},t.deepEqual=function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(var r=0;r0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t},t.number=We,t.offscreenCanvasSupported=dt,t.ortho=function(t,e,n,r,i,o,a){var s=1/(e-n),l=1/(r-i),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=(a+o)*c,t[15]=1,t},t.parseGlyphPBF=function(t){return new Ys(t).readFields(ml,[])},t.pbf=Ys,t.performSymbolLayout=function(t,e,n,r,i,o,a){t.createArrays(),t.tilePixelRatio=8192/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;var s=t.layers[0].layout,l=t.layers[0]._unevaluatedLayout._values,c={};if("composite"===t.textSizeData.kind){var u=t.textSizeData,p=u.maxZoom;c.compositeTextSizes=[l["text-size"].possiblyEvaluate(new li(u.minZoom),a),l["text-size"].possiblyEvaluate(new li(p),a)]}if("composite"===t.iconSizeData.kind){var h=t.iconSizeData,d=h.maxZoom;c.compositeIconSizes=[l["icon-size"].possiblyEvaluate(new li(h.minZoom),a),l["icon-size"].possiblyEvaluate(new li(d),a)]}c.layoutTextSize=l["text-size"].possiblyEvaluate(new li(t.zoom+1),a),c.layoutIconSize=l["icon-size"].possiblyEvaluate(new li(t.zoom+1),a),c.textMaxSize=l["text-size"].possiblyEvaluate(new li(18));for(var f=24*s.get("text-line-height"),m="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement"),g=s.get("text-keep-upright"),y=s.get("text-size"),v=function(){var o=x[_],l=s.get("text-font").evaluate(o,{},a).join(","),u=y.evaluate(o,{},a),p=c.layoutTextSize.evaluate(o,{},a),h=c.layoutIconSize.evaluate(o,{},a),d={horizontal:{},vertical:void 0},v=o.text,b=[0,0];if(v){var w=v.toString(),S=24*s.get("text-letter-spacing").evaluate(o,{},a),T=function(t){for(var e=0,n=t;e=8192||p.y<0||p.y>=8192||function(t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m,g,y,v,_,x,b,w,S,T){var E,A,C,L,P,I=t.addToLineVertexArray(e,n),R=0,k=0,z=0,D=0,O=-1,F=-1,B={},N=fo(""),U=0,j=0;if(void 0===s._unevaluatedLayout.getValue("text-radial-offset")?(U=(E=s.layout.get("text-offset").evaluate(x,{},S).map((function(t){return 24*t})))[0],j=E[1]):(U=24*s.layout.get("text-radial-offset").evaluate(x,{},S),j=oc),t.allowVerticalPlacement&&r.vertical){var V=s.layout.get("text-rotate").evaluate(x,{},S)+90;L=new Kl(l,e,c,u,p,r.vertical,h,d,f,V),a&&(P=new Kl(l,e,c,u,p,a,g,y,f,V))}if(i){var G=s.layout.get("icon-rotate").evaluate(x,{}),H="none"!==s.layout.get("icon-text-fit"),W=Xl(i,G,w,H),q=a?Xl(a,G,w,H):void 0;C=new Kl(l,e,c,u,p,i,g,y,!1,G),R=4*W.length;var Z=t.iconSizeData,X=null;"source"===Z.kind?(X=[128*s.layout.get("icon-size").evaluate(x,{})])[0]>32640&&M(t.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".'):"composite"===Z.kind&&((X=[128*b.compositeIconSizes[0].evaluate(x,{},S),128*b.compositeIconSizes[1].evaluate(x,{},S)])[0]>32640||X[1]>32640)&&M(t.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".'),t.addSymbols(t.icon,W,X,_,v,x,!1,e,I.lineStartIndex,I.lineLength,-1,S),O=t.icon.placedSymbolArray.length-1,q&&(k=4*q.length,t.addSymbols(t.icon,q,X,_,v,x,wl.vertical,e,I.lineStartIndex,I.lineLength,-1,S),F=t.icon.placedSymbolArray.length-1)}for(var $ in r.horizontal){var J=r.horizontal[$];if(!A){N=fo(J.text);var Y=s.layout.get("text-rotate").evaluate(x,{},S);A=new Kl(l,e,c,u,p,J,h,d,f,Y)}var Q=1===J.positionedLines.length;if(z+=lc(t,e,J,o,s,f,x,m,I,r.vertical?wl.horizontal:wl.horizontalOnly,Q?Object.keys(r.horizontal):[$],B,O,b,S),Q)break}r.vertical&&(D+=lc(t,e,r.vertical,o,s,f,x,m,I,wl.vertical,["vertical"],B,F,b,S));var K=A?A.boxStartIndex:t.collisionBoxArray.length,tt=A?A.boxEndIndex:t.collisionBoxArray.length,et=L?L.boxStartIndex:t.collisionBoxArray.length,nt=L?L.boxEndIndex:t.collisionBoxArray.length,rt=C?C.boxStartIndex:t.collisionBoxArray.length,it=C?C.boxEndIndex:t.collisionBoxArray.length,ot=P?P.boxStartIndex:t.collisionBoxArray.length,at=P?P.boxEndIndex:t.collisionBoxArray.length,st=-1,lt=function(t,e){return t&&t.circleDiameter?Math.max(t.circleDiameter,e):e};st=lt(A,st),st=lt(L,st),st=lt(C,st);var ct=(st=lt(P,st))>-1?1:0;ct&&(st*=T/24),t.glyphOffsetArray.length>=vc.MAX_GLYPHS&&M("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,B.right>=0?B.right:-1,B.center>=0?B.center:-1,B.left>=0?B.left:-1,B.vertical||-1,O,F,N,K,tt,et,nt,rt,it,ot,at,c,z,D,R,k,ct,0,h,U,j,st)}(t,p,s,n,r,i,h,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,y,b,T,l,_,w,E,f,e,o,c,u,a)};if("line"===A)for(var I=0,R=Zl(e.geometry,0,0,8192,8192);I1){var U=Wl(N,S,n.vertical||m,r,24,v);U&&P(N,U)}}else if("Polygon"===e.type)for(var j=0,V=is(e.geometry,0);j=C.maxzoom||"none"!==C.visibility&&(a(A,this.zoom,r),(m[C.id]=C.createBucket({index:u.bucketLayerIDs.length,layers:A,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:x,sourceID:this.source})).populate(b,g,this.tileID.canonical),u.bucketLayerIDs.push(A.map((function(t){return t.id}))))}}}var L=t.mapObject(g.glyphDependencies,(function(t){return Object.keys(t).map(Number)}));Object.keys(L).length?o.send("getGlyphs",{uid:this.uid,stacks:L},(function(t,e){p||(p=t,h=e,R.call(l))})):h={};var P=Object.keys(g.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(function(t,e){p||(p=t,d=e,R.call(l))})):d={};var I=Object.keys(g.patternDependencies);function R(){if(p)return s(p);if(h&&d&&f){var e=new i(h),n=new t.ImageAtlas(d,f);for(var o in m){var l=m[o];l instanceof t.SymbolBucket?(a(l.layers,this.zoom,r),t.performSymbolLayout(l,h,e.positions,d,n.iconPositions,this.showCollisionBoxes,this.tileID.canonical)):l.hasPattern&&(l instanceof t.LineBucket||l instanceof t.FillBucket||l instanceof t.FillExtrusionBucket)&&(a(l.layers,this.zoom,r),l.addFeatures(g,this.tileID.canonical,n.patternPositions))}this.status="done",s(null,{buckets:t.values(m).filter((function(t){return!t.isEmpty()})),featureIndex:u,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,imageAtlas:n,glyphMap:this.returnDependencies?h:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?e.positions:null})}}I.length?o.send("getImages",{icons:I,source:this.source,tileID:this.tileID,type:"patterns"},(function(t,e){p||(p=t,f=e,R.call(l))})):f={},R.call(this)};var l=function(t,e,n,r){this.actor=t,this.layerIndex=e,this.availableImages=n,this.loadVectorData=r||s,this.loading={},this.loaded={}};l.prototype.loadTile=function(e,n){var r=this,i=e.uid;this.loading||(this.loading={});var a=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.RequestPerformance(e.request),s=this.loading[i]=new o(e);s.abort=this.loadVectorData(e,(function(e,o){if(delete r.loading[i],e||!o)return s.status="done",r.loaded[i]=s,n(e);var l=o.rawData,c={};o.expires&&(c.expires=o.expires),o.cacheControl&&(c.cacheControl=o.cacheControl);var u={};if(a){var p=a.finish();p&&(u.resourceTiming=JSON.parse(JSON.stringify(p)))}s.vectorTile=o.vectorTile,s.parse(o.vectorTile,r.layerIndex,r.availableImages,r.actor,(function(e,r){if(e||!r)return n(e);n(null,t.extend({rawTileData:l.slice(0)},r,c,u))})),r.loaded=r.loaded||{},r.loaded[i]=s}))},l.prototype.reloadTile=function(t,e){var n=this,r=this.loaded,i=t.uid,o=this;if(r&&r[i]){var a=r[i];a.showCollisionBoxes=t.showCollisionBoxes;var s=function(t,r){var i=a.reloadCallback;i&&(delete a.reloadCallback,a.parse(a.vectorTile,o.layerIndex,n.availableImages,o.actor,i)),e(t,r)};"parsing"===a.status?a.reloadCallback=s:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}},l.prototype.abortTile=function(t,e){var n=this.loading,r=t.uid;n&&n[r]&&n[r].abort&&(n[r].abort(),delete n[r]),e()},l.prototype.removeTile=function(t,e){var n=this.loaded,r=t.uid;n&&n[r]&&delete n[r],e()};var c=t.window.ImageBitmap,u=function(){this.loaded={}};function p(t,e){if(0!==t.length){h(t[0],e);for(var n=1;n=0!=!!e&&t.reverse()}u.prototype.loadTile=function(e,n){var r=e.uid,i=e.encoding,o=e.rawImageData,a=c&&o instanceof c?this.getImageData(o):o,s=new t.DEMData(r,a,i);this.loaded=this.loaded||{},this.loaded[r]=s,n(null,s)},u.prototype.getImageData=function(e){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);var n=this.offscreenCanvasContext.getImageData(-1,-1,e.width+2,e.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new t.RGBAImage({width:n.width,height:n.height},n.data)},u.prototype.removeTile=function(t){var e=this.loaded,n=t.uid;e&&e[n]&&delete e[n]};var d=t.vectorTile.VectorTileFeature.prototype.toGeoJSON,f=function(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))};f.prototype.loadGeometry=function(){if(1===this._feature.type){for(var e=[],n=0,r=this._feature.geometry;n>31}function C(t,e){for(var n=t.loadGeometry(),r=t.type,i=0,o=0,a=n.length,s=0;s>1;!function t(e,n,r,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,l=r-i+1,c=Math.log(s),u=.5*Math.exp(2*c/3),p=.5*Math.sqrt(c*u*(s-u)/s)*(l-s/2<0?-1:1);t(e,n,r,Math.max(i,Math.floor(r-l*u/s+p)),Math.min(o,Math.floor(r+(s-l)*u/s+p)),a)}var h=n[2*r+a],d=i,f=o;for(P(e,n,i,r),n[2*o+a]>h&&P(e,n,i,o);dh;)f--}n[2*i+a]===h?P(e,n,i,f):P(e,n,++f,o),f<=r&&(i=f+1),r<=f&&(o=f-1)}}(e,n,s,i,o,a%2),t(e,n,r,i,s-1,a+1),t(e,n,r,s+1,o,a+1)}}(a,s,r,0,a.length-1,0)};D.prototype.range=function(t,e,n,r){return function(t,e,n,r,i,o,a){for(var s,l,c=[0,t.length-1,0],u=[];c.length;){var p=c.pop(),h=c.pop(),d=c.pop();if(h-d<=a)for(var f=d;f<=h;f++)l=e[2*f+1],(s=e[2*f])>=n&&s<=i&&l>=r&&l<=o&&u.push(t[f]);else{var m=Math.floor((d+h)/2);l=e[2*m+1],(s=e[2*m])>=n&&s<=i&&l>=r&&l<=o&&u.push(t[m]);var g=(p+1)%2;(0===p?n<=s:r<=l)&&(c.push(d),c.push(m-1),c.push(g)),(0===p?i>=s:o>=l)&&(c.push(m+1),c.push(h),c.push(g))}}return u}(this.ids,this.coords,t,e,n,r,this.nodeSize)},D.prototype.within=function(t,e,n){return function(t,e,n,r,i,o){for(var a=[0,t.length-1,0],s=[],l=i*i;a.length;){var c=a.pop(),u=a.pop(),p=a.pop();if(u-p<=o)for(var h=p;h<=u;h++)R(e[2*h],e[2*h+1],n,r)<=l&&s.push(t[h]);else{var d=Math.floor((p+u)/2),f=e[2*d],m=e[2*d+1];R(f,m,n,r)<=l&&s.push(t[d]);var g=(c+1)%2;(0===c?n-i<=f:r-i<=m)&&(a.push(p),a.push(d-1),a.push(g)),(0===c?n+i>=f:r+i>=m)&&(a.push(d+1),a.push(u),a.push(g))}}return s}(this.ids,this.coords,t,e,n,this.nodeSize)};var O={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:function(t){return t}},F=function(t){this.options=H(Object.create(O),t),this.trees=new Array(this.options.maxZoom+1)};function B(t,e,n,r,i){return{x:t,y:e,zoom:1/0,id:n,parentId:-1,numPoints:r,properties:i}}function N(t,e){var n=t.geometry.coordinates,r=n[1];return{x:V(n[0]),y:G(r),zoom:1/0,index:e,parentId:-1}}function U(t){return{type:"Feature",id:t.id,properties:j(t),geometry:{type:"Point",coordinates:[(r=t.x,360*(r-.5)),(e=t.y,n=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(n))/Math.PI-90)]}};var e,n,r}function j(t){var e=t.numPoints,n=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return H(H({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:n})}function V(t){return t/360+.5}function G(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function H(t,e){for(var n in e)t[n]=e[n];return t}function W(t){return t.x}function q(t){return t.y}function Z(t,e,n,r,i,o){var a=i-n,s=o-r;if(0!==a||0!==s){var l=((t-n)*a+(e-r)*s)/(a*a+s*s);l>1?(n=i,r=o):l>0&&(n+=a*l,r+=s*l)}return(a=t-n)*a+(s=e-r)*s}function X(t,e,n,r){var i={id:void 0===t?null:t,type:e,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,n=t.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)$(t,e);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r0&&(a+=r?(i*c-l*o)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(c-o,2))),i=l,o=c}var u=e.length-3;e[2]=1,function t(e,n,r,i){for(var o,a=i,s=r-n>>1,l=r-n,c=e[n],u=e[n+1],p=e[r],h=e[r+1],d=n+3;da)o=d,a=f;else if(f===a){var m=Math.abs(d-s);mi&&(o-n>3&&t(e,n,o,i),e[o+2]=a,r-o>3&&t(e,o,r,i))}(e,0,u,n),e[u+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function K(t,e,n,r){for(var i=0;i1?1:n}function nt(t,e,n,r,i,o,a,s){if(r/=e,o>=(n/=e)&&a=r)return null;for(var l=[],c=0;c=n&&f=r)){var m=[];if("Point"===h||"MultiPoint"===h)rt(p,m,n,r,i);else if("LineString"===h)it(p,m,n,r,i,!1,s.lineMetrics);else if("MultiLineString"===h)at(p,m,n,r,i,!1);else if("Polygon"===h)at(p,m,n,r,i,!0);else if("MultiPolygon"===h)for(var g=0;g=n&&a<=r&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function it(t,e,n,r,i,o,a){for(var s,l,c=ot(t),u=0===i?lt:ct,p=t.start,h=0;hn&&(l=u(c,d,f,g,y,n),a&&(c.start=p+s*l)):v>r?_=n&&(l=u(c,d,f,g,y,n),x=!0),_>r&&v<=r&&(l=u(c,d,f,g,y,r),x=!0),!o&&x&&(a&&(c.end=p+s*l),e.push(c),c=ot(t)),a&&(p+=s)}var b=t.length-3;d=t[b],f=t[b+1],m=t[b+2],(v=0===i?d:f)>=n&&v<=r&&st(c,d,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&st(c,c[0],c[1],c[2]),c.length&&e.push(c)}function ot(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function at(t,e,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=u),p>a.maxY&&(a.maxY=p)}return a}function mt(t,e,n,r){var i=e.geometry,o=e.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s0&&e.size<(i?a:r))n.numPoints+=e.length/3;else{for(var s=[],l=0;la)&&(n.numSimplified++,s.push(e[l]),s.push(e[l+1])),n.numPoints++;i&&function(t,e){for(var n=0,r=0,i=t.length,o=i-2;r0===e)for(r=0,i=t.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var n=[];if("FeatureCollection"===t.type)for(var r=0;r=r;c--){var u=+Date.now();s=this._cluster(s,c),this.trees[c]=new D(s,W,q,o,Float32Array),n&&console.log("z%d: %d clusters in %dms",c,s.length,+Date.now()-u)}return n&&console.timeEnd("total time"),this},F.prototype.getClusters=function(t,e){var n=((t[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,t[1])),i=180===t[2]?180:((t[2]+180)%360+360)%360-180,o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)n=-180,i=180;else if(n>i){var a=this.getClusters([n,r,180,o],e),s=this.getClusters([-180,r,i,o],e);return a.concat(s)}for(var l=this.trees[this._limitZoom(e)],c=[],u=0,p=l.range(V(n),G(o),V(i),G(r));ue&&(h+=m.numPoints||1)}if(h>=o){for(var g=l.x*p,y=l.y*p,v=i&&p>1?this._map(l,!0):null,_=(s<<5)+(e+1)+this.points.length,x=0,b=u;x1)for(var S=0,T=u;S>5},F.prototype._getOriginZoom=function(t){return(t-this.points.length)%32},F.prototype._map=function(t,e){if(t.numPoints)return e?H({},t.properties):t.properties;var n=this.points[t.index].properties,r=this.options.map(n);return e&&r===n?H({},r):r},yt.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},yt.prototype.splitTile=function(t,e,n,r,i,o,a){for(var s=[t,e,n,r],l=this.options,c=l.debug;s.length;){r=s.pop(),n=s.pop(),e=s.pop(),t=s.pop();var u=1<1&&console.time("creation"),h=this.tiles[p]=ft(t,e,n,r,l),this.tileCoords.push({z:e,x:n,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,n,r,h.numFeatures,h.numPoints,h.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(h.source=t,i){if(e===l.maxZoom||e===i)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,S=1+b;m=g=y=v=null,_=nt(t,u,n-b,n+M,0,h.minX,h.maxX,l),x=nt(t,u,n+w,n+S,0,h.minX,h.maxX,l),t=null,_&&(m=nt(_,u,r-b,r+M,1,h.minY,h.maxY,l),g=nt(_,u,r+w,r+S,1,h.minY,h.maxY,l),_=null),x&&(y=nt(x,u,r-b,r+M,1,h.minY,h.maxY,l),v=nt(x,u,r+w,r+S,1,h.minY,h.maxY,l),x=null),c>1&&console.timeEnd("clipping"),s.push(m||[],e+1,2*n,2*r),s.push(g||[],e+1,2*n,2*r+1),s.push(y||[],e+1,2*n+1,2*r),s.push(v||[],e+1,2*n+1,2*r+1)}}},yt.prototype.getTile=function(t,e,n){var r=this.options,i=r.extent,o=r.debug;if(t<0||t>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",t,e,n);for(var l,c=t,u=e,p=n;!l&&c>0;)c--,u=Math.floor(u/2),p=Math.floor(p/2),l=this.tiles[vt(c,u,p)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,p),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,p,t,e,n),o>1&&console.timeEnd("drilling down"),this.tiles[s]?ht(this.tiles[s],i):null):null};var xt=function(e){function n(t,n,r,i){e.call(this,t,n,r,_t),i&&(this.loadGeoJSON=i)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.loadData=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),this._pendingCallback=e,this._pendingLoadDataParams=t,this._state&&"Idle"!==this._state?this._state="NeedsLoadData":(this._state="Coalescing",this._loadData())},n.prototype._loadData=function(){var e=this;if(this._pendingCallback&&this._pendingLoadDataParams){var n=this._pendingCallback,r=this._pendingLoadDataParams;delete this._pendingCallback,delete this._pendingLoadDataParams;var i=!!(r&&r.request&&r.request.collectResourceTiming)&&new t.RequestPerformance(r.request);this.loadGeoJSON(r,(function(o,a){if(o||!a)return n(o);if("object"!=typeof a)return n(new Error("Input data given to '"+r.source+"' is not a valid GeoJSON object."));!function t(e,n){var r,i=e&&e.type;if("FeatureCollection"===i)for(r=0;r=0?0:e.button},n.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};var h=function(e){function n(){e.call(this),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.isLoaded=function(){return this.loaded},n.prototype.setLoaded=function(t){if(this.loaded!==t&&(this.loaded=t,t)){for(var e=0,n=this.requestors;e=0?1.2:1))}function y(t,e,n,r,i,o,a){for(var s=0;s65535)e(new Error("glyphs > 65535 not supported"));else if(o.ranges[s])e(null,{stack:n,id:i,glyph:a});else{var l=o.requests[s];l||(l=o.requests[s]=[],_.loadGlyphRange(n,s,r.url,r.requestManager,(function(t,e){if(e){for(var n in e)r._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=e[+n]);o.ranges[s]=!0}for(var i=0,a=l;i1&&(s=t[++a]);var c=Math.abs(l-s.left),u=Math.abs(l-s.right),p=Math.min(c,u),h=void 0,d=i/n*(r+1);if(s.isDash){var f=r-Math.abs(d);h=Math.sqrt(p*p+f*f)}else h=r-Math.sqrt(p*p+d*d);this.data[o+l]=Math.max(0,Math.min(255,h+128))}},M.prototype.addRegularDash=function(t){for(var e=t.length-1;e>=0;--e){var n=t[e],r=t[e+1];n.zeroLength?t.splice(e,1):r&&r.isDash===n.isDash&&(r.left=n.left,t.splice(e,1))}var i=t[0],o=t[t.length-1];i.isDash===o.isDash&&(i.left=o.left-this.width,o.right=i.right+this.width);for(var a=this.width*this.nextRow,s=0,l=t[s],c=0;c1&&(l=t[++s]);var u=Math.abs(c-l.left),p=Math.abs(c-l.right),h=Math.min(u,p);this.data[a+c]=Math.max(0,Math.min(255,(l.isDash?h:-h)+128))}},M.prototype.addDash=function(e,n){var r=n?7:0,i=2*r+1;if(this.nextRow+i>this.height)return t.warnOnce("LineAtlas out of space"),null;for(var o=0,a=0;a=r&&e.x=i&&e.y0&&(l[new t.OverscaledTileID(e.overscaledZ,o,n.z,i,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,n.z,a,n.y-1).key]={backfilled:!1}),n.y+10&&(r.resourceTiming=e._resourceTiming,e._resourceTiming=[]),e.fire(new t.Event("data",r))}}))},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setData=function(e){var n=this;return this._data=e,this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData((function(e){if(e)n.fire(new t.ErrorEvent(e));else{var r={dataType:"source",sourceDataType:"content"};n._collectResourceTiming&&n._resourceTiming&&n._resourceTiming.length>0&&(r.resourceTiming=n._resourceTiming,n._resourceTiming=[]),n.fire(new t.Event("data",r))}})),this},n.prototype.getClusterExpansionZoom=function(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this},n.prototype.getClusterChildren=function(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this},n.prototype.getClusterLeaves=function(t,e,n,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:n},r),this},n.prototype._updateWorkerData=function(e){var n=this;this._loaded=!1;var r=t.extend({},this.workerOptions),i=this._data;"string"==typeof i?(r.request=this.map._requestManager.transformRequest(t.browser.resolveURL(i),t.ResourceType.Source),r.request.collectResourceTiming=this._collectResourceTiming):r.data=JSON.stringify(i),this.actor.send(this.type+".loadData",r,(function(t,i){n._removed||i&&i.abandoned||(n._loaded=!0,i&&i.resourceTiming&&i.resourceTiming[n.id]&&(n._resourceTiming=i.resourceTiming[n.id].slice(0)),n.actor.send(n.type+".coalesce",{source:r.source},null),e(t))}))},n.prototype.loaded=function(){return this._loaded},n.prototype.loadTile=function(e,n){var r=this,i=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(i,{type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.browser.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(function(t,o){return delete e.request,e.unloadVectorData(),e.aborted?n(null):t?n(t):(e.loadVectorData(o,r.map.painter,"reloadTile"===i),n(null))}))},n.prototype.abortTile=function(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0},n.prototype.unloadTile=function(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})},n.prototype.onRemove=function(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})},n.prototype.serialize=function(){return t.extend({},this._options,{type:this.type,data:this._data})},n.prototype.hasTransition=function(){return!1},n}(t.Evented),I=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),R=function(e){function n(t,n,r,i){e.call(this),this.id=t,this.dispatcher=r,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=n}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(e,n){var r=this;this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),(function(i,o){r._loaded=!0,i?r.fire(new t.ErrorEvent(i)):o&&(r.image=o,e&&(r.coordinates=e),n&&n(),r._finishLoading())}))},n.prototype.loaded=function(){return this._loaded},n.prototype.updateImage=function(t){var e=this;return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(function(){e.texture=null})),this):this},n.prototype._finishLoading=function(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setCoordinates=function(e){var n=this;this.coordinates=e;var r=e.map(t.MercatorCoordinate.fromLngLat);this.tileID=function(e){for(var n=1/0,r=1/0,i=-1/0,o=-1/0,a=0,s=e;an.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError("sources."+this.id,null,"Playback for this video can be set only between the "+n.start(0)+" and "+n.end(0)+"-second mark."))):this.video.currentTime=e}},n.prototype.getVideo=function(){return this.video},n.prototype.onAdd=function(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))},n.prototype.prepare=function(){if(!(0===Object.keys(this.tiles).length||this.video.readyState<2)){var e=this.map.painter.context,n=e.gl;for(var r in this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,I.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){var i=this.tiles[r];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}}},n.prototype.serialize=function(){return{type:"video",urls:this.urls,coordinates:this.coordinates}},n.prototype.hasTransition=function(){return this.video&&!this.video.paused},n}(R),z=function(e){function n(n,r,i,o){e.call(this,n,r,i,o),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((function(t){return!Array.isArray(t)||2!==t.length||t.some((function(t){return"number"!=typeof t}))}))||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())},n.prototype.getCanvas=function(){return this.canvas},n.prototype.onAdd=function(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()},n.prototype.onRemove=function(){this.pause()},n.prototype.prepare=function(){var e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),!this._hasInvalidDimensions()&&0!==Object.keys(this.tiles).length){var n=this.map.painter.context,r=n.gl;for(var i in this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,I.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(n,this.canvas,r.RGBA,{premultiply:!0}),this.tiles){var o=this.tiles[i];"loaded"!==o.state&&(o.state="loaded",o.texture=this.texture)}}},n.prototype.serialize=function(){return{type:"canvas",coordinates:this.coordinates}},n.prototype.hasTransition=function(){return this._playing},n.prototype._hasInvalidDimensions=function(){for(var t=0,e=[this.canvas.width,this.canvas.height];tthis.max){var a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this},N.prototype.has=function(t){return t.wrapped().key in this.data},N.prototype.getAndRemove=function(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null},N.prototype._getAndRemoveByKey=function(t){var e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value},N.prototype.getByKey=function(t){var e=this.data[t];return e?e[0].value:null},N.prototype.get=function(t){return this.has(t)?this.data[t.wrapped().key][0].value:null},N.prototype.remove=function(t,e){if(!this.has(t))return this;var n=t.wrapped().key,r=void 0===e?0:this.data[n].indexOf(e),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this},N.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this},N.prototype.filter=function(t){var e=[];for(var n in this.data)for(var r=0,i=this.data[n];r1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,n,r),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}},n.prototype.getTile=function(t){return this.getTileByID(t.key)},n.prototype.getTileByID=function(t){return this._tiles[t]},n.prototype._retainLoadedChildren=function(t,e,n,r){for(var i in this._tiles){var o=this._tiles[i];if(!(r[i]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>n)){for(var a=o.tileID;o&&o.tileID.overscaledZ>e+1;){var s=o.tileID.scaledTo(o.tileID.overscaledZ-1);(o=this._tiles[s.key])&&o.hasData()&&(a=s)}for(var l=a;l.overscaledZ>e;)if(t[(l=l.scaledTo(l.overscaledZ-1)).key]){r[a.key]=a;break}}}},n.prototype.findLoadedParent=function(t,e){if(t.key in this._loadedParentTiles){var n=this._loadedParentTiles[t.key];return n&&n.tileID.overscaledZ>=e?n:null}for(var r=t.overscaledZ-1;r>=e;r--){var i=t.scaledTo(r),o=this._getLoadedTile(i);if(o)return o}},n.prototype._getLoadedTile=function(t){var e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)},n.prototype.updateCacheSize=function(t){var e=Math.ceil(t.width/this._source.tileSize)+1,n=Math.ceil(t.height/this._source.tileSize)+1,r=Math.floor(e*n*5),i="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(i)},n.prototype.handleWrapJump=function(t){var e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){var n={};for(var r in this._tiles){var i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),n[i.tileID.key]=i}for(var o in this._tiles=n,this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(var a in this._tiles)this._setTileReloadTimer(a,this._tiles[a])}},n.prototype.update=function(e){var r=this;if(this.transform=e,this._sourceLoaded&&!this._paused){var i;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((function(e){return new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)})):(i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}),this._source.hasTile&&(i=i.filter((function(t){return r._source.hasTile(t)})))):i=[];var o=e.coveringZoomLevel(this._source),a=Math.max(o-n.maxOverzooming,this._source.minzoom),s=Math.max(o+n.maxUnderzooming,this._source.minzoom),l=this._updateRetainedTiles(i,o);if(Rt(this._source.type)){for(var c={},u={},p=0,h=Object.keys(l);pthis._source.maxzoom){var g=f.children(this._source.maxzoom)[0],y=this.getTile(g);if(y&&y.hasData()){r[g.key]=g;continue}}else{var v=f.children(this._source.maxzoom);if(r[v[0].key]&&r[v[1].key]&&r[v[2].key]&&r[v[3].key])continue}for(var _=m.wasRequested(),x=f.overscaledZ-1;x>=o;--x){var b=f.scaledTo(x);if(i[b.key])break;if(i[b.key]=!0,!(m=this.getTile(b))&&_&&(m=this._addTile(b)),m&&(r[b.key]=b,_=m.wasRequested(),m.hasData()))break}}}return r},n.prototype._updateLoadedParentTileCache=function(){for(var t in this._loadedParentTiles={},this._tiles){for(var e=[],n=void 0,r=this._tiles[t].tileID;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}e.push(r.key);var i=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(i))break;r=i}for(var o=0,a=e;o0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))},n.prototype.clearTiles=function(){for(var t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(t);this._cache.reset()},n.prototype.tilesIn=function(e,n,r){var i=this,o=[],a=this.transform;if(!a)return o;for(var s=r?a.getCameraQueryGeometry(e):e,l=e.map((function(t){return a.pointCoordinate(t)})),c=s.map((function(t){return a.pointCoordinate(t)})),u=this.getIds(),p=1/0,h=1/0,d=-1/0,f=-1/0,m=0,g=c;m=0&&y[1].y+g>=0){var v=l.map((function(t){return s.getTilePoint(t)})),_=c.map((function(t){return s.getTilePoint(t)}));o.push({tile:r,tileID:s,queryGeometry:v,cameraQueryGeometry:_,scale:m})}}},_=0;_=t.browser.now())return!0}return!1},n.prototype.setFeatureState=function(t,e,n){this._state.updateState(t=t||"_geojsonTileLayer",e,n)},n.prototype.removeFeatureState=function(t,e,n){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,n)},n.prototype.getFeatureState=function(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)},n.prototype.setDependencies=function(t,e,n){var r=this._tiles[t];r&&r.setDependencies(e,n)},n.prototype.reloadTilesForDependencies=function(t,e){for(var n in this._tiles)this._tiles[n].hasDependency(t,e)&&this._reloadTile(n,"reloading");this._cache.filter((function(n){return!n.hasDependency(t,e)}))},n}(t.Evented);function It(t,e){var n=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-n||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Rt(t){return"raster"===t||"image"===t||"video"===t}function kt(){return new t.window.Worker($i.workerUrl)}Pt.maxOverzooming=10,Pt.maxUnderzooming=3;var zt="mapboxgl_preloaded_worker_pool",Dt=function(){this.active={}};Dt.prototype.acquire=function(t){if(!this.workers)for(this.workers=[];this.workers.length0?(i-a)/s:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))};var Jt=function(t,e,n){var r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(t/n),this.yCellCount=Math.ceil(e/n);for(var o=0;o=-e[0]&&n<=e[0]&&r>=-e[1]&&r<=e[1]}function ne(e,n,r,i,o,a,s,l){var c=i?e.textSizeData:e.iconSizeData,u=t.evaluateSizeForZoom(c,r.transform.zoom),p=[256/r.width*2+1,256/r.height*2+1],h=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;h.clear();for(var d=e.lineVertexArray,f=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,m=r.transform.width/r.transform.height,g=!1,y=0;yMath.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.WritingMode.vertical?n.yr.x)?{needsFlipping:!0}:null}function oe(e,n,r,i,o,a,s,l,c,u,p,h,d,f){var m,g=n/24,y=e.lineOffsetX*g,v=e.lineOffsetY*g;if(e.numGlyphs>1){var _=e.glyphStartIndex+e.numGlyphs,x=e.lineStartIndex,b=e.lineStartIndex+e.lineLength,w=re(g,l,y,v,r,p,h,e,c,a,d);if(!w)return{notEnoughRoom:!0};var M=Kt(w.first.point,s).point,S=Kt(w.last.point,s).point;if(i&&!r){var T=ie(e.writingMode,M,S,f);if(T)return T}m=[w.first];for(var E=e.glyphStartIndex+1;E<_-1;E++)m.push(se(g*l.getoffsetX(E),y,v,r,p,h,e.segment,x,b,c,a,d));m.push(w.last)}else{if(i&&!r){var A=Kt(h,o).point,C=e.lineStartIndex+e.segment+1,L=new t.Point(c.getx(C),c.gety(C)),P=Kt(L,o),I=P.signedDistanceFromCamera>0?P.point:ae(h,L,A,1,o),R=ie(e.writingMode,A,I,f);if(R)return R}var k=se(g*l.getoffsetX(e.glyphStartIndex),y,v,r,p,h,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,a,d);if(!k)return{notEnoughRoom:!0};m=[k]}for(var z=0,D=m;z0?1:-1,m=0;i&&(f*=-1,m=Math.PI),f<0&&(m+=Math.PI);for(var g=f>0?l+s:l+s+1,y=o,v=o,_=0,x=0,b=Math.abs(d),w=[];_+x<=b;){if((g+=f)=c)return null;if(v=y,w.push(y),void 0===(y=h[g])){var M=new t.Point(u.getx(g),u.gety(g)),S=Kt(M,p);if(S.signedDistanceFromCamera>0)y=h[g]=S.point;else{var T=g-f;y=ae(0===_?a:new t.Point(u.getx(T),u.gety(T)),M,v,b-_+1,p)}}_+=x,x=v.dist(y)}var E=(b-_)/x,A=y.sub(v),C=A.mult(E)._add(v);C._add(A._unit()._perp()._mult(r*f));var L=m+Math.atan2(y.y-v.y,y.x-v.x);return w.push(C),{point:C,angle:L,path:w}}Jt.prototype.keysLength=function(){return this.boxKeys.length+this.circleKeys.length},Jt.prototype.insert=function(t,e,n,r,i){this._forEachCell(e,n,r,i,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)},Jt.prototype.insertCircle=function(t,e,n,r){this._forEachCell(e-r,n-r,e+r,n+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(n),this.circles.push(r)},Jt.prototype._insertBoxCell=function(t,e,n,r,i,o){this.boxCells[i].push(o)},Jt.prototype._insertCircleCell=function(t,e,n,r,i,o){this.circleCells[i].push(o)},Jt.prototype._query=function(t,e,n,r,i,o){if(n<0||t>this.width||r<0||e>this.height)return!i&&[];var a=[];if(t<=0&&e<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(var s=0;s0:a},Jt.prototype._queryCircle=function(t,e,n,r,i){var o=t-n,a=t+n,s=e-n,l=e+n;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];var c=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,c,{hitTest:r,circle:{x:t,y:e,radius:n},seenUids:{box:{},circle:{}}},i),r?c.length>0:c},Jt.prototype.query=function(t,e,n,r,i){return this._query(t,e,n,r,!1,i)},Jt.prototype.hitTest=function(t,e,n,r,i){return this._query(t,e,n,r,!0,i)},Jt.prototype.hitTestCircle=function(t,e,n,r){return this._queryCircle(t,e,n,!0,r)},Jt.prototype._queryCell=function(t,e,n,r,i,o,a,s){var l=a.seenUids,c=this.boxCells[i];if(null!==c)for(var u=this.bboxes,p=0,h=c;p=u[f+0]&&r>=u[f+1]&&(!s||s(this.boxKeys[d]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[d],x1:u[f],y1:u[f+1],x2:u[f+2],y2:u[f+3]})}}}var m=this.circleCells[i];if(null!==m)for(var g=this.circles,y=0,v=m;ya*a+s*s},Jt.prototype._circleAndRectCollide=function(t,e,n,r,i,o,a){var s=(o-r)/2,l=Math.abs(t-(r+s));if(l>s+n)return!1;var c=(a-i)/2,u=Math.abs(e-(i+c));if(u>c+n)return!1;if(l<=s||u<=c)return!0;var p=l-s,h=u-c;return p*p+h*h<=n*n};var le=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ce(t,e){for(var n=0;n=1;I--)P.push(C.path[I]);for(var R=1;R0){for(var O=P[0].clone(),F=P[0].clone(),B=1;B=T.x&&F.x<=E.x&&O.y>=T.y&&F.y<=E.y?[P]:F.xE.x||F.yE.y?[]:t.clipLine([P],T.x,T.y,E.x,E.y)}for(var N=0,U=D;N=this.screenRightBoundary||r<100||e>this.screenBottomBoundary},pe.prototype.isInsideGrid=function(t,e,n,r){return n>=0&&t=0&&e0?(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(m=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:g,width:n,height:r,anchor:t,textBoxScale:i,prevAnchor:m},this.markUsedJustification(h,t,p,d),h.allowVerticalPlacement&&(this.markUsedOrientation(h,d,p),this.placedOrientations[p.crossTileID]=d),{shift:y,placedGlyphBoxes:v}):void 0},be.prototype.placeLayerBucketPart=function(e,n,r){var i=this,o=e.parameters,a=o.bucket,s=o.layout,l=o.posMatrix,c=o.textLabelPlaneMatrix,u=o.labelToScreenMatrix,p=o.textPixelRatio,h=o.holdingForFade,d=o.collisionBoxArray,f=o.partiallyEvaluatedTextSize,m=o.collisionGroup,g=s.get("text-optional"),y=s.get("icon-optional"),v=s.get("text-allow-overlap"),_=s.get("icon-allow-overlap"),x="map"===s.get("text-rotation-alignment"),b="map"===s.get("text-pitch-alignment"),w="none"!==s.get("icon-text-fit"),M="viewport-y"===s.get("symbol-z-order"),S=v&&(_||!a.hasIconData()||y),T=_&&(v||!a.hasTextData()||g);!a.collisionArrays&&d&&a.deserializeCollisionBoxes(d);var E=function(e,o){if(!n[e.crossTileID])if(h)i.placements[e.crossTileID]=new me(!1,!1,!1);else{var d,M=!1,E=!1,A=!0,C=null,L={box:null,offscreen:null},P={box:null,offscreen:null},I=null,R=null,k=0,z=0,D=0;o.textFeatureIndex?k=o.textFeatureIndex:e.useRuntimeCollisionCircles&&(k=e.featureIndex),o.verticalTextFeatureIndex&&(z=o.verticalTextFeatureIndex);var O=o.textBox;if(O){var F=function(n){var r=t.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&i.prevPlacement){var o=i.prevPlacement.placedOrientations[e.crossTileID];o&&(i.placedOrientations[e.crossTileID]=o,i.markUsedOrientation(a,r=o,e))}return r},B=function(n,r){if(a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&o.verticalTextBox)for(var i=0,s=a.writingModes;i0&&(N=N.filter((function(t){return t!==U.anchor}))).unshift(U.anchor)}var j=function(t,n,r){for(var o=t.x2-t.x1,s=t.y2-t.y1,c=e.textBoxScale,u=w&&!_?n:null,h={box:[],offscreen:!1},d=v?2*N.length:N.length,f=0;f=N.length,e,a,r,u);if(g&&(h=g.placedGlyphBoxes)&&h.box&&h.box.length){M=!0,C=g.shift;break}}return h};B((function(){return j(O,o.iconBox,t.WritingMode.horizontal)}),(function(){var n=o.verticalTextBox;return a.allowVerticalPlacement&&!(L&&L.box&&L.box.length)&&e.numVerticalGlyphVertices>0&&n?j(n,o.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null}})),L&&(M=L.box,A=L.offscreen);var V=F(L&&L.box);if(!M&&i.prevPlacement){var G=i.prevPlacement.variableOffsets[e.crossTileID];G&&(i.variableOffsets[e.crossTileID]=G,i.markUsedJustification(a,G.anchor,e,V))}}else{var H=function(t,n){var r=i.collisionIndex.placeCollisionBox(t,v,p,l,m.predicate);return r&&r.box&&r.box.length&&(i.markUsedOrientation(a,n,e),i.placedOrientations[e.crossTileID]=n),r};B((function(){return H(O,t.WritingMode.horizontal)}),(function(){var n=o.verticalTextBox;return a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&n?H(n,t.WritingMode.vertical):{box:null,offscreen:null}})),F(L&&L.box&&L.box.length)}}if(M=(d=L)&&d.box&&d.box.length>0,A=d&&d.offscreen,e.useRuntimeCollisionCircles){var W=a.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),q=t.evaluateSizeForFeature(a.textSizeData,f,W),Z=s.get("text-padding");I=i.collisionIndex.placeCollisionCircles(v,W,a.lineVertexArray,a.glyphOffsetArray,q,l,c,u,r,b,m.predicate,e.collisionCircleDiameter,Z),M=v||I.circles.length>0&&!I.collisionDetected,A=A&&I.offscreen}if(o.iconFeatureIndex&&(D=o.iconFeatureIndex),o.iconBox){var X=function(t){var e=w&&C?xe(t,C.x,C.y,x,b,i.transform.angle):t;return i.collisionIndex.placeCollisionBox(e,_,p,l,m.predicate)};E=P&&P.box&&P.box.length&&o.verticalIconBox?(R=X(o.verticalIconBox)).box.length>0:(R=X(o.iconBox)).box.length>0,A=A&&R.offscreen}var $=g||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,J=y||0===e.numIconVertices;if($||J?J?$||(E=E&&M):M=E&&M:E=M=E&&M,M&&d&&d.box&&i.collisionIndex.insertCollisionBox(d.box,s.get("text-ignore-placement"),a.bucketInstanceId,P&&P.box&&z?z:k,m.ID),E&&R&&i.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),a.bucketInstanceId,D,m.ID),I&&(M&&i.collisionIndex.insertCollisionCircles(I.circles,s.get("text-ignore-placement"),a.bucketInstanceId,k,m.ID),r)){var Y=a.bucketInstanceId,Q=i.collisionCircleArrays[Y];void 0===Q&&(Q=i.collisionCircleArrays[Y]=new ge);for(var K=0;K=0;--C){var L=A[C];E(a.symbolInstances.get(L),a.collisionArrays[L])}else for(var P=e.symbolInstanceStart;P=0&&(e.text.placedSymbolArray.get(l).crossTileID=o>=0&&l!==o?0:r.crossTileID)}},be.prototype.markUsedOrientation=function(e,n,r){for(var i=n===t.WritingMode.horizontal||n===t.WritingMode.horizontalOnly?n:0,o=n===t.WritingMode.vertical?n:0,a=0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];a0,v=i.placedOrientations[o.crossTileID],_=v===t.WritingMode.vertical,x=v===t.WritingMode.horizontal||v===t.WritingMode.horizontalOnly;if(s>0||l>0){var b=Pe(g.text);f(e.text,s,_?Ie:b),f(e.text,l,x?Ie:b);var w=g.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((function(t){t>=0&&(e.text.placedSymbolArray.get(t).hidden=w||_?1:0)})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=w||x?1:0);var M=i.variableOffsets[o.crossTileID];M&&i.markUsedJustification(e,M.anchor,o,v);var S=i.placedOrientations[o.crossTileID];S&&(i.markUsedJustification(e,"left",o,S),i.markUsedOrientation(e,S,o))}if(y){var T=Pe(g.icon),E=!(h&&o.verticalPlacedIconSymbolIndex&&_);o.placedIconSymbolIndex>=0&&(f(e.icon,o.numIconVertices,E?T:Ie),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=g.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(f(e.icon,o.numVerticalIconVertices,E?Ie:T),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){var A=e.collisionArrays[r];if(A){var C=new t.Point(0,0);if(A.textBox||A.verticalTextBox){var L=!0;if(c){var P=i.variableOffsets[m];P?(C=_e(P.anchor,P.width,P.height,P.textOffset,P.textBoxScale),u&&C._rotate(p?i.transform.angle:-i.transform.angle)):L=!1}A.textBox&&we(e.textCollisionBox.collisionVertexArray,g.text.placed,!L||_,C.x,C.y),A.verticalTextBox&&we(e.textCollisionBox.collisionVertexArray,g.text.placed,!L||x,C.x,C.y)}var I=Boolean(!x&&A.verticalIconBox);A.iconBox&&we(e.iconCollisionBox.collisionVertexArray,g.icon.placed,I,h?C.x:0,h?C.y:0),A.verticalIconBox&&we(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!I,h?C.x:0,h?C.y:0)}}},g=0;gt},be.prototype.setStale=function(){this.stale=!0};var Me=Math.pow(2,25),Se=Math.pow(2,24),Te=Math.pow(2,17),Ee=Math.pow(2,16),Ae=Math.pow(2,9),Ce=Math.pow(2,8),Le=Math.pow(2,1);function Pe(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;var e=t.placed?1:0,n=Math.floor(127*t.opacity);return n*Me+e*Se+n*Te+e*Ee+n*Ae+e*Ce+n*Le+e}var Ie=0,Re=function(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]};Re.prototype.continuePlacement=function(t,e,n,r,i){for(var o=this._bucketParts;this._currentTileIndex2};this._currentPlacementIndex>=0;){var s=n[e[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){if(this._inProgressLayer||(this._inProgressLayer=new Re(s)),this._inProgressLayer.continuePlacement(r[s.source],this.placement,this._showCollisionBoxes,s,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0},ke.prototype.commit=function(t){return this.placement.commit(t),this.placement};var ze=512/t.EXTENT/2,De=function(t,e,n){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(var r=0;rt.overscaledZ)for(var s in a){var l=a[s];l.tileID.isChildOf(t)&&l.findMatches(e.symbolInstances,t,i)}else{var c=a[t.scaledTo(Number(o)).key];c&&c.findMatches(e.symbolInstances,t,i)}}for(var u=0;u1?"@2x":"",l=t.getJSON(n.transformRequest(n.normalizeSpriteURL(e,s,".json"),t.ResourceType.SpriteJSON),(function(t,e){l=null,a||(a=t,i=e,u())})),c=t.getImage(n.transformRequest(n.normalizeSpriteURL(e,s,".png"),t.ResourceType.SpriteImage),(function(t,e){c=null,a||(a=t,o=e,u())}));function u(){if(a)r(a);else if(i&&o){var e=t.browser.getImageData(o),n={};for(var s in i){var l=i[s],c=l.width,u=l.height,p=l.x,h=l.y,d=l.sdf,f=l.pixelRatio,m=l.stretchX,g=l.stretchY,y=l.content,v=new t.RGBAImage({width:c,height:u});t.RGBAImage.copy(e,v,{x:p,y:h},{x:0,y:0},{width:c,height:u}),n[s]={data:v,pixelRatio:f,sdf:d,stretchX:m,stretchY:g,content:y}}r(null,n)}}return{cancel:function(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(e,this.map._requestManager,(function(e,r){if(n._spriteRequest=null,e)n.fire(new t.ErrorEvent(e));else if(r)for(var i in r)n.imageManager.addImage(i,r[i]);n.imageManager.setLoaded(!0),n._availableImages=n.imageManager.listImages(),n.dispatcher.broadcast("setImages",n._availableImages),n.fire(new t.Event("data",{dataType:"style"}))}))},n.prototype._validateLayer=function(e){var n=this.sourceCaches[e.source];if(n){var r=e.sourceLayer;if(r){var i=n.getSource();("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error('Source layer "'+r+'" does not exist on source "'+i.id+'" as specified by style layer "'+e.id+'"')))}}},n.prototype.loaded=function(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(var t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()},n.prototype._serializeLayers=function(t){for(var e=[],n=0,r=t;n0)throw new Error("Unimplemented: "+i.map((function(t){return t.command})).join(", ")+".");return r.forEach((function(t){"setTransition"!==t.command&&n[t.command].apply(n,t.args)})),this.stylesheet=e,!0},n.prototype.addImage=function(e,n){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,n),this._afterImageUpdated(e)},n.prototype.updateImage=function(t,e){this.imageManager.updateImage(t,e)},n.prototype.getImage=function(t){return this.imageManager.getImage(t)},n.prototype.removeImage=function(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this._afterImageUpdated(e)},n.prototype._afterImageUpdated=function(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))},n.prototype.listImages=function(){return this._checkLoaded(),this.imageManager.listImages()},n.prototype.addSource=function(e,n,r){var i=this;if(void 0===r&&(r={}),this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error("There is already a source with this ID");if(!n.type)throw new Error("The type property must be defined, but only the following properties were given: "+Object.keys(n).join(", ")+".");if(!(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,n,null,r))){this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);var o=this.sourceCaches[e]=new Pt(e,n,this.dispatcher);o.style=this,o.setEventedParent(this,(function(){return{isSourceLoaded:i.loaded(),source:o.serialize(),sourceId:e}})),o.onAdd(this.map),this._changed=!0}},n.prototype.removeSource=function(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(var n in this._layers)if(this._layers[n].source===e)return this.fire(new t.ErrorEvent(new Error('Source "'+e+'" cannot be removed while layer "'+n+'" is using it.')));var r=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],r.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),r.setEventedParent(null),r.clearTiles(),r.onRemove&&r.onRemove(this.map),this._changed=!0},n.prototype.setGeoJSONSourceData=function(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0},n.prototype.getSource=function(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()},n.prototype.addLayer=function(e,n,r){void 0===r&&(r={}),this._checkLoaded();var i=e.id;if(this.getLayer(i))this.fire(new t.ErrorEvent(new Error('Layer with id "'+i+'" already exists on this map')));else{var o;if("custom"===e.type){if(Ne(this,t.validateCustomStyleLayer(e)))return;o=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(i,e.source),e=t.clone$1(e),e=t.extend(e,{source:i})),this._validate(t.validateStyle.layer,"layers."+i,e,{arrayIndex:-1},r))return;o=t.createStyleLayer(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[o.id]=o.serialize()}var a=n?this._order.indexOf(n):this._order.length;if(n&&-1===a)this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.')));else{if(this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=o,this._removedLayers[i]&&o.source&&"custom"!==o.type){var s=this._removedLayers[i];delete this._removedLayers[i],s.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}},n.prototype.moveLayer=function(e,n){if(this._checkLoaded(),this._changed=!0,this._layers[e]){if(e!==n){var r=this._order.indexOf(e);this._order.splice(r,1);var i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.'))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be moved.")))},n.prototype.removeLayer=function(e){this._checkLoaded();var n=this._layers[e];if(n){n.setEventedParent(null);var r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be removed.")))},n.prototype.getLayer=function(t){return this._layers[t]},n.prototype.hasLayer=function(t){return t in this._layers},n.prototype.setLayerZoomRange=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot have zoom extent.")))},n.prototype.setFilter=function(e,n,r){void 0===r&&(r={}),this._checkLoaded();var i=this.getLayer(e);if(i){if(!t.deepEqual(i.filter,n))return null==n?(i.filter=void 0,void this._updateLayer(i)):void(this._validate(t.validateStyle.filter,"layers."+i.id+".filter",n,null,r)||(i.filter=t.clone$1(n),this._updateLayer(i)))}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be filtered.")))},n.prototype.getFilter=function(e){return t.clone$1(this.getLayer(e).filter)},n.prototype.setLayoutProperty=function(e,n,r,i){void 0===i&&(i={}),this._checkLoaded();var o=this.getLayer(e);o?t.deepEqual(o.getLayoutProperty(n),r)||(o.setLayoutProperty(n,r,i),this._updateLayer(o)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getLayoutProperty=function(e,n){var r=this.getLayer(e);if(r)return r.getLayoutProperty(n);this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style.")))},n.prototype.setPaintProperty=function(e,n,r,i){void 0===i&&(i={}),this._checkLoaded();var o=this.getLayer(e);o?t.deepEqual(o.getPaintProperty(n),r)||(o.setPaintProperty(n,r,i)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getPaintProperty=function(t,e){return this.getLayer(t).getPaintProperty(e)},n.prototype.setFeatureState=function(e,n){this._checkLoaded();var r=e.source,i=e.sourceLayer,o=this.sourceCaches[r];if(void 0!==o){var a=o.getSource().type;"geojson"===a&&i?this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==a||i?(void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),o.setFeatureState(i,e.id,n)):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+r+"' does not exist in the map's style.")))},n.prototype.removeFeatureState=function(e,n){this._checkLoaded();var r=e.source,i=this.sourceCaches[r];if(void 0!==i){var o=i.getSource().type,a="vector"===o?e.sourceLayer:void 0;"vector"!==o||a?n&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):i.removeFeatureState(a,e.id,n):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+r+"' does not exist in the map's style.")))},n.prototype.getFeatureState=function(e){this._checkLoaded();var n=e.source,r=e.sourceLayer,i=this.sourceCaches[n];if(void 0!==i){if("vector"!==i.getSource().type||r)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),i.getFeatureState(r,e.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+n+"' does not exist in the map's style.")))},n.prototype.getTransition=function(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)},n.prototype.serialize=function(){return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,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,sources:t.mapObject(this.sourceCaches,(function(t){return t.serialize()})),layers:this._serializeLayers(this._order)},(function(t){return void 0!==t}))},n.prototype._updateLayer=function(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0},n.prototype._flattenAndSortRenderedFeatures=function(t){for(var e=this,n=function(t){return"fill-extrusion"===e._layers[t].type},r={},i=[],o=this._order.length-1;o>=0;o--){var a=this._order[o];if(n(a)){r[a]=o;for(var s=0,l=t;s=0;d--){var f=this._order[d];if(n(f))for(var m=i.length-1;m>=0;m--){var g=i[m].feature;if(r[g.layer.id] 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;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_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,0.0,1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),Ke=vn("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;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;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-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(0.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);}"),tn=vn("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;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,0,1);}"),en=vn("#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_FragColor=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);}"),nn=vn("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);gl_FragColor=outline_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;}"),rn=vn("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);gl_FragColor=mix(color1,color2,u_fade)*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;}"),on=vn("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);gl_FragColor=mix(color1,color2,u_fade)*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);}"),an=vn("varying vec4 v_color;void main() {gl_FragColor=v_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 vec2 a_pos;attribute vec4 a_normal_ed;varying 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 normal=a_normal_ed.xyz;base=max(0.0,base);height=max(0.0,height);float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);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/16384.0,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*=((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.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),sn=vn("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 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\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 vec2 a_pos;attribute vec4 a_normal_ed;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;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_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=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\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/16383.0,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*=((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;}"),ln=vn("#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,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.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;}"),cn=vn("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;\n#define PI 3.141592653589793\nvoid 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 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;}"),un=vn("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\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 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);gl_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;uniform mat4 u_matrix;uniform mediump float u_ratio;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 float v_linesofar;\n#pragma mapbox: define highp vec4 color\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 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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.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_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float 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;v_width2=vec2(outset,inset);}"),pn=vn("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\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);vec4 color=texture2D(u_image,v_uv);gl_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_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\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 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;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float 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;v_width2=vec2(outset,inset);}"),hn=vn("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);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float 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;v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),dn=vn("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\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);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float 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;v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),fn=vn("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(dot(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);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*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 float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),mn=vn("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}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform 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 highp float u_pitch;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;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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];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;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),0.0,1.0);v_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(1.0,fade_opacity[0]+fade_change));}"),gn=vn("#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}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform 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 highp float u_pitch;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;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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];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;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),0.0,1.0);float 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(1.0,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),yn=vn("#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}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform 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 highp float u_pitch;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 vec2 u_texsize_icon;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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.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[2];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;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),0.0,1.0);float 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(1.0,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}");function vn(t,e){var n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),i=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=o?o.concat(i):i,s={};return{fragmentSource:t=t.replace(n,(function(t,e,n,r,i){return s[i]=!0,"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nvarying "+n+" "+r+" "+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"\n#ifdef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n"})),vertexSource:e=e.replace(n,(function(t,e,n,r,i){var o="float"===r?"vec2":"vec4",a=i.match(/color/)?"color":o;return s[i]?"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nuniform lowp float u_"+i+"_t;\nattribute "+n+" "+o+" a_"+i+";\nvarying "+n+" "+r+" "+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"vec4"===a?"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+i+" = a_"+i+";\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+i+" = unpack_mix_"+a+"(a_"+i+", u_"+i+"_t);\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nuniform lowp float u_"+i+"_t;\nattribute "+n+" "+o+" a_"+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"vec4"===a?"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = a_"+i+";\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = unpack_mix_"+a+"(a_"+i+", u_"+i+"_t);\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n"})),staticAttributes:r,staticUniforms:a}}var _n=Object.freeze({__proto__:null,prelude:We,background:qe,backgroundPattern:Ze,circle:Xe,clippingMask:$e,heatmap:Je,heatmapTexture:Ye,collisionBox:Qe,collisionCircle:Ke,debug:tn,fill:en,fillOutline:nn,fillOutlinePattern:rn,fillPattern:on,fillExtrusion:an,fillExtrusionPattern:sn,hillshadePrepare:ln,hillshade:cn,line:un,lineGradient:pn,linePattern:hn,lineSDF:dn,raster:fn,symbolIcon:mn,symbolSDF:gn,symbolTextAndIcon:yn}),xn=function(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null};function bn(t){for(var e=[],n=0;n>16,s>>16],u_pixel_coord_lower:[65535&a,65535&s]}}wn.prototype.draw=function(t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m){var g,y=t.gl;if(!this.failedToCreate){for(var v in t.program.set(this.program),t.setDepthMode(n),t.setStencilMode(r),t.setColorMode(i),t.setCullFace(o),this.fixedUniforms)this.fixedUniforms[v].set(a[v]);d&&d.setUniforms(t,this.binderUniforms,p,{zoom:h});for(var _=(g={},g[y.LINES]=2,g[y.TRIANGLES]=3,g[y.LINE_STRIP]=1,g)[e],x=0,b=u.get();x0?1-1/(1.001-a):-a),u_contrast_factor:(o=i.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:Gn(i.paint.get("raster-hue-rotate"))};var o,a};function Gn(t){t*=Math.PI/180;var e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}var Hn,Wn=function(t,e,n,r,i,o,a,s,l,c){var u=i.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:u.cameraToCenterDistance,u_pitch:u.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:u.width/u.height,u_fade_change:i.options.fadeDuration?i.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0}},qn=function(e,n,r,i,o,a,s,l,c,u,p){var h=o.transform;return t.extend(Wn(e,n,r,i,o,a,s,l,c,u),{u_gamma_scale:i?Math.cos(h._pitch)*h.cameraToCenterDistance:1,u_device_pixel_ratio:t.browser.devicePixelRatio,u_is_halo:+p})},Zn=function(e,n,r,i,o,a,s,l,c,u){return t.extend(qn(e,n,r,i,o,a,s,l,!0,c,!0),{u_texsize_icon:u,u_texture_icon:1})},Xn=function(t,e,n){return{u_matrix:t,u_opacity:e,u_color:n}},$n=function(e,n,r,i,o,a){return t.extend(function(t,e,n,r){var i=n.imageManager.getPattern(t.from.toString()),o=n.imageManager.getPattern(t.to.toString()),a=n.imageManager.getPixelSize(),s=a.width,l=a.height,c=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,n.transform.tileZoom)/c,p=u*(r.tileID.canonical.x+r.tileID.wrap*c),h=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:i.tl,u_pattern_br_a:i.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,l],u_mix:e.t,u_pattern_size_a:i.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/he(r,1,n.transform.tileZoom),u_pixel_coord_upper:[p>>16,h>>16],u_pixel_coord_lower:[65535&p,65535&h]}}(i,a,r,o),{u_matrix:e,u_opacity:n})},Jn={fillExtrusion:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_lightpos:new t.Uniform3f(e,n.u_lightpos),u_lightintensity:new t.Uniform1f(e,n.u_lightintensity),u_lightcolor:new t.Uniform3f(e,n.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,n.u_vertical_gradient),u_opacity:new t.Uniform1f(e,n.u_opacity)}},fillExtrusionPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_lightpos:new t.Uniform3f(e,n.u_lightpos),u_lightintensity:new t.Uniform1f(e,n.u_lightintensity),u_lightcolor:new t.Uniform3f(e,n.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,n.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,n.u_height_factor),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade),u_opacity:new t.Uniform1f(e,n.u_opacity)}},fill:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},fillPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},fillOutline:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world)}},fillOutlinePattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},circle:function(e,n){return{u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_scale_with_map:new t.Uniform1i(e,n.u_scale_with_map),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_extrude_scale:new t.Uniform2f(e,n.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},collisionBox:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pixels_to_tile_units:new t.Uniform1f(e,n.u_pixels_to_tile_units),u_extrude_scale:new t.Uniform2f(e,n.u_extrude_scale),u_overscale_factor:new t.Uniform1f(e,n.u_overscale_factor)}},collisionCircle:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,n.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,n.u_viewport_size)}},debug:function(e,n){return{u_color:new t.UniformColor(e,n.u_color),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_overlay:new t.Uniform1i(e,n.u_overlay),u_overlay_scale:new t.Uniform1f(e,n.u_overlay_scale)}},clippingMask:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},heatmap:function(e,n){return{u_extrude_scale:new t.Uniform1f(e,n.u_extrude_scale),u_intensity:new t.Uniform1f(e,n.u_intensity),u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},heatmapTexture:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world),u_image:new t.Uniform1i(e,n.u_image),u_color_ramp:new t.Uniform1i(e,n.u_color_ramp),u_opacity:new t.Uniform1f(e,n.u_opacity)}},hillshade:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_latrange:new t.Uniform2f(e,n.u_latrange),u_light:new t.Uniform2f(e,n.u_light),u_shadow:new t.UniformColor(e,n.u_shadow),u_highlight:new t.UniformColor(e,n.u_highlight),u_accent:new t.UniformColor(e,n.u_accent)}},hillshadePrepare:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_dimension:new t.Uniform2f(e,n.u_dimension),u_zoom:new t.Uniform1f(e,n.u_zoom),u_unpack:new t.Uniform4f(e,n.u_unpack)}},line:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels)}},lineGradient:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_image:new t.Uniform1i(e,n.u_image),u_image_height:new t.Uniform1f(e,n.u_image_height)}},linePattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_texsize:new t.Uniform2f(e,n.u_texsize),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_image:new t.Uniform1i(e,n.u_image),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},lineSDF:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_patternscale_a:new t.Uniform2f(e,n.u_patternscale_a),u_patternscale_b:new t.Uniform2f(e,n.u_patternscale_b),u_sdfgamma:new t.Uniform1f(e,n.u_sdfgamma),u_image:new t.Uniform1i(e,n.u_image),u_tex_y_a:new t.Uniform1f(e,n.u_tex_y_a),u_tex_y_b:new t.Uniform1f(e,n.u_tex_y_b),u_mix:new t.Uniform1f(e,n.u_mix)}},raster:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_tl_parent:new t.Uniform2f(e,n.u_tl_parent),u_scale_parent:new t.Uniform1f(e,n.u_scale_parent),u_buffer_scale:new t.Uniform1f(e,n.u_buffer_scale),u_fade_t:new t.Uniform1f(e,n.u_fade_t),u_opacity:new t.Uniform1f(e,n.u_opacity),u_image0:new t.Uniform1i(e,n.u_image0),u_image1:new t.Uniform1i(e,n.u_image1),u_brightness_low:new t.Uniform1f(e,n.u_brightness_low),u_brightness_high:new t.Uniform1f(e,n.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,n.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,n.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,n.u_spin_weights)}},symbolIcon:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texture:new t.Uniform1i(e,n.u_texture)}},symbolSDF:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texture:new t.Uniform1i(e,n.u_texture),u_gamma_scale:new t.Uniform1f(e,n.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,n.u_is_halo)}},symbolTextAndIcon:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texsize_icon:new t.Uniform2f(e,n.u_texsize_icon),u_texture:new t.Uniform1i(e,n.u_texture),u_texture_icon:new t.Uniform1i(e,n.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,n.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,n.u_is_halo)}},background:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_opacity:new t.Uniform1f(e,n.u_opacity),u_color:new t.UniformColor(e,n.u_color)}},backgroundPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_opacity:new t.Uniform1f(e,n.u_opacity),u_image:new t.Uniform1i(e,n.u_image),u_pattern_tl_a:new t.Uniform2f(e,n.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,n.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,n.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,n.u_pattern_br_b),u_texsize:new t.Uniform2f(e,n.u_texsize),u_mix:new t.Uniform1f(e,n.u_mix),u_pattern_size_a:new t.Uniform2f(e,n.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,n.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,n.u_scale_a),u_scale_b:new t.Uniform1f(e,n.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,n.u_tile_units_to_pixels)}}};function Yn(e,n,r,i,o,a,s){for(var l=e.context,c=l.gl,u=e.useProgram("collisionBox"),p=[],h=0,d=0,f=0;f0){var b=t.create(),w=v;t.mul(b,y.placementInvProjMatrix,e.transform.glCoordMatrix),t.mul(b,b,y.placementViewportMatrix),p.push({circleArray:x,circleOffset:d,transform:w,invTransform:b}),d=h+=x.length/4}_&&u.draw(l,c.LINES,Tt.disabled,Et.disabled,e.colorModeForRenderPass(),Ct.disabled,In(v,e.transform,g),r.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,null,e.transform.zoom,null,null,_.collisionVertexBuffer)}}if(s&&p.length){var M=e.useProgram("collisionCircle"),S=new t.StructArrayLayout2f1f2i16;S.resize(4*h),S._trim();for(var T=0,E=0,A=p;E=0&&(m[y.associatedIconIndex]={shiftedAnchor:S,angle:T})}else ce(y.numGlyphs,d)}if(p){f.clear();for(var A=e.icon.placedSymbolArray,C=0;C0){var s=t.browser.now(),l=(s-e.timeAdded)/a,c=n?(s-n.timeAdded)/a:-1,u=r.getSource(),p=o.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-p)>Math.abs(e.tileID.overscaledZ-p),d=h&&e.refreshedUponExpiration?1:t.clamp(h?l:1-c,0,1);return e.refreshedUponExpiration&&l>=1&&(e.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}var cr=new t.Color(1,0,0,1),ur=new t.Color(0,1,0,1),pr=new t.Color(0,0,1,1),hr=new t.Color(1,0,1,1),dr=new t.Color(0,1,1,1);function fr(t,e,n,r){gr(t,0,e+n/2,t.transform.width,n,r)}function mr(t,e,n,r){gr(t,e-n/2,0,n,t.transform.height,r)}function gr(e,n,r,i,o,a){var s=e.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*t.browser.devicePixelRatio,r*t.browser.devicePixelRatio,i*t.browser.devicePixelRatio,o*t.browser.devicePixelRatio),s.clear({color:a}),l.disable(l.SCISSOR_TEST)}function yr(e,n,r){var i=e.context,o=i.gl,a=r.posMatrix,s=e.useProgram("debug"),l=Tt.disabled,c=Et.disabled,u=e.colorModeForRenderPass();i.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s.draw(i,o.LINE_STRIP,l,c,u,Ct.disabled,kn(a,t.Color.red),"$debug",e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);var p=n.getTileByID(r.key).latestRawTileData,h=Math.floor((p&&p.byteLength||0)/1024),d=n.getTile(r).tileSize,f=512/Math.min(d,512)*(r.overscaledZ/e.transform.zoom)*.5,m=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(m+=" => "+r.overscaledZ),function(t,e){t.initDebugOverlayCanvas();var n=t.debugOverlayCanvas,r=t.context.gl,i=t.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(e,5,5),i.strokeText(e,5,5),t.debugOverlayTexture.update(n),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,m+" "+h+"kb"),s.draw(i,o.TRIANGLES,l,c,At.alphaBlended,Ct.disabled,kn(a,t.Color.transparent,f),"$debug",e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments)}var vr={symbol:function(e,n,r,i,o){if("translucent"===e.renderPass){var a=Et.disabled,s=e.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(e,n,r,i,o,a,s){for(var l=n.transform,c="map"===o,u="map"===a,p=0,h=e;p256&&this.clearStencil(),n.setColorMode(At.disabled),n.setDepthMode(Tt.disabled);var i=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(var o=0,a=e;o256&&this.clearStencil();var t=this.nextStencilID++,e=this.context.gl;return new Et({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)},_r.prototype.stencilModeForClipping=function(t){var e=this.context.gl;return new Et({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)},_r.prototype.stencilConfigForOverlap=function(t){var e,n=this.context.gl,r=t.sort((function(t,e){return e.overscaledZ-t.overscaledZ})),i=r[r.length-1].overscaledZ,o=r[0].overscaledZ-i+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();for(var a={},s=0;s=0;this.currentLayer--){var x=this.style._layers[i[this.currentLayer]],b=o[x.source],w=u[x.source];this._renderTileClippingMasks(x,w),this.renderLayer(this,b,x,w)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer0?e.pop():null},_r.prototype.isPatternMissing=function(t){if(!t)return!1;if(!t.from||!t.to)return!0;var e=this.imageManager.getPattern(t.from.toString()),n=this.imageManager.getPattern(t.to.toString());return!e||!n},_r.prototype.useProgram=function(t,e){this.cache=this.cache||{};var n=""+t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"");return this.cache[n]||(this.cache[n]=new wn(this.context,t,_n[t],e,Jn[t],this._showOverdrawInspector)),this.cache[n]},_r.prototype.setCustomLayerDefaults=function(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()},_r.prototype.setBaseState=function(){var t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)},_r.prototype.initDebugOverlayCanvas=function(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))},_r.prototype.destroy=function(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()};var xr=function(t,e){this.points=t,this.planes=e};xr.fromInvProjectionMatrix=function(e,n,r){var i=Math.pow(2,r),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((function(n){return t.transformMat4([],n,e)})).map((function(e){return t.scale$1([],e,1/e[3]/n*i)})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((function(e){var n=t.sub([],o[e[0]],o[e[1]]),r=t.sub([],o[e[2]],o[e[1]]),i=t.normalize([],t.cross([],n,r)),a=-t.dot(i,o[e[1]]);return i.concat(a)}));return new xr(o,a)};var br=function(e,n){this.min=e,this.max=n,this.center=t.scale$2([],t.add([],this.min,this.max),.5)};br.prototype.quadrant=function(e){for(var n=[e%2==0,e<2],r=t.clone$2(this.min),i=t.clone$2(this.max),o=0;o=0;if(0===a)return 0;a!==n.length&&(r=!1)}if(r)return 2;for(var l=0;l<3;l++){for(var c=Number.MAX_VALUE,u=-Number.MAX_VALUE,p=0;pthis.max[l]-this.min[l])return 0}return 1};var wr=function(t,e,n,r){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),isNaN(t)||t<0||isNaN(e)||e<0||isNaN(n)||n<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=n,this.right=r};wr.prototype.interpolate=function(e,n,r){return null!=n.top&&null!=e.top&&(this.top=t.number(e.top,n.top,r)),null!=n.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,n.bottom,r)),null!=n.left&&null!=e.left&&(this.left=t.number(e.left,n.left,r)),null!=n.right&&null!=e.right&&(this.right=t.number(e.right,n.right,r)),this},wr.prototype.getCenter=function(e,n){var r=t.clamp((this.left+e-this.right)/2,0,e),i=t.clamp((this.top+n-this.bottom)/2,0,n);return new t.Point(r,i)},wr.prototype.equals=function(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right},wr.prototype.clone=function(){return new wr(this.top,this.bottom,this.left,this.right)},wr.prototype.toJSON=function(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}};var Mr=function(e,n,r,i,o){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=void 0===o||o,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==i?60:i,this.setMaxBounds(),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new wr,this._posMatrixCache={},this._alignedPosMatrixCache={}},Sr={minZoom:{configurable:!0},maxZoom:{configurable:!0},minPitch:{configurable:!0},maxPitch:{configurable:!0},renderWorldCopies:{configurable:!0},worldSize:{configurable:!0},centerOffset:{configurable:!0},size:{configurable:!0},bearing:{configurable:!0},pitch:{configurable:!0},fov:{configurable:!0},zoom:{configurable:!0},center:{configurable:!0},padding:{configurable:!0},centerPoint:{configurable:!0},unmodified:{configurable:!0},point:{configurable:!0}};Mr.prototype.clone=function(){var t=new Mr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t},Sr.minZoom.get=function(){return this._minZoom},Sr.minZoom.set=function(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},Sr.maxZoom.get=function(){return this._maxZoom},Sr.maxZoom.set=function(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},Sr.minPitch.get=function(){return this._minPitch},Sr.minPitch.set=function(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))},Sr.maxPitch.get=function(){return this._maxPitch},Sr.maxPitch.set=function(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))},Sr.renderWorldCopies.get=function(){return this._renderWorldCopies},Sr.renderWorldCopies.set=function(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t},Sr.worldSize.get=function(){return this.tileSize*this.scale},Sr.centerOffset.get=function(){return this.centerPoint._sub(this.size._div(2))},Sr.size.get=function(){return new t.Point(this.width,this.height)},Sr.bearing.get=function(){return-this.angle/Math.PI*180},Sr.bearing.set=function(e){var n=-t.wrap(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=t.create$2(),t.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},Sr.pitch.get=function(){return this._pitch/Math.PI*180},Sr.pitch.set=function(e){var n=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())},Sr.fov.get=function(){return this._fov/Math.PI*180},Sr.fov.set=function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())},Sr.zoom.get=function(){return this._zoom},Sr.zoom.set=function(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())},Sr.center.get=function(){return this._center},Sr.center.set=function(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())},Sr.padding.get=function(){return this._edgeInsets.toJSON()},Sr.padding.set=function(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())},Sr.centerPoint.get=function(){return this._edgeInsets.getCenter(this.width,this.height)},Mr.prototype.isPaddingEqual=function(t){return this._edgeInsets.equals(t)},Mr.prototype.interpolatePadding=function(t,e,n){this._unmodified=!1,this._edgeInsets.interpolate(t,e,n),this._constrain(),this._calcMatrices()},Mr.prototype.coveringZoomLevel=function(t){var e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)},Mr.prototype.getVisibleUnwrappedCoordinates=function(e){var n=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies)for(var r=this.pointCoordinate(new t.Point(0,0)),i=this.pointCoordinate(new t.Point(this.width,0)),o=this.pointCoordinate(new t.Point(this.width,this.height)),a=this.pointCoordinate(new t.Point(0,this.height)),s=Math.floor(Math.min(r.x,i.x,o.x,a.x)),l=Math.floor(Math.max(r.x,i.x,o.x,a.x)),c=s-1;c<=l+1;c++)0!==c&&n.push(new t.UnwrappedTileID(c,e));return n},Mr.prototype.coveringTiles=function(e){var n=this.coveringZoomLevel(e),r=n;if(void 0!==e.minzoom&&ne.maxzoom&&(n=e.maxzoom);var i=t.MercatorCoordinate.fromLngLat(this.center),o=Math.pow(2,n),a=[o*i.x,o*i.y,0],s=xr.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,n),l=e.minzoom||0;this.pitch<=60&&this._edgeInsets.top<.1&&(l=n);var c=function(t){return{aabb:new br([t*o,0,0],[(t+1)*o,o,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}},u=[],p=[],h=n,d=e.reparseOverscaled?r:n;if(this._renderWorldCopies)for(var f=1;f<=3;f++)u.push(c(-f)),u.push(c(f));for(u.push(c(0));u.length>0;){var m=u.pop(),g=m.x,y=m.y,v=m.fullyVisible;if(!v){var _=m.aabb.intersects(s);if(0===_)continue;v=2===_}var x=m.aabb.distanceX(a),b=m.aabb.distanceY(a),w=Math.max(Math.abs(x),Math.abs(b));if(m.zoom===h||w>3+(1<=l)p.push({tileID:new t.OverscaledTileID(m.zoom===h?d:m.zoom,m.wrap,m.zoom,g,y),distanceSq:t.sqrLen([a[0]-.5-g,a[1]-.5-y])});else for(var M=0;M<4;M++){var S=(g<<1)+M%2,T=(y<<1)+(M>>1);u.push({aabb:m.aabb.quadrant(M),zoom:m.zoom+1,x:S,y:T,wrap:m.wrap,fullyVisible:v})}}return p.sort((function(t,e){return t.distanceSq-e.distanceSq})).map((function(t){return t.tileID}))},Mr.prototype.resize=function(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()},Sr.unmodified.get=function(){return this._unmodified},Mr.prototype.zoomScale=function(t){return Math.pow(2,t)},Mr.prototype.scaleZoom=function(t){return Math.log(t)/Math.LN2},Mr.prototype.project=function(e){var n=t.clamp(e.lat,-this.maxValidLatitude,this.maxValidLatitude);return new t.Point(t.mercatorXfromLng(e.lng)*this.worldSize,t.mercatorYfromLat(n)*this.worldSize)},Mr.prototype.unproject=function(e){return new t.MercatorCoordinate(e.x/this.worldSize,e.y/this.worldSize).toLngLat()},Sr.point.get=function(){return this.project(this.center)},Mr.prototype.setLocationAtPoint=function(e,n){var r=this.pointCoordinate(n),i=this.pointCoordinate(this.centerPoint),o=this.locationCoordinate(e),a=new t.MercatorCoordinate(o.x-(r.x-i.x),o.y-(r.y-i.y));this.center=this.coordinateLocation(a),this._renderWorldCopies&&(this.center=this.center.wrap())},Mr.prototype.locationPoint=function(t){return this.coordinatePoint(this.locationCoordinate(t))},Mr.prototype.pointLocation=function(t){return this.coordinateLocation(this.pointCoordinate(t))},Mr.prototype.locationCoordinate=function(e){return t.MercatorCoordinate.fromLngLat(e)},Mr.prototype.coordinateLocation=function(t){return t.toLngLat()},Mr.prototype.pointCoordinate=function(e){var n=[e.x,e.y,0,1],r=[e.x,e.y,1,1];t.transformMat4(n,n,this.pixelMatrixInverse),t.transformMat4(r,r,this.pixelMatrixInverse);var i=n[3],o=r[3],a=n[1]/i,s=r[1]/o,l=n[2]/i,c=r[2]/o,u=l===c?0:(0-l)/(c-l);return new t.MercatorCoordinate(t.number(n[0]/i,r[0]/o,u)/this.worldSize,t.number(a,s,u)/this.worldSize)},Mr.prototype.coordinatePoint=function(e){var n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(n,n,this.pixelMatrix),new t.Point(n[0]/n[3],n[1]/n[3])},Mr.prototype.getBounds=function(){return(new t.LngLatBounds).extend(this.pointLocation(new t.Point(0,0))).extend(this.pointLocation(new t.Point(this.width,0))).extend(this.pointLocation(new t.Point(this.width,this.height))).extend(this.pointLocation(new t.Point(0,this.height)))},Mr.prototype.getMaxBounds=function(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new t.LngLatBounds([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null},Mr.prototype.setMaxBounds=function(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])},Mr.prototype.calculatePosMatrix=function(e,n){void 0===n&&(n=!1);var r=e.key,i=n?this._alignedPosMatrixCache:this._posMatrixCache;if(i[r])return i[r];var o=e.canonical,a=this.worldSize/this.zoomScale(o.z),s=o.x+Math.pow(2,o.z)*e.wrap,l=t.identity(new Float64Array(16));return t.translate(l,l,[s*a,o.y*a,0]),t.scale(l,l,[a/t.EXTENT,a/t.EXTENT,1]),t.multiply(l,n?this.alignedProjMatrix:this.projMatrix,l),i[r]=new Float32Array(l),i[r]},Mr.prototype.customLayerMatrix=function(){return this.mercatorMatrix.slice()},Mr.prototype._constrain=function(){if(this.center&&this.width&&this.height&&!this._constraining){this._constraining=!0;var e,n,r,i,o=-90,a=90,s=-180,l=180,c=this.size,u=this._unmodified;if(this.latRange){var p=this.latRange;o=t.mercatorYfromLat(p[1])*this.worldSize,e=(a=t.mercatorYfromLat(p[0])*this.worldSize)-oa&&(i=a-g)}if(this.lngRange){var y=d.x,v=c.x/2;y-vl&&(r=l-v)}void 0===r&&void 0===i||(this.center=this.unproject(new t.Point(void 0!==r?r:d.x,void 0!==i?i:d.y))),this._unmodified=u,this._constraining=!1}},Mr.prototype._calcMatrices=function(){if(this.height){var e=this.centerOffset;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;var n=Math.PI/2+this._pitch,r=this._fov*(.5+e.y/this.height),i=Math.sin(r)*this.cameraToCenterDistance/Math.sin(t.clamp(Math.PI-n-r,.01,Math.PI-.01)),o=this.point,a=o.x,s=o.y,l=1.01*(Math.cos(Math.PI/2-this._pitch)*i+this.cameraToCenterDistance),c=this.height/50,u=new Float64Array(16);t.perspective(u,this._fov,this.width/this.height,c,l),u[8]=2*-e.x/this.width,u[9]=2*e.y/this.height,t.scale(u,u,[1,-1,1]),t.translate(u,u,[0,0,-this.cameraToCenterDistance]),t.rotateX(u,u,this._pitch),t.rotateZ(u,u,this.angle),t.translate(u,u,[-a,-s,0]),this.mercatorMatrix=t.scale([],u,[this.worldSize,this.worldSize,this.worldSize]),t.scale(u,u,[1,1,t.mercatorZfromAltitude(1,this.center.lat)*this.worldSize,1]),this.projMatrix=u,this.invProjMatrix=t.invert([],this.projMatrix);var p=this.width%2/2,h=this.height%2/2,d=Math.cos(this.angle),f=Math.sin(this.angle),m=a-Math.round(a)+d*p+f*h,g=s-Math.round(s)+d*h+f*p,y=new Float64Array(u);if(t.translate(y,y,[m>.5?m-1:m,g>.5?g-1:g,0]),this.alignedProjMatrix=y,u=t.create(),t.scale(u,u,[this.width/2,-this.height/2,1]),t.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=t.create(),t.scale(u,u,[1,-1,1]),t.translate(u,u,[-1,-1,0]),t.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),!(u=t.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=u,this._posMatrixCache={},this._alignedPosMatrixCache={}}},Mr.prototype.maxPitchScaleFactor=function(){if(!this.pixelMatrixInverse)return 1;var e=this.pointCoordinate(new t.Point(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance},Mr.prototype.getCameraPoint=function(){var e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.Point(0,e))},Mr.prototype.getCameraQueryGeometry=function(e){var n=this.getCameraPoint();if(1===e.length)return[e[0],n];for(var r=n.x,i=n.y,o=n.x,a=n.y,s=0,l=e;s=3&&!t.some((function(t){return isNaN(t)}))){var e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},Tr.prototype._updateHashUnthrottled=function(){var e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());try{t.window.history.replaceState(t.window.history.state,null,e)}catch(t){}};var Er={linearity:.3,easing:t.bezier(0,0,.3,1)},Ar=t.extend({deceleration:2500,maxSpeed:1400},Er),Cr=t.extend({deceleration:20,maxSpeed:1400},Er),Lr=t.extend({deceleration:1e3,maxSpeed:360},Er),Pr=t.extend({deceleration:1e3,maxSpeed:90},Er),Ir=function(t){this._map=t,this.clear()};function Rr(t,e){(!t.duration||t.duration0&&n-e[0].time>160;)e.shift()},Ir.prototype._onMoveEnd=function(e){if(this._drainInertiaBuffer(),!(this._inertiaBuffer.length<2)){for(var n={zoom:0,bearing:0,pitch:0,pan:new t.Point(0,0),pinchAround:void 0,around:void 0},r=0,i=this._inertiaBuffer;r=this._clickTolerance||this._map.fire(new zr(t.type,this._map,t))},Fr.prototype.dblclick=function(t){return this._firePreventable(new zr(t.type,this._map,t))},Fr.prototype.mouseover=function(t){this._map.fire(new zr(t.type,this._map,t))},Fr.prototype.mouseout=function(t){this._map.fire(new zr(t.type,this._map,t))},Fr.prototype.touchstart=function(t){return this._firePreventable(new Dr(t.type,this._map,t))},Fr.prototype.touchmove=function(t){this._map.fire(new Dr(t.type,this._map,t))},Fr.prototype.touchend=function(t){this._map.fire(new Dr(t.type,this._map,t))},Fr.prototype.touchcancel=function(t){this._map.fire(new Dr(t.type,this._map,t))},Fr.prototype._firePreventable=function(t){if(this._map.fire(t),t.defaultPrevented)return{}},Fr.prototype.isEnabled=function(){return!0},Fr.prototype.isActive=function(){return!1},Fr.prototype.enable=function(){},Fr.prototype.disable=function(){};var Br=function(t){this._map=t};Br.prototype.reset=function(){this._delayContextMenu=!1,delete this._contextMenuEvent},Br.prototype.mousemove=function(t){this._map.fire(new zr(t.type,this._map,t))},Br.prototype.mousedown=function(){this._delayContextMenu=!0},Br.prototype.mouseup=function(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new zr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)},Br.prototype.contextmenu=function(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new zr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()},Br.prototype.isEnabled=function(){return!0},Br.prototype.isActive=function(){return!1},Br.prototype.enable=function(){},Br.prototype.disable=function(){};var Nr=function(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1};function Ur(t,e){for(var n={},r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){for(var n=new t.Point(0,0),r=0,i=e;r30)&&(this.aborted=!0)}}},jr.prototype.touchend=function(t,e,n){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){var r=!this.aborted&&this.centroid;if(this.reset(),r)return r}};var Vr=function(t){this.singleTap=new jr(t),this.numTaps=t.numTaps,this.reset()};Vr.prototype.reset=function(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()},Vr.prototype.touchstart=function(t,e,n){this.singleTap.touchstart(t,e,n)},Vr.prototype.touchmove=function(t,e,n){this.singleTap.touchmove(t,e,n)},Vr.prototype.touchend=function(t,e,n){var r=this.singleTap.touchend(t,e,n);if(r){var i=t.timeStamp-this.lastTime<500,o=!this.lastTap||this.lastTap.dist(r)<30;if(i&&o||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}};var Gr=function(){this._zoomIn=new Vr({numTouches:1,numTaps:2}),this._zoomOut=new Vr({numTouches:2,numTaps:1}),this.reset()};Gr.prototype.reset=function(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()},Gr.prototype.touchstart=function(t,e,n){this._zoomIn.touchstart(t,e,n),this._zoomOut.touchstart(t,e,n)},Gr.prototype.touchmove=function(t,e,n){this._zoomIn.touchmove(t,e,n),this._zoomOut.touchmove(t,e,n)},Gr.prototype.touchend=function(t,e,n){var r=this,i=this._zoomIn.touchend(t,e,n),o=this._zoomOut.touchend(t,e,n);return i?(this._active=!0,t.preventDefault(),setTimeout((function(){return r.reset()}),0),{cameraAnimation:function(e){return e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(i)},{originalEvent:t})}}):o?(this._active=!0,t.preventDefault(),setTimeout((function(){return r.reset()}),0),{cameraAnimation:function(e){return e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(o)},{originalEvent:t})}}):void 0},Gr.prototype.touchcancel=function(){this.reset()},Gr.prototype.enable=function(){this._enabled=!0},Gr.prototype.disable=function(){this._enabled=!1,this.reset()},Gr.prototype.isEnabled=function(){return this._enabled},Gr.prototype.isActive=function(){return this._active};var Hr={0:1,2:2},Wr=function(t){this.reset(),this._clickTolerance=t.clickTolerance||1};Wr.prototype.reset=function(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton},Wr.prototype._correctButton=function(t,e){return!1},Wr.prototype._move=function(t,e){return{}},Wr.prototype.mousedown=function(t,e){if(!this._lastPoint){var r=n.mouseButton(t);this._correctButton(t,r)&&(this._lastPoint=e,this._eventButton=r)}},Wr.prototype.mousemoveWindow=function(t,e){var n=this._lastPoint;if(n)if(t.preventDefault(),function(t,e){var n=Hr[e];return void 0===t.buttons||(t.buttons&n)!==n}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(n)0&&(this._active=!0);var i=Ur(r,n),o=new t.Point(0,0),a=new t.Point(0,0),s=0;for(var l in i){var c=i[l],u=this._touches[l];u&&(o._add(c),a._add(c.sub(u)),s++,i[l]=c)}if(this._touches=i,!(sMath.abs(t.x)}var ri=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.reset=function(){t.prototype.reset.call(this),this._valid=void 0,delete this._firstMove,delete this._lastPoints},e.prototype._start=function(t){this._lastPoints=t,ni(t[0].sub(t[1]))&&(this._valid=!1)},e.prototype._move=function(t,e,n){var r=t[0].sub(this._lastPoints[0]),i=t[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,i,n.timeStamp),this._valid)return this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+i.y)/2*-.5}},e.prototype.gestureBeginsVertically=function(t,e,n){if(void 0!==this._valid)return this._valid;var r=t.mag()>=2,i=e.mag()>=2;if(r||i){if(!r||!i)return void 0===this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;var o=t.y>0==e.y>0;return ni(t)&&ni(e)&&o}},e}(Jr),ii={panStep:100,bearingStep:15,pitchStep:10},oi=function(){var t=ii;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1};function ai(t){return t*(2-t)}oi.prototype.reset=function(){this._active=!1},oi.prototype.keydown=function(t){var e=this;if(!(t.altKey||t.ctrlKey||t.metaKey)){var n=0,r=0,i=0,o=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),o=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),o=1);break;case 38:t.shiftKey?i=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?i=-1:(t.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:function(s){var l=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:ai,zoom:n?Math.round(l)+n*(t.shiftKey?2:1):l,bearing:s.getBearing()+r*e._bearingStep,pitch:s.getPitch()+i*e._pitchStep,offset:[-o*e._panStep,-a*e._panStep],center:s.getCenter()},{originalEvent:t})}}}},oi.prototype.enable=function(){this._enabled=!0},oi.prototype.disable=function(){this._enabled=!1,this.reset()},oi.prototype.isEnabled=function(){return this._enabled},oi.prototype.isActive=function(){return this._active},oi.prototype.disableRotation=function(){this._rotationDisabled=!0},oi.prototype.enableRotation=function(){this._rotationDisabled=!1};var si=function(e,n){this._map=e,this._el=e.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=1/450,t.bindAll(["_onTimeout"],this)};si.prototype.setZoomRate=function(t){this._defaultZoomRate=t},si.prototype.setWheelZoomRate=function(t){this._wheelZoomRate=t},si.prototype.isEnabled=function(){return!!this._enabled},si.prototype.isActive=function(){return!!this._active||void 0!==this._finishTimeout},si.prototype.isZooming=function(){return!!this._zooming},si.prototype.enable=function(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)},si.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},si.prototype.wheel=function(e){if(this.isEnabled()){var n=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,r=t.browser.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%4.000244140625==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}},si.prototype._onTimeout=function(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},si.prototype._start=function(e){if(this._delta){this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);var r=n.mousePos(this._el,e);this._around=t.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(r)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}},si.prototype.renderFrame=function(){var e=this;if(this._frameId&&(this._frameId=null,this.isActive())){var n=this._map.transform;if(0!==this._delta){var r="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*r)));this._delta<0&&0!==i&&(i=1/i);var o="number"==typeof this._targetZoom?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(o*i))),"wheel"===this._type&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}var a,s="number"==typeof this._targetZoom?this._targetZoom:n.zoom,l=this._startZoom,c=this._easing,u=!1;if("wheel"===this._type&&l&&c){var p=Math.min((t.browser.now()-this._lastWheelEventTime)/200,1),h=c(p);a=t.number(l,s,h),p<1?this._frameId||(this._frameId=!0):u=!0}else a=s,u=!0;return this._active=!0,u&&(this._active=!1,this._finishTimeout=setTimeout((function(){e._zooming=!1,e._handler._triggerRenderFrame(),delete e._targetZoom,delete e._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!u,zoomDelta:a-n.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}},si.prototype._smoothOutEasing=function(e){var n=t.ease;if(this._prevEase){var r=this._prevEase,i=(t.browser.now()-r.start)/r.duration,o=r.easing(i+.01)-r.easing(i),a=.27/Math.sqrt(o*o+1e-4)*.01,s=Math.sqrt(.0729-a*a);n=t.bezier(a,s,.25,1)}return this._prevEase={start:t.browser.now(),duration:e,easing:n},n},si.prototype.reset=function(){this._active=!1};var li=function(t,e){this._clickZoom=t,this._tapZoom=e};li.prototype.enable=function(){this._clickZoom.enable(),this._tapZoom.enable()},li.prototype.disable=function(){this._clickZoom.disable(),this._tapZoom.disable()},li.prototype.isEnabled=function(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()},li.prototype.isActive=function(){return this._clickZoom.isActive()||this._tapZoom.isActive()};var ci=function(){this.reset()};ci.prototype.reset=function(){this._active=!1},ci.prototype.dblclick=function(t,e){return t.preventDefault(),{cameraAnimation:function(n){n.easeTo({duration:300,zoom:n.getZoom()+(t.shiftKey?-1:1),around:n.unproject(e)},{originalEvent:t})}}},ci.prototype.enable=function(){this._enabled=!0},ci.prototype.disable=function(){this._enabled=!1,this.reset()},ci.prototype.isEnabled=function(){return this._enabled},ci.prototype.isActive=function(){return this._active};var ui=function(){this._tap=new Vr({numTouches:1,numTaps:1}),this.reset()};ui.prototype.reset=function(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()},ui.prototype.touchstart=function(t,e,n){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=e[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(t,e,n))},ui.prototype.touchmove=function(t,e,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;var r=e[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(t,e,n)},ui.prototype.touchend=function(t,e,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(t,e,n)&&(this._tapTime=t.timeStamp)},ui.prototype.touchcancel=function(){this.reset()},ui.prototype.enable=function(){this._enabled=!0},ui.prototype.disable=function(){this._enabled=!1,this.reset()},ui.prototype.isEnabled=function(){return this._enabled},ui.prototype.isActive=function(){return this._active};var pi=function(t,e,n){this._el=t,this._mousePan=e,this._touchPan=n};pi.prototype.enable=function(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")},pi.prototype.disable=function(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")},pi.prototype.isEnabled=function(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()},pi.prototype.isActive=function(){return this._mousePan.isActive()||this._touchPan.isActive()};var hi=function(t,e,n){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=n};hi.prototype.enable=function(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()},hi.prototype.disable=function(){this._mouseRotate.disable(),this._mousePitch.disable()},hi.prototype.isEnabled=function(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())},hi.prototype.isActive=function(){return this._mouseRotate.isActive()||this._mousePitch.isActive()};var di=function(t,e,n,r){this._el=t,this._touchZoom=e,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0};di.prototype.enable=function(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")},di.prototype.disable=function(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")},di.prototype.isEnabled=function(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()},di.prototype.isActive=function(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()},di.prototype.disableRotation=function(){this._rotationDisabled=!0,this._touchRotate.disable()},di.prototype.enableRotation=function(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()};var fi=function(t){return t.zoom||t.drag||t.pitch||t.rotate},mi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(t.Event);function gi(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}var yi=function(e,r){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ir(e),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r),t.bindAll(["handleEvent","handleWindowEvent"],this);var i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[t.window,"blur",void 0]];for(var o=0,a=this._listeners;oo?Math.min(2,b):Math.max(.5,b),w=Math.pow(g,1-e),M=i.unproject(_.add(x.mult(e*w)).mult(m));i.setLocationAtPoint(i.renderWorldCopies?M.wrap():M,f)}r._fireMoveEvents(n)}),(function(t){r._afterEase(n,t)}),e),this},n.prototype._prepareEase=function(e,n,r){void 0===r&&(r={}),this._moving=!0,n||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))},n.prototype._fireMoveEvents=function(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))},n.prototype._afterEase=function(e,n){if(!this._easeId||!n||this._easeId!==n){delete this._easeId;var r=this._zooming,i=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),i&&this.fire(new t.Event("rotateend",e)),o&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}},n.prototype.flyTo=function(e,n){var r=this;if(!e.essential&&t.browser.prefersReducedMotion){var i=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,n)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);var o=this.transform,a=this.getZoom(),s=this.getBearing(),l=this.getPitch(),c=this.getPadding(),u="zoom"in e?t.clamp(+e.zoom,o.minZoom,o.maxZoom):a,p="bearing"in e?this._normalizeBearing(e.bearing,s):s,h="pitch"in e?+e.pitch:l,d="padding"in e?e.padding:o.padding,f=o.zoomScale(u-a),m=t.Point.convert(e.offset),g=o.centerPoint.add(m),y=o.pointLocation(g),v=t.LngLat.convert(e.center||y);this._normalizeCenter(v);var _=o.project(y),x=o.project(v).sub(_),b=e.curve,w=Math.max(o.width,o.height),M=w/f,S=x.mag();if("minZoom"in e){var T=t.clamp(Math.min(e.minZoom,a,u),o.minZoom,o.maxZoom),E=w/o.zoomScale(T-a);b=Math.sqrt(E/S*2)}var A=b*b;function C(t){var e=(M*M-w*w+(t?-1:1)*A*A*S*S)/(2*(t?M:w)*A*S);return Math.log(Math.sqrt(e*e+1)-e)}function L(t){return(Math.exp(t)-Math.exp(-t))/2}function P(t){return(Math.exp(t)+Math.exp(-t))/2}var I=C(0),R=function(t){return P(I)/P(I+b*t)},k=function(t){return w*((P(I)*(L(e=I+b*t)/P(e))-L(I))/A)/S;var e},z=(C(1)-I)/b;if(Math.abs(S)<1e-6||!isFinite(z)){if(Math.abs(w-M)<1e-6)return this.easeTo(e,n);var D=Me.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=s!==p,this._pitching=h!==l,this._padding=!o.isPaddingEqual(d),this._prepareEase(n,!1),this._ease((function(e){var i=e*z,f=1/R(i);o.zoom=1===e?u:a+o.scaleZoom(f),r._rotating&&(o.bearing=t.number(s,p,e)),r._pitching&&(o.pitch=t.number(l,h,e)),r._padding&&(o.interpolatePadding(c,d,e),g=o.centerPoint.add(m));var y=1===e?v:o.unproject(_.add(x.mult(k(i))).mult(f));o.setLocationAtPoint(o.renderWorldCopies?y.wrap():y,g),r._fireMoveEvents(n)}),(function(){return r._afterEase(n)}),e),this},n.prototype.isEasing=function(){return!!this._easeFrameId},n.prototype.stop=function(){return this._stop()},n.prototype._stop=function(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){var n=this._onEaseEnd;delete this._onEaseEnd,n.call(this,e)}if(!t){var r=this.handlers;r&&r.stop(!1)}return this},n.prototype._ease=function(e,n,r){!1===r.animate||0===r.duration?(e(1),n()):(this._easeStart=t.browser.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))},n.prototype._renderFrameCallback=function(){var e=Math.min((t.browser.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},n.prototype._normalizeBearing=function(e,n){e=t.wrap(e,-180,180);var r=Math.abs(e-n);return Math.abs(e-360-n)180?-360:n<-180?360:0}},n}(t.Evented),_i=function(e){void 0===e&&(e={}),this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)};_i.prototype.getDefaultPosition=function(){return"bottom-right"},_i.prototype.onAdd=function(t){var e=this.options&&this.options.compact;return this._map=t,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=n.create("button","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.type="button",this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&this._container.classList.add("maplibregl-compact","mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container},_i.prototype.onRemove=function(){n.remove(this._container),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},_i.prototype._setElementTitle=function(t,e){var n=this._map._getUIString("AttributionControl."+e);t.title=n,t.setAttribute("aria-label",n)},_i.prototype._toggleAttribution=function(){this._container.classList.contains("maplibregl-compact-show")||this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show"),this._compactButton.setAttribute("aria-pressed","false")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._compactButton.setAttribute("aria-pressed","true"))},_i.prototype._updateEditLink=function(){var e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));var n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){var r=n.reduce((function(t,e,r){return e.value&&(t+=e.key+"="+e.value+(r=0)return!1;return!0}))).join(" | ");a!==this._attribHTML&&(this._attribHTML=a,t.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._editLink=null)}},_i.prototype._updateCompact=function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("maplibregl-compact","mapboxgl-compact"):this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show")};var xi=function(){t.bindAll(["_updateLogo"],this),t.bindAll(["_updateCompact"],this)};xi.prototype.onAdd=function(t){this._map=t,this._container=n.create("div","maplibregl-ctrl mapboxgl-ctrl");var e=n.create("a","maplibregl-ctrl-logo mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container},xi.prototype.onRemove=function(){n.remove(this._container),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)},xi.prototype.getDefaultPosition=function(){return"bottom-left"},xi.prototype._updateLogo=function(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")},xi.prototype._logoRequired=function(){if(this._map.style){var t=this._map.style.sourceCaches;for(var e in t)if(t[e].getSource().mapbox_logo)return!0;return!1}},xi.prototype._updateCompact=function(){var t=this._container.children;if(t.length){var e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("maplibregl-compact","mapboxgl-compact"):e.classList.remove("maplibregl-compact","mapboxgl-compact")}};var bi=function(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1};bi.prototype.add=function(t){var e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e},bi.prototype.remove=function(t){for(var e=this._currentlyRunning,n=0,r=e?this._queue.concat(e):this._queue;ne.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>60)throw new Error("maxPitch must be less than or equal to 60");var i=new Mr(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies);if(r.call(this,i,e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new bi,this._controls=[],this._mapId=t.uniqueId(),this._locale=t.extend({},wi,e.locale),this._clickTolerance=e.clickTolerance,this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken),"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error("Container '"+e.container+"' not found.")}else{if(!(e.container instanceof Si))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),t.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",(function(){return n._update(!1)})),this.on("moveend",(function(){return n._update(!1)})),this.on("zoom",(function(){return n._update(!0)})),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new yi(this,e),this._hash=e.hash&&new Tr("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new _i({customAttribution:e.customAttribution})),this.addControl(new xi,e.logoPosition),this.on("style.load",(function(){n.transform.unmodified&&n.jumpTo(n.style.stylesheet)})),this.on("data",(function(e){n._update("style"===e.dataType),n.fire(new t.Event(e.dataType+"data",e))})),this.on("dataloading",(function(e){n.fire(new t.Event(e.dataType+"dataloading",e))}))}r&&(i.__proto__=r),(i.prototype=Object.create(r&&r.prototype)).constructor=i;var o={showTileBoundaries:{configurable:!0},showPadding:{configurable:!0},showCollisionBoxes:{configurable:!0},showOverdrawInspector:{configurable:!0},repaint:{configurable:!0},vertices:{configurable:!0},version:{configurable:!0}};return i.prototype._getMapId=function(){return this._mapId},i.prototype.addControl=function(e,n){if(void 0===n&&(n=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));var r=e.onAdd(this);this._controls.push(e);var i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this},i.prototype.removeControl=function(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));var n=this._controls.indexOf(e);return n>-1&&this._controls.splice(n,1),e.onRemove(this),this},i.prototype.hasControl=function(t){return this._controls.indexOf(t)>-1},i.prototype.resize=function(e){var n=this._containerDimensions(),r=n[0],i=n[1];this._resizeCanvas(r,i),this.transform.resize(r,i),this.painter.resize(r,i);var o=!this._moving;return o&&(this.stop(),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e))),this.fire(new t.Event("resize",e)),o&&this.fire(new t.Event("moveend",e)),this},i.prototype.getBounds=function(){return this.transform.getBounds()},i.prototype.getMaxBounds=function(){return this.transform.getMaxBounds()},i.prototype.setMaxBounds=function(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()},i.prototype.setMinZoom=function(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;throw new Error("maxZoom must be greater than the current minZoom")},i.prototype.getMaxZoom=function(){return this.transform.maxZoom},i.prototype.setMinPitch=function(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()60)throw new Error("maxPitch must be less than or equal to 60");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")},i.prototype.getMaxPitch=function(){return this.transform.maxPitch},i.prototype.getRenderWorldCopies=function(){return this.transform.renderWorldCopies},i.prototype.setRenderWorldCopies=function(t){return this.transform.renderWorldCopies=t,this._update()},i.prototype.project=function(e){return this.transform.locationPoint(t.LngLat.convert(e))},i.prototype.unproject=function(e){return this.transform.pointLocation(t.Point.convert(e))},i.prototype.isMoving=function(){return this._moving||this.handlers.isMoving()},i.prototype.isZooming=function(){return this._zooming||this.handlers.isZooming()},i.prototype.isRotating=function(){return this._rotating||this.handlers.isRotating()},i.prototype._createDelegatedListener=function(t,e,n){var r,i=this;if("mouseenter"===t||"mouseover"===t){var o=!1;return{layer:e,listener:n,delegates:{mousemove:function(r){var a=i.getLayer(e)?i.queryRenderedFeatures(r.point,{layers:[e]}):[];a.length?o||(o=!0,n.call(i,new zr(t,i,r.originalEvent,{features:a}))):o=!1},mouseout:function(){o=!1}}}}if("mouseleave"===t||"mouseout"===t){var a=!1;return{layer:e,listener:n,delegates:{mousemove:function(r){(i.getLayer(e)?i.queryRenderedFeatures(r.point,{layers:[e]}):[]).length?a=!0:a&&(a=!1,n.call(i,new zr(t,i,r.originalEvent)))},mouseout:function(e){a&&(a=!1,n.call(i,new zr(t,i,e.originalEvent)))}}}}return{layer:e,listener:n,delegates:(r={},r[t]=function(t){var r=i.getLayer(e)?i.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,n.call(i,t),delete t.features)},r)}},i.prototype.on=function(t,e,n){if(void 0===n)return r.prototype.on.call(this,t,e);var i=this._createDelegatedListener(t,e,n);for(var o in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(i),i.delegates)this.on(o,i.delegates[o]);return this},i.prototype.once=function(t,e,n){if(void 0===n)return r.prototype.once.call(this,t,e);var i=this._createDelegatedListener(t,e,n);for(var o in i.delegates)this.once(o,i.delegates[o]);return this},i.prototype.off=function(t,e,n){var i=this;return void 0===n?r.prototype.off.call(this,t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&function(r){for(var o=r[t],a=0;a180;){var s=r.locationPoint(e);if(s.x>=0&&s.y>=0&&s.x<=r.width&&s.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e}Ii.prototype.down=function(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),n.disableDrag()},Ii.prototype.move=function(t,e){var n=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&n.setBearing(n.getBearing()+r.bearingDelta),this.mousePitch){var i=this.mousePitch.mousemoveWindow(t,e);i&&i.pitchDelta&&n.setPitch(n.getPitch()+i.pitchDelta)}},Ii.prototype.off=function(){var t=this.element;n.removeEventListener(t,"mousedown",this.mousedown),n.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(t,"touchmove",this.touchmove),n.removeEventListener(t,"touchend",this.touchend),n.removeEventListener(t,"touchcancel",this.reset),this.offTemp()},Ii.prototype.offTemp=function(){n.enableDrag(),n.removeEventListener(t.window,"mousemove",this.mousemove),n.removeEventListener(t.window,"mouseup",this.mouseup)},Ii.prototype.mousedown=function(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:function(){return e.preventDefault()}}),n.mousePos(this.element,e)),n.addEventListener(t.window,"mousemove",this.mousemove),n.addEventListener(t.window,"mouseup",this.mouseup)},Ii.prototype.mousemove=function(t){this.move(t,n.mousePos(this.element,t))},Ii.prototype.mouseup=function(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()},Ii.prototype.touchstart=function(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:function(){return t.preventDefault()}},this._startPos))},Ii.prototype.touchmove=function(t){1!==t.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,t.targetTouches)[0],this.move({preventDefault:function(){return t.preventDefault()}},this._lastPos))},Ii.prototype.touchend=function(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)=n}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag")))},r.prototype._onUp=function(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"},r.prototype._addDragHandler=function(t){this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},r.prototype.setDraggable=function(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this},r.prototype.isDraggable=function(){return this._draggable},r.prototype.setRotation=function(t){return this._rotation=t||0,this._update(),this},r.prototype.getRotation=function(){return this._rotation},r.prototype.setRotationAlignment=function(t){return this._rotationAlignment=t||"auto",this._update(),this},r.prototype.getRotationAlignment=function(){return this._rotationAlignment},r.prototype.setPitchAlignment=function(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this},r.prototype.getPitchAlignment=function(){return this._pitchAlignment},r}(t.Evented),Fi={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Bi=0,Ni=!1,Ui=function(e){function r(n){e.call(this),this.options=t.extend({},Fi,n),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r.prototype.onAdd=function(e){var r;return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),r=this._setupUI,void 0!==Di?r(Di):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((function(t){r(Di="denied"!==t.state)})):r(Di=!!t.window.navigator.geolocation),this._container},r.prototype.onRemove=function(){void 0!==this._geolocationWatchID&&(t.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Bi=0,Ni=!1},r.prototype._isOutOfMapMaxBounds=function(t){var e=this._map.getMaxBounds(),n=t.coords;return e&&(n.longitudee.getEast()||n.latitudee.getNorth())},r.prototype._setErrorState=function(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting")}},r.prototype._onSuccess=function(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}},r.prototype._updateCamera=function(e){var n=new t.LngLat(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,i=this._map.getBearing(),o=t.extend({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(r),o,{geolocateSource:!0})},r.prototype._updateMarker=function(e){if(e){var n=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},r.prototype._updateCircleRadius=function(){var t=this._map._container.clientHeight/2,e=this._map.unproject([0,t]),n=this._map.unproject([1,t]),r=e.distanceTo(n),i=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=i+"px",this._circleElement.style.height=i+"px"},r.prototype._onZoom=function(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},r.prototype._onError=function(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;var n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&Ni)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}},r.prototype._finish=function(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},r.prototype._setupUI=function(e){var r=this;if(this._container.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate mapboxgl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");var i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}else{var o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=o,this._geolocateButton.setAttribute("aria-label",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot mapboxgl-user-location-dot"),this._userLocationDotMarker=new Oi(this._dotElement),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Oi({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",(function(e){e.geolocateSource||"ACTIVE_LOCK"!==r._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(r._watchState="BACKGROUND",r._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),r._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),r.fire(new t.Event("trackuserlocationend")))}))},r.prototype.trigger=function(){if(!this._setup)return t.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Bi--,Ni=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){var e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++Bi>1?(e={maximumAge:6e5,timeout:0},Ni=!0):(e=this.options.positionOptions,Ni=!1),this._geolocationWatchID=t.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else t.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0},r.prototype._clearWatch=function(){t.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)},r}(t.Evented),ji={maxWidth:100,unit:"metric"},Vi=function(e){this.options=t.extend({},ji,e),t.bindAll(["_onMove","setUnit"],this)};function Gi(t,e,n){var r=n&&n.maxWidth||100,i=t._container.clientHeight/2,o=t.unproject([0,i]),a=t.unproject([r,i]),s=o.distanceTo(a);if(n&&"imperial"===n.unit){var l=3.2808*s;l>5280?Hi(e,r,l/5280,t._getUIString("ScaleControl.Miles")):Hi(e,r,l,t._getUIString("ScaleControl.Feet"))}else n&&"nautical"===n.unit?Hi(e,r,s/1852,t._getUIString("ScaleControl.NauticalMiles")):s>=1e3?Hi(e,r,s/1e3,t._getUIString("ScaleControl.Kilometers")):Hi(e,r,s,t._getUIString("ScaleControl.Meters"))}function Hi(t,e,n,r){var i,o,a,s=(i=n,(o=Math.pow(10,(""+Math.floor(i)).length-1))*(a=(a=i/o)>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(t){var e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(a)));t.style.width=e*(s/n)+"px",t.innerHTML=s+" "+r}Vi.prototype.getDefaultPosition=function(){return"bottom-left"},Vi.prototype._onMove=function(){Gi(this._map,this._container,this.options)},Vi.prototype.onAdd=function(t){return this._map=t,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container},Vi.prototype.onRemove=function(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0},Vi.prototype.setUnit=function(t){this.options.unit=t,Gi(this._map,this._container,this.options)};var Wi=function(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in t.window.document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in t.window.document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in t.window.document&&(this._fullscreenchange="MSFullscreenChange")};Wi.prototype.onAdd=function(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer},Wi.prototype.onRemove=function(){n.remove(this._controlContainer),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)},Wi.prototype._checkFullscreenSupport=function(){return!!(t.window.document.fullscreenEnabled||t.window.document.mozFullScreenEnabled||t.window.document.msFullscreenEnabled||t.window.document.webkitFullscreenEnabled)},Wi.prototype._setupUI=function(){var e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen mapboxgl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",e).setAttribute("aria-hidden",!0),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)},Wi.prototype._updateTitle=function(){var t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t},Wi.prototype._getTitle=function(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")},Wi.prototype._isFullscreen=function(){return this._fullscreen},Wi.prototype._changeIcon=function(){(t.window.document.fullscreenElement||t.window.document.mozFullScreenElement||t.window.document.webkitFullscreenElement||t.window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())},Wi.prototype._onClickFullscreen=function(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.mozCancelFullScreen?t.window.document.mozCancelFullScreen():t.window.document.msExitFullscreen?t.window.document.msExitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()};var qi={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Zi=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),Xi=function(e){function r(n){e.call(this),this.options=t.extend(Object.create(qi),n),t.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r.prototype.addTo=function(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new t.Event("open")),this},r.prototype.isOpen=function(){return!!this._map},r.prototype.remove=function(){return this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new t.Event("close")),this},r.prototype.getLngLat=function(){return this._lngLat},r.prototype.setLngLat=function(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer","mapboxgl-track-pointer")),this},r.prototype.trackPointer=function(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")),this},r.prototype.getElement=function(){return this._container},r.prototype.setText=function(e){return this.setDOMContent(t.window.document.createTextNode(e))},r.prototype.setHTML=function(e){var n,r=t.window.document.createDocumentFragment(),i=t.window.document.createElement("body");for(i.innerHTML=e;n=i.firstChild;)r.appendChild(n);return this.setDOMContent(r)},r.prototype.getMaxWidth=function(){return this._container&&this._container.style.maxWidth},r.prototype.setMaxWidth=function(t){return this.options.maxWidth=t,this._update(),this},r.prototype.setDOMContent=function(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content mapboxgl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this},r.prototype.addClassName=function(t){this._container&&this._container.classList.add(t)},r.prototype.removeClassName=function(t){this._container&&this._container.classList.remove(t)},r.prototype.setOffset=function(t){return this.options.offset=t,this._update(),this},r.prototype.toggleClassName=function(t){if(this._container)return this._container.classList.toggle(t)},r.prototype._createCloseButton=function(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))},r.prototype._onMouseUp=function(t){this._update(t.point)},r.prototype._onMouseMove=function(t){this._update(t.point)},r.prototype._onDrag=function(t){this._update(t.point)},r.prototype._update=function(e){var r=this;if(this._map&&(this._lngLat||this._trackPointer)&&this._content&&(this._container||(this._container=n.create("div","maplibregl-popup mapboxgl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach((function(t){return r._container.classList.add(t)})),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer")),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ri(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||e)){var i=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat),o=this.options.anchor,a=function e(n){if(n){if("number"==typeof n){var r=Math.round(Math.sqrt(.5*Math.pow(n,2)));return{center:new t.Point(0,0),top:new t.Point(0,n),"top-left":new t.Point(r,r),"top-right":new t.Point(-r,r),bottom:new t.Point(0,-n),"bottom-left":new t.Point(r,-r),"bottom-right":new t.Point(-r,-r),left:new t.Point(n,0),right:new t.Point(-n,0)}}if(n instanceof t.Point||Array.isArray(n)){var i=t.Point.convert(n);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.Point.convert(n.center||[0,0]),top:t.Point.convert(n.top||[0,0]),"top-left":t.Point.convert(n["top-left"]||[0,0]),"top-right":t.Point.convert(n["top-right"]||[0,0]),bottom:t.Point.convert(n.bottom||[0,0]),"bottom-left":t.Point.convert(n["bottom-left"]||[0,0]),"bottom-right":t.Point.convert(n["bottom-right"]||[0,0]),left:t.Point.convert(n.left||[0,0]),right:t.Point.convert(n.right||[0,0])}}return e(new t.Point(0,0))}(this.options.offset);if(!o){var s,l=this._container.offsetWidth,c=this._container.offsetHeight;s=i.y+a.bottom.ythis._map.transform.height-c?["bottom"]:[],i.xthis._map.transform.width-l/2&&s.push("right"),o=0===s.length?"bottom":s.join("-")}var u=i.add(a[o]).round();n.setTransform(this._container,ki[o]+" translate("+u.x+"px,"+u.y+"px)"),zi(this._container,o,"popup")}},r.prototype._focusFirstElement=function(){if(this.options.focusAfterOpen&&this._container){var t=this._container.querySelector(Zi);t&&t.focus()}},r.prototype._onClose=function(){this.remove()},r}(t.Evented),$i={version:t.version,supported:e,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:Ai,NavigationControl:Pi,GeolocateControl:Ui,AttributionControl:_i,ScaleControl:Vi,FullscreenControl:Wi,Popup:Xi,Marker:Oi,Style:Ge,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.Point,MercatorCoordinate:t.MercatorCoordinate,Evented:t.Evented,config:t.config,prewarm:function(){Bt().acquire(zt)},clearPrewarmedResources:function(){var t=Ot;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(zt),Ot=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 t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return Dt.workerCount},set workerCount(t){Dt.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage:function(e){t.clearTileCache(e)},workerUrl:"",addProtocol:function(e,n){t.config.REGISTERED_PROTOCOLS[e]=n},removeProtocol:function(e){delete t.config.REGISTERED_PROTOCOLS[e]}};return $i}));return n}));!function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(o)return o(a,!0);throw(s=new Error("Cannot find module '"+a+"'")).code="MODULE_NOT_FOUND",s}l=n[a]={exports:{}},e[a][0].call(l.exports,(function(t){return i(e[a][1][t]||t)}),l,l.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;athis._bounds.width?this._bounds.width:t},_getY:function(t){return(t=(t=(t=t.touches?t.touches[0]:t).clientY-this._bounds.top)<0?0:t)>this._bounds.height?this._bounds.height:t},setSlider:function(t){this._setPosition(t)},on:function(t,e){return this._ev.on(t,e),this},fire:function(t,e){return this._ev.emit(t,e),this},off:function(t,e){return this._ev.removeListener(t,e),this},remove:function(){this._clearSync(),this._mapB.off("resize",this._onResize);var t;(t=((t=this._mapA.getContainer())&&(t.style.clip=null,t.removeEventListener("mousemove",this._onMove)),this._mapB.getContainer()))&&(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.maplibregl?maplibregl.Compare=o:void 0!==e&&(e.exports=o)},{"@mapbox/mapbox-gl-sync-move":2,events:3}],2:[function(t,e,n){e.exports=function(){var t=arguments.length;if(1===t)e=arguments[0];else for(var e=[],n=0;ni&&!o.warned&&(o.warned=!0,(r=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit")).name="MaxListenersExceededWarning",r.emitter=t,r.type=e,r.count=o.length,n=r,console&&console.warn&&console.warn(n))),t}function h(t,e,n){e=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(t={fired:!1,wrapFn:void 0,target:t,type:e,listener:n});return e.listener=n,t.wrapFn=e}function d(t,e,n){if(void 0===(t=t._events))return[];if(void 0===(t=t[e]))return[];if("function"==typeof t)return n?[t.listener||t]:[t];if(n){for(var r=t,i=new Array(r.length),o=0;o=0?1:-1)}function o(t,e,n){var r=(t=i(t*n))-(e=i(e*n));r<<=1;t-e<0&&(r=~r);for(var o="";r>=32;){o+=String.fromCharCode(63+(32|31&r));r>>=5}return o+=String.fromCharCode(r+63)}r.decode=function(t,e){for(var n,r=0,i=0,o=0,a=[],s=0,l=0,c=null,u=Math.pow(10,Number.isInteger(e)?e:5);r=32);n=1&l?~(l>>1):l>>1;s=l=0;do{l|=(31&(c=t.charCodeAt(r++)-63))<=32);i+=n;o+=1&l?~(l>>1):l>>1;a.push([i/u,o/u])}return a};r.encode=function(t,e){if(!t.length)return"";for(var n=Math.pow(10,Number.isInteger(e)?e:5),r=o(t[0][0],0,n)+o(t[0][1],0,n),i=1;i0&&this._events[t].length>n){this._events[t].warned=!0;console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length);"function"==typeof console.trace&&console.trace()}return this};r.prototype.on=r.prototype.addListener;r.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(t,r);if(!n){n=!0;e.apply(this,arguments)}}r.listener=e;this.on(t,r);return this};r.prototype.removeListener=function(t,e){var n,r,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;a=(n=this._events[t]).length;r=-1;if(n===e||i(n.listener)&&n.listener===e){delete this._events[t];this._events.removeListener&&this.emit("removeListener",t,e)}else if(o(n)){for(s=a;s-- >0;)if(n[s]===e||n[s].listener&&n[s].listener===e){r=s;break}if(r<0)return this;if(1===n.length){n.length=0;delete this._events[t]}else n.splice(r,1);this._events.removeListener&&this.emit("removeListener",t,e)}return this};r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener){0===arguments.length?this._events={}:this._events[t]&&delete this._events[t];return this}if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);this.removeAllListeners("removeListener");this._events={};return this}if(i(n=this._events[t]))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);delete this._events[t];return this};r.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]};r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0};r.listenerCount=function(t,e){return t.listenerCount(e)};function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function a(t){return void 0===t}},{}],4:[function(t,e,n){!function(){var t={};void 0!==n?e.exports=t:this.fuzzy=t;t.simpleFilter=function(e,n){return n.filter((function(n){return t.test(e,n)}))};t.test=function(e,n){return null!==t.match(e,n)};t.match=function(t,e,n){n=n||{};var r,i=0,o=[],a=e.length,s=0,l=0,c=n.pre||"",u=n.post||"",p=n.caseSensitive&&e||e.toLowerCase();t=n.caseSensitive&&t||t.toLowerCase();for(var h=0;h/g},{}],7:[function(t,e,n){(function(t){var n=NaN,r="[object Symbol]",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt,c="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,p=c||u||Function("return this")(),h=Object.prototype.toString,d=Math.max,f=Math.min,m=function(){return p.Date.now()};function g(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function y(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&h.call(t)==r}(t))return n;if(g(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=g(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(i,"");var c=a.test(t);return c||s.test(t)?l(t.slice(2),c?2:8):o.test(t)?n:+t}e.exports=function(t,e,n){var r,i,o,a,s,l,c=0,u=!1,p=!1,h=!0;if("function"!=typeof t)throw new TypeError("Expected a function");e=y(e)||0;if(g(n)){u=!!n.leading;o=(p="maxWait"in n)?d(y(n.maxWait)||0,e):o;h="trailing"in n?!!n.trailing:h}function v(e){var n=r,o=i;r=i=void 0;c=e;return a=t.apply(o,n)}function _(t){var n=t-l;return void 0===l||n>=e||n<0||p&&t-c>=o}function x(){var t=m();if(_(t))return b(t);s=setTimeout(x,function(t){var n=e-(t-l);return p?f(n,o-(t-c)):n}(t))}function b(t){s=void 0;if(h&&r)return v(t);r=i=void 0;return a}function w(){var t=m(),n=_(t);r=arguments;i=this;l=t;if(n){if(void 0===s)return function(t){c=t;s=setTimeout(x,e);return u?v(t):a}(l);if(p){s=setTimeout(x,e);return v(l)}}void 0===s&&(s=setTimeout(x,e));return a}w.cancel=function(){void 0!==s&&clearTimeout(s);c=0;r=l=i=s=void 0};w.flush=function(){return void 0===s?a:b(m())};return w}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(t,e,n){(function(t){var r="__lodash_hash_undefined__",i=1,o=2,a=9007199254740991,s="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",p="[object Date]",h="[object Error]",d="[object Function]",f="[object GeneratorFunction]",m="[object Map]",g="[object Number]",y="[object Null]",v="[object Object]",_="[object Promise]",x="[object Proxy]",b="[object RegExp]",w="[object Set]",M="[object String]",S="[object Symbol]",T="[object Undefined]",E="[object WeakMap]",A="[object ArrayBuffer]",C="[object DataView]",L=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,I={};I["[object Float32Array]"]=I["[object Float64Array]"]=I["[object Int8Array]"]=I["[object Int16Array]"]=I["[object Int32Array]"]=I["[object Uint8Array]"]=I["[object Uint8ClampedArray]"]=I["[object Uint16Array]"]=I["[object Uint32Array]"]=!0;I[s]=I[l]=I[A]=I[u]=I[C]=I[p]=I[h]=I[d]=I[m]=I[g]=I[v]=I[b]=I[w]=I[M]=I[E]=!1;var R="object"==typeof t&&t&&t.Object===Object&&t,k="object"==typeof self&&self&&self.Object===Object&&self,z=R||k||Function("return this")(),D="object"==typeof n&&n&&!n.nodeType&&n,O=D&&"object"==typeof e&&e&&!e.nodeType&&e,F=O&&O.exports===D,B=F&&R.process,N=function(){try{return B&&B.binding&&B.binding("util")}catch(t){}}(),U=N&&N.isTypedArray;function j(t,e){for(var n=-1,r=null==t?0:t.length;++n-1};Tt.prototype.set=function(t,e){var n=this.__data__,r=Pt(n,t);if(r<0){++this.size;n.push([t,e])}else n[r][1]=e;return this};function Et(t){var e=-1,n=null==t?0:t.length;this.clear();for(;++ec))return!1;var p=s.get(t);if(p&&s.get(e))return p==e;var h=-1,d=!0,f=n&o?new At:void 0;s.set(t,e);s.set(e,t);for(;++h-1&&t%1==0&&t-1&&t%1==0&&t<=a}function Jt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Yt(t){return null!=t&&"object"==typeof t}var Qt=U?function(t){return function(e){return t(e)}}(U):function(t){return Yt(t)&&$t(t.length)&&!!I[It(t)]};function Kt(t){return null!=(e=t)&&$t(e.length)&&!Xt(e)?Lt(t):Dt(t);var e}e.exports=function(t,e){return kt(t,e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(t,e,n){(function(r){var i=t("lodash._reinterpolate"),o=t("lodash.templatesettings"),a=1/0,s=9007199254740991,l="[object Arguments]",c="[object AsyncFunction]",u="[object DOMException]",p="[object Error]",h="[object Function]",d="[object GeneratorFunction]",f="[object Null]",m="[object Object]",g="[object Proxy]",y="[object Symbol]",v="[object Undefined]",_=/\b__p \+= '';/g,x=/\b(__p \+=) '' \+/g,b=/(__e\(.*?\)|\b__t\)) \+\n'';/g,w=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,M=/^\[object .+?Constructor\]$/,S=/^(?:0|[1-9]\d*)$/,T=/($^)/,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[p]=A[h]=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 r&&r&&r.Object===Object&&r,P="object"==typeof self&&self&&self.Object===Object&&self,I=L||P||Function("return this")(),R="object"==typeof n&&n&&!n.nodeType&&n,k=R&&"object"==typeof e&&e&&!e.nodeType&&e,z=k&&k.exports===R,D=z&&L.process,O=function(){try{var t=k&&k.require&&k.require("util").types;return t||D&&D.binding&&D.binding("util")}catch(t){}}(),F=O&&O.isTypedArray;function B(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function N(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n-1&&t%1==0&&t0){if(++St>=800)return arguments[0]}else St=0;return Mt.apply(void 0,arguments)});function At(t,e){return t===e||t!=t&&e!=e}var Ct=ft(function(){return arguments}())?ft:function(t){return Ot(t)&&Z.call(t,"callee")&&!et.call(t,"callee")},Lt=Array.isArray;function Pt(t){return null!=t&&zt(t.length)&&!kt(t)}var It=it||function(){return!1};function Rt(t){if(!Ot(t))return!1;var e=dt(t);return e==p||e==u||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!Ot(t)||dt(t)!=m)return!1;var e=tt(t);if(null===e)return!0;var n=Z.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&q.call(n)==J}(t)}function kt(t){if(!Dt(t))return!1;var e=dt(t);return e==h||e==d||e==c||e==g}function zt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=s}function Dt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ot(t){return null!=t&&"object"==typeof t}var Ft=F?function(t){return function(e){return t(e)}}(F):function(t){return Ot(t)&&zt(t.length)&&!!A[dt(t)]};var Bt,Nt=(Bt=function(t,e,n,r){!function(t,e,n,r){var i=!n;n||(n={});for(var o=-1,a=e.length;++o1?e[r-1]:void 0,o=r>2?e[2]:void 0;i=Bt.length>3&&"function"==typeof i?(r--,i):void 0;if(o&&bt(e[0],e[1],o)){i=r<3?void 0:i;r=1}t=Object(t);for(;++n"']/g,c=RegExp(l.source),u="object"==typeof n&&n&&n.Object===Object&&n,p="object"==typeof self&&self&&self.Object===Object&&self,h=u||p||Function("return this")();var d,f=(d={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==d?void 0:d[t]}),m=Object.prototype,g=m.hasOwnProperty,y=m.toString,v=h.Symbol,_=v?v.toStringTag:void 0,x=v?v.prototype:void 0,b=x?x.toString:void 0,w={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:r,variable:"",imports:{_:{escape:function(t){return(t=(e=t,null==e?"":S(e)))&&c.test(t)?t.replace(l,f):t;var e}}}};function M(t){return null==t?void 0===t?s:o:_&&_ in Object(t)?function(t){var e=g.call(t,_),n=t[_];try{t[_]=void 0;var r=!0}catch(t){}var i=y.call(t);r&&(e?t[_]=n:delete t[_]);return i}(t):function(t){return y.call(t)}(t)}function S(t){if("string"==typeof t)return t;if(T(t))return function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n1)for(var n=1;n0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(h)throw h;if("production"!==e.env.NODE_ENV){var l=function(t,e,n,o){var a=Object.keys(e),s=n&&n.type===r.ActionTypes.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===a.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,i.default)(t))return"The "+s+' has unexpected type of "'+{}.toString.call(t).match(/\s([a-z|A-Z]+)/)[1]+'". Expected argument to be an object with the following keys: "'+a.join('", "')+'"';var l=Object.keys(t).filter((function(t){return!e.hasOwnProperty(t)&&!o[t]}));l.forEach((function(t){o[t]=!0}));if(l.length>0)return"Unexpected "+(l.length>1?"keys":"key")+' "'+l.join('", "')+'" found in '+s+'. Expected to find one of the known reducer keys instead: "'+a.join('", "')+'". Unexpected keys will be ignored.'}(t,a,n,p);l&&(0,o.default)(l)}for(var c=!1,d={},f=0;f-1};a.prototype.value=function(t){this.selected=t;this.el.value=this.getItemValue(t);if(document.createEvent){var e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1);this.el.dispatchEvent(e)}else this.el.fireEvent("onchange")};a.prototype.getCandidates=function(t){var e={pre:"",post:"",extract:function(t){return this.getItemValue(t)}.bind(this)};t(this.options.filter?i.filter(this.query,this.data,e):this.data.map(function(t){for(var e=this.getItemValue(t),n=this.normalize(e),r=n.lastIndexOf(this.query);r>-1;){var i=r+this.query.length;e=e.slice(0,r)+""+e.slice(r,i)+""+e.slice(i);r=n.slice(0,r).lastIndexOf(this.query)}return{original:t,string:e}}.bind(this)))};a.prototype.getItemValue=function(t){return t};e.exports=a},{"./list":31,fuzzy:4,xtend:37}],33:[function(t,e,n){(function(r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i,o,a=t("./ponyfill.js"),s=(i=a)&&i.__esModule?i:{default:i};o="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==r?r:void 0!==e?e:Function("return this")();var l=(0,s.default)(o);n.default=l}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./ponyfill.js":34}],34:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.default=function(t){var e,n=t.Symbol;if("function"==typeof n)if(n.observable)e=n.observable;else{e=n("observable");n.observable=e}else e="@@observable";return e}},{}],35:[function(t,e,n){var r=t("turf-meta").coordEach;e.exports=function(t){var e=[1/0,1/0,-1/0,-1/0];r(t,(function(t){e[0]>t[0]&&(e[0]=t[0]);e[1]>t[1]&&(e[1]=t[1]);e[2]=200&&s.status<400)){t(u([]));return t(f(JSON.parse(s.responseText).message))}var e=JSON.parse(s.responseText);if(e.error){t(u([]));return t(f(e.error))}t(f(null));e.routes[o]||t(y(0));t(u(e.routes));t(l(e.waypoints[0].location));t(c(e.waypoints[e.waypoints.length-1].location))};s.onerror=function(){t(u([]));return t(f(JSON.parse(s.responseText).message))};s.send()}}}function d(t){var e={id:"waypoint"};return Object.assign(t,{properties:t.properties?Object.assign(t.properties,e):e})}function f(t){return function(e){e({type:"ERROR",error:t});t&&e(x("error",{error:t}))}}function m(t){return{type:i.ORIGIN_FROM_COORDINATES,coordinates:t}}function g(t){return{type:i.DESTINATION_FROM_COORDINATES,coordinates:t}}function y(t){return{type:i.ROUTE_INDEX,routeIndex:t}}function v(t){return function(e,n){var r=n().destination;e(l(t));r.geometry&&e(h())}}function _(t){return function(e,n){var r=n().origin;e(c(t));r.geometry&&e(h())}}function x(t,e){var n=this;return function(r,o){var a=o().events;if(!a[t])return{type:i.EVENTS,events:a};for(var s=a[t].slice(),l=0;l=200&&this.request.status<400){var t=JSON.parse(this.request.responseText);if(t.features.length)this._clearEl.classList.add("active");else{this._clearEl.classList.remove("active");this._typeahead.selected=null}this.fire("results",{results:t.features});this._typeahead.update(t.features);return e(t.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(t){(t=t.trim())||this._clear();t.length>2&&this._geocode(t,function(t){this._results=t}.bind(this))}},{key:"_change",value:function(){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1);this._inputEl.dispatchEvent(t)}},{key:"_query",value:function(t){if(t){"object"===(void 0===t?"undefined":r(t))&&t.length&&(t=[l.default.wrap(t[0]),l.default.wrap(t[1])].join());this._geocode(t,function(t){if(t.length){var e=t[0];this._results=t;this._typeahead.selected=e;this._inputEl.value=e.place_name;this._change()}}.bind(this))}}},{key:"_setInput",value:function(t){if(t){"object"===(void 0===t?"undefined":r(t))&&t.length&&(t=[l.default.roundWithOriginalPrecision(l.default.wrap(t[0]),t[0]),l.default.roundWithOriginalPrecision(l.default.wrap(t[1]),t[1])].join());this._inputEl.value=t;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(t){this._query(t);return this}},{key:"setInput",value:function(t){this._setInput(t);return this}},{key:"on",value:function(t,e){this._ev.on(t,e);this._ev.on("error",(function(t){console.log(t)}));return this}},{key:"fire",value:function(t,e){this._ev.emit(t,e);return this}},{key:"off",value:function(t,e){this._ev.removeListener(t,e);return this}}]);return t}();n.default=u},{"../utils":47,events:3,"lodash.debounce":7,suggestions:30}],41:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n\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 t(e,n,r,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var o=n.getState(),a=o.originQuery,s=o.destinationQuery,l=o.profile,u=o.controls;e.innerHTML=c({originQuery:a,destinationQuery:s,profile:l,controls:u});this.container=e;this.actions=r;this.store=n;this._map=i;this.onAdd();this.render()}r(t,[{key:"animateToCoordinates",value:function(t,e){var n=this.store.getState(),r=n.origin,i=n.destination,o=n.routePadding;if(r.geometry&&i.geometry&&!(0,a.default)(r.geometry,i.geometry)){var l=(0,s.default)({type:"FeatureCollection",features:[r,i]});this._map.fitBounds([[l[0],l[1]],[l[2],l[3]]],{padding:o})}else this._map.flyTo({center:e})}},{key:"onAdd",value:function(){var t=this,e=this.actions,n=e.clearOrigin,r=e.clearDestination,o=e.createOrigin,a=e.createDestination,s=e.setProfile,l=e.reverse,c=this.store.getState(),u=c.geocoder,p=c.accessToken,h=c.flyTo,d=c.placeholderOrigin,f=c.placeholderDestination,m=c.zoom;this.originInput=new i.default(Object.assign({},{accessToken:p},u,{flyTo:h,placeholder:d,zoom:m}));var g=this.originInput.onAdd(this._map);this.container.querySelector("#mapbox-directions-origin-input").appendChild(g);this.destinationInput=new i.default(Object.assign({},{accessToken:p},u,{flyTo:h,placeholder:f,zoom:m}));var y=this.destinationInput.onAdd(this._map);this.container.querySelector("#mapbox-directions-destination-input").appendChild(y);this.originInput.on("result",(function(e){var n=e.result.center;o(n);t.animateToCoordinates("origin",n)}));this.originInput.on("clear",n);this.destinationInput.on("result",(function(e){var n=e.result.center;a(n);t.animateToCoordinates("destination",n)}));this.destinationInput.on("clear",r);var v=this.container.querySelectorAll('input[type="radio"]');Array.prototype.forEach.call(v,(function(t){t.addEventListener("change",(function(){s(t.value)}))}));this.container.querySelector(".js-reverse-inputs").addEventListener("click",(function(){var e=t.store.getState(),n=e.origin,r=e.destination;n&&t.actions.queryDestination(n.geometry.coordinates);r&&t.actions.queryOrigin(r.geometry.coordinates);l()}))}},{key:"render",value:function(){var t=this;this.store.subscribe((function(){var e=t.store.getState(),n=e.originQuery,r=e.destinationQuery,i=e.originQueryCoordinates,o=e.destinationQueryCoordinates;if(n){t.originInput.query(n);t.actions.queryOrigin(null)}if(r){t.destinationInput.query(r);t.actions.queryDestination(null)}if(i){t.originInput.setInput(i);t.animateToCoordinates("origin",i);t.actions.queryOriginCoordinates(null)}if(o){t.destinationInput.setInput(o);t.animateToCoordinates("destination",o);t.actions.queryDestinationCoordinates(null)}}))}}]);return t}();n.default=u},{"./geocoder":40,"lodash.isequal":8,"lodash.template":9,"turf-extent":35}],42:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n\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 t(e,n,r,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);this.container=e;this.actions=r;this.store=n;this._map=i;this.directions={};this.render()}r(t,[{key:"render",value:function(){var t=this;this.store.subscribe((function(){var e=t.actions,n=e.hoverMarker,r=e.setRouteIndex,o=t.store.getState(),s=o.routeIndex,u=o.unit,p=o.directions,h=o.error,d=o.compile,f=!(0,a.default)(p[s],t.directions);if(h)t.container.innerHTML=c({error:h});else if(p.length&&f){var m=t.directions=p[s];d&&m.legs.forEach((function(t){t.steps.forEach((function(t){t.maneuver.instruction=d("en",t)}))}));t.container.innerHTML=l({routeIndex:s,routes:p.length,steps:m.legs[0].steps,format:i.default.format[u],duration:i.default.format[u](m.distance),distance:i.default.format.duration(m.duration)});var g=t.container.querySelectorAll(".mapbox-directions-step");Array.prototype.forEach.call(g,(function(e){var r=e.getAttribute("data-lng"),i=e.getAttribute("data-lat");e.addEventListener("mouseover",(function(){n([r,i])}));e.addEventListener("mouseout",(function(){n(null)}));e.addEventListener("click",(function(){t._map.flyTo({center:[r,i],zoom:16})}))}));var y=t.container.querySelectorAll('input[type="radio"]');Array.prototype.forEach.call(y,(function(t){t.addEventListener("change",(function(t){r(parseInt(t.target.id,10))}))}))}else t.container.innerHTML&&f&&(t.container.innerHTML="")}))}}]);return t}();n.default=u},{"../utils":47,"lodash.isequal":8,"lodash.template":9}],43:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:s,e=arguments[1];switch(e.type){case i.SET_OPTIONS:return(0,a.default)({},t,e.options);case i.DIRECTIONS_PROFILE:return Object.assign({},t,{profile:e.profile});case i.ORIGIN:return Object.assign({},t,{origin:e.origin,hoverMarker:{}});case i.DESTINATION:return Object.assign({},t,{destination:e.destination,hoverMarker:{}});case i.HOVER_MARKER:return Object.assign({},t,{hoverMarker:e.hoverMarker});case i.WAYPOINTS:return Object.assign({},t,{waypoints:e.waypoints});case i.ORIGIN_QUERY:return Object.assign({},t,{originQuery:e.query});case i.DESTINATION_QUERY:return Object.assign({},t,{destinationQuery:e.query});case i.ORIGIN_FROM_COORDINATES:return Object.assign({},t,{originQueryCoordinates:e.coordinates});case i.DESTINATION_FROM_COORDINATES:return Object.assign({},t,{destinationQueryCoordinates:e.coordinates});case i.ORIGIN_CLEAR:return Object.assign({},t,{origin:{},originQuery:"",waypoints:[],directions:[]});case i.DESTINATION_CLEAR:return Object.assign({},t,{destination:{},destinationQuery:"",waypoints:[],directions:[]});case i.DIRECTIONS:return Object.assign({},t,{directions:e.directions});case i.ROUTE_INDEX:return Object.assign({},t,{routeIndex:e.routeIndex});case i.ERROR:return Object.assign({},t,{error:e.error});default:return t}}},{"../constants/action_types.js":39,"deep-assign":2}],47:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={duration:function(t){var e=Math.floor(t/60),n=Math.floor(e/60);t%=60;e%=60;return 0===n&&0===e?t+"s":0===n?e+"min":n+"h "+e+"min"},imperial:function(t){var e=t/1609.344;return e>=100?e.toFixed(0)+"mi":e>=10?e.toFixed(1)+"mi":e>=.1?e.toFixed(2)+"mi":(5280*e).toFixed(0)+"ft"},metric:function(t){return t>=1e5?(t/1e3).toFixed(0)+"km":t>=1e4?(t/1e3).toFixed(1)+"km":t>=100?(t/1e3).toFixed(2)+"km":t.toFixed(0)+"m"}};n.default={format:r,coordinateMatch:function(t,e){t=t.geometry.coordinates;e=e.geometry.coordinates;return t.join()===e.join()||t[0].toFixed(3)===e[0].toFixed(3)&&t[1].toFixed(3)===e[1].toFixed(3)},createPoint:function(t,e){return{type:"Feature",geometry:{type:"Point",coordinates:t},properties:e||{}}},validCoords:function(t){return t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90},wrap:function(t){var e=((t- -180)%360+360)%360-180;return-180===e?180:e},roundWithOriginalPrecision:function(t,e){var n=0;Math.floor(e)!==e&&(n=e.toString().split(".")[1].length);return t.toFixed(Math.min(n,5))}}},{}]},{},[45])(45)}));!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MapboxGeocoder=t()}}((function(){return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};e[a][0].call(u.exports,(function(t){return i(e[a][1][t]||t)}),u,u.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a0&&(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(t,e){this.eventQueue.push(t),(this.eventQueue.length>=this.maxQueueSize||e)&&this.flush()},remove:function(){this.flush()}},e.exports=r},{nanoid:30}],2:[function(t,e,n){e.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(t,e,n){"use strict";function r(t){this._eventEmitter=new s,this.options=a({},this.options,t),this.inputString="",this.fresh=!0,this.lastSelected=null}var i=t("suggestions"),o=t("lodash.debounce"),a=t("xtend"),s=t("events").EventEmitter,l=t("./exceptions"),c=t("@mapbox/mapbox-sdk"),u=t("@mapbox/mapbox-sdk/services/geocoding"),p=t("./events"),h=t("./localization"),d=t("subtag");const f=0,m=1,g=2;r.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(t){return t.place_name},render:function(t){var e=t.place_name.split(",");return'
'+e[0]+'
'+e.splice(1,e.length).join(",")+"
"}},addTo:function(t){function e(t,e){if(!document.body.contains(e))throw new Error("Element provided to #addTo() exists, but is not in the DOM");const n=t.onAdd();e.appendChild(n)}if(t._controlContainer)t.addControl(this);else if(t instanceof HTMLElement)e(this,t);else{if("string"!=typeof t)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 n=document.querySelectorAll(t);if(0===n.length)throw new Error("Element ",t,"not found.");if(n.length>1)throw new Error("Geocoder can only be added to a single html element");e(this,n[0])}},onAdd:function(t){if(t&&"string"!=typeof t&&(this._map=t),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 p(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 e=this.container=document.createElement("div");e.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var n=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(t){this.eventManager.keyevent(t,this)}.bind(this));var r=document.createElement("div");r.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 a=this.createIcon("close",'');return this._clearEl.appendChild(a),this._loadingEl=this.createIcon("loading",''),r.appendChild(this._clearEl),r.appendChild(this._loadingEl),e.appendChild(n),e.appendChild(this._inputEl),e.appendChild(r),this._typeahead=new i(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)),e},createIcon:function(t,e){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");if(n.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+t),n.setAttribute("viewBox","0 0 18 18"),n.setAttribute("xml:space","preserve"),n.setAttribute("width",18),n.setAttribute("height",18),"innerHTML"in n)n.innerHTML=e;else{var r=document.createElement("div");r.innerHTML=""+e.valueOf().toString()+"";var i=r.firstChild.firstChild;n.appendChild(i)}return n},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(t){var e=(t.clipboardData||window.clipboardData).getData("text");e.length>=this.options.minLength&&this._geocode(e)},_onKeyDown:function(t){if(27===t.keyCode&&this.options.clearAndBlurOnEsc)return this._clear(t),this._inputEl.blur();var e=t.target&&t.target.shadowRoot?t.target.shadowRoot.activeElement:t.target;if(!e||!e.value)return this.fresh=!0,9!==t.keyCode&&this.clear(t),this._clearEl.style.display="none";t.metaKey||-1!==[9,27,37,39,13,38,40].indexOf(t.keyCode)||e.value.length>=this.options.minLength&&this._geocode(e.value)},_showButton:function(){this._typeahead.selected&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onBlur:function(t){this.options.clearOnBlur&&this._clearOnBlur(t),this.options.collapsed&&this._collapse()},_onChange:function(){var t=this._typeahead.selected;if(t&&JSON.stringify(t)!==this.lastSelected){if(this._clearEl.style.display="none",this.options.flyTo){var e;if(t.properties&&l[t.properties.short_code])e=a({},this.options.flyTo),this._map&&this._map.fitBounds(l[t.properties.short_code].bbox,e);else if(t.bbox){var n=t.bbox;e=a({},this.options.flyTo),this._map&&this._map.fitBounds([[n[0],n[1]],[n[2],n[3]]],e)}else{var r={zoom:this.options.zoom};e=a({},r,this.options.flyTo),t.center?e.center=t.center:t.geometry&&t.geometry.type&&"Point"===t.geometry.type&&t.geometry.coordinates&&(e.center=t.geometry.coordinates),this._map&&this._map.flyTo(e)}}this.options.marker&&this._mapboxgl&&this._handleMarker(t),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(t),this._eventEmitter.emit("result",{result:t}),this.eventManager.select(t,this)}},_requestType:function(t,e){return t.localGeocoderOnly?m:t.reverseGeocode&&/^[ ]*(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)[ ]*$/.test(e)?g:f},_setupConfig:function(t,e){const n=/[\s,]+/;var r=this,i=["bbox","limit","proximity","countries","types","language","reverseMode","mode"].reduce((function(t,e){if(!r.options[e])return t;["countries","types","language"].indexOf(e)>-1?t[e]=r.options[e].split(n):t[e]=r.options[e];const i="number"==typeof r.options[e].longitude&&"number"==typeof r.options[e].latitude;if("proximity"===e&&i){const n=r.options[e].longitude,i=r.options[e].latitude;t[e]=[n,i]}return t}),{});switch(t){case g:var o=e.split(n).map((function(t){return parseFloat(t,10)})).reverse();i.types&&i.types[0],"proximity"in(i=a(i,{query:o,limit:1}))&&delete i.proximity;break;case f:/^[ ]*(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)*[ ]*$/.test(e)&&(e=e.replace(/,/g," ")),i=a(i,{query:e})}return i},_geocode:function(t){this.inputString=t,this._loadingEl.style.display="block",this._eventEmitter.emit("loading",{query:t});const e=this._requestType(this.options,t),n=this._setupConfig(e,t);var r;switch(e){case m:r=Promise.resolve();break;case f:r=this.geocoderService.forwardGeocode(n).send();break;case g:r=this.geocoderService.reverseGeocode(n).send()}var i=this.options.localGeocoder&&this.options.localGeocoder(t)||[],o=[],a=null;return r.catch(function(t){a=t}.bind(this)).then(function(e){this._loadingEl.style.display="none";var r={};return e?"200"==e.statusCode&&((r=e.body).request=e.request,r.headers=e.headers):r={type:"FeatureCollection",features:[]},r.config=n,this.fresh&&(this.eventManager.start(this),this.fresh=!1),r.features=r.features?i.concat(r.features):i,this.options.externalGeocoder?(o=this.options.externalGeocoder(t,r.features)||[]).then((function(t){return r.features=r.features?t.concat(r.features):t,r}),(function(){return r})):r}.bind(this)).then(function(t){if(a)throw a;this.options.filter&&t.features.length&&(t.features=t.features.filter(this.options.filter)),t.features.length?(this._clearEl.style.display="block",this._eventEmitter.emit("results",t),this._typeahead.update(t.features)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",t))}.bind(this)).catch(function(t){this._loadingEl.style.display="none",i.length&&this.options.localGeocoder||o.length&&this.options.externalGeocoder?(this._clearEl.style.display="block",this._typeahead.update(i)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:i}),this._eventEmitter.emit("error",{error:t})}.bind(this)),r},_clear:function(t){t&&t.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(t){this._clear(t),this._inputEl.focus()},_clearOnBlur:function(t){t.relatedTarget&&this._clear(t)},_onQueryResult:function(t){var e=t.body;if(e.features.length){var n=e.features[0];this._typeahead.selected=n,this._inputEl.value=n.place_name,this._onChange()}},_updateProximity:function(){if(this._map)if(this._map.getZoom()>9){var t=this._map.getCenter().wrap();this.setProximity({longitude:t.lng,latitude:t.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(t){return this._geocode(t).then(this._onQueryResult),this},_renderError:function(){this._renderMessage("
There was an error reaching the server
")},_renderNoResults:function(){this._renderMessage("
No results found
")},_renderMessage:function(t){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(t)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var t=this.options.language.split(",")[0],e=d.language(t),n=h.placeholder[e];if(n)return n}return"Search"},setInput:function(t){return this._inputEl.value=t,this._typeahead.selected=null,this._typeahead.clear(),t.length>=this.options.minLength&&this._geocode(t),this},setProximity:function(t){return this.options.proximity=t,this},getProximity:function(){return this.options.proximity},setRenderFunction:function(t){return t&&"function"==typeof t&&(this._typeahead.render=t),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(t){var e=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=t||this.options.language||e,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(t){return this.options.zoom=t,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(t){return this.options.flyTo=t,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(t){return this.placeholder=t||this._getPlaceholderText(),this._inputEl.placeholder=this.placeholder,this._inputEl.setAttribute("aria-label",this.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(t){return this.options.bbox=t,this},getCountries:function(){return this.options.countries},setCountries:function(t){return this.options.countries=t,this},getTypes:function(){return this.options.types},setTypes:function(t){return this.options.types=t,this},getMinLength:function(){return this.options.minLength},setMinLength:function(t){return this.options.minLength=t,this._typeahead&&(this._typeahead.options.minLength=t),this},getLimit:function(){return this.options.limit},setLimit:function(t){return this.options.limit=t,this._typeahead&&(this._typeahead.options.limit=t),this},getFilter:function(){return this.options.filter},setFilter:function(t){return this.options.filter=t,this},setOrigin:function(t){return this.options.origin=t,this.geocoderService=u(c({accessToken:this.options.accessToken,origin:this.options.origin})),this},getOrigin:function(){return this.options.origin},_handleMarker:function(t){if(this._map){this._removeMarker();var e=a({},{color:"#4668F2"},this.options.marker);return this.mapMarker=new this._mapboxgl.Marker(e),t.center?this.mapMarker.setLngLat(t.center).addTo(this._map):t.geometry&&t.geometry.type&&"Point"===t.geometry.type&&t.geometry.coordinates&&this.mapMarker.setLngLat(t.geometry.coordinates).addTo(this._map),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(t,e){return this._eventEmitter.on(t,e),this},off:function(t,e){return this._eventEmitter.removeListener(t,e),this.eventManager.remove(),this}},e.exports=r},{"./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(t,e,n){"use strict";e.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(t,e,n){"use strict";function r(t){var e=Array.isArray(t),n=function(n){return e?t[n]:t};return function(r){var o=i(p.plainArray,r);if(o)return o;if(e&&r.length!==t.length)return"an array with "+t.length+" items";for(var a=0;at.length?e:t}))}},p.equal=function(t){return function(e){if(e!==t)return JSON.stringify(t)}},p.oneOf=function(){var t=(Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments)).map((function(t){return p.equal(t)}));return p.oneOfType.apply(this,t)},p.range=function(t){var e=t[0],n=t[1];return function(t){if(i(p.number,t)||tn)return"number between "+e+" & "+n+" (inclusive)"}},p.any=function(){},p.boolean=function(t){if("boolean"!=typeof t)return"boolean"},p.number=function(t){if("number"!=typeof t)return"number"},p.plainArray=function(t){if(!Array.isArray(t))return"array"},p.plainObject=function(t){if(!l(t))return"object"},p.string=function(t){if("string"!=typeof t)return"string"},p.func=function(t){if("function"!=typeof t)return"function"},p.validate=i,p.processMessage=o,e.exports=p},{"is-plain-obj":28,xtend:36}],6:[function(t,e,n){"use strict";var r=t("./lib/client");e.exports=r},{"./lib/client":7}],7:[function(t,e,n){"use strict";function r(t){o.call(this,t)}var i=t("./browser-layer"),o=t("../classes/mapi-client");r.prototype=Object.create(o.prototype),r.prototype.constructor=r,r.prototype.sendRequest=i.browserSend,r.prototype.abortRequest=i.browserAbort,e.exports=function(t){return new r(t)}},{"../classes/mapi-client":9,"./browser-layer":8}],8:[function(t,e,n){"use strict";function r(t){var e=t.total,n=t.loaded;return{total:e,transferred:n,percent:100*n/e}}function i(t,e){return new Promise((function(n,i){e.onprogress=function(e){t.emitter.emit(l.EVENT_PROGRESS_DOWNLOAD,r(e))};var o=t.file;o&&(e.upload.onprogress=function(e){t.emitter.emit(l.EVENT_PROGRESS_UPLOAD,r(e))}),e.onerror=function(t){i(t)},e.onabort=function(){var e=new s({request:t,type:l.ERROR_REQUEST_ABORTED});i(e)},e.onload=function(){if(delete u[t.id],e.status<200||e.status>=400){var r=new s({request:t,body:e.response,statusCode:e.status});i(r)}else n(e)};var a=t.body;"string"==typeof a?e.send(a):a?e.send(JSON.stringify(a)):o?e.send(o):e.send(),u[t.id]=e})).then((function(e){return function(t,e){return new a(t,{body:e.response,headers:c(e.getAllResponseHeaders()),statusCode:e.status})}(t,e)}))}function o(t,e){var n=t.url(e),r=new window.XMLHttpRequest;return r.open(t.method,n),Object.keys(t.headers).forEach((function(e){r.setRequestHeader(e,t.headers[e])})),r}var a=t("../classes/mapi-response"),s=t("../classes/mapi-error"),l=t("../constants"),c=t("../helpers/parse-headers"),u={};e.exports={browserAbort:function(t){var e=u[t.id];e&&(e.abort(),delete u[t.id])},sendRequestXhr:i,browserSend:function(t){return Promise.resolve().then((function(){var e=o(t,t.client.accessToken);return i(t,e)}))},createRequestXhr:o}},{"../classes/mapi-error":10,"../classes/mapi-response":12,"../constants":13,"../helpers/parse-headers":14}],9:[function(t,e,n){"use strict";function r(t){if(!t||!t.accessToken)throw new Error("Cannot create a client without an access token");i(t.accessToken),this.accessToken=t.accessToken,this.origin=t.origin||a.API_ORIGIN}var i=t("@mapbox/parse-mapbox-token"),o=t("./mapi-request"),a=t("../constants");r.prototype.createRequest=function(t){return new o(this,t)},e.exports=r},{"../constants":13,"./mapi-request":11,"@mapbox/parse-mapbox-token":23}],10:[function(t,e,n){"use strict";var r=t("../constants");e.exports=function(t){var e,n=t.type||r.ERROR_HTTP;if(t.body)try{e=JSON.parse(t.body)}catch(n){e=t.body}else e=null;var i=t.message||null;i||("string"==typeof e?i=e:e&&"string"==typeof e.message?i=e.message:n===r.ERROR_REQUEST_ABORTED&&(i="Request aborted")),this.message=i,this.type=n,this.statusCode=t.statusCode||null,this.request=t.request,this.body=e}},{"../constants":13}],11:[function(t,e,n){"use strict";function r(t,e){if(!t)throw new Error("MapiRequest requires a client");if(!e||!e.path||!e.method)throw new Error("MapiRequest requires an options object with path and method properties");var n={};e.body&&(n["content-type"]="application/json");var r=o(n,e.headers),i=Object.keys(r).reduce((function(t,e){return t[e.toLowerCase()]=r[e],t}),{});this.id=c++,this._options=e,this.emitter=new a,this.client=t,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=e.path,this.method=e.method,this.origin=e.origin||t.origin,this.query=e.query||{},this.params=e.params||{},this.body=e.body||null,this.file=e.file||null,this.encoding=e.encoding||"utf8",this.sendFileAs=e.sendFileAs||null,this.headers=i}var i=t("@mapbox/parse-mapbox-token"),o=t("xtend"),a=t("eventemitter3"),s=t("../helpers/url-utils"),l=t("../constants"),c=1;r.prototype.url=function(t){var e=s.prependOrigin(this.path,this.origin);e=s.appendQueryObject(e,this.query);var n=this.params,r=null==t?this.client.accessToken:t;if(r){e=s.appendQueryParam(e,"access_token",r);var a=i(r).user;n=o({ownerId:a},n)}return e=s.interpolateRouteParams(e,n)},r.prototype.send=function(){var t=this;if(t.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return t.sent=!0,t.client.sendRequest(t).then((function(e){return t.response=e,t.emitter.emit(l.EVENT_RESPONSE,e),e}),(function(e){throw t.error=e,t.emitter.emit(l.EVENT_ERROR,e),e}))},r.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},r.prototype.eachPage=function(t){function e(e){t(null,e,(function(){delete i._nextPageRequest;var t=e.nextPage();t&&(i._nextPageRequest=t,r(t))}))}function n(e){t(e,null,(function(){}))}function r(t){t.send().then(e,n)}var i=this;r(this)},r.prototype.clone=function(){return this._extend()},r.prototype._extend=function(t){var e=o(this._options,t);return new r(this.client,e)},e.exports=r},{"../constants":13,"../helpers/url-utils":16,"@mapbox/parse-mapbox-token":23,eventemitter3:26,xtend:36}],12:[function(t,e,n){"use strict";function r(t,e){this.request=t,this.headers=e.headers,this.rawBody=e.body,this.statusCode=e.statusCode;try{this.body=JSON.parse(e.body||"{}")}catch(t){this.body=e.body}this.links=i(this.headers.link)}var i=t("../helpers/parse-link-header");r.prototype.hasNextPage=function(){return!!this.links.next},r.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null},e.exports=r},{"../helpers/parse-link-header":15}],13:[function(t,e,n){"use strict";e.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(t,e,n){"use strict";e.exports=function(t){var e={};return t?(t.trim().split(/[\r|\n]+/).forEach((function(t){var n=function(t){var e=t.indexOf(":");return{name:t.substring(0,e).trim().toLowerCase(),value:t.substring(e+1).trim()}}(t);e[n.name]=n.value})),e):e}},{}],15:[function(t,e,n){"use strict";e.exports=function(t){return t?t.split(/,\s*]*)>(.*)/);if(!e)return null;var n=e[1],r=e[2].split(";"),i=null,o=r.reduce((function(t,e){var n=function(t){var e=t.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return e?{key:e[1],value:e[2]}:null}(e);return n?"rel"===n.key?(i||(i=n.value),t):(t[n.key]=n.value,t):t}),{});return i?{url:n,rel:i,params:o}:null}(e);return n?(n.rel.split(/\s+/).forEach((function(e){t[e]||(t[e]={url:n.url,params:n.params})})),t):t}),{}):{}}},{}],16:[function(t,e,n){"use strict";function r(t){return Array.isArray(t)?function(t){return t.map(encodeURIComponent).join(",")}(t):encodeURIComponent(String(t))}function i(t,e,n){if(!1===n||null===n)return t;var i=/\?/.test(t)?"&":"?",o=encodeURIComponent(e);return void 0!==n&&""!==n&&!0!==n&&(o+="="+r(n)),""+t+i+o}e.exports={appendQueryObject:function(t,e){if(!e)return t;var n=t;return Object.keys(e).forEach((function(t){var r=e[t];void 0!==r&&(Array.isArray(r)&&(r=r.filter((function(t){return null!=t})).join(",")),n=i(n,t,r))})),n},appendQueryParam:i,prependOrigin:function(t,e){if(!e)return t;if("http"===t.slice(0,4))return t;var n="/"===t[0]?"":"/";return""+e.replace(/\/$/,"")+n+t},interpolateRouteParams:function(t,e){return e?t.replace(/\/:([a-zA-Z0-9]+)/g,(function(t,n){var i=e[n];if(void 0===i)throw new Error("Unspecified route parameter "+n);return"/"+r(i)})):t}}},{}],17:[function(t,e,n){"use strict";var r=t("xtend"),i=t("./service-helpers/validator"),o=t("./service-helpers/pick"),a=t("./service-helpers/stringify-booleans"),s=t("./service-helpers/create-service-factory"),l={},c=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];l.forwardGeocode=function(t){i.assertShape({query:i.required(i.string),mode:i.oneOf("mapbox.places","mapbox.places-permanent"),countries:i.arrayOf(i.string),proximity:i.coordinates,types:i.arrayOf(i.oneOf(c)),autocomplete:i.boolean,bbox:i.arrayOf(i.number),limit:i.number,language:i.arrayOf(i.string),routing:i.boolean})(t),t.mode=t.mode||"mapbox.places";var e=a(r({country:t.countries},o(t,["proximity","types","autocomplete","bbox","limit","language","routing"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(t,["mode","query"]),query:e})},l.reverseGeocode=function(t){i.assertShape({query:i.required(i.coordinates),mode:i.oneOf("mapbox.places","mapbox.places-permanent"),countries:i.arrayOf(i.string),types:i.arrayOf(i.oneOf(c)),bbox:i.arrayOf(i.number),limit:i.number,language:i.arrayOf(i.string),reverseMode:i.oneOf("distance","score"),routing:i.boolean})(t),t.mode=t.mode||"mapbox.places";var e=a(r({country:t.countries},o(t,["country","types","bbox","limit","language","reverseMode","routing"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(t,["mode","query"]),query:e})},e.exports=s(l)},{"./service-helpers/create-service-factory":18,"./service-helpers/pick":20,"./service-helpers/stringify-booleans":21,"./service-helpers/validator":22,xtend:36}],18:[function(t,e,n){"use strict";var r=t("../../lib/classes/mapi-client"),i=t("../../lib/client");e.exports=function(t){return function(e){var n;n=r.prototype.isPrototypeOf(e)?e:i(e);var o=Object.create(t);return o.client=n,o}}},{"../../lib/classes/mapi-client":9,"../../lib/client":7}],19:[function(t,e,n){"use strict";e.exports=function(t,e){return Object.keys(t).reduce((function(n,r){return n[r]=e(r,t[r]),n}),{})}},{}],20:[function(t,e,n){"use strict";e.exports=function(t,e){var n=function(t,n){return-1!==e.indexOf(t)&&void 0!==n};return"function"==typeof e&&(n=e),Object.keys(t).filter((function(e){return n(e,t[e])})).reduce((function(e,n){return e[n]=t[n],e}),{})}},{}],21:[function(t,e,n){"use strict";var r=t("./object-map");e.exports=function(t){return r(t,(function(t,e){return"boolean"==typeof e?JSON.stringify(e):e}))}},{"./object-map":19}],22:[function(t,e,n){(function(n){"use strict";var r=t("xtend"),i=t("@mapbox/fusspot");e.exports=r(i,{file:function(t){if("undefined"!=typeof window){if(t instanceof n.Blob||t instanceof n.ArrayBuffer)return;return"Blob or ArrayBuffer"}if("string"!=typeof t&&void 0===t.pipe)return"Filename or Readable stream"},date:function(t){if("boolean"==typeof t)return"date";try{var e=new Date(t);if(e.getTime&&isNaN(e.getTime()))return"date"}catch(t){return"date"}},coordinates:function(t){return i.tuple(i.number,i.number)(t)},assertShape:function(t,e){return i.assert(i.strictShape(t),e)}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"@mapbox/fusspot":5,xtend:36}],23:[function(t,e,n){"use strict";function r(t){try{return JSON.parse(o.decode(t))}catch(t){throw new Error("Invalid token")}}function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var o=t("base-64"),a={};e.exports=function(t){if(a[t])return a[t];var e=t.split("."),n=e[0],o=e[1];if(!o)throw new Error("Invalid token");var s=r(o),l={usage:n,user:s.u};return i(s,"a")&&(l.authorization=s.a),i(s,"exp")&&(l.expires=1e3*s.exp),i(s,"iat")&&(l.created=1e3*s.iat),i(s,"scopes")&&(l.scopes=s.scopes),i(s,"client")&&(l.client=s.client),i(s,"ll")&&(l.lastLogin=s.ll),i(s,"iu")&&(l.impersonator=s.iu),a[t]=l,l}},{"base-64":24}],24:[function(t,e,n){(function(t){!function(r){var i="object"==typeof n&&n,o="object"==typeof e&&e&&e.exports==i&&e,a="object"==typeof t&&t;a.global!==a&&a.window!==a||(r=a);var s=function(t){this.message=t};(s.prototype=new Error).name="InvalidCharacterError";var l=function(t){throw new s(t)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,p={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var e,n,r,i,o=t.length%3,a="",s=-1,u=t.length-o;++s>18&63)+c.charAt(i>>12&63)+c.charAt(i>>6&63)+c.charAt(63&i);return 2==o?(e=t.charCodeAt(s)<<8,n=t.charCodeAt(++s),a+=c.charAt((i=e+n)>>10)+c.charAt(i>>4&63)+c.charAt(i<<2&63)+"="):1==o&&(i=t.charCodeAt(s),a+=c.charAt(i>>2)+c.charAt(i<<4&63)+"=="),a},decode:function(t){var e=(t=String(t).replace(u,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),(e%4==1||/[^+a-zA-Z0-9/]/.test(t))&&l("Invalid character: the string to be decoded is not correctly encoded.");for(var n,r,i=0,o="",a=-1;++a>(-2*i&6)));return o},version:"0.1.0"};if(i&&!i.nodeType)if(o)o.exports=p;else for(var h in p)p.hasOwnProperty(h)&&(i[h]=p[h]);else r.base64=p}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],25:[function(t,e,n){function r(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=p(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function i(t){return void 0===t._maxListeners?r.defaultMaxListeners:t._maxListeners}function o(t,e,n,r){var o,a,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=t._events)?(a.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),a=t._events),s=a[e]):(a=t._events=p(null),t._eventsCount=0),s){if("function"==typeof s?s=a[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(o=i(t))&&o>0&&s.length>o){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=a[e]=n,++t._eventsCount;return t}function a(){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 t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(n=a[t]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=u(t,r),o=0;o=0;o--)if(n[o]===e||n[o].listener===e){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(var n=e,r=n+1,i=t.length;r=0;r--)this.removeListener(t,e[r]);return this},r.prototype.listeners=function(t){return l(this,t,!0)},r.prototype.rawListeners=function(t){return l(this,t,!1)},r.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):c.call(t,e)},r.prototype.listenerCount=c,r.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],26:[function(t,e,n){"use strict";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,r||t,o),s=c?c+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],a]:t._events[s].push(a):(t._events[s]=a,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function s(){this._events=new r,this._eventsCount=0}var l=Object.prototype.hasOwnProperty,c="~";Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(c=!1)),s.prototype.eventNames=function(){var t,e,n=[];if(0===this._eventsCount)return n;for(e in t=this._events)l.call(t,e)&&n.push(c?e.slice(1):e);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},s.prototype.listeners=function(t){var e=c?c+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,o=new Array(i);r=e||n<0||w&&t-x>=d}function l(){var t=v();if(s(t))return c(t);m=setTimeout(l,function(t){var n=e-(t-_);return w?y(n,d-(t-x)):n}(t))}function c(t){return m=void 0,M&&p?a(t):(p=h=void 0,f)}function u(){var t=v(),n=s(t);if(p=arguments,h=this,_=t,n){if(void 0===m)return function(t){return x=t,m=setTimeout(l,e),b?a(t):f}(_);if(w)return m=setTimeout(l,e),a(_)}return void 0===m&&(m=setTimeout(l,e)),f}var p,h,d,f,m,_,x=0,b=!1,w=!1,M=!0;if("function"!=typeof t)throw new TypeError(i);return e=r(e)||0,n(o)&&(b=!!o.leading,d=(w="maxWait"in o)?g(r(o.maxWait)||0,e):d,M="trailing"in o?!!o.trailing:M),u.cancel=function(){void 0!==m&&clearTimeout(m),x=0,p=_=h=m=void 0},u.flush=function(){return void 0===m?f:c(v())},u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],30:[function(t,e,n){(function(t){if("production"!==t.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 n=self.crypto||self.msCrypto;e.exports=function(t){t=t||21;for(var e="",r=n.getRandomValues(new Uint8Array(t));01)for(var n=1;n-1},a.prototype.value=function(t){if(this.selected=t,this.el.value=this.getItemValue(t),document.createEvent){var e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1),this.el.dispatchEvent(e)}else this.el.fireEvent("onchange")},a.prototype.getCandidates=function(t){var e,n={pre:"",post:"",extract:function(t){return this.getItemValue(t)}.bind(this)};this.options.filter?e=(e=i.filter(this.query,this.data,n)).map(function(t){return{original:t.original,string:this.render(t.original,t.string)}}.bind(this)):e=this.data.map(function(t){return{original:t,string:this.render(t)}}.bind(this)),t(e)},a.prototype.getItemValue=function(t){return t},a.prototype.render=function(t,e){if(e)return e;for(var n=t.original?this.getItemValue(t.original):this.getItemValue(t),r=this.normalize(n),i=r.lastIndexOf(this.query);i>-1;){var o=i+this.query.length;n=n.slice(0,i)+""+n.slice(i,o)+""+n.slice(o),i=r.slice(0,i).lastIndexOf(this.query)}return n},a.prototype.renderError=function(t){this.list.drawError(t)},e.exports=a},{"./list":34,fuzzy:27,xtend:36}],36:[function(t,e,n){e.exports=function(){for(var t={},e=0;e>8&255]+it[t>>16&255]+it[t>>24&255]+"-"+it[255&e]+it[e>>8&255]+"-"+it[e>>16&15|64]+it[e>>24&255]+"-"+it[63&n|128]+it[n>>8&255]+"-"+it[n>>16&255]+it[n>>24&255]+it[255&r]+it[r>>8&255]+it[r>>16&255]+it[r>>24&255]).toUpperCase()}function ct(t,e,n){return Math.max(e,Math.min(n,t))}function ut(t,e){return(t%e+e)%e}function pt(t,e,n){return(1-n)*t+n*e}function ht(t){return 0==(t&t-1)&&0!==t}function dt(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ft(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var mt=Object.freeze({__proto__:null,DEG2RAD:at,RAD2DEG:st,generateUUID:lt,clamp:ct,euclideanModulo:ut,mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:pt,damp:function(t,e,n,r){return pt(t,e,1-Math.exp(-n*r))},pingpong:function(t,e=1){return e-Math.abs(ut(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(ot=t%2147483647),((ot=16807*ot%2147483647)-1)/2147483646},degToRad:function(t){return t*at},radToDeg:function(t){return t*st},isPowerOfTwo:ht,ceilPowerOfTwo:dt,floorPowerOfTwo:ft,setQuaternionFromProperEuler:function(t,e,n,r,i){const o=Math.cos,a=Math.sin,s=o(n/2),l=a(n/2),c=o((e+r)/2),u=a((e+r)/2),p=o((e-r)/2),h=a((e-r)/2),d=o((r-e)/2),f=a((r-e)/2);switch(i){case"XYX":t.set(s*u,l*p,l*h,s*c);break;case"YZY":t.set(l*h,s*u,l*p,s*c);break;case"ZXZ":t.set(l*p,l*h,s*u,s*c);break;case"XZX":t.set(s*u,l*f,l*d,s*c);break;case"YXY":t.set(l*d,s*u,l*f,s*c);break;case"ZYZ":t.set(l*f,l*d,s*u,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}});class gt{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*n-o*r+t.x,this.y=i*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}gt.prototype.isVector2=!0;class yt{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(t,e,n,r,i,o,a,s,l){const c=this.elements;return c[0]=t,c[1]=r,c[2]=a,c[3]=e,c[4]=i,c[5]=s,c[6]=n,c[7]=o,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],a=n[3],s=n[6],l=n[1],c=n[4],u=n[7],p=n[2],h=n[5],d=n[8],f=r[0],m=r[3],g=r[6],y=r[1],v=r[4],_=r[7],x=r[2],b=r[5],w=r[8];return i[0]=o*f+a*y+s*x,i[3]=o*m+a*v+s*b,i[6]=o*g+a*_+s*w,i[1]=l*f+c*y+u*x,i[4]=l*m+c*v+u*b,i[7]=l*g+c*_+u*w,i[2]=p*f+h*y+d*x,i[5]=p*m+h*v+d*b,i[8]=p*g+h*_+d*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],c=t[8];return e*o*c-e*a*l-n*i*c+n*a*s+r*i*l-r*o*s}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],c=t[8],u=c*o-a*l,p=a*s-c*i,h=l*i-o*s,d=e*u+n*p+r*h;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const f=1/d;return t[0]=u*f,t[1]=(r*l-c*n)*f,t[2]=(a*n-r*o)*f,t[3]=p*f,t[4]=(c*e-r*s)*f,t[5]=(r*i-a*e)*f,t[6]=h*f,t[7]=(n*s-l*e)*f,t[8]=(o*e-n*i)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,i,o,a){const s=Math.cos(i),l=Math.sin(i);return this.set(n*s,n*l,-n*(s*o+l*a)+o+t,-r*l,r*s,-r*(-l*o+s*a)+a+e,0,0,1),this}scale(t,e){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this}rotate(t){const e=Math.cos(t),n=Math.sin(t),r=this.elements,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],c=r[7];return r[0]=e*i+n*s,r[3]=e*o+n*l,r[6]=e*a+n*c,r[1]=-n*i+e*s,r[4]=-n*o+e*l,r[7]=-n*a+e*c,this}translate(t,e){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}let vt;yt.prototype.isMatrix3=!0;class _t{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===vt&&(vt=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),vt.width=t.width,vt.height=t.height;const n=vt.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=vt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}}let xt=0;class bt extends rt{constructor(t=bt.DEFAULT_IMAGE,e=bt.DEFAULT_MAPPING,n=1001,r=1001,i=1006,o=1008,a=1023,s=1009,l=1,c=3e3){super(),Object.defineProperty(this,"id",{value:xt++}),this.uuid=lt(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=s,this.offset=new gt(0,0),this.repeat=new gt(1,1),this.center=new gt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yt,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(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.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 r=this.image;if(void 0===r.uuid&&(r.uuid=lt()),!e&&void 0===t.images[r.uuid]){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t1)switch(this.wrapS){case u:t.x=t.x-Math.floor(t.x);break;case p:t.x=t.x<0?0:1;break;case h:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case u:t.y=t.y-Math.floor(t.y);break;case p:t.y=t.y<0?0:1;break;case h:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function wt(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?_t.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}bt.DEFAULT_IMAGE=void 0,bt.DEFAULT_MAPPING=r,bt.prototype.isTexture=!0;class Mt{constructor(t=0,e=0,n=0,r=1){this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*i,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,i;const o=.01,a=t.elements,s=a[0],l=a[4],c=a[8],u=a[1],p=a[5],h=a[9],d=a[2],f=a[6],m=a[10];if(Math.abs(l-u)a&&t>g?tg?a=0?1:-1,r=1-e*e;if(r>Number.EPSILON){const i=Math.sqrt(r),o=Math.atan2(i,e*n);t=Math.sin(t*o)/i,a=Math.sin(a*o)/i}const i=a*n;if(s=s*t+p*i,l=l*t+h*i,c=c*t+d*i,u=u*t+f*i,t===1-a){const t=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=t,l*=t,c*=t,u*=t}}t[e]=s,t[e+1]=l,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,r,i,o){const a=n[r],s=n[r+1],l=n[r+2],c=n[r+3],u=i[o],p=i[o+1],h=i[o+2],d=i[o+3];return t[e]=a*d+c*u+s*h-l*p,t[e+1]=s*d+c*p+l*u-a*h,t[e+2]=l*d+c*h+a*p-s*u,t[e+3]=c*d-a*u-s*p-l*h,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=t._x,r=t._y,i=t._z,o=t._order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(r/2),u=a(i/2),p=s(n/2),h=s(r/2),d=s(i/2);switch(o){case"XYZ":this._x=p*c*u+l*h*d,this._y=l*h*u-p*c*d,this._z=l*c*d+p*h*u,this._w=l*c*u-p*h*d;break;case"YXZ":this._x=p*c*u+l*h*d,this._y=l*h*u-p*c*d,this._z=l*c*d-p*h*u,this._w=l*c*u+p*h*d;break;case"ZXY":this._x=p*c*u-l*h*d,this._y=l*h*u+p*c*d,this._z=l*c*d+p*h*u,this._w=l*c*u-p*h*d;break;case"ZYX":this._x=p*c*u-l*h*d,this._y=l*h*u+p*c*d,this._z=l*c*d-p*h*u,this._w=l*c*u+p*h*d;break;case"YZX":this._x=p*c*u+l*h*d,this._y=l*h*u+p*c*d,this._z=l*c*d-p*h*u,this._w=l*c*u-p*h*d;break;case"XZY":this._x=p*c*u-l*h*d,this._y=l*h*u-p*c*d,this._z=l*c*d+p*h*u,this._w=l*c*u+p*h*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],i=e[8],o=e[1],a=e[5],s=e[9],l=e[2],c=e[6],u=e[10],p=n+a+u;if(p>0){const t=.5/Math.sqrt(p+1);this._w=.25/t,this._x=(c-s)*t,this._y=(i-l)*t,this._z=(o-r)*t}else if(n>a&&n>u){const t=2*Math.sqrt(1+n-a-u);this._w=(c-s)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(i+l)/t}else if(a>u){const t=2*Math.sqrt(1+a-n-u);this._w=(i-l)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(s+c)/t}else{const t=2*Math.sqrt(1+u-n-a);this._w=(o-r)/t,this._x=(i+l)/t,this._y=(s+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ct(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,i=t._z,o=t._w,a=e._x,s=e._y,l=e._z,c=e._w;return this._x=n*c+o*a+r*l-i*s,this._y=r*c+o*s+i*a-n*l,this._z=i*c+o*l+n*s-r*a,this._w=o*c-n*a-r*s-i*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,r=this._y,i=this._z,o=this._w;let a=o*t._w+n*t._x+r*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;const s=1-a*a;if(s<=Number.EPSILON){const t=1-e;return this._w=t*o+e*this._w,this._x=t*n+e*this._x,this._y=t*r+e*this._y,this._z=t*i+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,a),u=Math.sin((1-e)*c)/l,p=Math.sin(e*c)/l;return this._w=o*u+this._w*p,this._x=n*u+this._x*p,this._y=r*u+this._y*p,this._z=i*u+this._z*p,this._onChangeCallback(),this}slerpQuaternions(t,e,n){this.copy(t).slerp(e,n)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}At.prototype.isQuaternion=!0;class Ct{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Pt.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Pt.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=t.elements,o=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,i=t.x,o=t.y,a=t.z,s=t.w,l=s*e+o*r-a*n,c=s*n+a*e-i*r,u=s*r+i*n-o*e,p=-i*e-o*n-a*r;return this.x=l*s+p*-i+c*-a-u*-o,this.y=c*s+p*-o+u*-i-l*-a,this.z=u*s+p*-a+l*-o-c*-i,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=r*s-i*a,this.y=i*o-n*s,this.z=n*a-r*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Lt.copy(this).projectOnVector(t),this.sub(Lt)}reflect(t){return this.sub(Lt.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ct(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}Ct.prototype.isVector3=!0;const Lt=new Ct,Pt=new At;class It{constructor(t=new Ct(1/0,1/0,1/0),e=new Ct(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=t.length;si&&(i=l),c>o&&(o=c),u>a&&(a=u)}return this.min.set(e,n,r),this.max.set(i,o,a),this}setFromBufferAttribute(t){let e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=t.count;si&&(i=l),c>o&&(o=c),u>a&&(a=u)}return this.min.set(e,n,r),this.max.set(i,o,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,kt),kt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(jt),Vt.subVectors(this.max,jt),Dt.subVectors(t.a,jt),Ot.subVectors(t.b,jt),Ft.subVectors(t.c,jt),Bt.subVectors(Ot,Dt),Nt.subVectors(Ft,Ot),Ut.subVectors(Dt,Ft);let e=[0,-Bt.z,Bt.y,0,-Nt.z,Nt.y,0,-Ut.z,Ut.y,Bt.z,0,-Bt.x,Nt.z,0,-Nt.x,Ut.z,0,-Ut.x,-Bt.y,Bt.x,0,-Nt.y,Nt.x,0,-Ut.y,Ut.x,0];return!!Wt(e,Dt,Ot,Ft,Vt)&&!!Wt(e=[1,0,0,0,1,0,0,0,1],Dt,Ot,Ft,Vt)&&(Gt.crossVectors(Bt,Nt),Wt(e=[Gt.x,Gt.y,Gt.z],Dt,Ot,Ft,Vt))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return kt.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(kt).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Rt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Rt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Rt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Rt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Rt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Rt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Rt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Rt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Rt)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}It.prototype.isBox3=!0;const Rt=[new Ct,new Ct,new Ct,new Ct,new Ct,new Ct,new Ct,new Ct],kt=new Ct,zt=new It,Dt=new Ct,Ot=new Ct,Ft=new Ct,Bt=new Ct,Nt=new Ct,Ut=new Ct,jt=new Ct,Vt=new Ct,Gt=new Ct,Ht=new Ct;function Wt(t,e,n,r,i){for(let o=0,a=t.length-3;o<=a;o+=3){Ht.fromArray(t,o);const a=i.x*Math.abs(Ht.x)+i.y*Math.abs(Ht.y)+i.z*Math.abs(Ht.z),s=e.dot(Ht),l=n.dot(Ht),c=r.dot(Ht);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>a)return!1}return!0}const qt=new It,Zt=new Ct,Xt=new Ct,$t=new Ct;class Jt{constructor(t=new Ct,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):qt.setFromPoints(t).getCenter(n);let r=0;for(let e=0,i=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){$t.subVectors(t,this.center);const e=$t.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.add($t.multiplyScalar(n/t)),this.radius+=n}return this}union(t){return Xt.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(Zt.copy(t.center).add(Xt)),this.expandByPoint(Zt.copy(t.center).sub(Xt)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Yt=new Ct,Qt=new Ct,Kt=new Ct,te=new Ct,ee=new Ct,ne=new Ct,re=new Ct;class ie{constructor(t=new Ct,e=new Ct(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Yt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Yt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Yt.copy(this.direction).multiplyScalar(e).add(this.origin),Yt.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){Qt.copy(t).add(e).multiplyScalar(.5),Kt.copy(e).sub(t).normalize(),te.copy(this.origin).sub(Qt);const i=.5*t.distanceTo(e),o=-this.direction.dot(Kt),a=te.dot(this.direction),s=-te.dot(Kt),l=te.lengthSq(),c=Math.abs(1-o*o);let u,p,h,d;if(c>0)if(p=o*a-s,d=i*c,(u=o*s-a)>=0)if(p>=-d)if(p<=d){const t=1/c;h=(u*=t)*(u+o*(p*=t)+2*a)+p*(o*u+p+2*s)+l}else p=i,h=-(u=Math.max(0,-(o*p+a)))*u+p*(p+2*s)+l;else p=-i,h=-(u=Math.max(0,-(o*p+a)))*u+p*(p+2*s)+l;else p<=-d?h=-(u=Math.max(0,-(-o*i+a)))*u+(p=u>0?-i:Math.min(Math.max(-i,-s),i))*(p+2*s)+l:p<=d?(u=0,h=(p=Math.min(Math.max(-i,-s),i))*(p+2*s)+l):h=-(u=Math.max(0,-(o*i+a)))*u+(p=u>0?i:Math.min(Math.max(-i,-s),i))*(p+2*s)+l;else p=o>0?-i:i,h=-(u=Math.max(0,-(o*p+a)))*u+p*(p+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(Kt).multiplyScalar(p).add(Qt),h}intersectSphere(t,e){Yt.subVectors(t.center,this.origin);const n=Yt.dot(this.direction),r=Yt.dot(Yt)-n*n,i=t.radius*t.radius;if(r>i)return null;const o=Math.sqrt(i-r),a=n-o,s=n+o;return a<0&&s<0?null:a<0?this.at(s,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,i,o,a,s;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,p=this.origin;return l>=0?(n=(t.min.x-p.x)*l,r=(t.max.x-p.x)*l):(n=(t.max.x-p.x)*l,r=(t.min.x-p.x)*l),c>=0?(i=(t.min.y-p.y)*c,o=(t.max.y-p.y)*c):(i=(t.max.y-p.y)*c,o=(t.min.y-p.y)*c),n>o||i>r?null:((i>n||n!=n)&&(n=i),(o=0?(a=(t.min.z-p.z)*u,s=(t.max.z-p.z)*u):(a=(t.max.z-p.z)*u,s=(t.min.z-p.z)*u),n>s||a>r?null:((a>n||n!=n)&&(n=a),(s=0?n:r,e)))}intersectsBox(t){return null!==this.intersectBox(t,Yt)}intersectTriangle(t,e,n,r,i){ee.subVectors(e,t),ne.subVectors(n,t),re.crossVectors(ee,ne);let o,a=this.direction.dot(re);if(a>0){if(r)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}te.subVectors(this.origin,t);const s=o*this.direction.dot(ne.crossVectors(te,ne));if(s<0)return null;const l=o*this.direction.dot(ee.cross(te));if(l<0)return null;if(s+l>a)return null;const c=-o*te.dot(re);return c<0?null:this.at(c/a,i)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class oe{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(t,e,n,r,i,o,a,s,l,c,u,p,h,d,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=p,g[3]=h,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 oe).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/ae.setFromMatrixColumn(t,0).length(),i=1/ae.setFromMatrixColumn(t,1).length(),o=1/ae.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,n=t.x,r=t.y,i=t.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){const t=o*c,n=o*u,r=a*c,i=a*u;e[0]=s*c,e[4]=-s*u,e[8]=l,e[1]=n+r*l,e[5]=t-i*l,e[9]=-a*s,e[2]=i-t*l,e[6]=r+n*l,e[10]=o*s}else if("YXZ"===t.order){const t=s*c,n=s*u,r=l*c,i=l*u;e[0]=t+i*a,e[4]=r*a-n,e[8]=o*l,e[1]=o*u,e[5]=o*c,e[9]=-a,e[2]=n*a-r,e[6]=i+t*a,e[10]=o*s}else if("ZXY"===t.order){const t=s*c,n=s*u,r=l*c,i=l*u;e[0]=t-i*a,e[4]=-o*u,e[8]=r+n*a,e[1]=n+r*a,e[5]=o*c,e[9]=i-t*a,e[2]=-o*l,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){const t=o*c,n=o*u,r=a*c,i=a*u;e[0]=s*c,e[4]=r*l-n,e[8]=t*l+i,e[1]=s*u,e[5]=i*l+t,e[9]=n*l-r,e[2]=-l,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){const t=o*s,n=o*l,r=a*s,i=a*l;e[0]=s*c,e[4]=i-t*u,e[8]=r*u+n,e[1]=u,e[5]=o*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*u+r,e[10]=t-i*u}else if("XZY"===t.order){const t=o*s,n=o*l,r=a*s,i=a*l;e[0]=s*c,e[4]=-u,e[8]=l*c,e[1]=t*u+i,e[5]=o*c,e[9]=n*u-r,e[2]=r*u-n,e[6]=a*c,e[10]=i*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(le,t,ce)}lookAt(t,e,n){const r=this.elements;return he.subVectors(t,e),0===he.lengthSq()&&(he.z=1),he.normalize(),ue.crossVectors(n,he),0===ue.lengthSq()&&(1===Math.abs(n.z)?he.x+=1e-4:he.z+=1e-4,he.normalize(),ue.crossVectors(n,he)),ue.normalize(),pe.crossVectors(he,ue),r[0]=ue.x,r[4]=pe.x,r[8]=he.x,r[1]=ue.y,r[5]=pe.y,r[9]=he.y,r[2]=ue.z,r[6]=pe.z,r[10]=he.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],a=n[4],s=n[8],l=n[12],c=n[1],u=n[5],p=n[9],h=n[13],d=n[2],f=n[6],m=n[10],g=n[14],y=n[3],v=n[7],_=n[11],x=n[15],b=r[0],w=r[4],M=r[8],S=r[12],T=r[1],E=r[5],A=r[9],C=r[13],L=r[2],P=r[6],I=r[10],R=r[14],k=r[3],z=r[7],D=r[11],O=r[15];return i[0]=o*b+a*T+s*L+l*k,i[4]=o*w+a*E+s*P+l*z,i[8]=o*M+a*A+s*I+l*D,i[12]=o*S+a*C+s*R+l*O,i[1]=c*b+u*T+p*L+h*k,i[5]=c*w+u*E+p*P+h*z,i[9]=c*M+u*A+p*I+h*D,i[13]=c*S+u*C+p*R+h*O,i[2]=d*b+f*T+m*L+g*k,i[6]=d*w+f*E+m*P+g*z,i[10]=d*M+f*A+m*I+g*D,i[14]=d*S+f*C+m*R+g*O,i[3]=y*b+v*T+_*L+x*k,i[7]=y*w+v*E+_*P+x*z,i[11]=y*M+v*A+_*I+x*D,i[15]=y*S+v*C+_*R+x*O,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[12],o=t[1],a=t[5],s=t[9],l=t[13],c=t[2],u=t[6],p=t[10],h=t[14];return t[3]*(+i*s*u-r*l*u-i*a*p+n*l*p+r*a*h-n*s*h)+t[7]*(+e*s*h-e*l*p+i*o*p-r*o*h+r*l*c-i*s*c)+t[11]*(+e*l*u-e*a*h-i*o*u+n*o*h+i*a*c-n*l*c)+t[15]*(-r*a*c-e*s*u+e*a*p+r*o*u-n*o*p+n*s*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],c=t[8],u=t[9],p=t[10],h=t[11],d=t[12],f=t[13],m=t[14],g=t[15],y=u*m*l-f*p*l+f*s*h-a*m*h-u*s*g+a*p*g,v=d*p*l-c*m*l-d*s*h+o*m*h+c*s*g-o*p*g,_=c*f*l-d*u*l+d*a*h-o*f*h-c*a*g+o*u*g,x=d*u*s-c*f*s-d*a*p+o*f*p+c*a*m-o*u*m,b=e*y+n*v+r*_+i*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 t[0]=y*w,t[1]=(f*p*i-u*m*i-f*r*h+n*m*h+u*r*g-n*p*g)*w,t[2]=(a*m*i-f*s*i+f*r*l-n*m*l-a*r*g+n*s*g)*w,t[3]=(u*s*i-a*p*i-u*r*l+n*p*l+a*r*h-n*s*h)*w,t[4]=v*w,t[5]=(c*m*i-d*p*i+d*r*h-e*m*h-c*r*g+e*p*g)*w,t[6]=(d*s*i-o*m*i-d*r*l+e*m*l+o*r*g-e*s*g)*w,t[7]=(o*p*i-c*s*i+c*r*l-e*p*l-o*r*h+e*s*h)*w,t[8]=_*w,t[9]=(d*u*i-c*f*i-d*n*h+e*f*h+c*n*g-e*u*g)*w,t[10]=(o*f*i-d*a*i+d*n*l-e*f*l-o*n*g+e*a*g)*w,t[11]=(c*a*i-o*u*i-c*n*l+e*u*l+o*n*h-e*a*h)*w,t[12]=x*w,t[13]=(c*f*r-d*u*r+d*n*p-e*f*p-c*n*m+e*u*m)*w,t[14]=(d*a*r-o*f*r-d*n*s+e*f*s+o*n*m-e*a*m)*w,t[15]=(o*u*r-c*a*r+c*n*s-e*u*s-o*n*p+e*a*p)*w,this}scale(t){const e=this.elements,n=t.x,r=t.y,i=t.z;return e[0]*=n,e[4]*=r,e[8]*=i,e[1]*=n,e[5]*=r,e[9]*=i,e[2]*=n,e[6]*=r,e[10]*=i,e[3]*=n,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),i=1-n,o=t.x,a=t.y,s=t.z,l=i*o,c=i*a;return this.set(l*o+n,l*a-r*s,l*s+r*a,0,l*a+r*s,c*a+n,c*s-r*o,0,l*s-r*a,c*s+r*o,i*s*s+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,i,o){return this.set(1,n,i,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,i=e._x,o=e._y,a=e._z,s=e._w,l=i+i,c=o+o,u=a+a,p=i*l,h=i*c,d=i*u,f=o*c,m=o*u,g=a*u,y=s*l,v=s*c,_=s*u,x=n.x,b=n.y,w=n.z;return r[0]=(1-(f+g))*x,r[1]=(h+_)*x,r[2]=(d-v)*x,r[3]=0,r[4]=(h-_)*b,r[5]=(1-(p+g))*b,r[6]=(m+y)*b,r[7]=0,r[8]=(d+v)*w,r[9]=(m-y)*w,r[10]=(1-(p+f))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let i=ae.set(r[0],r[1],r[2]).length();const o=ae.set(r[4],r[5],r[6]).length(),a=ae.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),t.x=r[12],t.y=r[13],t.z=r[14],se.copy(this);const s=1/i,l=1/o,c=1/a;return se.elements[0]*=s,se.elements[1]*=s,se.elements[2]*=s,se.elements[4]*=l,se.elements[5]*=l,se.elements[6]*=l,se.elements[8]*=c,se.elements[9]*=c,se.elements[10]*=c,e.setFromRotationMatrix(se),n.x=i,n.y=o,n.z=a,this}makePerspective(t,e,n,r,i,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,s=2*i/(e-t),l=2*i/(n-r),c=(e+t)/(e-t),u=(n+r)/(n-r),p=-(o+i)/(o-i),h=-2*o*i/(o-i);return a[0]=s,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=p,a[14]=h,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,n,r,i,o){const a=this.elements,s=1/(e-t),l=1/(n-r),c=1/(o-i),u=(e+t)*s,p=(n+r)*l,h=(o+i)*c;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-p,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-h,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}oe.prototype.isMatrix4=!0;const ae=new Ct,se=new oe,le=new Ct(0,0,0),ce=new Ct(1,1,1),ue=new Ct,pe=new Ct,he=new Ct,de=new oe,fe=new At;class me{constructor(t=0,e=0,n=0,r=me.DefaultOrder){this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,i=r[0],o=r[4],a=r[8],s=r[1],l=r[5],c=r[9],u=r[2],p=r[6],h=r[10];switch(e){case"XYZ":this._y=Math.asin(ct(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,h),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(p,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ct(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,h),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(ct(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-ct(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(p,h),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(ct(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(a,h));break;case"XZY":this._z=Math.asin(-ct(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-c,h),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return de.makeRotationFromQuaternion(t),this.setFromRotationMatrix(de,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return fe.setFromEuler(this),this.setFromQuaternion(fe,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new Ct(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}me.prototype.isEuler=!0,me.DefaultOrder="XYZ",me.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ge{constructor(){this.mask=1}set(t){this.mask=1<1){for(let t=0;t1){for(let t=0;t0){r.children=[];for(let e=0;e0){r.animations=[];for(let e=0;e0&&(n.geometries=e),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c)}return n.object=r,n;function o(t){const e=[];for(const n in t){const r=t[n];delete r.metadata,e.push(r)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(t,e,n,r,i){Ie.subVectors(r,e),Re.subVectors(n,e),ke.subVectors(t,e);const o=Ie.dot(Ie),a=Ie.dot(Re),s=Ie.dot(ke),l=Re.dot(Re),c=Re.dot(ke),u=o*l-a*a;if(0===u)return i.set(-2,-1,-1);const p=1/u,h=(l*s-a*c)*p,d=(o*c-a*s)*p;return i.set(1-h-d,d,h)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,ze),ze.x>=0&&ze.y>=0&&ze.x+ze.y<=1}static getUV(t,e,n,r,i,o,a,s){return this.getBarycoord(t,e,n,r,ze),s.set(0,0),s.addScaledVector(i,ze.x),s.addScaledVector(o,ze.y),s.addScaledVector(a,ze.z),s}static isFrontFacing(t,e,n,r){return Ie.subVectors(n,e),Re.subVectors(t,e),Ie.cross(Re).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ie.subVectors(this.c,this.b),Re.subVectors(this.a,this.b),.5*Ie.cross(Re).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return je.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return je.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,r,i){return je.getUV(t,this.a,this.b,this.c,e,n,r,i)}containsPoint(t){return je.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return je.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,i=this.c;let o,a;De.subVectors(r,n),Oe.subVectors(i,n),Be.subVectors(t,n);const s=De.dot(Be),l=Oe.dot(Be);if(s<=0&&l<=0)return e.copy(n);Ne.subVectors(t,r);const c=De.dot(Ne),u=Oe.dot(Ne);if(c>=0&&u<=c)return e.copy(r);const p=s*u-c*l;if(p<=0&&s>=0&&c<=0)return o=s/(s-c),e.copy(n).addScaledVector(De,o);Ue.subVectors(t,i);const h=De.dot(Ue),d=Oe.dot(Ue);if(d>=0&&h<=d)return e.copy(i);const f=h*l-s*d;if(f<=0&&l>=0&&d<=0)return a=l/(l-d),e.copy(n).addScaledVector(Oe,a);const m=c*d-h*u;if(m<=0&&u-c>=0&&h-d>=0)return Fe.subVectors(i,r),a=(u-c)/(u-c+(h-d)),e.copy(r).addScaledVector(Fe,a);const g=1/(m+f+p);return o=f*g,a=p*g,e.copy(n).addScaledVector(De,o).addScaledVector(Oe,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Ve=0;class Ge extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:Ve++}),this.uuid=lt(),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=n,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(t){const e=[];for(const n in t){const r=t[n];delete r.metadata,e.push(r)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheenTint&&this.sheenTint.isColor&&(n.sheenTint=this.sheenTint.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularTint&&this.specularTint.isColor&&(n.specularTint=this.specularTint.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularTintMap&&this.specularTintMap.isTexture&&(n.specularTintMap=this.specularTintMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationTint&&(n.attenuationTint=this.attenuationTint.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.format!==E&&(n.format=this.format),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){const e=r(t.textures),i=r(t.images);e.length>0&&(n.textures=e),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.format=t.format,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let r=0;r!==t;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}Ge.prototype.isMaterial=!0;const He={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},We={h:0,s:0,l:0},qe={h:0,s:0,l:0};function Ze(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function Xe(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function $e(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Je{constructor(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,n){return this.r=t,this.g=e,this.b=n,this}setHSL(t,e,n){if(t=ut(t,1),e=ct(e,0,1),n=ct(n,0,1),0===e)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Ze(i,r,t+1/3),this.g=Ze(i,r,t),this.b=Ze(i,r,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const r=n[1],i=n[2];switch(r){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const n=parseFloat(t[1])/360,r=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(n,r,i)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=He[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Xe(t.r),this.g=Xe(t.g),this.b=Xe(t.b),this}copyLinearToSRGB(t){return this.r=$e(t.r),this.g=$e(t.g),this.b=$e(t.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(t){const e=this.r,n=this.g,r=this.b,i=Math.max(e,n,r),o=Math.min(e,n,r);let a,s;const l=(o+i)/2;if(o===i)a=0,s=0;else{const t=i-o;switch(s=l<=.5?t/(i+o):t/(2-i-o),i){case e:a=(n-r)/t+(ne&&(e=t[n]);return e}const dn={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function fn(t,e){return new dn[t](e)}let mn=0;const gn=new oe,yn=new Pe,vn=new Ct,_n=new It,xn=new It,bn=new Ct;class wn extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:mn++}),this.uuid=lt(),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(t){return Array.isArray(t)?this.index=new(hn(t)>65535?ln:an)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new yt).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(t),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return gn.makeRotationFromQuaternion(t),this.applyMatrix4(gn),this}rotateX(t){return gn.makeRotationX(t),this.applyMatrix4(gn),this}rotateY(t){return gn.makeRotationY(t),this.applyMatrix4(gn),this}rotateZ(t){return gn.makeRotationZ(t),this.applyMatrix4(gn),this}translate(t,e,n){return gn.makeTranslation(t,e,n),this.applyMatrix4(gn),this}scale(t,e,n){return gn.makeScale(t,e,n),this.applyMatrix4(gn),this}lookAt(t){return yn.lookAt(t),yn.updateMatrix(),this.applyMatrix4(yn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vn).negate(),this.translate(vn.x,vn.y,vn.z),this}setFromPoints(t){const e=[];for(let n=0,r=t.length;n0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const r=n[e];t.data.attributes[e]=r.toJSON(t.data)}const r={};let i=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],o=[];for(let e=0,r=n.length;e0&&(r[e]=o,i=!0)}i&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new wn).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const r=t.attributes;for(const t in r){const n=r[t];this.setAttribute(t,n.clone(e))}const i=t.morphAttributes;for(const t in i){const n=[],r=i[t];for(let t=0,i=r.length;t0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(t,e){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),Tn.copy(n.boundingSphere),Tn.applyMatrix4(i),!1===t.ray.intersectsSphere(Tn))return;if(Mn.copy(i).invert(),Sn.copy(t.ray).applyMatrix4(Mn),null!==n.boundingBox&&!1===Sn.intersectsBox(n.boundingBox))return;let o;if(n.isBufferGeometry){const i=n.index,a=n.attributes.position,s=n.morphAttributes.position,l=n.morphTargetsRelative,c=n.attributes.uv,u=n.attributes.uv2,p=n.groups,h=n.drawRange;if(null!==i)if(Array.isArray(r))for(let n=0,d=p.length;nn.far?null:{distance:c,point:Nn.clone(),object:t}}(t,e,n,r,En,An,Cn,Bn);if(d){s&&(Dn.fromBufferAttribute(s,c),On.fromBufferAttribute(s,u),Fn.fromBufferAttribute(s,p),d.uv=je.getUV(Bn,En,An,Cn,Dn,On,Fn,new gt)),l&&(Dn.fromBufferAttribute(l,c),On.fromBufferAttribute(l,u),Fn.fromBufferAttribute(l,p),d.uv2=je.getUV(Bn,En,An,Cn,Dn,On,Fn,new gt));const t={a:c,b:u,c:p,normal:new Ct,materialIndex:0};je.getNormal(En,An,Cn,t.normal),d.face=t}return d}Un.prototype.isMesh=!0;class Vn extends wn{constructor(t=1,e=1,n=1,r=1,i=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:i,depthSegments:o};const a=this;r=Math.floor(r),i=Math.floor(i),o=Math.floor(o);const s=[],l=[],c=[],u=[];let p=0,h=0;function d(t,e,n,r,i,o,d,f,m,g,y){const v=o/m,_=d/g,x=o/2,b=d/2,w=f/2,M=m+1,S=g+1;let T=0,E=0;const A=new Ct;for(let o=0;o0?1:-1,c.push(A.x,A.y,A.z),u.push(s/m),u.push(1-o/g),T+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}qn.prototype.isShaderMaterial=!0;class Zn extends Pe{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new oe,this.projectionMatrix=new oe,this.projectionMatrixInverse=new oe}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}Zn.prototype.isCamera=!0;class Xn extends Zn{constructor(t=50,e=1,n=.1,r=2e3){super(),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*st*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*at*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*st*Math.atan(Math.tan(.5*at*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,r,i,o){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*at*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r;const o=this.view;if(null!==this.view&&this.view.enabled){const t=o.fullWidth,a=o.fullHeight;i+=o.offsetX*r/t,e-=o.offsetY*n/a,r*=o.width/t,n*=o.height/a}const a=this.filmOffset;0!==a&&(i+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}Xn.prototype.isPerspectiveCamera=!0;class $n extends Pe{constructor(t,e,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const r=new Xn(90,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Ct(1,0,0)),this.add(r);const i=new Xn(90,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Ct(-1,0,0)),this.add(i);const o=new Xn(90,1,t,e);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new Ct(0,1,0)),this.add(o);const a=new Xn(90,1,t,e);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new Ct(0,-1,0)),this.add(a);const s=new Xn(90,1,t,e);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new Ct(0,0,1)),this.add(s);const l=new Xn(90,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Ct(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,o,a,s,l]=this.children,c=t.xr.enabled,u=t.getRenderTarget();t.xr.enabled=!1;const p=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,r),t.setRenderTarget(n,1),t.render(e,i),t.setRenderTarget(n,2),t.render(e,o),t.setRenderTarget(n,3),t.render(e,a),t.setRenderTarget(n,4),t.render(e,s),n.texture.generateMipmaps=p,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(u),t.xr.enabled=c}}class Jn extends bt{constructor(t,e,n,r,o,a,s,l,c,u){super(t=void 0!==t?t:[],e=void 0!==e?e:i,n,r,o,a,s=void 0!==s?s:T,l,c,u),this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}Jn.prototype.isCubeTexture=!0;class Yn extends St{constructor(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),super(t,t,e),e=e||{},this.texture=new Jn(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:g,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=E,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n=new Vn(5,5,5),r=new qn({name:"CubemapFromEquirect",uniforms:Gn({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});r.uniforms.tEquirect.value=e;const i=new Un(n,r),o=e.minFilter;return e.minFilter===v&&(e.minFilter=g),new $n(1,10,this).update(t,i),e.minFilter=o,i.geometry.dispose(),i.material.dispose(),this}clear(t,e,n,r){const i=t.getRenderTarget();for(let i=0;i<6;i++)t.setRenderTarget(this,i),t.clear(e,n,r);t.setRenderTarget(i)}}Yn.prototype.isWebGLCubeRenderTarget=!0;const Qn=new Ct,Kn=new Ct,tr=new yt;class er{constructor(t=new Ct(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=Qn.subVectors(n,e).cross(Kn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){const n=t.delta(Qn),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:e.copy(n).multiplyScalar(i).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||tr.getNormalMatrix(t),r=this.coplanarPoint(Qn).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}er.prototype.isPlane=!0;const nr=new Jt,rr=new Ct;class ir{constructor(t=new er,e=new er,n=new er,r=new er,i=new er,o=new er){this.planes=[t,e,n,r,i,o]}set(t,e,n,r,i,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){const e=this.planes,n=t.elements,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],c=n[6],u=n[7],p=n[8],h=n[9],d=n[10],f=n[11],m=n[12],g=n[13],y=n[14],v=n[15];return e[0].setComponents(a-r,u-s,f-p,v-m).normalize(),e[1].setComponents(a+r,u+s,f+p,v+m).normalize(),e[2].setComponents(a+i,u+l,f+h,v+g).normalize(),e[3].setComponents(a-i,u-l,f-h,v-g).normalize(),e[4].setComponents(a-o,u-c,f-d,v-y).normalize(),e[5].setComponents(a+o,u+c,f+d,v+y).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),nr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(nr)}intersectsSprite(t){return nr.center.set(0,0,0),nr.radius=.7071067811865476,nr.applyMatrix4(t.matrixWorld),this.intersectsSphere(nr)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)0?t.max.x:t.min.x,rr.y=r.normal.y>0?t.max.y:t.min.y,rr.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(rr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function or(){let t=null,e=!1,n=null,r=null;function i(e,o){n(e,o),r=t.requestAnimationFrame(i)}return{start:function(){!0!==e&&null!==n&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function ar(t,e){const n=e.isWebGL2,r=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),r.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const n=r.get(e);n&&(t.deleteBuffer(n.buffer),r.delete(e))},update:function(e,i){if(e.isGLBufferAttribute){const t=r.get(e);return void((!t||t.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}"},cr={common:{diffuse:{value:new Je(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new yt},uv2Transform:{value:new yt},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 gt(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 Je(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 Je(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new yt}},sprite:{diffuse:{value:new Je(16777215)},opacity:{value:1},center:{value:new gt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new yt}}},ur={basic:{uniforms:Hn([cr.common,cr.specularmap,cr.envmap,cr.aomap,cr.lightmap,cr.fog]),vertexShader:lr.meshbasic_vert,fragmentShader:lr.meshbasic_frag},lambert:{uniforms:Hn([cr.common,cr.specularmap,cr.envmap,cr.aomap,cr.lightmap,cr.emissivemap,cr.fog,cr.lights,{emissive:{value:new Je(0)}}]),vertexShader:lr.meshlambert_vert,fragmentShader:lr.meshlambert_frag},phong:{uniforms:Hn([cr.common,cr.specularmap,cr.envmap,cr.aomap,cr.lightmap,cr.emissivemap,cr.bumpmap,cr.normalmap,cr.displacementmap,cr.fog,cr.lights,{emissive:{value:new Je(0)},specular:{value:new Je(1118481)},shininess:{value:30}}]),vertexShader:lr.meshphong_vert,fragmentShader:lr.meshphong_frag},standard:{uniforms:Hn([cr.common,cr.envmap,cr.aomap,cr.lightmap,cr.emissivemap,cr.bumpmap,cr.normalmap,cr.displacementmap,cr.roughnessmap,cr.metalnessmap,cr.fog,cr.lights,{emissive:{value:new Je(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:lr.meshphysical_vert,fragmentShader:lr.meshphysical_frag},toon:{uniforms:Hn([cr.common,cr.aomap,cr.lightmap,cr.emissivemap,cr.bumpmap,cr.normalmap,cr.displacementmap,cr.gradientmap,cr.fog,cr.lights,{emissive:{value:new Je(0)}}]),vertexShader:lr.meshtoon_vert,fragmentShader:lr.meshtoon_frag},matcap:{uniforms:Hn([cr.common,cr.bumpmap,cr.normalmap,cr.displacementmap,cr.fog,{matcap:{value:null}}]),vertexShader:lr.meshmatcap_vert,fragmentShader:lr.meshmatcap_frag},points:{uniforms:Hn([cr.points,cr.fog]),vertexShader:lr.points_vert,fragmentShader:lr.points_frag},dashed:{uniforms:Hn([cr.common,cr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:lr.linedashed_vert,fragmentShader:lr.linedashed_frag},depth:{uniforms:Hn([cr.common,cr.displacementmap]),vertexShader:lr.depth_vert,fragmentShader:lr.depth_frag},normal:{uniforms:Hn([cr.common,cr.bumpmap,cr.normalmap,cr.displacementmap,{opacity:{value:1}}]),vertexShader:lr.meshnormal_vert,fragmentShader:lr.meshnormal_frag},sprite:{uniforms:Hn([cr.sprite,cr.fog]),vertexShader:lr.sprite_vert,fragmentShader:lr.sprite_frag},background:{uniforms:{uvTransform:{value:new yt},t2D:{value:null}},vertexShader:lr.background_vert,fragmentShader:lr.background_frag},cube:{uniforms:Hn([cr.envmap,{opacity:{value:1}}]),vertexShader:lr.cube_vert,fragmentShader:lr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:lr.equirect_vert,fragmentShader:lr.equirect_frag},distanceRGBA:{uniforms:Hn([cr.common,cr.displacementmap,{referencePosition:{value:new Ct},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:lr.distanceRGBA_vert,fragmentShader:lr.distanceRGBA_frag},shadow:{uniforms:Hn([cr.lights,cr.fog,{color:{value:new Je(0)},opacity:{value:1}}]),vertexShader:lr.shadow_vert,fragmentShader:lr.shadow_frag}};function pr(t,e,n,r,i){const o=new Je(0);let a,s,c=0,u=null,p=0,h=null;function d(t,e){n.buffers.color.setClear(t.r,t.g,t.b,e,i)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),d(o,c=e)},getClearAlpha:function(){return c},setClearAlpha:function(t){d(o,c=t)},render:function(n,i){let f=!1,m=!0===i.isScene?i.background:null;m&&m.isTexture&&(m=e.get(m));const g=t.xr,y=g.getSession&&g.getSession();y&&"additive"===y.environmentBlendMode&&(m=null),null===m?d(o,c):m&&m.isColor&&(d(m,1),f=!0),(t.autoClear||f)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),m&&(m.isCubeTexture||m.mapping===l)?(void 0===s&&((s=new Un(new Vn(1,1,1),new qn({name:"BackgroundCubeMaterial",uniforms:Gn(ur.cube.uniforms),vertexShader:ur.cube.vertexShader,fragmentShader:ur.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(s)),s.material.uniforms.envMap.value=m,s.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,u===m&&p===m.version&&h===t.toneMapping||(s.material.needsUpdate=!0,u=m,p=m.version,h=t.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null)):m&&m.isTexture&&(void 0===a&&((a=new Un(new sr(2,2),new qn({name:"BackgroundMaterial",uniforms:Gn(ur.background.uniforms),vertexShader:ur.background.vertexShader,fragmentShader:ur.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(a)),a.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),a.material.uniforms.uvTransform.value.copy(m.matrix),u===m&&p===m.version&&h===t.toneMapping||(a.material.needsUpdate=!0,u=m,p=m.version,h=t.toneMapping),n.unshift(a,a.geometry,a.material,0,0,null))}}}function hr(t,e,n,r){const i=t.getParameter(34921),o=r.isWebGL2?null:e.get("OES_vertex_array_object"),a=r.isWebGL2||null!==o,s={},l=h(null);let c=l;function u(e){return r.isWebGL2?t.bindVertexArray(e):o.bindVertexArrayOES(e)}function p(e){return r.isWebGL2?t.deleteVertexArray(e):o.deleteVertexArrayOES(e)}function h(t){const e=[],n=[],r=[];for(let t=0;t=0){let o=l[e];if(void 0===o&&("instanceMatrix"===e&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===e&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const e=o.normalized,a=o.itemSize,l=n.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,p=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const n=o.data,l=n.stride,h=o.offset;if(n&&n.isInstancedInterleavedBuffer){for(let t=0;t0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=i(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=o||e.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,u=t.getParameter(34930),p=t.getParameter(35660),h=t.getParameter(3379),d=t.getParameter(34076),f=t.getParameter(34921),m=t.getParameter(36347),g=t.getParameter(36348),y=t.getParameter(36349),v=p>0,_=o||e.has("OES_texture_float");return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:p,maxTextureSize:h,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:y,vertexTextures:v,floatFragmentTextures:_,floatVertexTextures:v&&_,maxSamples:o?t.getParameter(36183):0}}function mr(t){const e=this;let n=null,r=0,i=!1,o=!1;const a=new er,s=new yt,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(t,n,r,i){const o=null!==t?t.length:0;let c=null;if(0!==o){if(c=l.value,!0!==i||null===c){const e=r+4*o,i=n.matrixWorldInverse;s.getNormalMatrix(i),(null===c||c.length0){const a=t.getRenderTarget(),s=new Yn(o.height/2);return s.fromEquirectangularTexture(t,i),e.set(i,s),t.setRenderTarget(a),i.addEventListener("dispose",r),n(s.texture,i.mapping)}return null}}}return i},dispose:function(){e=new WeakMap}}}ur.physical={uniforms:Hn([ur.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new gt(1,1)},clearcoatNormalMap:{value:null},sheenTint:{value:new Je(0)},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new gt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationTint:{value:new Je(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularTint:{value:new Je(1,1,1)},specularTintMap:{value:null}}]),vertexShader:lr.meshphysical_vert,fragmentShader:lr.meshphysical_frag};class yr extends Zn{constructor(t=-1,e=1,n=1,r=-1,i=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=i,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,r,i,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-t,o=n+t,a=r+e,s=r-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o=(i+=t*this.view.offsetX)+t*this.view.width,s=(a-=e*this.view.offsetY)-e*this.view.height}this.projectionMatrix.makeOrthographic(i,o,a,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}yr.prototype.isOrthographicCamera=!0;class vr extends qn{constructor(t){super(t),this.type="RawShaderMaterial"}}vr.prototype.isRawShaderMaterial=!0;const _r=Math.pow(2,8),xr=[.125,.215,.35,.446,.526,.582],br=5+xr.length,wr={[Z]:0,[X]:1,[J]:2,[Y]:3,[Q]:4,[K]:5,[$]:6},Mr=new yr,{_lodPlanes:Sr,_sizeLods:Tr,_sigmas:Er}=function(){const t=[],e=[],n=[];let r=8;for(let i=0;i4?a=xr[i-8+4-1]:0==i&&(a=0),n.push(a);const s=1/(o-1),l=-s/2,c=1+s/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],p=6,h=6,d=3,f=2,m=1,g=new Float32Array(d*h*p),y=new Float32Array(f*h*p),v=new Float32Array(m*h*p);for(let t=0;t2?0:-1,r=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];g.set(r,d*h*t),y.set(u,f*h*t);const i=[t,t,t,t,t,t];v.set(i,m*h*t)}const _=new wn;_.setAttribute("position",new tn(g,d)),_.setAttribute("uv",new tn(y,f)),_.setAttribute("faceIndex",new tn(v,m)),t.push(_),r>4&&r--}return{_lodPlanes:t,_sizeLods:e,_sigmas:n}}(),Ar=new Je;let Cr=null;const Lr=(1+Math.sqrt(5))/2,Pr=1/Lr,Ir=[new Ct(1,1,1),new Ct(-1,1,1),new Ct(1,1,-1),new Ct(-1,1,-1),new Ct(0,Lr,Pr),new Ct(0,Lr,-Pr),new Ct(Pr,0,Lr),new Ct(-Pr,0,Lr),new Ct(Lr,Pr,0),new Ct(-Lr,Pr,0)];class Rr{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=function(t){const e=new Float32Array(20),n=new Ct(0,1,0);return new vr({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[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(t,e=0,n=.1,r=100){Cr=this._renderer.getRenderTarget();const i=this._allocateTargets();return this._sceneToCubeUV(t,n,r,i),e>0&&this._blur(i,0,0,e),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=Fr(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=Or(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let t=0;t2?_r:0,_r,_r),s.setRenderTarget(r),d&&s.render(h,i),s.render(t,i)}h.geometry.dispose(),h.material.dispose(),s.toneMapping=u,s.outputEncoding=c,s.autoClear=l,t.background=f}_textureToCubeUV(t,e){const n=this._renderer;t.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=Fr()):null==this._equirectShader&&(this._equirectShader=Or());const r=t.isCubeTexture?this._cubemapShader:this._equirectShader,i=new Un(Sr[0],r),o=r.uniforms;o.envMap.value=t,t.isCubeTexture||o.texelSize.value.set(1/t.image.width,1/t.image.height),o.inputEncoding.value=wr[t.encoding],o.outputEncoding.value=wr[e.texture.encoding],Dr(e,0,0,3*_r,2*_r),n.setRenderTarget(e),n.render(i,Mr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let e=1;e20&&console.warn(`sigmaRadians, ${i}, 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 t=0;t<20;++t){const e=t/d,n=Math.exp(-e*e/2);m.push(n),0==t?g+=n:t4?r-8+4:0),3*y,2*y),s.setRenderTarget(e),s.render(c,Mr)}}function kr(t){return void 0!==t&&t.type===_&&(t.encoding===Z||t.encoding===X||t.encoding===$)}function zr(t){const e=new St(3*_r,3*_r,t);return e.texture.mapping=l,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Dr(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Or(){const t=new gt(1,1);return new vr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:t},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[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 Fr(){return new vr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[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 Br(t){let e=new WeakMap,n=null;function r(t){const n=t.target;n.removeEventListener("dispose",r);const i=e.get(n);void 0!==i&&(e.delete(n),i.dispose())}return{get:function(l){if(l&&l.isTexture&&!1===l.isRenderTargetTexture){const c=l.mapping,u=c===a||c===s,p=c===i||c===o;if(u||p){if(e.has(l))return e.get(l).texture;{const i=l.image;if(u&&i&&i.height>0||p&&i&&function(t){let e=0;for(let n=0;n<6;n++)void 0!==t[n]&&e++;return 6===e}(i)){const i=t.getRenderTarget();null===n&&(n=new Rr(t));const o=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,o),t.setRenderTarget(i),l.addEventListener("dispose",r),o.texture}return null}}}return l},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Nr(t){const e={};function n(n){if(void 0!==e[n])return e[n];let r;switch(n){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=t.getExtension(n)}return e[n]=r,r}return{has:function(t){return null!==n(t)},init:function(t){t.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(t){const e=n(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Ur(t,e,n,r){const i={},o=new WeakMap;function a(t){const s=t.target;null!==s.index&&e.remove(s.index);for(const t in s.attributes)e.remove(s.attributes[t]);s.removeEventListener("dispose",a),delete i[s.id];const l=o.get(s);l&&(e.remove(l),o.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(t){const n=[],r=t.index,i=t.attributes.position;let a=0;if(null!==r){const t=r.array;a=r.version;for(let e=0,r=t.length;e65535?ln:an)(n,1);s.version=a;const l=o.get(t);l&&e.remove(l),o.set(t,s)}return{get:function(t,e){return!0===i[e.id]||(e.addEventListener("dispose",a),i[e.id]=!0,n.memory.geometries++),e},update:function(t){const n=t.attributes;for(const t in n)e.update(n[t],34962);const r=t.morphAttributes;for(const t in r){const n=r[t];for(let t=0,r=n.length;t0)return t;const i=e*n;let o=Kr[i];if(void 0===o&&(o=new Float32Array(i),Kr[i]=o),0!==e){r.toArray(o,0);for(let r=1,i=0;r!==e;++r)i+=n,t[r].toArray(o,i)}return o}function oi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n/gm;function lo(t){return t.replace(so,co)}function co(t,e){const n=lr[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return lo(n)}const uo=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,po=/#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 ho(t){return t.replace(po,mo).replace(uo,fo)}function fo(t,e,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),mo(t,e,n,r)}function mo(t,e,n,r){let i="";for(let t=parseInt(e);t0?t.gammaFactor:1,y=n.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(io).join("\n")}(n),v=function(t){const e=[];for(const n in t){const r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(s),_=a.createProgram();let x,b,w=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?((x=[v].filter(io).join("\n")).length>0&&(x+="\n"),(b=[y,v].filter(io).join("\n")).length>0&&(b+="\n")):(x=[go(n),"#define SHADER_NAME "+n.shaderName,v,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularTintMap?"#define USE_SPECULARTINTMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.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(io).join("\n"),b=[y,go(n),"#define SHADER_NAME "+n.shaderName,v,"#define GAMMA_FACTOR "+g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",n.envMap?"#define "+m:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularTintMap?"#define USE_SPECULARTINTMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheenTint?"#define USE_SHEEN":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?lr.tonemapping_pars_fragment:"",0!==n.toneMapping?ro("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.format===T?"#define OPAQUE":"",lr.encodings_pars_fragment,n.map?eo("mapTexelToLinear",n.mapEncoding):"",n.matcap?eo("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?eo("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?eo("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.specularTintMap?eo("specularTintMapTexelToLinear",n.specularTintMapEncoding):"",n.lightMap?eo("lightMapTexelToLinear",n.lightMapEncoding):"",no("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(io).join("\n")),u=ao(u=oo(u=lo(u),n),n),p=ao(p=oo(p=lo(p),n),n),u=ho(u),p=ho(p),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(w="#version 300 es\n",x=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,b=["#define varying in",n.glslVersion===nt?"":"out highp vec4 pc_fragColor;",n.glslVersion===nt?"":"#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+p,S=Yi(a,35633,w+x+u),E=Yi(a,35632,M);if(a.attachShader(_,S),a.attachShader(_,E),void 0!==n.index0AttributeName?a.bindAttribLocation(_,0,n.index0AttributeName):!0===n.morphTargets&&a.bindAttribLocation(_,0,"position"),a.linkProgram(_),t.debug.checkShaderErrors){const t=a.getProgramInfoLog(_).trim(),e=a.getShaderInfoLog(S).trim(),n=a.getShaderInfoLog(E).trim();let r=!0,i=!0;if(!1===a.getProgramParameter(_,35714)){r=!1;const e=to(a,S,"vertex"),n=to(a,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(_,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==n||(i=!1);i&&(this.diagnostics={runnable:r,programLog:t,vertexShader:{log:e,prefix:x},fragmentShader:{log:n,prefix:b}})}let A,C;return a.deleteShader(S),a.deleteShader(E),this.getUniforms=function(){return void 0===A&&(A=new Ji(a,_)),A},this.getAttributes=function(){return void 0===C&&(C=function(t,e){const n={},r=t.getProgramParameter(e,35721);for(let i=0;i0,P=o.clearcoat>0;return{isWebGL2:u,shaderID:S,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?v(C.texture):t.outputEncoding,map:!!o.map,mapEncoding:v(o.map),matcap:!!o.matcap,matcapEncoding:v(o.matcap),envMap:!!M,envMapMode:M&&M.mapping,envMapEncoding:v(M),envMapCubeUV:!!M&&(M.mapping===l||M.mapping===c),lightMap:!!o.lightMap,lightMapEncoding:v(o.lightMap),aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,emissiveMapEncoding:v(o.emissiveMap),bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:1===o.normalMapType,tangentSpaceNormalMap:0===o.normalMapType,clearcoat:P,clearcoatMap:P&&!!o.clearcoatMap,clearcoatRoughnessMap:P&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:P&&!!o.clearcoatNormalMap,displacementMap:!!o.displacementMap,roughnessMap:!!o.roughnessMap,metalnessMap:!!o.metalnessMap,specularMap:!!o.specularMap,specularIntensityMap:!!o.specularIntensityMap,specularTintMap:!!o.specularTintMap,specularTintMapEncoding:v(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:p,skinning:!0===x.isSkinnedMesh&&T>0,maxBones:T,useVertexTexture:h,morphTargets:!!x.geometry&&!!x.geometry.morphAttributes.position,morphNormals:!!x.geometry&&!!x.geometry.morphAttributes.normal,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,format:o.format,dithering:o.dithering,shadowMapEnabled:t.shadowMap.enabled&&y.length>0,shadowMapType:t.shadowMap.type,toneMapping:o.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.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||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t0?i.push(u):!0===n.transparent?o.push(u):r.push(u)},unshift:function(t,e,n,a,l,c){const u=s(t,e,n,a,l,c);n.transmission>0?i.unshift(u):!0===n.transparent?o.unshift(u):r.unshift(u)},finish:function(){for(let t=n,r=e.length;t1&&r.sort(t||xo),i.length>1&&i.sort(e||bo),o.length>1&&o.sort(e||bo)}}}function Mo(t){let e=new WeakMap;return{get:function(n,r){let i;return!1===e.has(n)?(i=new wo(t),e.set(n,[i])):r>=e.get(n).length?(i=new wo(t),e.get(n).push(i)):i=e.get(n)[r],i},dispose:function(){e=new WeakMap}}}function So(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Ct,color:new Je};break;case"SpotLight":n={position:new Ct,direction:new Ct,color:new Je,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ct,color:new Je,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ct,skyColor:new Je,groundColor:new Je};break;case"RectAreaLight":n={color:new Je,position:new Ct,halfWidth:new Ct,halfHeight:new Ct}}return t[e.id]=n,n}}}let To=0;function Eo(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function Ao(t,e){const n=new So,r=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={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 t=0;t<9;t++)i.probe.push(new Ct);const o=new Ct,a=new oe,s=new oe;return{setup:function(o,a){let s=0,l=0,c=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let u=0,p=0,h=0,d=0,f=0,m=0,g=0,y=0;o.sort(Eo);const v=!0!==a?Math.PI:1;for(let t=0,e=o.length;t0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=cr.LTC_FLOAT_1,i.rectAreaLTC2=cr.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=cr.LTC_HALF_1,i.rectAreaLTC2=cr.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=l,i.ambient[2]=c;const _=i.hash;_.directionalLength===u&&_.pointLength===p&&_.spotLength===h&&_.rectAreaLength===d&&_.hemiLength===f&&_.numDirectionalShadows===m&&_.numPointShadows===g&&_.numSpotShadows===y||(i.directional.length=u,i.spot.length=h,i.rectArea.length=d,i.point.length=p,i.hemi.length=f,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=g,i.spotShadowMatrix.length=y,_.directionalLength=u,_.pointLength=p,_.spotLength=h,_.rectAreaLength=d,_.hemiLength=f,_.numDirectionalShadows=m,_.numPointShadows=g,_.numSpotShadows=y,i.version=To++)},setupView:function(t,e){let n=0,r=0,l=0,c=0,u=0;const p=e.matrixWorldInverse;for(let e=0,h=t.length;e=n.get(r).length?(o=new Co(t,e),n.get(r).push(o)):o=n.get(r)[i],o},dispose:function(){n=new WeakMap}}}class Po extends Ge{constructor(t){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(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}Po.prototype.isMeshDepthMaterial=!0;class Io extends Ge{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Ct,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(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Ro(t,e,n){let r=new ir;const i=new gt,o=new gt,a=new Mt,s=new Po({depthPacking:3201}),l=new Io,c={},u=n.maxTextureSize,p={0:1,1:0,2:2},h=new qn({uniforms:{shadow_pass:{value:null},resolution:{value:new gt},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=h.clone();f.defines.HORIZONTAL_PASS=1;const m=new wn;m.setAttribute("position",new tn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Un(m,h),v=this;function _(n,r){const i=e.update(y);h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,h.uniforms.samples.value=n.blurSamples,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(r,null,i,h,y,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,f.uniforms.samples.value=n.blurSamples,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(r,null,i,f,y,null)}function x(e,n,r,i,o,a,u){let h=null;const d=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(h=void 0!==d?d:!0===i.isPointLight?l:s,t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length||r.displacementMap&&0!==r.displacementScale||r.alphaMap&&r.alphaTest>0){const t=h.uuid,e=r.uuid;let n=c[t];void 0===n&&(n={},c[t]=n);let i=n[e];void 0===i&&(i=h.clone(),n[e]=i),h=i}return h.visible=r.visible,h.wireframe=r.wireframe,h.side=3===u?null!==r.shadowSide?r.shadowSide:r.side:null!==r.shadowSide?r.shadowSide:p[r.side],h.alphaMap=r.alphaMap,h.alphaTest=r.alphaTest,h.clipShadows=r.clipShadows,h.clippingPlanes=r.clippingPlanes,h.clipIntersection=r.clipIntersection,h.displacementMap=r.displacementMap,h.displacementScale=r.displacementScale,h.displacementBias=r.displacementBias,h.wireframeLinewidth=r.wireframeLinewidth,h.linewidth=r.linewidth,!0===i.isPointLight&&!0===h.isMeshDistanceMaterial&&(h.referencePosition.setFromMatrixPosition(i.matrixWorld),h.nearDistance=o,h.farDistance=a),h}function b(n,i,o,a,s){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const r=e.update(n),i=n.material;if(Array.isArray(i)){const e=r.groups;for(let l=0,c=e.length;lu||i.y>u)&&(i.x>u&&(o.x=Math.floor(u/f.x),i.x=o.x*f.x,p.mapSize.x=o.x),i.y>u&&(o.y=Math.floor(u/f.y),i.y=o.y*f.y,p.mapSize.y=o.y)),null===p.map&&!p.isPointLightShadow&&3===this.type){const t={minFilter:g,magFilter:g,format:E};p.map=new St(i.x,i.y,t),p.map.texture.name=c.name+".shadowMap",p.mapPass=new St(i.x,i.y,t),p.camera.updateProjectionMatrix()}if(null===p.map){const t={minFilter:d,magFilter:d,format:E};p.map=new St(i.x,i.y,t),p.map.texture.name=c.name+".shadowMap",p.camera.updateProjectionMatrix()}t.setRenderTarget(p.map),t.clear();const m=p.getViewportCount();for(let t=0;t=1):-1!==L.indexOf("OpenGL ES")&&(C=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),A=C>=2);let P=null,I={};const R=t.getParameter(3088),k=t.getParameter(2978),z=(new Mt).fromArray(R),D=(new Mt).fromArray(k);function O(e,n,r){const i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;er||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const r=e?ft:Math.floor,o=r(i*t.width),a=r(i*t.height);void 0===I&&(I=k(o,a));const s=n?k(o,a):I;return s.width=o,s.height=a,s.getContext("2d").drawImage(t,0,0,o,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+a+")."),s}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function D(t){return ht(t.width)&&ht(t.height)}function O(t,e){return t.generateMipmaps&&e&&t.minFilter!==d&&t.minFilter!==g}function F(e,n,i,o,a=1){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log2(Math.max(i,o,a))}function B(n,r,i){if(!1===s)return r;if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=r;return 6403===r&&(5126===i&&(o=33326),5131===i&&(o=33325),5121===i&&(o=33321)),6407===r&&(5126===i&&(o=34837),5131===i&&(o=34843),5121===i&&(o=32849)),6408===r&&(5126===i&&(o=34836),5131===i&&(o=34842),5121===i&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||e.get("EXT_color_buffer_float"),o}function N(t){return t===d||t===f||t===m?9728:9729}function U(e){const n=e.target;n.removeEventListener("dispose",U),function(e){const n=r.get(e);void 0!==n.__webglInit&&(t.deleteTexture(n.__webglTexture),r.remove(e))}(n),n.isVideoTexture&&P.delete(n),a.memory.textures--}function j(e){const n=e.target;n.removeEventListener("dispose",j),function(e){const n=e.texture,i=r.get(e),o=r.get(n);if(e){if(void 0!==o.__webglTexture&&(t.deleteTexture(o.__webglTexture),a.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&t.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,i=n.length;e0&&i.__version!==t.version){const n=t.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void $(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function H(e,i){const a=r.get(e);e.version>0&&a.__version!==e.version?function(e,r,i){if(6!==r.image.length)return;X(e,r),n.activeTexture(33984+i),n.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const a=r&&(r.isCompressedTexture||r.image[0].isCompressedTexture),l=r.image[0]&&r.image[0].isDataTexture,u=[];for(let t=0;t<6;t++)u[t]=a||l?l?r.image[t].image:r.image[t]:z(r.image[t],!1,!0,c);const p=u[0],h=D(p)||s,d=o.convert(r.format),f=o.convert(r.type),m=B(r.internalFormat,d,f);let g;if(Z(34067,r,h),a){for(let t=0;t<6;t++){g=u[t].mipmaps;for(let e=0;e1||r.get(o).__currentAnisotropy)&&(t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function X(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",U),e.__webglTexture=t.createTexture(),a.memory.textures++)}function $(e,r,i){let a=3553;r.isDataTexture2DArray&&(a=35866),r.isDataTexture3D&&(a=32879),X(e,r),n.activeTexture(33984+i),n.bindTexture(a,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const l=function(t){return!s&&(t.wrapS!==p||t.wrapT!==p||t.minFilter!==d&&t.minFilter!==g)}(r)&&!1===D(r.image),c=z(r.image,l,!1,_),u=D(c)||s,h=o.convert(r.format);let f,m=o.convert(r.type),y=B(r.internalFormat,h,m);Z(a,r,u);const v=r.mipmaps;if(r.isDepthTexture)y=6402,s?y=r.type===w?36012:r.type===b?33190:r.type===S?35056:33189:r.type===w&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===A&&6402===y&&r.type!==x&&r.type!==b&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=x,m=o.convert(r.type)),r.format===C&&6402===y&&(y=34041,r.type!==S&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=S,m=o.convert(r.type))),n.texImage2D(3553,0,y,c.width,c.height,0,h,m,null);else if(r.isDataTexture)if(v.length>0&&u){for(let t=0,e=v.length;t0&&u){for(let t=0,e=v.length;t=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),V+=1,t},this.resetTextureUnits=function(){V=0},this.setTexture2D=G,this.setTexture2DArray=function(t,e){const i=r.get(t);t.version>0&&i.__version!==t.version?$(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){const i=r.get(t);t.version>0&&i.__version!==t.version?$(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=H,this.setupRenderTarget=function(e){const l=e.texture,c=r.get(e),u=r.get(l);e.addEventListener("dispose",j),!0!==e.isWebGLMultipleRenderTargets&&(u.__webglTexture=t.createTexture(),u.__version=l.version,a.memory.textures++);const p=!0===e.isWebGLCubeRenderTarget,h=!0===e.isWebGLMultipleRenderTargets,d=!0===e.isWebGLMultisampleRenderTarget,f=l.isDataTexture3D||l.isDataTexture2DArray,m=D(e)||s;if(!s||l.format!==T||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.")),p){c.__webglFramebuffer=[];for(let e=0;e<6;e++)c.__webglFramebuffer[e]=t.createFramebuffer()}else if(c.__webglFramebuffer=t.createFramebuffer(),h)if(i.drawBuffers){const n=e.texture;for(let e=0,i=n.length;es+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=s-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==s&&t.gripSpace&&null!==(i=e.getPose(t.gripSpace,n))&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1);return null!==a&&(a.visible=null!==r),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==o),this}}class Uo extends rt{constructor(t,e){super();const n=this,r=t.state;let i=null,o=1,a=null,s="local-floor",l=null,c=null,u=null,p=null,h=null,d=!1,f=null,m=null,g=null,y=null,v=null,_=null;const x=[],b=new Map,w=new Xn;w.layers.enable(1),w.viewport=new Mt;const M=new Xn;M.layers.enable(2),M.viewport=new Mt;const S=[w,M],T=new Oo;T.layers.enable(1),T.layers.enable(2);let E=null,A=null;function C(t){const e=b.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function L(){b.forEach((function(t,e){t.disconnect(e)})),b.clear(),E=null,A=null,r.bindXRFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),u&&e.deleteFramebuffer(u),f&&e.deleteFramebuffer(f),m&&e.deleteRenderbuffer(m),g&&e.deleteRenderbuffer(g),u=null,f=null,m=null,g=null,h=null,p=null,c=null,i=null,D.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function P(t){const e=i.inputSources;for(let t=0;t0&&(e.alphaTest.value=n.alphaTest);const r=t.get(n).envMap;if(r){e.envMap.value=r,e.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,e.reflectivity.value=n.reflectivity,e.ior.value=n.ior,e.refractionRatio.value=n.refractionRatio;const i=t.get(r).__maxMipLevel;void 0!==i&&(e.maxMipLevel.value=i)}let i,o;n.lightMap&&(e.lightMap.value=n.lightMap,e.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(e.aoMap.value=n.aoMap,e.aoMapIntensity.value=n.aoMapIntensity),n.map?i=n.map:n.specularMap?i=n.specularMap:n.displacementMap?i=n.displacementMap:n.normalMap?i=n.normalMap:n.bumpMap?i=n.bumpMap:n.roughnessMap?i=n.roughnessMap:n.metalnessMap?i=n.metalnessMap:n.alphaMap?i=n.alphaMap:n.emissiveMap?i=n.emissiveMap:n.clearcoatMap?i=n.clearcoatMap:n.clearcoatNormalMap?i=n.clearcoatNormalMap:n.clearcoatRoughnessMap?i=n.clearcoatRoughnessMap:n.specularIntensityMap?i=n.specularIntensityMap:n.specularTintMap?i=n.specularTintMap:n.transmissionMap?i=n.transmissionMap:n.thicknessMap&&(i=n.thicknessMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix)),n.aoMap?o=n.aoMap:n.lightMap&&(o=n.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),e.uv2Transform.value.copy(o.matrix))}function n(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(e.emissiveMap.value=n.emissiveMap),n.bumpMap&&(e.bumpMap.value=n.bumpMap,e.bumpScale.value=n.bumpScale,1===n.side&&(e.bumpScale.value*=-1)),n.normalMap&&(e.normalMap.value=n.normalMap,e.normalScale.value.copy(n.normalScale),1===n.side&&e.normalScale.value.negate()),n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias),t.get(n).envMap&&(e.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,r,i,o,a){r.isMeshBasicMaterial?e(t,r):r.isMeshLambertMaterial?(e(t,r),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,r)):r.isMeshToonMaterial?(e(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshPhongMaterial?(e(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshStandardMaterial?(e(t,r),r.isMeshPhysicalMaterial?function(t,e,r){n(t,e),t.ior.value=e.ior,e.sheenTint&&t.sheenTint.value.copy(e.sheenTint),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate())),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=r.texture,t.transmissionSamplerSize.value.set(r.width,r.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationTint.value.copy(e.attenuationTint)),t.specularIntensity.value=e.specularIntensity,t.specularTint.value.copy(e.specularTint),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap),e.specularTintMap&&(t.specularTintMap.value=e.specularTintMap)}(t,r,a):n(t,r)):r.isMeshMatcapMaterial?(e(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDepthMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDistanceMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,r)):r.isMeshNormalMaterial?(e(t,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){let i;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?i=e.map:e.alphaMap&&(i=e.alphaMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,r,i,o):r.isSpriteMaterial?function(t,e){let n;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?n=e.map:e.alphaMap&&(n=e.alphaMap),void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Vo(t={}){const e=void 0!==t.canvas?t.canvas:function(){const t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.style.display="block",t}(),n=void 0!==t.context?t.context:null,r=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,c=void 0!==t.powerPreference?t.powerPreference:"default",u=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let h=null,f=null;const m=[],g=[];this.domElement=e,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=Z,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const y=this;let x=!1,b=0,S=0,T=null,A=-1,C=null;const L=new Mt,P=new Mt;let I=null,R=e.width,k=e.height,z=1,D=null,O=null;const F=new Mt(0,0,R,k),B=new Mt(0,0,R,k);let N=!1;const U=[],j=new ir;let V=!1,G=!1,H=null;const W=new oe,q=new Ct,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function $(){return null===T?z:1}let J,Y,Q,K,tt,et,nt,rt,it,ot,at,st,lt,ct,ut,pt,ht,dt,ft,mt,gt,yt,vt,_t=n;function xt(t,n){for(let r=0;r0&&function(t,e,n){if(null===H){const t=!0===a&&!0===Y.isWebGL2;H=new(t?Et:St)(1024,1024,{generateMipmaps:!0,type:null!==yt.convert(M)?M:_,minFilter:v,magFilter:d,wrapS:p,wrapT:p})}const r=y.getRenderTarget();y.setRenderTarget(H),y.clear();const i=y.toneMapping;y.toneMapping=0,Dt(t,e,n),y.toneMapping=i,et.updateMultisampleRenderTarget(H),et.updateRenderTargetMipmap(H),y.setRenderTarget(r)}(i,e,n),r&&Q.viewport(L.copy(r)),i.length>0&&Dt(i,e,n),o.length>0&&Dt(o,e,n),s.length>0&&Dt(s,e,n)}function Dt(t,e,n){const r=!0===e.isScene?e.overrideMaterial:null;for(let i=0,o=t.length;i0?g[g.length-1]:null,m.pop(),h=m.length>0?m[m.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return T},this.setRenderTarget=function(t,e=0,n=0){T=t,b=e,S=n,t&&void 0===tt.get(t).__webglFramebuffer&&et.setupRenderTarget(t);let r=null,i=!1,o=!1;if(t){const n=t.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(o=!0);const a=tt.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=a[e],i=!0):r=t.isWebGLMultisampleRenderTarget?tt.get(t).__webglMultisampledFramebuffer:a,L.copy(t.viewport),P.copy(t.scissor),I=t.scissorTest}else L.copy(F).multiplyScalar(z).floor(),P.copy(B).multiplyScalar(z).floor(),I=N;if(Q.bindFramebuffer(36160,r)&&Y.drawBuffers){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const n=t.texture;if(U.length!==n.length||36064!==U[0]){for(let t=0,e=n.length;t=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&_t.readPixels(e,n,r,i,yt.convert(s),yt.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==T?tt.get(T).__webglFramebuffer:null;Q.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,n=0){const r=Math.pow(2,-n),i=Math.floor(e.image.width*r),o=Math.floor(e.image.height*r);let a=yt.convert(e.format);Y.isWebGL2&&(6407===a&&(a=32849),6408===a&&(a=32856)),et.setTexture2D(e,0),_t.copyTexImage2D(3553,n,a,t.x,t.y,i,o,0),Q.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r=0){const i=e.image.width,o=e.image.height,a=yt.convert(n.format),s=yt.convert(n.type);et.setTexture2D(n,0),_t.pixelStorei(37440,n.flipY),_t.pixelStorei(37441,n.premultiplyAlpha),_t.pixelStorei(3317,n.unpackAlignment),e.isDataTexture?_t.texSubImage2D(3553,r,t.x,t.y,i,o,a,s,e.image.data):e.isCompressedTexture?_t.compressedTexSubImage2D(3553,r,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,a,e.mipmaps[0].data):_t.texSubImage2D(3553,r,t.x,t.y,a,s,e.image),0===r&&n.generateMipmaps&&_t.generateMipmap(3553),Q.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n,r,i=0){if(y.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=t.max.x-t.min.x+1,a=t.max.y-t.min.y+1,s=t.max.z-t.min.z+1,l=yt.convert(r.format),c=yt.convert(r.type);let u;if(r.isDataTexture3D)et.setTexture3D(r,0),u=32879;else{if(!r.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");et.setTexture2DArray(r,0),u=35866}_t.pixelStorei(37440,r.flipY),_t.pixelStorei(37441,r.premultiplyAlpha),_t.pixelStorei(3317,r.unpackAlignment);const p=_t.getParameter(3314),h=_t.getParameter(32878),d=_t.getParameter(3316),f=_t.getParameter(3315),m=_t.getParameter(32877),g=n.isCompressedTexture?n.mipmaps[0]:n.image;_t.pixelStorei(3314,g.width),_t.pixelStorei(32878,g.height),_t.pixelStorei(3316,t.min.x),_t.pixelStorei(3315,t.min.y),_t.pixelStorei(32877,t.min.z),n.isDataTexture||n.isDataTexture3D?_t.texSubImage3D(u,i,e.x,e.y,e.z,o,a,s,l,c,g.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),_t.compressedTexSubImage3D(u,i,e.x,e.y,e.z,o,a,s,l,g.data)):_t.texSubImage3D(u,i,e.x,e.y,e.z,o,a,s,l,c,g),_t.pixelStorei(3314,p),_t.pixelStorei(32878,h),_t.pixelStorei(3316,d),_t.pixelStorei(3315,f),_t.pixelStorei(32877,m),0===i&&r.generateMipmaps&&_t.generateMipmap(u),Q.unbindTexture()},this.initTexture=function(t){et.setTexture2D(t,0),Q.unbindTexture()},this.resetState=function(){b=0,S=0,T=null,Q.reset(),vt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Go extends Vo{}Go.prototype.isWebGL1Renderer=!0;class Ho{constructor(t,e=25e-5){this.name="",this.color=new Je(t),this.density=e}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(t,e=1,n=1e3){this.name="",this.color=new Je(t),this.near=e,this.far=n}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 Pe{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(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}qo.prototype.isScene=!0;class Zo{constructor(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=tt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=lt()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,i=this.stride;rt.far||e.push({distance:s,point:Qo.clone(),uv:je.getUV(Qo,ia,oa,aa,sa,la,ca,new gt),face:null,object:this})}copy(t){return super.copy(t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function pa(t,e,n,r,i,o){ea.subVectors(t,n).addScalar(.5).multiply(r),void 0!==i?(na.x=o*ea.x-i*ea.y,na.y=i*ea.x+o*ea.y):na.copy(ea),t.copy(e),t.x+=na.x,t.y+=na.y,t.applyMatrix4(ra)}ua.prototype.isSprite=!0;const ha=new Ct,da=new Ct;class fa extends Pe{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t0){let n,r;for(n=1,r=e.length;n0){ha.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(ha);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){ha.setFromMatrixPosition(t.matrixWorld),da.setFromMatrixPosition(this.matrixWorld);const n=ha.distanceTo(da)/t.zoom;let r,i;for(e[0].object.visible=!0,r=1,i=e.length;r=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(this._currentLevel=r-1;rs)continue;p.applyMatrix4(this.matrixWorld);const h=t.ray.origin.distanceTo(p);ht.far||e.push({distance:h,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,o.start),r=Math.min(i.count,o.start+o.count)-1;ns)continue;p.applyMatrix4(this.matrixWorld);const r=t.ray.origin.distanceTo(p);rt.far||e.push({distance:r,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Ba.prototype.isLine=!0;const Na=new Ct,Ua=new Ct;class ja extends Ba{constructor(t,e){super(t,e),this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,r=e.count;t0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function $a(t,e,n,r,i,o,a){const s=Wa.distanceSqToPoint(t);if(si.far)return;o.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:e,face:null,object:a})}}Xa.prototype.isPoints=!0;class Ja extends bt{constructor(t,e,n,r,i,o,a,s,l){super(t,e,n,r,i,o,a,s,l),this.format=void 0!==a?a:T,this.minFilter=void 0!==o?o:g,this.magFilter=void 0!==i?i:g,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;0=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Ja.prototype.isVideoTexture=!0;class Ya extends bt{constructor(t,e,n,r,i,o,a,s,l,c,u,p){super(null,o,a,s,l,c,r,i,u,p),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}Ya.prototype.isCompressedTexture=!0;class Qa extends bt{constructor(t,e,n,r,i,o,a,s,l){super(t,e,n,r,i,o,a,s,l),this.needsUpdate=!0}}Qa.prototype.isCanvasTexture=!0;class Ka extends bt{constructor(t,e,n,r,i,o,a,s,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===n&&c===A&&(n=x),void 0===n&&c===C&&(n=S),super(null,r,i,o,a,s,c,n,l),this.image={width:t,height:e},this.magFilter=void 0!==a?a:d,this.minFilter=void 0!==s?s:d,this.flipY=!1,this.generateMipmaps=!1}}Ka.prototype.isDepthTexture=!0;class ts extends wn{constructor(t=1,e=8,n=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const i=[],o=[],a=[],s=[],l=new Ct,c=new gt;o.push(0,0,0),a.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=e;i++,u+=3){const p=n+i/e*r;l.x=t*Math.cos(p),l.y=t*Math.sin(p),o.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(o[u]/t+1)/2,c.y=(o[u+1]/t+1)/2,s.push(c.x,c.y)}for(let t=1;t<=e;t++)i.push(t,t+1,0);this.setIndex(i),this.setAttribute("position",new un(o,3)),this.setAttribute("normal",new un(a,3)),this.setAttribute("uv",new un(s,2))}static fromJSON(t){return new ts(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class es extends wn{constructor(t=1,e=1,n=1,r=8,i=1,o=!1,a=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:i,openEnded:o,thetaStart:a,thetaLength:s};const l=this;r=Math.floor(r),i=Math.floor(i);const c=[],u=[],p=[],h=[];let d=0;const f=[],m=n/2;let g=0;function y(n){const i=d,o=new gt,f=new Ct;let y=0;const v=!0===n?t:e,_=!0===n?1:-1;for(let t=1;t<=r;t++)u.push(0,m*_,0),p.push(0,_,0),h.push(.5,.5),d++;const x=d;for(let t=0;t<=r;t++){const e=t/r*s+a,n=Math.cos(e),i=Math.sin(e);f.x=v*i,f.y=m*_,f.z=v*n,u.push(f.x,f.y,f.z),p.push(0,_,0),o.x=.5*n+.5,o.y=.5*i*_+.5,h.push(o.x,o.y),d++}for(let t=0;t0&&y(!0),e>0&&y(!1)),this.setIndex(c),this.setAttribute("position",new un(u,3)),this.setAttribute("normal",new un(p,3)),this.setAttribute("uv",new un(h,2))}static fromJSON(t){return new es(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ns extends es{constructor(t=1,e=1,n=8,r=1,i=!1,o=0,a=2*Math.PI){super(0,t,e,n,r,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}static fromJSON(t){return new ns(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class rs extends wn{constructor(t,e,n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};const i=[],o=[];function a(t,e,n,r){const i=r+1,o=[];for(let r=0;r<=i;r++){o[r]=[];const a=t.clone().lerp(n,r/i),s=e.clone().lerp(n,r/i),l=i-r;for(let t=0;t<=l;t++)o[r][t]=0===t&&r===i?a:a.clone().lerp(s,t/l)}for(let t=0;t.9&&a<.1&&(e<.2&&(o[t+0]+=1),n<.2&&(o[t+2]+=1),r<.2&&(o[t+4]+=1))}}()}(),this.setAttribute("position",new un(i,3)),this.setAttribute("normal",new un(i.slice(),3)),this.setAttribute("uv",new un(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(t){return new rs(t.vertices,t.indices,t.radius,t.details)}}class is extends rs{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,r=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new is(t.radius,t.detail)}}const os=new Ct,as=new Ct,ss=new Ct,ls=new je;class cs extends wn{constructor(t,e){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1,!0===t.isGeometry)return void console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const n=Math.pow(10,4),r=Math.cos(at*e),i=t.getIndex(),o=t.getAttribute("position"),a=i?i.count:o.count,s=[0,0,0],l=["a","b","c"],c=new Array(3),u={},p=[];for(let t=0;t0)){l=r;break}l=r-1}if(n[r=l]===o)return r/(i-1);const c=n[r];return(r+(o-c)/(n[r+1]-c))/(i-1)}getTangent(t,e){let n=t-1e-4,r=t+1e-4;n<0&&(n=0),r>1&&(r=1);const i=this.getPoint(n),o=this.getPoint(r),a=e||(i.isVector2?new gt:new Ct);return a.copy(o).sub(i).normalize(),a}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new Ct,r=[],i=[],o=[],a=new Ct,s=new oe;for(let e=0;e<=t;e++){const n=e/t;r[e]=this.getTangentAt(n,new Ct),r[e].normalize()}i[0]=new Ct,o[0]=new Ct;let l=Number.MAX_VALUE;const c=Math.abs(r[0].x),u=Math.abs(r[0].y),p=Math.abs(r[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),p<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],a),o[0].crossVectors(r[0],i[0]);for(let e=1;e<=t;e++){if(i[e]=i[e-1].clone(),o[e]=o[e-1].clone(),a.crossVectors(r[e-1],r[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ct(r[e-1].dot(r[e]),-1,1));i[e].applyMatrix4(s.makeRotationAxis(a,t))}o[e].crossVectors(r[e],i[e])}if(!0===e){let e=Math.acos(ct(i[0].dot(i[t]),-1,1));e/=t,r[0].dot(a.crossVectors(i[0],i[t]))>0&&(e=-e);for(let n=1;n<=t;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],e*n)),o[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class ps extends us{constructor(t=0,e=0,n=1,r=1,i=0,o=2*Math.PI,a=!1,s=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s}getPoint(t,e){const n=e||new gt,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const o=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===c&&l===i-1&&(l=i-2,c=1),this.closed||l>0?a=r[(l-1)%i]:(fs.subVectors(r[0],r[1]).add(r[0]),a=fs);const u=r[l%i],p=r[(l+1)%i];if(this.closed||l+2r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return n.set(_s(a,s.x,l.x,c.x,u.x),_s(a,s.y,l.y,c.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e0)for(o=e;o=e;o-=r)a=Ys(o,t[o],t[o+1],a);return a&&Ws(a,a.next)&&(Qs(a),a=a.next),a}function Is(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!Ws(r,r.next)&&0!==Hs(r.prev,r,r.next))r=r.next;else{if(Qs(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Rs(t,e,n,r,i,o,a){if(!t)return;!a&&o&&function(t,e,n,r){let i=t;do{null===i.z&&(i.z=Us(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,n,r,i,o,a,s,l,c=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,c*=2}while(a>1)}(i)}(t,r,i,o);let s,l,c=t;for(;t.prev!==t.next;)if(s=t.prev,l=t.next,o?zs(t,r,i,o):ks(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Qs(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Rs(t=Ds(Is(t),e,n),e,n,r,i,o,2):2===a&&Os(t,e,n,r,i,o):Rs(Is(t),e,n,r,i,o,1);break}}function ks(t){const e=t.prev,n=t,r=t.next;if(Hs(e,n,r)>=0)return!1;let i=t.next.next;for(;i!==t.prev;){if(Vs(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Hs(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function zs(t,e,n,r){const i=t.prev,o=t,a=t.next;if(Hs(i,o,a)>=0)return!1;const s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,u=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,p=Us(s,l,e,n,r),h=Us(c,u,e,n,r);let d=t.prevZ,f=t.nextZ;for(;d&&d.z>=p&&f&&f.z<=h;){if(d!==t.prev&&d!==t.next&&Vs(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Hs(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==t.prev&&f!==t.next&&Vs(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Hs(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=p;){if(d!==t.prev&&d!==t.next&&Vs(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Hs(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=h;){if(f!==t.prev&&f!==t.next&&Vs(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Hs(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Ds(t,e,n){let r=t;do{const i=r.prev,o=r.next.next;!Ws(i,o)&&qs(i,r,r.next,o)&&$s(i,o)&&$s(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Qs(r),Qs(r.next),r=t=o),r=r.next}while(r!==t);return Is(r)}function Os(t,e,n,r,i,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&Gs(a,t)){let s=Js(a,t);return a=Is(a,a.next),s=Is(s,s.next),Rs(a,e,n,r,i,o),void Rs(s,e,n,r,i,o)}t=t.next}a=a.next}while(a!==t)}function Fs(t,e){return t.x-e.x}function Bs(t,e){if(e=function(t,e){let n=e;const r=t.x,i=t.y;let o,a=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const t=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>a){if(a=t,t===r){if(i===n.y)return n;if(i===n.next.y)return n.next}o=n.x=n.x&&n.x>=l&&r!==n.x&&Vs(io.x||n.x===o.x&&Ns(o,n)))&&(o=n,p=u)),n=n.next}while(n!==s);return o}(t,e)){const n=Js(e,t);Is(e,e.next),Is(n,n.next)}}function Ns(t,e){return Hs(t.prev,t,e.prev)<0&&Hs(e.next,t,t.next)<0}function Us(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function js(t){let e=t,n=t;do{(e.x=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function Gs(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&qs(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&($s(t,e)&&$s(e,t)&&function(t,e){let n=t,r=!1;const i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(Hs(t.prev,t,e.prev)||Hs(t,e.prev,e))||Ws(t,e)&&Hs(t.prev,t,t.next)>0&&Hs(e.prev,e,e.next)>0)}function Hs(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Ws(t,e){return t.x===e.x&&t.y===e.y}function qs(t,e,n,r){const i=Xs(Hs(t,e,n)),o=Xs(Hs(t,e,r)),a=Xs(Hs(n,r,t)),s=Xs(Hs(n,r,e));return i!==o&&a!==s||!(0!==i||!Zs(t,n,e))||!(0!==o||!Zs(t,r,e))||!(0!==a||!Zs(n,t,r))||!(0!==s||!Zs(n,e,r))}function Zs(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Xs(t){return t>0?1:t<0?-1:0}function $s(t,e){return Hs(t.prev,t,t.next)<0?Hs(t,e,t.next)>=0&&Hs(t,t.prev,e)>=0:Hs(t,e,t.prev)<0||Hs(t,t.next,e)<0}function Js(t,e){const n=new Ks(t.i,t.x,t.y),r=new Ks(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Ys(t,e,n,r){const i=new Ks(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Qs(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ks(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class tl{static area(t){const e=t.length;let n=0;for(let r=e-1,i=0;i80*n){s=c=t[0],l=u=t[1];for(let e=n;ec&&(c=p),h>u&&(u=h);d=0!==(d=Math.max(c-s,u-l))?1/d:0}return Rs(o,a,n,s,l,d),a}(n,r);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function nl(t,e){for(let n=0;nNumber.EPSILON){const p=Math.sqrt(u),h=Math.sqrt(l*l+c*c),d=e.x-s/p,f=e.y+a/p,m=((n.x-c/h-d)*c-(n.y+l/h-f)*l)/(a*c-s*l),g=(r=d+a*m-t.x)*r+(i=f+s*m-t.y)*i;if(g<=2)return new gt(r,i);o=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(s)===Math.sign(c)&&(t=!0),t?(r=-s,i=a,o=Math.sqrt(u)):(r=a,i=s,o=Math.sqrt(u/2))}return new gt(r/o,i/o)}const I=[];for(let t=0,e=E.length,n=e-1,r=t+1;t=0;t--){const e=t/d,n=u*Math.cos(e*Math.PI/2),r=p*Math.sin(e*Math.PI/2)+h;for(let t=0,e=E.length;t=0;){const r=n;let i=n-1;i<0&&(i=t.length-1);for(let t=0,n=s+2*d;t=0?(t(r-s,d,u),p.subVectors(c,u)):(t(r+s,d,u),p.subVectors(u,c)),d-s>=0?(t(r,d-s,u),h.subVectors(c,u)):(t(r,d+s,u),h.subVectors(u,c)),l.crossVectors(p,h).normalize(),o.push(l.x,l.y,l.z),a.push(r,d)}}for(let t=0;t0)&&h.push(e,i,l),(t!==n-1||s0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.sheenTint.copy(t.sheenTint),this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationTint.copy(t.attenuationTint),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularTint.copy(t.specularTint),this.specularTintMap=t.specularTintMap,this}}wl.prototype.isMeshPhysicalMaterial=!0;class Ml extends Ge{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new Je(16777215),this.specular=new Je(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this}}Ml.prototype.isMeshPhongMaterial=!0;class Sl extends Ge{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Je(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Sl.prototype.isMeshToonMaterial=!0;class Tl extends Ge{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(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(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}Tl.prototype.isMeshNormalMaterial=!0;class El extends Ge{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new Je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}El.prototype.isMeshLambertMaterial=!0;class Al extends Ge{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Je(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this}}Al.prototype.isMeshMatcapMaterial=!0;class Cl extends Ra{constructor(t){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}Cl.prototype.isLineDashedMaterial=!0;var Ll=Object.freeze({__proto__:null,ShadowMaterial:xl,SpriteMaterial:Jo,RawShaderMaterial:vr,ShaderMaterial:qn,PointsMaterial:Ga,MeshPhysicalMaterial:wl,MeshStandardMaterial:bl,MeshPhongMaterial:Ml,MeshToonMaterial:Sl,MeshNormalMaterial:Tl,MeshLambertMaterial:El,MeshDepthMaterial:Po,MeshDistanceMaterial:Io,MeshBasicMaterial:Ye,MeshMatcapMaterial:Al,LineDashedMaterial:Cl,LineBasicMaterial:Ra,Material:Ge});const Pl={arraySlice:function(t,e,n){return Pl.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==n?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){const r=t.length,i=new t.constructor(r);for(let o=0,a=0;a!==r;++o){const r=n[o]*e;for(let n=0;n!==e;++n)i[a++]=t[r+n]}return i},flattenJSON:function(t,e,n,r){let i=1,o=t[0];for(;void 0!==o&&void 0===o[r];)o=t[i++];if(void 0===o)return;let a=o[r];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[r])&&(e.push(o.time),n.push.apply(n,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[r])&&(e.push(o.time),a.toArray(n,n.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[r])&&(e.push(o.time),n.push(a)),o=t[i++]}while(void 0!==o)},subclip:function(t,e,n,r,i=30){const o=t.clone();o.name=e;const a=[];for(let t=0;t=r)){l.push(e.times[t]);for(let n=0;no.tracks[t].times[0]&&(s=o.tracks[t].times[0]);for(let t=0;t=r.times[p]){const t=p*l+s,e=t+l-s;h=Pl.arraySlice(r.values,t,e)}else{const t=r.createInterpolant(),e=s,n=l-s;t.evaluate(o),h=Pl.arraySlice(t.resultBuffer,e,n)}"quaternion"===i&&(new At).fromArray(h).normalize().conjugate().toArray(h);const d=a.times.length;for(let t=0;t=i)break t;{const a=e[1];t=(i=e[--n-1]))break e}o=n,n=0}}for(;n>>1;te;)--o;if(++o,0!==i||o!==r){i>=o&&(i=(o=Math.max(o,1))-1);const t=this.getValueSize();this.times=Pl.arraySlice(n,i,o),this.values=Pl.arraySlice(this.values,i*t,o*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let e=0;e!==i;e++){const r=n[e];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,r),t=!1;break}if(null!==o&&o>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,r,o),t=!1;break}o=r}if(void 0!==r&&Pl.isTypedArray(r))for(let e=0,n=r.length;e!==n;++e){const n=r[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=Pl.arraySlice(this.times),e=Pl.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===j,i=t.length-1;let o=1;for(let a=1;a0){t[o]=t[i];for(let t=i*n,r=o*n,a=0;a!==n;++a)e[r+a]=e[t+a];++o}return o!==t.length?(this.times=Pl.arraySlice(t,0,o),this.values=Pl.arraySlice(e,0,o*n)):(this.times=t,this.values=e),this}clone(){const t=Pl.arraySlice(this.times,0),e=Pl.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}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 Il{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=(n-e)/(r-e);let l=t*a;for(let t=l+a;l!==t;l+=4)At.slerpFlat(i,0,o,l-a,o,l,s);return i}}class Ul extends Dl{InterpolantFactoryMethodLinear(t){return new Nl(this.times,this.values,this.getValueSize(),t)}}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(t,e=-1,n,r=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=lt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,r=1/(t.fps||1);for(let t=0,i=n.length;t!==i;++t)e.push(Hl(n[t]).scale(r));const i=new this(t.name,t.duration,e,t.blendMode);return i.uuid=t.uuid,i}static toJSON(t){const e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,r=n.length;t!==r;++t)e.push(Dl.toJSON(n[t]));return r}static CreateFromMorphTargetSequence(t,e,n,r){const i=e.length,o=[];for(let t=0;t1){const t=o[1];let e=r[t];e||(r[t]=e=[]),e.push(n)}}const o=[];for(const t in r)o.push(this.CreateFromMorphTargetSequence(t,r[t],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,r,i){if(0!==n.length){const o=[],a=[];Pl.flattenJSON(n,o,a,r),0!==o.length&&i.push(new t(e,o,a))}},r=[],i=t.name||"default",o=t.fps||30,a=t.blendMode;let s=t.length||-1;const l=t.hierarchy||[];for(let t=0;t0||0===t.search(/^data\:image\/jpeg/);i.format=r?T:E,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}class ec extends us{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ss(e,t))}getPoint(t){const e=t*this.getLength(),n=this.getCurveLengths();let r=0;for(;r=e){const t=n[r]-e,i=this.curves[r],o=i.getLength(),a=0===o?0:1-t/o;return i.getPointAt(a)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,r=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class rc extends nc{constructor(t){super(t),this.uuid=lt(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,r=this.holes.length;n0:r.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const i=t.uniforms[e];switch(r.uniforms[e]={},i.type){case"t":r.uniforms[e].value=n(i.value);break;case"c":r.uniforms[e].value=(new Je).setHex(i.value);break;case"v2":r.uniforms[e].value=(new gt).fromArray(i.value);break;case"v3":r.uniforms[e].value=(new Ct).fromArray(i.value);break;case"v4":r.uniforms[e].value=(new Mt).fromArray(i.value);break;case"m3":r.uniforms[e].value=(new yt).fromArray(i.value);break;case"m4":r.uniforms[e].value=(new oe).fromArray(i.value);break;default:r.uniforms[e].value=i.value}}if(void 0!==t.defines&&(r.defines=t.defines),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)r.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(r.flatShading=1===t.shading),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=n(t.map)),void 0!==t.matcap&&(r.matcap=n(t.matcap)),void 0!==t.alphaMap&&(r.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(r.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(r.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),r.normalScale=(new gt).fromArray(e)}return void 0!==t.displacementMap&&(r.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(r.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularTintMap&&(r.specularTintMap=n(t.specularTintMap)),void 0!==t.envMap&&(r.envMap=n(t.envMap)),void 0!==t.envMapIntensity&&(r.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(r.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(r.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(r.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(r.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(r.clearcoatNormalScale=(new gt).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(r.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(r.thicknessMap=n(t.thicknessMap)),r}setTextures(t){return this.textures=t,this}}class Sc{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,r=t.length;nNumber.EPSILON){if(l<0&&(n=e[o],s=-s,a=e[i],l=-l),t.ya.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-s*(t.y-n.y);if(0===e)return!0;if(e<0)continue;r=!r}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return r}const i=tl.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return n(o);let a,s,l;const c=[];if(1===o.length)return s=o[0],(l=new rc).curves=s.curves,c.push(l),c;let u=!i(o[0].getPoints());u=t?!u:u;const p=[],h=[];let d,f,m=[],g=0;h[g]=void 0,m[g]=[];for(let e=0,n=o.length;e1){let t=!1;const e=[];for(let t=0,e=h.length;t0&&(t||(m=p))}for(let t=0,e=h.length;t0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let t=e,i=e+e;t!==i;++t)if(n[t]!==n[t+e]){a.setValue(n,r);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let t=n,i=r;t!==i;++t)e[t]=e[r+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let r=0;r!==i;++r)t[e+r]=t[n+r]}_slerp(t,e,n,r){At.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,i){const o=this._workIndex*i;At.multiplyQuaternionsFlat(t,o,t,e,t,n),At.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,i){const o=1-r;for(let a=0;a!==i;++a){const i=e+a;t[i]=t[i]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,i){for(let o=0;o!==i;++o){const i=e+o;t[i]=t[i]+t[n+o]*r}}}const tu=new RegExp("[\\[\\]\\.:\\/]","g"),eu="[^\\[\\]\\.:\\/]",nu="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",ru=/((?:WC+[\/:])*)/.source.replace("WC",eu),iu=/(WCOD+)?/.source.replace("WCOD",nu),ou=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",eu),au=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",eu),su=new RegExp("^"+ru+iu+ou+au+"$"),lu=["material","materials","bones"];class cu{constructor(t,e,n){this.path=e,this.parsedPath=n||cu.parseTrackName(e),this.node=cu.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new cu.Composite(t,e,n):new cu(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(tu,"")}static parseTrackName(t){const e=su.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const t=n.nodeName.substring(r+1);-1!==lu.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let r=0;r=i){const o=i++,c=t[o];e[c.uuid]=l,t[l]=c,e[s]=o,t[o]=a;for(let t=0,e=r;t!==e;++t){const e=n[t],r=e[o],i=e[l];e[l]=r,e[o]=i}}}this.nCachedObjects_=i}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_,o=t.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=e[s];if(void 0!==l)if(delete e[s],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=r;t!==e;++t){const e=n[t];e[l]=e[i],e.pop()}}}this.nCachedObjects_=i}subscribe_(t,e){const n=this._bindingsIndicesByPath;let r=n[t];const i=this._bindings;if(void 0!==r)return i[r];const o=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);r=i.length,n[t]=r,o.push(t),a.push(e),i.push(u);for(let n=c,r=s.length;n!==r;++n){const r=s[n];u[n]=new cu(r,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const r=this._paths,i=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];e[t[a]]=n,o[n]=s,o.pop(),i[n]=i[a],i.pop(),r[n]=r[a],r.pop()}}}uu.prototype.isAnimationObjectGroup=!0;class pu{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;const i=e.tracks,o=i.length,a=new Array(o),s={endingStart:V,endingEnd:V};for(let t=0;t!==o;++t){const e=i[t].createInterpolant(null);a[t]=e,e.settings=s}this._interpolantSettings=s,this._interpolants=a,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,r=t._clip.duration,i=r/n,o=n/r;t.warp(1,i,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const r=this._mixer,i=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=i,s[1]=i+n,l[0]=t/o,l[1]=e/o,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,r){if(!this.enabled)return void this._updateWeight(t);const i=this._startTime;if(null!==i){const r=(t-i)*n;if(r<0||0===n)return;this._startTime=null,e=n*r}e*=this._updateTimeScale(t);const o=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===q)for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(o),e[n].accumulateAdditive(a);else for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(o),e[n].accumulate(r,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let r=this.time+t,i=this._loopCount;const o=2202===n;if(0===t)return-1===i?r:o&&1==(1&i)?e-r:r;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=e)r=e;else{if(!(r<0)){this.time=r;break t}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),r>=e||r<0){const n=Math.floor(r/e);r-=e*n,i+=Math.abs(n);const a=this.repetitions-i;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(o&&1==(1&i))return e-r}return r}_setEndings(t,e,n){const r=this._interpolantSettings;n?(r.endingStart=G,r.endingEnd=G):(r.endingStart=t?this.zeroSlopeAtStart?G:V:H,r.endingEnd=e?this.zeroSlopeAtEnd?G:V:H)}_scheduleFading(t,e,n){const r=this._mixer,i=r.time;let o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=n,this}}class hu extends rt{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,o=t._propertyBindings,a=t._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let t=0;t!==i;++t){const i=r[t],l=i.name;let u=c[l];if(void 0!==u)o[t]=u;else{if(void 0!==(u=o[t])){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,l));continue}const r=e&&e._propertyBindings[t].binding.parsedPath;++(u=new Kc(cu.create(n,l,r),i.ValueTypeName,i.getValueSize())).referenceCount,this._addInactiveBinding(u,s,l),o[t]=u}a[t].resultBuffer=u.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,r=this.time+=t,i=Math.sign(t),o=this._accuIndex^=1;for(let a=0;a!==n;++a)e[a]._update(r,t,i,o);const a=this._bindings,s=this._nActiveBindings;for(let t=0;t!==s;++t)a[t].apply(o);return this}setTime(t){this.time=0;for(let t=0;tthis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return vu.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}_u.prototype.isBox2=!0;const xu=new Ct,bu=new Ct;class wu{constructor(t=new Ct,e=new Ct){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){xu.subVectors(t,this.start),bu.subVectors(this.end,this.start);const n=bu.dot(bu);let r=bu.dot(xu)/n;return e&&(r=ct(r,0,1)),r}closestPointToPoint(t,e,n){const r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}class Mu extends Pe{constructor(t){super(),this.material=t,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 Su=new Ct,Tu=new Ct,Eu=new oe,Au=new oe;class Cu extends ja{constructor(t){const e=function t(e){const n=[];e&&e.isBone&&n.push(e);for(let r=0;r.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{ju.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(ju,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}},t.Audio=Zc,t.AudioAnalyser=Qc,t.AudioContext=Dc,t.AudioListener=class extends Pe{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(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Gc,Hc,Wc),qc.set(0,0,-1).applyQuaternion(Hc),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Gc.x,t),e.positionY.linearRampToValueAtTime(Gc.y,t),e.positionZ.linearRampToValueAtTime(Gc.z,t),e.forwardX.linearRampToValueAtTime(qc.x,t),e.forwardY.linearRampToValueAtTime(qc.y,t),e.forwardZ.linearRampToValueAtTime(qc.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(Gc.x,Gc.y,Gc.z),e.setOrientation(qc.x,qc.y,qc.z,n.x,n.y,n.z)}},t.AudioLoader=Oc,t.AxesHelper=Hu,t.AxisHelper=function(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Hu(t)},t.BackSide=1,t.BasicDepthPacking=3200,t.BasicShadowMap=0,t.BinaryTextureLoader=function(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Kl(t)},t.Bone=ba,t.BooleanKeyframeTrack=Ol,t.BoundingBoxHelper=function(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Uu(t,e)},t.Box2=_u,t.Box3=It,t.Box3Helper=class extends ja{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new wn;r.setIndex(new tn(n,1)),r.setAttribute("position",new un([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(r,new Ra({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}},t.BoxBufferGeometry=Vn,t.BoxGeometry=Vn,t.BoxHelper=Uu,t.BufferAttribute=tn,t.BufferGeometry=wn,t.BufferGeometryLoader=Ec,t.ByteType=1010,t.Cache=Wl,t.Camera=Zn,t.CameraHelper=class extends ja{constructor(t){const e=new wn,n=new Ra({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],o={},a=new Je(16755200),s=new Je(16711680),l=new Je(43775),c=new Je(16777215),u=new Je(3355443);function p(t,e,n){h(t,n),h(e,n)}function h(t,e){r.push(0,0,0),i.push(e.r,e.g,e.b),void 0===o[t]&&(o[t]=[]),o[t].push(r.length/3-1)}p("n1","n2",a),p("n2","n4",a),p("n4","n3",a),p("n3","n1",a),p("f1","f2",a),p("f2","f4",a),p("f4","f3",a),p("f3","f1",a),p("n1","f1",a),p("n2","f2",a),p("n3","f3",a),p("n4","f4",a),p("p","n1",s),p("p","n2",s),p("p","n3",s),p("p","n4",s),p("u1","u2",l),p("u2","u3",l),p("u3","u1",l),p("c","t",c),p("p","c",u),p("cn1","cn2",u),p("cn3","cn4",u),p("cf1","cf2",u),p("cf3","cf4",u),e.setAttribute("position",new un(r,3)),e.setAttribute("color",new un(i,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){const t=this.geometry,e=this.pointMap;Fu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Bu("c",e,t,Fu,0,0,-1),Bu("t",e,t,Fu,0,0,1),Bu("n1",e,t,Fu,-1,-1,-1),Bu("n2",e,t,Fu,1,-1,-1),Bu("n3",e,t,Fu,-1,1,-1),Bu("n4",e,t,Fu,1,1,-1),Bu("f1",e,t,Fu,-1,-1,1),Bu("f2",e,t,Fu,1,-1,1),Bu("f3",e,t,Fu,-1,1,1),Bu("f4",e,t,Fu,1,1,1),Bu("u1",e,t,Fu,.7,1.1,-1),Bu("u2",e,t,Fu,-.7,1.1,-1),Bu("u3",e,t,Fu,0,2,-1),Bu("cf1",e,t,Fu,-1,0,1),Bu("cf2",e,t,Fu,1,0,1),Bu("cf3",e,t,Fu,0,-1,1),Bu("cf4",e,t,Fu,0,1,1),Bu("cn1",e,t,Fu,-1,0,-1),Bu("cn2",e,t,Fu,1,0,-1),Bu("cn3",e,t,Fu,0,-1,-1),Bu("cn4",e,t,Fu,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},t.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},t.CanvasTexture=Qa,t.CatmullRomCurve3=vs,t.CineonToneMapping=3,t.CircleBufferGeometry=ts,t.CircleGeometry=ts,t.ClampToEdgeWrapping=p,t.Clock=jc,t.Color=Je,t.ColorKeyframeTrack=Fl,t.CompressedTexture=Ya,t.CompressedTextureLoader=class extends Xl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=[],a=new Ya,s=new Jl(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let l=0;function c(c){s.load(t[c],(function(t){const n=i.parse(t,!0);o[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},6===(l+=1)&&(1===n.mipmapCount&&(a.minFilter=g),a.image=o,a.format=n.format,a.needsUpdate=!0,e&&e(a))}),n,r)}if(Array.isArray(t))for(let e=0,n=t.length;e>16&32768,r=e>>12&2047;const i=e>>23&255;return i<103?n:i>142?(n|=31744,n|=(255==i?0:1)&&8388607&e):i<113?n|=((r|=2048)>>114-i)+(r>>113-i&1):(n|=i-112<<10|r>>1,n+=1&r)}},t.DecrementStencilOp=7683,t.DecrementWrapStencilOp=34056,t.DefaultLoadingManager=Zl,t.DepthFormat=A,t.DepthStencilFormat=C,t.DepthTexture=Ka,t.DirectionalLight=vc,t.DirectionalLightHelper=class extends Pe{constructor(t,e,n){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===e&&(e=1);let r=new wn;r.setAttribute("position",new un([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const i=new Ra({fog:!1,toneMapped:!1});this.lightPlane=new Ba(r,i),this.add(this.lightPlane),(r=new wn).setAttribute("position",new un([0,0,0,0,0,1],3)),this.targetLine=new Ba(r,i),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()}},t.DiscreteInterpolant=zl,t.DodecahedronBufferGeometry=is,t.DodecahedronGeometry=is,t.DoubleSide=2,t.DstAlphaFactor=206,t.DstColorFactor=208,t.DynamicBufferAttribute=function(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new tn(t,e).setUsage(et)},t.DynamicCopyUsage=35050,t.DynamicDrawUsage=et,t.DynamicReadUsage=35049,t.EdgesGeometry=cs,t.EdgesHelper=function(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new ja(new cs(t.geometry),new Ra({color:void 0!==e?e:16777215}))},t.EllipseCurve=ps,t.EqualDepth=4,t.EqualStencilFunc=514,t.EquirectangularReflectionMapping=a,t.EquirectangularRefractionMapping=s,t.Euler=me,t.EventDispatcher=rt,t.ExtrudeBufferGeometry=rl,t.ExtrudeGeometry=rl,t.FaceColors=1,t.FileLoader=Jl,t.FlatShading=1,t.Float16BufferAttribute=cn,t.Float32Attribute=function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new un(t,e)},t.Float32BufferAttribute=un,t.Float64Attribute=function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new pn(t,e)},t.Float64BufferAttribute=pn,t.FloatType=w,t.Fog=Wo,t.FogExp2=Ho,t.Font=Rc,t.FontLoader=class extends Xl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=new Jl(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(i.withCredentials),o.load(t,(function(t){let n;try{n=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(t.substring(65,t.length-2))}const r=i.parse(n);e&&e(r)}),n,r)}parse(t){return new Rc(t)}},t.FrontSide=0,t.Frustum=ir,t.GLBufferAttribute=mu,t.GLSL1="100",t.GLSL3=nt,t.GammaEncoding=$,t.GreaterDepth=6,t.GreaterEqualDepth=5,t.GreaterEqualStencilFunc=518,t.GreaterStencilFunc=516,t.GridHelper=Ru,t.Group=Fo,t.HalfFloatType=M,t.HemisphereLight=oc,t.HemisphereLightHelper=class extends Pe{constructor(t,e,n){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const r=new sl(e);r.rotateY(.5*Math.PI),this.material=new Ye({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const i=r.getAttribute("position"),o=new Float32Array(3*i.count);r.setAttribute("color",new tn(o,3)),this.add(new Un(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Pu.copy(this.light.color),Iu.copy(this.light.groundColor);for(let t=0,n=e.count;t0){const n=new ql(e);(i=new Yl(n)).setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e0){(r=new Yl(this.manager)).setCrossOrigin(this.crossOrigin);for(let e=0,r=t.length;e90))return t;console.error("Latitude must be between -90 and 90")}else console.error("Coords must be an array")},Line:function(t){if(t.constructor===Array){for(const e of t)if(!this.Coords(e))return void console.error("Each coordinate in a line must be a valid Coords type");return t}console.error("Line must be an array")},Rotation:function(t){if(t.constructor===Number)t={z:t};else{if(t.constructor!==Object)return void console.error("Rotation must be an object or a number");for(const e of Object.keys(t)){if(!["x","y","z"].includes(e))return void console.error("Rotation parameters must be x, y, or z");if(t[e].constructor!==Number)return void console.error("Individual rotation values must be numbers")}}return t},Scale:function(t){if(t.constructor===Number)t={x:t,y:t,z:t};else{if(t.constructor!==Object)return void console.error("Scale must be an object or a number");for(const e of Object.keys(t)){if(!["x","y","z"].includes(e))return void console.error("Scale parameters must be x, y, or z");if(t[e].constructor!==Number)return void console.error("Individual scale values must be numbers")}}return t}},l=l=c;var u={},p={prettyPrintMatrix:function(t){for(var e=0;e<4;e++){var n=[t[e],t[e+4],t[e+8],t[e+12]];console.log(n.map((function(t){return t.toFixed(4)})))}},makePerspectiveMatrix:function(t,e,n,i){var o=new r.Matrix4,a=1/Math.tan(t/2),s=1/(n-i),l=[a/e,0,0,0,0,a,0,0,0,0,(i+n)*s,-1,0,0,2*i*n*s,0];return o.elements=l,o},makeOrthographicMatrix:function(t,e,n,i,o,a){var s=new r.Matrix4;const l=1/(e-t),c=1/(n-i),u=1/(a-o);var p=[2*l,0,0,0,0,2*c,0,0,0,0,-1*u,0,-(e+t)*l,-(n+i)*c,-o*u,1];return s.elements=p,s},radify:function(t){function e(t){return t=t||0,2*Math.PI*t/360}return"object"==typeof t?t.length>0?t.map((function(t){return e(t)})):[e(t.x),e(t.y),e(t.z)]:e(t)},degreeify:function(t){function e(t){return 360*(t=t||0)/(2*Math.PI)}return"object"==typeof t?[e(t.x),e(t.y),e(t.z)]:e(t)},projectToWorld:function(t){var e=[-i.MERCATOR_A*i.DEG2RAD*t[0]*i.PROJECTION_WORLD_SIZE,-i.MERCATOR_A*Math.log(Math.tan(.25*Math.PI+.5*i.DEG2RAD*t[1]))*i.PROJECTION_WORLD_SIZE];if(t[2]){var n=this.projectedUnitsPerMeter(t[1]);e.push(t[2]*n)}else e.push(0);return new r.Vector3(e[0],e[1],e[2])},projectedUnitsPerMeter:function(t){return Math.abs(i.WORLD_SIZE/Math.cos(i.DEG2RAD*t)/i.EARTH_CIRCUMFERENCE)},_circumferenceAtLatitude:function(t){return i.EARTH_CIRCUMFERENCE*Math.cos(t*Math.PI/180)},mercatorZfromAltitude:function(t,e){return t/this._circumferenceAtLatitude(e)},_scaleVerticesToMeters:function(t,e){for(var n=this.projectedUnitsPerMeter(t[1]),r=(this.projectToWorld(t),0);r{let{width:n,color:i}=e,o=(new r.BufferGeometry).setFromPoints(t.getPoints(100)),a=new r.LineBasicMaterial({color:i,linewidth:n});return new r.Line(o,a)},curvesToLines:t=>{var e=[16711680,2031360,2490623];return t.map(((t,n)=>curveToLine(t,{width:3,color:e[n]||"purple"})))},_validate:function(t,e){t=t||{};var n={};p.extend(n,t);for(let r of Object.keys(e))if(void 0===t[r]){if(null===e[r])return void console.error(r+" is required");n[r]=e[r]}else n[r]=t[r];return n},Validator:new l,exposedMethods:["projectToWorld","projectedUnitsPerMeter","extend","unprojectFromWorld"]};u=u=p;var h={};function d(t,e,n){this.map=t,this.camera=e,this.active=!0,this.camera.matrixAutoUpdate=!1,this.world=n||new r.Group,this.world.position.x=this.world.position.y=i.WORLD_SIZE/2,this.world.matrixAutoUpdate=!1,this.state={translateCenter:(new r.Matrix4).makeTranslation(i.WORLD_SIZE/2,-i.WORLD_SIZE/2,0),worldSizeRatio:i.TILE_SIZE/i.WORLD_SIZE,worldSize:i.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 t=this.map.transform;this.camera.aspect=t.width/t.height,this.halfFov=t._fov/2,this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*t.height;const e=t._maxPitch*Math.PI/180;this.acuteAngle=Math.PI/2-e,this.updateCamera()},updateCamera:function(t){if(!this.camera)return void console.log("nocamera");const e=this.map.transform;this.camera.aspect=e.width/e.height;const n=e.centerOffset||new r.Vector3;let i=0,o=0;this.halfFov=e._fov/2;const a=Math.PI/2+e._pitch,s=Math.cos(Math.PI/2-e._pitch);this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*e.height;let l=1;const c=this.worldSize();if(this.map.tb.mapboxVersion>=2){l=this.mercatorZfromAltitude(1,e.center.lat)*c;const t=e._fov*(.5+e.centerOffset.y/e.height),n=e.elevation?e.elevation.getMinElevationBelowMSL()*l:0,r=(e._camera.position[2]*c-n)/Math.cos(e._pitch);o=s*(Math.sin(t)*r/Math.sin(u.clamp(Math.PI-a-t,.01,Math.PI-.01)))+r;const p=r*(1/e._horizonShift);i=Math.min(1.01*o,p)}else i=1.01*(o=s*(Math.sin(this.halfFov)*this.cameraToCenterDistance/Math.sin(Math.PI-a-this.halfFov))+this.cameraToCenterDistance);this.cameraTranslateZ=(new r.Matrix4).makeTranslation(0,0,this.cameraToCenterDistance);const p=e.height/50,h=Math.max(p*s,p),f=e.height,m=e.width;this.camera instanceof r.OrthographicCamera?this.camera.projectionMatrix=u.makeOrthographicMatrix(m/-2,m/2,f/2,f/-2,h,i):this.camera.projectionMatrix=u.makePerspectiveMatrix(e._fov,m/f,h,i),this.camera.projectionMatrix.elements[8]=2*-n.x/e.width,this.camera.projectionMatrix.elements[9]=2*n.y/e.height;let g=this.calcCameraMatrix(e._pitch,e.angle);e.elevation&&(g.elements[14]=e._camera.position[2]*c),this.camera.matrixWorld.copy(g);let y=e.scale*this.state.worldSizeRatio,v=new r.Matrix4,_=new r.Matrix4,x=new r.Matrix4;v.makeScale(y,y,y);let b=e.x||e.point.x,w=e.y||e.point.y;_.makeTranslation(-b,w,0),x.makeRotationZ(Math.PI),this.world.matrix=(new r.Matrix4).premultiply(x).premultiply(this.state.translateCenter).premultiply(v).premultiply(_),this.map.fire("CameraSynced",{detail:{nearZ:h,farZ:i,pitch:e._pitch,angle:e.angle,furthestDistance:o,cameraToCenterDistance:this.cameraToCenterDistance,t:this.map.transform,tbProjMatrix:this.camera.projectionMatrix.elements,tbWorldMatrix:this.world.matrix.elements,cameraSyn:d}})},worldSize(){let t=this.map.transform;return t.tileSize*t.scale},worldSizeFromZoom(){let t=this.map.transform;return Math.pow(2,t.zoom)*t.tileSize},mercatorZfromAltitude(t,e){return t/this.circumferenceAtLatitude(e)},mercatorZfromZoom(){return this.cameraToCenterDistance/this.worldSizeFromZoom()},circumferenceAtLatitude:t=>i.EARTH_CIRCUMFERENCE*Math.cos(t*Math.PI/180),calcCameraMatrix(t,e,n){const i=this.map.transform,o=void 0===t?i._pitch:t,a=void 0===e?i.angle:e,s=void 0===n?this.cameraTranslateZ:n;return(new r.Matrix4).premultiply(s).premultiply((new r.Matrix4).makeRotationX(o)).premultiply((new r.Matrix4).makeRotationZ(a))},updateCameraState(){let t=this.map.transform;if(!t.height)return;const e=t._camera.forward(),n=t.cameraToCenterDistance,r=t.point,i=(t._cameraZoom?t._cameraZoom:t._zoom,this.mercatorZfromZoom(t)-this.mercatorZfromAltitude(t._centerAltitude,t.center.lat)),o=t.cameraToCenterDistance/i;return[r.x/this.worldSize()-e[0]*n/o,r.y/this.worldSize()-e[1]*n/o,this.mercatorZfromAltitude(t._centerAltitude,t._center.lat)+-e[2]*n/o]},getWorldToCamera(t,e){let n=this.map.transform;const i=new r.Matrix4,o=new r.Matrix4,a=n._camera._orientation,s=n._camera.position,l=new r.Vector3(s[0],s[1],s[2]),c=new r.Quaternion;c.set(a[0],a[1],a[2],a[3]);const u=c.conjugate();return l.multiplyScalar(-t),o.makeTranslation(l.x,l.y,l.z),i.makeRotationFromQuaternion(u).premultiply(o),i.elements[1]*=-1,i.elements[5]*=-1,i.elements[9]*=-1,i.elements[13]*=-1,i.elements[8]*=e,i.elements[9]*=e,i.elements[10]*=e,i.elements[11]*=e,i},translate(t,e,n){let r,i,o,a,s,l,c,u,p,h,d,f,m=n[0]||n.x,g=n[1]||n.y,y=n[2]||n.z;return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*y+e[12],t[13]=e[1]*m+e[5]*g+e[9]*y+e[13],t[14]=e[2]*m+e[6]*g+e[10]*y+e[14],t[15]=e[3]*m+e[7]*g+e[11]*y+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],p=e[8],h=e[9],d=e[10],f=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=p,t[9]=h,t[10]=d,t[11]=f,t[12]=r*m+s*g+p*y+e[12],t[13]=i*m+l*g+h*y+e[13],t[14]=o*m+c*g+d*y+e[14],t[15]=a*m+u*g+f*y+e[15]),t}},h=h=d;var f={};!function(){"use strict";var t=Math.PI,e=Math.sin,n=Math.cos,r=Math.tan,i=Math.asin,o=Math.atan2,a=Math.acos,s=t/180;function l(t){return t.valueOf()/864e5-.5+2440588}function c(t){return new Date(864e5*(t+.5-2440588))}function u(t){return l(t)-2451545}var p=23.4397*s;function h(t,i){return o(e(t)*n(p)-r(i)*e(p),n(t))}function d(t,r){return i(e(r)*n(p)+n(r)*e(p)*e(t))}function m(t,i,a){return o(e(t),n(t)*e(i)-r(a)*n(i))}function g(t,r,o){return i(e(r)*e(o)+n(r)*n(o)*n(t))}function y(t,e){return s*(280.16+360.9856235*t)-e}function v(t){return s*(357.5291+.98560028*t)}function _(n){return n+s*(1.9148*e(n)+.02*e(2*n)+3e-4*e(3*n))+102.9372*s+t}function x(t){var e=_(v(t));return{dec:d(e,0),ra:h(e,0)}}var b={getPosition:function(t,e,n){var r=s*-n,i=s*e,o=u(t),a=x(o),l=y(o,r)-a.ra;return{azimuth:m(l,i,a.dec),altitude:g(l,i,a.dec)}},toJulian:function(t){return l(t)}},w=b.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];b.addTime=function(t,e,n){w.push([t,e,n])};function M(e,n,r){return 9e-4+(e+n)/(2*t)+r}function S(t,n,r){return 2451545+t+.0053*e(n)-.0069*e(2*r)}function T(t,r,i,o,s,l,c){return S(M(function(t,r,i){return a((e(t)-e(r)*e(i))/(n(r)*n(i)))}(t,i,o),r,s),l,c)}function E(t){var r=s*(134.963+13.064993*t),i=s*(93.272+13.22935*t),o=s*(218.316+13.176396*t)+6.289*s*e(r),a=5.128*s*e(i),l=385001-20905*n(r);return{ra:h(o,a),dec:d(o,a),dist:l}}function A(t,e){return new Date(t.valueOf()+864e5*e/24)}b.getTimes=function(e,n,r,i){var o,a,l,p,h,f=s*-r,m=s*n,g=function(t){return-2.076*Math.sqrt(t)/60}(i=i||0),y=function(e,n){return Math.round(e-9e-4-n/(2*t))}(u(e),f),x=M(0,f,y),b=v(x),E=_(b),A=d(E,0),C=S(x,b,E),L={solarNoon:c(C),nadir:c(C-.5)};for(o=0,a=w.length;o=0&&(g=h-(v=Math.sqrt(f)/(2*Math.abs(u))),y=h+v,Math.abs(g)<=1&&m++,Math.abs(y)<=1&&m++,g<-1&&(g=y)),1===m?x<0?l=w+g:c=w+g:2===m&&(l=w+(d<0?y:g),c=w+(d<0?g:y)),!l||!c);w+=2)x=a;var M={};return l&&(M.rise=A(i,l)),c&&(M.set=A(i,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(t){var e;function n(){return new r[g.material]({color:g.color})}return t?((e=(t=u._validate(t,g)).material&&t.material.isMaterial?t.material:t.material||t.color||t.opacity?new r[t.material]({color:t.color,transparent:t.opacity<1}):n()).opacity=t.opacity,t.side&&(e.side=t.side)):e=n(),e};var y={};function v(t){this.map=t,this.enrolledObjects=[],this.previousFrameTime}v.prototype={unenroll:function(t){this.enrolledObjects.splice(this.enrolledObjects.indexOf(t),1)},enroll:function(t){if(t.clock=new r.Clock,t.hasDefaultAnimation=!1,t.defaultAction,t.actions=[],t.mixer,t.animations&&t.animations.length>0){t.hasDefaultAnimation=!0;let n=t.userData.defaultAnimation?t.userData.defaultAnimation:0;t.mixer=new r.AnimationMixer(t),e(n)}function e(e){for(let n=0;nt.animations.length&&console.log("The animation index "+e+" doesn't exist for this object");let r=t.animations[n],i=t.mixer.clipAction(r);t.actions.push(i),e===n?(t.defaultAction=i,i.setEffectiveWeight(1)):i.setEffectiveWeight(0),i.play()}}let n=!1;Object.defineProperty(t,"isPlaying",{get:()=>n,set(e){n!=e&&(n=e,t.dispatchEvent({type:"IsPlayingChanged",detail:t}))}}),this.enrolledObjects.push(t),t.animationQueue=[],t.set=function(e){if(e.duration>0){let n={start:Date.now(),expiration:Date.now()+e.duration,endState:{}};u.extend(e,n);let i=e.coords,o=e.rotation,a=e.scale||e.scaleX||e.scaleY||e.scaleZ;if(o){let n=t.rotation;e.startRotation=[n.x,n.y,n.z],e.endState.rotation=u.types.rotation(e.rotation,e.startRotation),e.rotationPerMs=e.endState.rotation.map((function(t,n){return(t-e.startRotation[n])/e.duration}))}if(a){let n=t.scale;e.startScale=[n.x,n.y,n.z],e.endState.scale=u.types.scale(e.scale,e.startScale),e.scalePerMs=e.endState.scale.map((function(t,n){return(t-e.startScale[n])/e.duration}))}i&&(e.pathCurve=new r.CatmullRomCurve3(u.lnglatsToWorld([t.coordinates,e.coords])));let s={type:"set",parameters:e};this.animationQueue.push(s),tb.map.repaint=!0}else this.stop(),e.rotation=u.radify(e.rotation),this._setObject(e);return this},t.animationMethod=null,t.stop=function(e){return t.mixer&&(t.isPlaying=!1,cancelAnimationFrame(t.animationMethod)),this.animationQueue=[],this},t.followPath=function(t,e){let n={type:"followPath",parameters:u._validate(t,_.followPath)};return u.extend(n.parameters,{pathCurve:new r.CatmullRomCurve3(u.lnglatsToWorld(t.path)),start:Date.now(),expiration:Date.now()+n.parameters.duration,cb:e}),this.animationQueue.push(n),tb.map.repaint=!0,this},t._setObject=function(e){t.setScale();let n=e.position,i=e.rotation,o=e.scale,a=e.worldCoordinates,s=e.quaternion,l=e.translate,c=e.worldTranslate;if(n){this.coordinates=n;let t=u.projectToWorld(n);this.position.copy(t)}if(l){this.coordinates=[this.coordinates[0]+l[0],this.coordinates[1]+l[1],this.coordinates[2]+l[2]];let t=u.projectToWorld(l);this.position.copy(t),e.position=this.coordinates}if(c){this.translateX(c.x),this.translateY(c.y),this.translateZ(c.z);let t=u.unprojectFromWorld(this.position);this.coordinates=e.position=t}if(i&&(this.rotation.set(i[0],i[1],i[2]),e.rotation=new r.Vector3(i[0],i[1],i[2])),o&&(this.scale.set(o[0],o[1],o[2]),e.scale=this.scale),s&&(this.quaternion.setFromAxisAngle(s[0],s[1]),e.rotation=s[0].multiplyScalar(s[1])),a){this.position.copy(a);let t=u.unprojectFromWorld(a);this.coordinates=e.position=t}this.setBoundingBoxShadowFloor(),this.setReceiveShadowFloor(),this.updateMatrixWorld(),tb.map.repaint=!0;let p={type:"ObjectChanged",detail:{object:this,action:{position:e.position,rotation:e.rotation,scale:e.scale}}};this.dispatchEvent(p)},t.playDefault=function(e){if(t.mixer&&t.hasDefaultAnimation){let n={start:Date.now(),expiration:Date.now()+e.duration,endState:{}};u.extend(e,n),t.mixer.timeScale=e.speed||1;let r={type:"playDefault",parameters:e};return this.animationQueue.push(r),tb.map.repaint=!0,this}},t.playAnimation=function(n){t.mixer&&(n.animation&&e(n.animation),t.playDefault(n))},t.pauseAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.paused=!0}))},t.unPauseAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.paused=!1}))},t.deactivateAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.stop()}))},t.activateAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.play()}))},t.idle=function(){return t.mixer&&t.mixer.update(.01),tb.map.repaint=!0,this}},update:function(t){if(void 0===this.previousFrameTime&&(this.previousFrameTime=t),!this.enrolledObjects)return!1;for(let e=this.enrolledObjects.length-1;e>=0;e--){let n=this.enrolledObjects[e];if(n.animationQueue&&0!==n.animationQueue.length)for(let e=n.animationQueue.length-1;e>=0;e--){let i=n.animationQueue[e];if(!i)continue;let o=i.parameters;if(!o.expiration)return n.animationQueue.splice(e,1),void(n.animationQueue[e]&&(n.animationQueue[e].parameters.start=t));if(t>=o.expiration)o.expiration=!1,"playDefault"===i.type?n.stop():(o.endState&&n._setObject(o.endState),void 0!==o.cb&&o.cb());else{let e=(t-o.start)/o.duration;if("set"===i.type){let t={};o.pathCurve&&(t.worldCoordinates=o.pathCurve.getPoint(e)),o.rotationPerMs&&(t.rotation=o.startRotation.map((function(t,n){return t+o.rotationPerMs[n]*e*o.duration}))),o.scalePerMs&&(t.scale=o.startScale.map((function(t,n){return t+o.scalePerMs[n]*e*o.duration}))),n._setObject(t)}if("followPath"===i.type){let t={worldCoordinates:o.pathCurve.getPointAt(e)};if(o.trackHeading){let n=o.pathCurve.getTangentAt(e).normalize(),i=new r.Vector3(0,0,0),a=new r.Vector3(0,1,0);i.crossVectors(a,n).normalize();let s=Math.acos(a.dot(n));t.quaternion=[i,s]}n._setObject(t)}"playDefault"===i.type&&(n.activateAllActions(),n.isPlaying=!0,n.animationMethod=requestAnimationFrame(this.update),n.mixer.update(n.clock.getDelta()),tb.map.repaint=!0)}}}this.previousFrameTime=t}};const _={followPath:{path:null,duration:1e3,trackHeading:!0}};y=y=v;var x={};!function(){class t extends r.Object3D{constructor(t){super(),this.element=t||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(t,e){return super.copy(t,e),this.element=t.element.cloneNode(!0),this}}t.prototype.isCSS2DObject=!0;const e=new r.Vector3,n=new r.Matrix4,i=new r.Matrix4,o=new r.Vector3,a=new r.Vector3;r.CSS2DObject=t,r.CSS2DRenderer=class{constructor(){const t=this;let r,s,l,c;const u={objects:new WeakMap,list:new Map};this.cacheList=u.list;const p=document.createElement("div");p.style.overflow="hidden",this.domElement=p,this.getSize=function(){return{width:r,height:s}},this.render=function(r,s){!0===r.autoUpdate&&r.updateMatrixWorld(),null===s.parent&&s.updateMatrixWorld(),n.copy(s.matrixWorldInverse),i.multiplyMatrices(s.projectionMatrix,n),function n(r,s,h){if(r.isCSS2DObject)if(r.visible){r.onBeforeRender(t,s,h),e.setFromMatrixPosition(r.matrixWorld),e.applyMatrix4(i);const n=r.element;var d;d=/apple/i.test(navigator.vendor)?"translate(-50%,-50%) translate("+Math.round(e.x*l+l)+"px,"+Math.round(-e.y*c+c)+"px)":"translate(-50%,-50%) translate("+(e.x*l+l)+"px,"+(-e.y*c+c)+"px)",n.style.WebkitTransform=d,n.style.MozTransform=d,n.style.oTransform=d,n.style.transform=d,n.style.display=r.visible&&e.z>=-1&&e.z<=1?"":"none";const g={distanceToCameraSquared:(f=h,m=r,o.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(m.matrixWorld),o.distanceToSquared(a))};u.objects.set({key:r.uuid},g),u.list.set(r.uuid,r),n.parentNode!==p&&p.appendChild(n),r.onAfterRender(t,s,h)}else u.objects.delete({key:r.uuid}),u.list.delete(r.uuid),r.remove();var f,m;for(let t=0,e=r.children.length;tt.getObjectByName("model")}),Object.defineProperty(t,"animations",{get(){const e=t.model;return e?e.animations:null}}),n.animationManager.enroll(t),t.setCoords=function(e){return t.userData.topMargin&&t.userData.feature&&(e[2]+=((t.userData.feature.properties.height||0)-(t.userData.feature.properties.base_height||t.userData.feature.properties.min_height||0))*(t.userData.topMargin||0)),t.coordinates=e,t.set({position:e}),t},t.setTranslate=function(e){return t.set({translate:e}),t},t.setRotation=function(e){"number"==typeof e&&(e={z:e});var n={x:u.radify(e.x)||t.rotation.x,y:u.radify(e.y)||t.rotation.y,z:u.radify(e.z)||t.rotation.z};t._setObject({rotation:[n.x,n.y,n.z]})},t.calculateAdjustedPosition=function(e,n,r){let i=e.slice(),o=u.unprojectFromWorld(t.modelSize);return r?(i[0]-=0!=n.x?o[0]/n.x:0,i[1]-=0!=n.y?o[1]/n.y:0,i[2]-=0!=n.z?o[2]/n.z:0):(i[0]+=0!=n.x?o[0]/n.x:0,i[1]+=0!=n.y?o[1]/n.y:0,i[2]+=0!=n.z?o[2]/n.z:0),i},t.setRotationAxis=function(e){"number"==typeof e&&(e={z:e});let n=t.modelBox(),i=new w.Vector3(n.max.x,n.max.y,n.min.z);0!=e.x&&r(t,i,new w.Vector3(0,0,1),e.x),0!=e.y&&r(t,i,new w.Vector3(0,0,1),e.y),0!=e.z&&r(t,i,new w.Vector3(0,0,1),e.z)},Object.defineProperty(t,"scaleGroup",{get:()=>t.getObjectByName("scaleGroup")}),Object.defineProperty(t,"boxGroup",{get:()=>t.getObjectByName("boxGroup")}),Object.defineProperty(t,"boundingBox",{get:()=>t.getObjectByName("boxModel")}),Object.defineProperty(t,"boundingBoxShadow",{get:()=>t.getObjectByName("boxShadow")}),t.drawBoundingBox=function(){let e=t.box3(),n=new w.Group;n.name="boxGroup",n.updateMatrixWorld(!0);let r=new w.Box3Helper(e,M.prototype._defaults.colors.yellow);r.name="boxModel",n.add(r),r.layers.disable(0);let i=e.clone();i.max.z=i.min.z;let o=new w.Box3Helper(i,M.prototype._defaults.colors.black);o.name="boxShadow",n.add(o),o.layers.disable(0),n.visible=!1,t.scaleGroup.add(n),t.setBoundingBoxShadowFloor()},t.setBoundingBoxShadowFloor=function(){if(t.boundingBoxShadow){let e=-t.modelHeight,n=t.rotation,r=t.boundingBoxShadow;r.box.max.z=r.box.min.z=e,r.rotation.y=n.y,r.rotation.x=-n.x}},t.setAnchor=function(e){const n=t.box3(),r=n.getCenter(new w.Vector3);switch(t.none={x:0,y:0,z:0},t.center={x:r.x,y:r.y,z:n.min.z},t.bottom={x:r.x,y:n.max.y,z:n.min.z},t.bottomLeft={x:n.max.x,y:n.max.y,z:n.min.z},t.bottomRight={x:n.min.x,y:n.max.y,z:n.min.z},t.top={x:r.x,y:n.min.y,z:n.min.z},t.topLeft={x:n.max.x,y:n.min.y,z:n.min.z},t.topRight={x:n.min.x,y:n.min.y,z:n.min.z},t.left={x:n.max.x,y:r.y,z:n.min.z},t.right={x:n.min.x,y:r.y,z:n.min.z},e){case"center":t.anchor=t.center;break;case"top":t.anchor=t.top;break;case"top-left":t.anchor=t.topLeft;break;case"top-right":t.anchor=t.topRight;break;case"left":t.anchor=t.left;break;case"right":t.anchor=t.right;break;case"bottom":t.anchor=t.bottom;break;case"bottom-left":default:t.anchor=t.bottomLeft;break;case"bottom-right":t.anchor=t.bottomRight;break;case"auto":case"none":t.anchor=t.none}t.model.position.set(-t.anchor.x,-t.anchor.y,-t.anchor.z)},t.setCenter=function(e){if(e&&(0!=e.x||0!=e.y||0!=e.z)){let n=t.getSize();t.anchor={x:t.anchor.x-n.x*e.x,y:t.anchor.y-n.y*e.y,z:t.anchor.z-n.z*e.z},t.model.position.set(-t.anchor.x,-t.anchor.y,-t.anchor.z)}},Object.defineProperty(t,"label",{get:()=>t.getObjectByName("label")}),Object.defineProperty(t,"tooltip",{get:()=>t.getObjectByName("tooltip")}),Object.defineProperty(t,"help",{get:()=>t.getObjectByName("help")});let o=!1;Object.defineProperty(t,"hidden",{get:()=>o,set(e){o!=e&&(o=e,t.visibility=!o)}}),Object.defineProperty(t,"visibility",{get:()=>t.visible,set(e){let n=e;if("visible"==e||1==e)n=!0,t.label&&(t.label.visible=n);else{if("none"!=e&&0!=e)return;n=!1,t.label&&t.label.alwaysVisible&&(t.label.visible=n),t.tooltip&&(t.tooltip.visible=n)}if(t.visible!=n){if(t.hidden&&n)return;t.visible=n,t.model&&t.model.traverse((function(e){"Mesh"!=e.type&&"SkinnedMesh"!=e.type||(n&&t.raycasted?e.layers.enable(0):e.layers.disable(0)),"LineSegments"==e.type&&e.layers.disableAll()}))}}}),t.addLabel=function(e,n,r,i){e&&t.drawLabelHTML(e,n,r,i)},t.removeLabel=function(){t.removeCSS2D("label")},t.drawLabelHTML=function(e,r=!1,i=t.anchor,o=.5){let a=n.drawLabelHTML(e,M.prototype._defaults.label.cssClass),s=t.addCSS2D(a,"label",i,o);return s.alwaysVisible=r,s.visible=r,s},t.addTooltip=function(e,n,r,i=!0,o=1){let a=t.addHelp(e,"tooltip",n,r,o);a.visible=!1,a.custom=i},t.removeTooltip=function(){t.removeCSS2D("tooltip")},t.addHelp=function(e,r="help",i=!1,o=t.anchor,a=0){let s=n.drawTooltip(e,i),l=t.addCSS2D(s,r,o,a);return l.visible=!0,l},t.removeHelp=function(){t.removeCSS2D("help")},t.addCSS2D=function(e,n,r=t.anchor,i=1){if(e){const o=t.box3(),a=o.getSize(new w.Vector3);let s={x:o.max.x,y:o.max.y,z:o.min.z};t.removeCSS2D(n);let l=new x.CSS2DObject(e);return l.name=n,l.position.set(.5*-a.x-t.model.position.x-r.x+s.x,.5*-a.y-t.model.position.y-r.y+s.y,a.z*i),l.visible=!1,t.scaleGroup.add(l),l}},t.removeCSS2D=function(e){let n=t.getObjectByName(e);if(n){n.dispose();let e=t.scaleGroup.children;e.splice(e.indexOf(n),1)}},Object.defineProperty(t,"shadowPlane",{get:()=>t.getObjectByName("shadowPlane")});let a=!1;Object.defineProperty(t,"castShadow",{get:()=>a,set(e){if(t.model&&a!==e){if(t.model.traverse((function(t){t.isMesh&&(t.castShadow=!0)})),e){const n=t.modelSize,r=[n.x,n.y,n.z,t.modelHeight],i=10*Math.max(...r),o=new w.PlaneBufferGeometry(i,i),a=new w.ShadowMaterial;a.opacity=.5;let s=new w.Mesh(o,a);s.name="shadowPlane",s.layers.enable(1),s.layers.disable(0),s.receiveShadow=e,t.add(s)}else t.traverse((function(e){e.isMesh&&e.material instanceof w.ShadowMaterial&&t.remove(e)}));a=e}}}),t.setReceiveShadowFloor=function(){if(t.castShadow){let e=t.shadowPlane,n=e.position,r=e.rotation;if(n.z=-t.modelHeight,r.y=t.rotation.y,r.x=-t.rotation.x,"meters"===t.userData.units){const r=t.modelSize,i=[r.x,r.y,r.z,-n.z],o=10*Math.max(...i)/e.geometry.parameters.width;e.scale.set(o,o,o)}}};let s=!1;Object.defineProperty(t,"receiveShadow",{get:()=>s,set(e){t.model&&s!==e&&(t.model.traverse((function(t){t.isMesh&&(t.receiveShadow=!0)})),s=e)}});let l=!1;Object.defineProperty(t,"wireframe",{get:()=>l,set(e){t.model&&l!==e&&(t.model.traverse((function(t){if("Mesh"==t.type||"SkinnedMesh"==t.type){let n=[];Array.isArray(t.material)?n=t.material:n.push(t.material);let r=n[0];e?(t.userData.materials=r,t.material=r.clone(),t.material.wireframe=t.material.transparent=e,t.material.opacity=.3):(t.material.dispose(),t.material=t.userData.materials,t.userData.materials.dispose(),t.userData.materials=null),e?(t.layers.disable(0),t.layers.enable(1)):(t.layers.disable(1),t.layers.enable(0))}"LineSegments"==t.type&&t.layers.disableAll()})),l=e,t.dispatchEvent({type:"Wireframed",detail:t}))}});let c=null;Object.defineProperty(t,"color",{get:()=>c,set(e){t.model&&c!==e&&(t.model.traverse((function(t){if("Mesh"==t.type||"SkinnedMesh"==t.type){let n=[];Array.isArray(t.material)?n=t.material:n.push(t.material);let r=n[0];e?(t.userData.materials=r,t.material=new w.MeshStandardMaterial,t.material.color.setHex(e)):(t.material.dispose(),t.material=t.userData.materials,t.userData.materials.dispose(),t.userData.materials=null)}})),c=e)}});let p=!1;Object.defineProperty(t,"selected",{get:()=>p,set(e){e?(t.userData.bbox&&!t.boundingBox&&t.drawBoundingBox(),t.boxGroup&&(t.boundingBox.material=M.prototype._defaults.materials.boxSelectedMaterial,t.boundingBox.parent.visible=!0,t.boundingBox.layers.enable(1),t.boundingBoxShadow.layers.enable(1)),t.label&&!t.label.alwaysVisible&&(t.label.visible=!0)):(t.boxGroup&&t.remove(t.boxGroup),t.label&&!t.label.alwaysVisible&&(t.label.visible=!1),t.removeHelp()),t.tooltip&&(t.tooltip.visible=e),p!=e&&(p=e,t.dispatchEvent({type:"SelectedChange",detail:t}))}});let h=!0;Object.defineProperty(t,"raycasted",{get:()=>h,set(e){t.model&&h!==e&&(t.model.traverse((function(t){"Mesh"!=t.type&&"SkinnedMesh"!=t.type||(e?(t.layers.disable(1),t.layers.enable(0)):(t.layers.disable(0),t.layers.enable(1)))})),h=e)}});let d=!1;Object.defineProperty(t,"over",{get:()=>d,set(e){e?(t.selected||(t.userData.bbox&&!t.boundingBox&&t.drawBoundingBox(),t.userData.tooltip&&!t.tooltip&&t.addTooltip(t.uuid,!0,t.anchor,!1),t.boxGroup&&(t.boundingBox.material=M.prototype._defaults.materials.boxOverMaterial,t.boundingBox.parent.visible=!0,t.boundingBox.layers.enable(1),t.boundingBoxShadow.layers.enable(1))),t.label&&!t.label.alwaysVisible&&(t.label.visible=!0),t.dispatchEvent({type:"ObjectMouseOver",detail:t})):(t.selected||(t.boxGroup&&(t.remove(t.boxGroup),t.tooltip&&!t.tooltip.custom&&t.removeTooltip()),t.label&&!t.label.alwaysVisible&&(t.label.visible=!1)),t.dispatchEvent({type:"ObjectMouseOut",detail:t})),t.tooltip&&(t.tooltip.visible=e||t.selected),d=e}}),t.box3=function(){let e;if(t.updateMatrix(),t.updateMatrixWorld(!0,!0),t.model){let n=t.clone(!0),r=t.model.clone();if(e=(new w.Box3).setFromObject(r),t.parent){let i=new w.Matrix4,o=new w.Matrix4;t.matrix.extractRotation(i),o.copy(i).invert(),n.setRotationFromMatrix(o),e=(new w.Box3).setFromObject(r)}}return e},t.modelBox=function(){return t.box3()},t.getSize=function(){return t.box3().getSize(new w.Vector3(0,0,0))};let f=!1;Object.defineProperty(t,"modelSize",{get:()=>f=t.getSize(),set(t){f!=t&&(f=t)}}),Object.defineProperty(t,"modelHeight",{get(){let e=t.coordinates[2]||0;return"scene"===t.userData.units&&(e*=t.unitsPerMeter/t.scale.x),e}}),Object.defineProperty(t,"unitsPerMeter",{get:()=>Number(u.projectedUnitsPerMeter(t.coordinates[1]).toFixed(7))}),Object.defineProperty(t,"fixedZoom",{get:()=>t.userData.fixedZoom,set(e){t.userData.fixedZoom!==e&&(t.userData.fixedZoom=e,t.userData.units=e?"scene":"meters")}}),t.setFixedZoom=function(e){if(null!=t.fixedZoom&&0!=t.fixedZoom){e||(e=t.userData.mapScale);let r=(n=t.fixedZoom,Math.pow(2,n));if(r>e){let n=r/e;t.scale.set(n,n,n)}else t.scale.set(1,1,1)}var n},t.setScale=function(e){if("scene"!=t.userData.units){let e=t.unitsPerMeter;t.scale.set(e,e,e)}else t.fixedZoom?(e&&(t.userData.mapScale=e),t.setFixedZoom(t.userData.mapScale)):t.scale.set(1,1,1)},t.setObjectScale=function(e){t.setScale(e),t.setBoundingBoxShadowFloor(),t.setReceiveShadowFloor()}}t.add=function(e){return t.scaleGroup.add(e),e.position.z=t.coordinates[2]?-t.coordinates[2]:0,e},t.remove=function(e){e&&(e.traverse((t=>{if(t.geometry&&t.geometry.dispose(),t.material)if(t.material.isMaterial)i(t.material);else for(const e of t.material)i(e);t.dispose&&t.dispose()})),t.scaleGroup.remove(e),tb.map.repaint=!0)},t.duplicate=function(e){let r=t.clone(!0);if(r.getObjectByName("model").animations=t.animations,r.userData.feature&&(e&&e.feature&&(r.userData.feature=e.feature),r.userData.feature.properties.uuid=r.uuid),n._addMethods(r),!e||u.equal(e.scale,t.userData.scale))return r.copyAnchor(t),r;{r.userData=e,r.userData.isGeoGroup=!0,r.remove(r.boxGroup);const t=u.types.rotation(e.rotation,[0,0,0]),n=u.types.scale(e.scale,[1,1,1]);return r.model.position.set(0,0,0),r.model.rotation.set(t[0],t[1],t[2]),r.model.scale.set(n[0],n[1],n[2]),r.setAnchor(e.anchor),r.setCenter(e.adjustment),r}},t.copyAnchor=function(e){t.anchor=e.anchor,t.none={x:0,y:0,z:0},t.center=e.center,t.bottom=e.bottom,t.bottomLeft=e.bottomLeft,t.bottomRight=e.bottomRight,t.top=e.top,t.topLeft=e.topLeft,t.topRight=e.topRight,t.left=e.left,t.right=e.right},t.dispose=function(){M.prototype.unenroll(t),t.traverse((t=>{if((!t.parent||"world"!=t.parent.name)&&"threeboxObject"!==t.name){if(t.geometry&&t.geometry.dispose(),t.material)if(t.material.isMaterial)i(t.material);else for(const e of t.material)i(e);t.dispose&&t.dispose()}})),t.children=[]};const i=t=>{t.dispose();for(const e of Object.keys(t)){const n=t[e];n&&"object"==typeof n&&"minFilter"in n&&n.dispose()}let e=t;(e.map||e.alphaMap||e.aoMap||e.bumpMap||e.displacementMap||e.emissiveMap||e.envMap||e.lightMap||e.metalnessMap||e.normalMap||e.roughnessMap)&&(e.map&&e.map.dispose(),e.alphaMap&&e.alphaMap.dispose(),e.aoMap&&e.aoMap.dispose(),e.bumpMap&&e.bumpMap.dispose(),e.displacementMap&&e.displacementMap.dispose(),e.emissiveMap&&e.emissiveMap.dispose(),e.envMap&&e.envMap.dispose(),e.lightMap&&e.lightMap.dispose(),e.metalnessMap&&e.metalnessMap.dispose(),e.normalMap&&e.normalMap.dispose(),e.roughnessMap&&e.roughnessMap.dispose())};return t},_makeGroup:function(t,e){let n=new w.Group;n.name="scaleGroup",n.add(t);var r=new w.Group;if(r.userData=e||{},r.userData.isGeoGroup=!0,r.userData.feature&&(r.userData.feature.properties.uuid=r.uuid),n.length)for(o of n)r.add(o);else r.add(n);return r.name="threeboxObject",r},animationManager:new y,drawTooltip:function(t,e=!1){if(t){let n;if(e){let e=document.createElement("div");e.className="mapboxgl-popup-content";let r=document.createElement("strong");r.innerHTML=t,e.appendChild(r);let i=document.createElement("div");i.className="mapboxgl-popup-tip";let o=document.createElement("div");o.className="marker mapboxgl-popup-anchor-bottom",o.appendChild(i),o.appendChild(e),(n=document.createElement("div")).className+="label3D",n.appendChild(o)}else(n=document.createElement("span")).className=this._defaults.tooltip.cssClass,n.innerHTML=t;return n}},drawLabelHTML:function(t,e){let n=document.createElement("div");return n.className+=e,n.innerHTML="string"==typeof t?t:t.outerHTML,n},_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 S={};S=S=function(t){let e=(t=u._validate(t,b.prototype._defaults.Object3D)).obj;const n=u.types.rotation(t.rotation,[0,0,0]),r=u.types.scale(t.scale,[1,1,1]);e.rotation.set(n[0],n[1],n[2]),e.scale.set(r[0],r[1],r[2]),e.name="model";let i=b.prototype._makeGroup(e,t);return t.obj.name="model",b.prototype._addMethods(i),i.setAnchor(t.anchor),i.setCenter(t.adjustment),i.raycasted=t.raycasted,i.visibility=!0,i};var T={};T=T=function(t){t=u._validate(t,b.prototype._defaults.sphere);let e=new r.SphereBufferGeometry(t.radius,t.sides,t.sides),n=m(t),i=new r.Mesh(e,n);return new S({obj:i,units:t.units,anchor:t.anchor,adjustment:t.adjustment,bbox:t.bbox,tooltip:t.tooltip,raycasted:t.raycasted})};var E={};function A(t){t=u._validate(t,b.prototype._defaults.extrusion);let e=A.prototype.buildShape(t.coordinates),n=A.prototype.buildGeometry(e,t.geometryOptions),i=new r.Mesh(n,t.materials);return t.obj=i,new S(t)}A.prototype={buildShape:function(t){if(t[0]instanceof(r.Vector2||r.Vector3))return new r.Shape(t);let e=new r.Shape;for(let n=0;n0?e[e.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(t){const e={index:"number"==typeof t?t:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return e.clone=this.clone.bind(e),e}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(t){const e=this.currentMaterial();if(e&&-1===e.groupEnd&&(e.groupEnd=this.geometry.vertices.length/3,e.groupCount=e.groupEnd-e.groupStart,e.inherited=!1),t&&this.materials.length>1)for(let t=this.materials.length-1;t>=0;t--)this.materials[t].groupCount<=0&&this.materials.splice(t,1);return t&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),e}},n&&n.name&&"function"==typeof n.clone){const t=n.clone(0);t.inherited=!0,this.object.materials.push(t)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(t,e){const n=parseInt(t,10);return 3*(n>=0?n-1:n+e/3)},parseNormalIndex:function(t,e){const n=parseInt(t,10);return 3*(n>=0?n-1:n+e/3)},parseUVIndex:function(t,e){const n=parseInt(t,10);return 2*(n>=0?n-1:n+e/2)},addVertex:function(t,e,n){const r=this.vertices,i=this.object.geometry.vertices;i.push(r[t+0],r[t+1],r[t+2]),i.push(r[e+0],r[e+1],r[e+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addVertexLine:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addNormal:function(t,e,n){const r=this.normals,i=this.object.geometry.normals;i.push(r[t+0],r[t+1],r[t+2]),i.push(r[e+0],r[e+1],r[e+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(t,e,n){const r=this.vertices,i=this.object.geometry.normals;o.fromArray(r,t),a.fromArray(r,e),s.fromArray(r,n),c.subVectors(s,a),l.subVectors(o,a),c.cross(l),c.normalize(),i.push(c.x,c.y,c.z),i.push(c.x,c.y,c.z),i.push(c.x,c.y,c.z)},addColor:function(t,e,n){const r=this.colors,i=this.object.geometry.colors;void 0!==r[t]&&i.push(r[t+0],r[t+1],r[t+2]),void 0!==r[e]&&i.push(r[e+0],r[e+1],r[e+2]),void 0!==r[n]&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(t,e,n){const r=this.uvs,i=this.object.geometry.uvs;i.push(r[t+0],r[t+1]),i.push(r[e+0],r[e+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){const t=this.object.geometry.uvs;t.push(0,0),t.push(0,0),t.push(0,0)},addUVLine:function(t){const e=this.uvs;this.object.geometry.uvs.push(e[t+0],e[t+1])},addFace:function(t,e,n,r,i,o,a,s,l){const c=this.vertices.length;let u=this.parseVertexIndex(t,c),p=this.parseVertexIndex(e,c),h=this.parseVertexIndex(n,c);if(this.addVertex(u,p,h),this.addColor(u,p,h),void 0!==a&&""!==a){const t=this.normals.length;u=this.parseNormalIndex(a,t),p=this.parseNormalIndex(s,t),h=this.parseNormalIndex(l,t),this.addNormal(u,p,h)}else this.addFaceNormal(u,p,h);if(void 0!==r&&""!==r){const t=this.uvs.length;u=this.parseUVIndex(r,t),p=this.parseUVIndex(i,t),h=this.parseUVIndex(o,t),this.addUV(u,p,h),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(t){this.object.geometry.type="Points";const e=this.vertices.length;for(let n=0,r=t.length;n=7?a.colors.push(parseFloat(t[4]),parseFloat(t[5]),parseFloat(t[6])):a.colors.push(void 0,void 0,void 0);break;case"vn":a.normals.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]));break;case"vt":a.uvs.push(parseFloat(t[1]),parseFloat(t[2]))}}else if("f"===c){const t=l.substr(1).trim().split(/\s+/),e=[];for(let n=0,r=t.length;n0){const t=r.split("/");e.push(t)}}const n=e[0];for(let t=1,r=e.length-1;t1){const t=h[1].trim().toLowerCase();a.object.smooth="0"!==t&&"off"!==t}else a.object.smooth=!0;const t=a.object.currentMaterial();t&&(t.smooth=a.object.smooth)}else{if("\0"===l)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}a.finalize();const f=new r.Group;if(f.materialLibraries=[].concat(a.materialLibraries),1==!(1===a.objects.length&&0===a.objects[0].geometry.vertices.length))for(let t=0,e=a.objects.length;t0&&c.setAttribute("normal",new r.Float32BufferAttribute(n.normals,3)),n.colors.length>0&&(l=!0,c.setAttribute("color",new r.Float32BufferAttribute(n.colors,3))),!0===n.hasUVIndices&&c.setAttribute("uv",new r.Float32BufferAttribute(n.uvs,2));const u=[];for(let t=0,e=i.length;t1){for(let t=0,e=i.length;t0){const t=new r.PointsMaterial({size:1,sizeAttenuation:!1}),e=new r.BufferGeometry;e.setAttribute("position",new r.Float32BufferAttribute(a.vertices,3)),a.colors.length>0&&void 0!==a.colors[0]&&(e.setAttribute("color",new r.Float32BufferAttribute(a.colors,3)),t.vertexColors=!0);const n=new r.Points(e,t);f.add(n)}return f}}}(),P=P=r.OBJLoader;var I={};!function(){class t{constructor(t="",e={}){this.baseUrl=t,this.options=e,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:r.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:r.RepeatWrapping}setCrossOrigin(t){return this.crossOrigin=t,this}setManager(t){this.manager=t}setMaterials(t){this.materialsInfo=this.convert(t),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(t){if(!this.options)return t;const e={};for(const n in t){const r=t[n],i={};e[n]=i;for(const t in r){let e=!0,n=r[t];const o=t.toLowerCase();switch(o){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(e=!1)}e&&(i[o]=n)}}return e}preload(){for(const t in this.materialsInfo)this.create(t)}getIndex(t){return this.nameLookup[t]}getAsArray(){let t=0;for(const e in this.materialsInfo)this.materialsArray[t]=this.create(e),this.nameLookup[e]=t,t++;return this.materialsArray}create(t){return void 0===this.materials[t]&&this.createMaterial_(t),this.materials[t]}createMaterial_(t){const e=this,n=this.materialsInfo[t],i={name:t,side:this.side};function o(t,n){if(i[t])return;const r=e.getTextureParams(n,i),o=e.loadTexture((a=e.baseUrl,"string"!=typeof(s=r.url)||""===s?"":/^https?:\/\//i.test(s)?s:a+s));var a,s;o.repeat.copy(r.scale),o.offset.copy(r.offset),o.wrapS=e.wrap,o.wrapT=e.wrap,i[t]=o}for(const t in n){const e=n[t];let a;if(""!==e)switch(t.toLowerCase()){case"kd":i.color=(new r.Color).fromArray(e);break;case"ks":i.specular=(new r.Color).fromArray(e);break;case"ke":i.emissive=(new r.Color).fromArray(e);break;case"map_kd":o("map",e);break;case"map_ks":o("specularMap",e);break;case"map_ke":o("emissiveMap",e);break;case"norm":o("normalMap",e);break;case"map_bump":case"bump":o("bumpMap",e);break;case"map_d":o("alphaMap",e),i.transparent=!0;break;case"ns":i.shininess=parseFloat(e);break;case"d":(a=parseFloat(e))<1&&(i.opacity=a,i.transparent=!0);break;case"tr":a=parseFloat(e),this.options&&this.options.invertTrProperty&&(a=1-a),a>0&&(i.opacity=1-a,i.transparent=!0)}}return this.materials[t]=new r.MeshPhongMaterial(i),this.materials[t]}getTextureParams(t,e){const n={scale:new r.Vector2(1,1),offset:new r.Vector2(0,0)},i=t.split(/\s+/);let o;return(o=i.indexOf("-bm"))>=0&&(e.bumpScale=parseFloat(i[o+1]),i.splice(o,2)),(o=i.indexOf("-s"))>=0&&(n.scale.set(parseFloat(i[o+1]),parseFloat(i[o+2])),i.splice(o,4)),(o=i.indexOf("-o"))>=0&&(n.offset.set(parseFloat(i[o+1]),parseFloat(i[o+2])),i.splice(o,4)),n.url=i.join(" ").trim(),n}loadTexture(t,e,n,i,o){const a=void 0!==this.manager?this.manager:r.DefaultLoadingManager;let s=a.getHandler(t);null===s&&(s=new r.TextureLoader(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);const l=s.load(t,n,i,o);return void 0!==e&&(l.mapping=e),l}}r.MTLLoader=class extends r.Loader{constructor(t){super(t)}load(t,e,n,i){const o=this,a=""===this.path?r.LoaderUtils.extractUrlBase(t||""):this.path,s=new r.FileLoader(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{e(o.parse(n,a))}catch(e){i?i(e):console.error(e),o.manager.itemError(t)}}),n,i)}setMaterialOptions(t){return this.materialOptions=t,this}parse(e,n){const r=e.split("\n");let i={};const o=/\s+/,a={};for(let t=0;t=0?e.substring(0,n):e;s=s.toLowerCase();let l=n>=0?e.substring(n+1):"";if(l=l.trim(),"newmtl"===s)i={name:l},a[l]=i;else if("ka"===s||"kd"===s||"ks"===s||"ke"===s){const t=l.split(o,3);i[s]=[parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2])]}else i[s]=l}const s=new t(this.resourcePath||n,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}}}(),I=I=r.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(t){if(R===setTimeout)return setTimeout(t,0);if((R===O||!R)&&setTimeout)return R=setTimeout,setTimeout(t,0);try{return R(t,0)}catch(e){try{return R.call(null,t,0)}catch(e){return R.call(this,t,0)}}}!function(){try{R="function"==typeof setTimeout?setTimeout:O}catch(t){R=O}try{k="function"==typeof clearTimeout?clearTimeout:F}catch(t){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 t=B(G);j=!0;for(var e=U.length;e;){for(N=U,U=[];++V1)for(var n=1;n>>1|(21845&y)<<1;g[y]=((65280&(v=(61680&(v=(52428&v)>>>2|(13107&v)<<2))>>>4|(3855&v)<<4))>>>8|(255&v)<<8)>>>1}var _=function(t,e,n){for(var r=t.length,o=0,a=new i(e);o>>c]=u}else for(s=new i(r),o=0;o>>15-t[o]);return s},x=new r(288);for(y=0;y<144;++y)x[y]=8;for(y=144;y<256;++y)x[y]=9;for(y=256;y<280;++y)x[y]=7;for(y=280;y<288;++y)x[y]=8;var b=new r(32);for(y=0;y<32;++y)b[y]=5;var w=_(x,9,0),M=_(x,9,1),S=_(b,5,0),T=_(b,5,1),E=function(t){for(var e=t[0],n=1;ne&&(e=t[n]);return e},A=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&n},C=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},L=function(t){return(t/8|0)+(7&t&&1)},P=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var a=new(t instanceof i?i:t instanceof o?o:r)(n-e);return a.set(t.subarray(e,n)),a},I=function(t,e,n){var i=t.length;if(!i||n&&!n.l&&i<5)return e||new r(0);var o=!e||n,c=!n||n.i;n||(n={}),e||(e=new r(3*i));var u=function(t){var n=e.length;if(t>n){var i=new r(Math.max(2*n,t));i.set(e),e=i}},h=n.f||0,d=n.p||0,m=n.b||0,g=n.l,y=n.d,v=n.m,x=n.n,b=8*i;do{if(!g){n.f=h=A(t,d,1);var w=A(t,d+1,3);if(d+=3,!w){var S=t[(j=L(d)+4)-4]|t[j-3]<<8,I=j+S;if(I>i){if(c)throw"unexpected EOF";break}o&&u(m+S),e.set(t.subarray(j,I),m),n.b=m+=S,n.p=d=8*I;continue}if(1==w)g=M,y=T,v=9,x=5;else{if(2!=w)throw"invalid block type";var R=A(t,d,31)+257,k=A(t,d+10,15)+4,z=R+A(t,d+5,31)+1;d+=14;for(var D=new r(z),O=new r(19),F=0;Fb)break;var U=_(O,B,1);for(F=0;F>>4)<16)D[F++]=j;else{var G=0,H=0;for(16==j?(H=3+A(t,d,3),d+=2,G=D[F-1]):17==j?(H=3+A(t,d,7),d+=3):18==j&&(H=11+A(t,d,127),d+=7);H--;)D[F++]=G}}var W=D.subarray(0,R),q=D.subarray(R);v=E(W),x=E(q),g=_(W,v,1),y=_(q,x,1)}if(d>b)throw"unexpected EOF"}o&&u(m+131072);for(var Z=(1<>>4;if((d+=15&G)>b)throw"unexpected EOF";if(!G)throw"invalid length/literal";if(J<256)e[m++]=J;else{if(256==J){g=null;break}var Y=J-254;J>264&&(Y=A(t,d,(1<<(tt=a[F=J-257]))-1)+p[F],d+=tt);var Q=y[C(t,d)&X],K=Q>>>4;if(!Q)throw"invalid distance";if(d+=15&Q,q=f[K],K>3){var tt=s[K];q+=C(t,d)&(1<b)throw"unexpected EOF";o&&u(m+131072);for(var et=m+Y;m>>8},k=function(t,e,n){var r=e/8|0;t[r]|=n<<=7&e,t[r+1]|=n>>>8,t[r+2]|=n>>>16},z=function(t,e){for(var n=[],o=0;of&&(f=s[o].s);var m=new i(f+1),g=D(n[h-1],m,0);if(g>e){o=0;var y=0,v=g-e,_=1<e))break;y+=_-(1<>>=v;y>0;){var b=s[o].s;m[b]=0&&y;--o){var w=s[o].s;m[w]==e&&(--m[w],++y)}g=e}return[new r(m),g]},D=function(t,e,n){return-1==t.s?Math.max(D(t.l,e,n+1),D(t.r,e,n+1)):e[t.s]=n},O=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new i(++e),r=0,o=t[0],a=1,s=function(t){n[r++]=t},l=1;l<=e;++l)if(t[l]==o&&l!=e)++a;else{if(!o&&a>2){for(;a>138;a-=138)s(32754);a>2&&(s(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(s(o),--a;a>6;a-=6)s(8304);a>2&&(s(a-3<<5|8208),a=0)}for(;a--;)s(o);a=1,o=t[l]}return[n.subarray(0,r),e]},F=function(t,e){for(var n=0,r=0;r>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var o=0;o4&&!j[l[G-1]];--G);var H,W,q,Z,X=d+5<<3,$=F(o,x)+F(c,b)+u,J=F(o,g)+F(c,M)+u+14+3*G+F(D,j)+(2*D[16]+3*D[17]+7*D[18]);if(X<=$&&X<=J)return B(e,f,t.subarray(h,h+d));if(R(e,f,1+(J<$)),f+=2,J<$){H=_(g,y,0),W=g,q=_(M,T,0),Z=M;var Y=_(j,V,0);for(R(e,f,C-257),R(e,f+5,I-1),R(e,f+10,G-4),f+=14,N=0;N15&&(R(e,f,tt[N]>>>5&127),f+=tt[N]>>>12)}}else H=w,W=x,q=S,Z=b;for(N=0;N255){var et;k(e,f,H[257+(et=r[N]>>>18&31)]),f+=W[et+257],et>7&&(R(e,f,r[N]>>>23&31),f+=a[et]);var nt=31&r[N];k(e,f,q[nt]),f+=Z[nt],nt>3&&(k(e,f,r[N]>>>5&8191),f+=s[nt])}else k(e,f,H[r[N]]),f+=W[r[N]];return k(e,f,H[256]),f+W[256]},U=new o([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),j=new r(0),V=function(t,e,n,l,c,u){var p=t.length,d=new r(l+p+5*(1+Math.ceil(p/7e3))+c),f=d.subarray(l,d.length-c),g=0;if(!e||p<8)for(var y=0;y<=p;y+=65535){var v=y+65535;v>>13,b=8191&_,w=(1<7e3||D>24576)&&W>423){g=N(t,f,0,C,I,R,z,D,F,y-F,g),D=k=z=0,F=y;for(var q=0;q<286;++q)I[q]=0;for(q=0;q<30;++q)R[q]=0}var Z=2,X=0,$=b,J=G-H&32767;if(W>2&&V==A(y-J))for(var Y=Math.min(x,W)-1,Q=Math.min(32767,y),K=Math.min(258,W);J<=Q&&--$&&G!=H;){if(t[y+Z]==t[y+Z-J]){for(var tt=0;ttZ){if(Z=tt,X=J,tt>Y)break;var et=Math.min(J,tt-2),nt=0;for(q=0;qnt&&(nt=it,H=rt)}}}J+=(G=H)-(H=M[G])+32768&32767}if(X){C[D++]=268435456|h[Z]<<18|m[X];var ot=31&h[Z],at=31&m[X];z+=a[ot]+s[at],++I[257+ot],++R[at],O=y+Z,++k}else C[D++]=t[y],++I[t[y]]}}g=N(t,f,u,C,I,R,z,D,F,y-F,g),!u&&7&g&&(g=B(f,g+1,j))}return P(d,0,l+L(g)+c)},G=function(){for(var t=new o(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),H=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r>>8;t=n},d:function(){return~t}}},W=function(){var t=1,e=0;return{p:function(n){for(var r=t,i=e,o=n.length,a=0;a!=o;){for(var s=Math.min(a+2655,o);a>16),i=(65535&i)+15*(i>>16)}t=r,e=i},d:function(){return((t%=65521)>>>8<<16|(255&(e%=65521))<<8|e>>>8)+2*((255&t)<<23)}}},q=function(t,e,n,r,i){return V(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,r,!i)},X=function(t,e){var n={};for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n},$=function(t,e,n){for(var r=t(),i=""+t,o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),a=0;a>>=8},ft=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&dt(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},mt=function(t){if(31!=t[0]||139!=t[1]||8!=t[2])throw"invalid gzip data";var e=t[3],n=10;4&e&&(n+=t[10]|2+(t[11]<<8));for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!t[n++]);return n+(2&e)},gt=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16)+2*(t[e-1]<<23)},yt=function(t){return 10+(t.filename&&t.filename.length+1||0)},vt=function(t,e){var n=e.level,r=0==n?0:n<6?1:9==n?3:2;t[0]=120,t[1]=r<<6|(r?32-2*r:1)},_t=function(t){if(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)throw"invalid zlib data";if(32&t[1])throw"invalid zlib data: preset dictionaries not supported"};function xt(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var bt=function(){function t(t,e){e||"function"!=typeof t||(e=t,t={}),this.ondata=e,this.o=t||{}}return t.prototype.p=function(t,e){this.ondata(q(t,this.o,0,0,!e),e)},t.prototype.push=function(t,e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=e,this.p(t,e||!1)},t}();e.Deflate=bt;var wt=function(t,e){ct([tt,function(){return[lt,bt]}],this,xt.call(this,t,e),(function(t){var e=new bt(t.data);onmessage=lt(e)}),6)};function Mt(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt],(function(t){return ot(St(t.data[0],t.data[1]))}),0,n)}function St(t,e){return q(t,e||{},0,0)}e.AsyncDeflate=wt,e.deflate=Mt,e.deflateSync=St;var Tt=function(){function t(t){this.s={},this.p=new r(0),this.ondata=t}return t.prototype.e=function(t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var e=this.p.length,n=new r(e+t.length);n.set(this.p),n.set(t,e),this.p=n},t.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,n=I(this.p,this.o,this.s);this.ondata(P(n,e,this.s.b),this.d),this.o=P(n,this.s.b-32768),this.s.b=this.o.length,this.p=P(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}();e.Inflate=Tt;var Et=function(t){this.ondata=t,ct([K,function(){return[lt,Tt]}],this,0,(function(){var t=new Tt;onmessage=lt(t)}),7)};function At(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[K],(function(t){return ot(Ct(t.data[0],at(t.data[1])))}),1,n)}function Ct(t,e){return I(t,e)}e.AsyncInflate=Et,e.inflate=At,e.inflateSync=Ct;var Lt=function(){function t(t,e){this.c=H(),this.l=0,this.v=1,bt.call(this,t,e)}return t.prototype.push=function(t,e){bt.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=q(t,this.o,this.v&&yt(this.o),e&&8,!e);this.v&&(ft(n,this.o),this.v=0),e&&(dt(n,n.length-8,this.c.d()),dt(n,n.length-4,this.l)),this.ondata(n,e)},t}();e.Gzip=Lt,e.Compress=Lt;var Pt=function(t,e){ct([tt,et,function(){return[lt,bt,Lt]}],this,xt.call(this,t,e),(function(t){var e=new Lt(t.data);onmessage=lt(e)}),8)};function It(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt,et,function(){return[Rt]}],(function(t){return ot(Rt(t.data[0],t.data[1]))}),2,n)}function Rt(t,e){e||(e={});var n=H(),r=t.length;n.p(t);var i=q(t,e,yt(e),8),o=i.length;return ft(i,e),dt(i,o-8,n.d()),dt(i,o-4,r),i}e.AsyncGzip=Pt,e.AsyncCompress=Pt,e.gzip=It,e.compress=It,e.gzipSync=Rt,e.compressSync=Rt;var kt=function(){function t(t){this.v=1,Tt.call(this,t)}return t.prototype.push=function(t,e){if(Tt.prototype.e.call(this,t),this.v){var n=this.p.length>3?mt(this.p):4;if(n>=this.p.length&&!e)return;this.p=this.p.subarray(n),this.v=0}if(e){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Tt.prototype.c.call(this,e)},t}();e.Gunzip=kt;var zt=function(t){this.ondata=t,ct([K,nt,function(){return[lt,Tt,kt]}],this,0,(function(){var t=new kt;onmessage=lt(t)}),9)};function Dt(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[K,nt,function(){return[Ot]}],(function(t){return ot(Ot(t.data[0]))}),3,n)}function Ot(t,e){return I(t.subarray(mt(t),-8),e||new r(gt(t)))}e.AsyncGunzip=zt,e.gunzip=Dt,e.gunzipSync=Ot;var Ft=function(){function t(t,e){this.c=W(),this.v=1,bt.call(this,t,e)}return t.prototype.push=function(t,e){bt.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var n=q(t,this.o,this.v&&2,e&&4,!e);this.v&&(vt(n,this.o),this.v=0),e&&dt(n,n.length-4,this.c.d()),this.ondata(n,e)},t}();e.Zlib=Ft;function Bt(t,e){e||(e={});var n=W();n.p(t);var r=q(t,e,2,4);return vt(r,e),dt(r,r.length-4,n.d()),r}e.AsyncZlib=function(t,e){ct([tt,rt,function(){return[lt,bt,Ft]}],this,xt.call(this,t,e),(function(t){var e=new Ft(t.data);onmessage=lt(e)}),10)},e.zlib=function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt,rt,function(){return[Bt]}],(function(t){return ot(Bt(t.data[0],t.data[1]))}),4,n)},e.zlibSync=Bt;var Nt=function(){function t(t){this.v=1,Tt.call(this,t)}return t.prototype.push=function(t,e){if(Tt.prototype.e.call(this,t),this.v){if(this.p.length<2&&!e)return;this.p=this.p.subarray(2),this.v=0}if(e){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Tt.prototype.c.call(this,e)},t}();e.Unzlib=Nt;var Ut=function(t){this.ondata=t,ct([K,it,function(){return[lt,Tt,Nt]}],this,0,(function(){var t=new Nt;onmessage=lt(t)}),11)};function jt(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[K,it,function(){return[Vt]}],(function(t){return ot(Vt(t.data[0],at(t.data[1])))}),5,n)}function Vt(t,e){return I((_t(t),t.subarray(2,-4)),e)}e.AsyncUnzlib=Ut,e.unzlib=jt,e.unzlibSync=Vt;var Gt=function(){function t(t){this.G=kt,this.I=Tt,this.Z=Nt,this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var n=new r(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var i=this,o=function(){i.ondata.apply(i,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,e),this.p=null}}},t}();e.Decompress=Gt;var Ht=function(){function t(t){this.G=zt,this.I=Et,this.Z=Ut,this.ondata=t}return t.prototype.push=function(t,e){Gt.prototype.push.call(this,t,e)},t}();e.AsyncDecompress=Ht,e.decompress=function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return 31==t[0]&&139==t[1]&&8==t[2]?Dt(t,e,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?At(t,e,n):jt(t,e,n)},e.decompressSync=function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?Ot(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Ct(t,e):Vt(t,e)};var Wt=function(t,e,n,i){for(var o in t){var a=t[o],s=e+o;a instanceof r?n[s]=[a,i]:Array.isArray(a)?n[s]=[a[0],X(i,a[1])]:Wt(a,s+"/",n,i)}},qt="undefined"!=typeof TextEncoder&&new TextEncoder,Zt="undefined"!=typeof TextDecoder&&new TextDecoder,Xt=0;try{Zt.decode(j,{stream:!0}),Xt=1}catch(n){}var $t=function(t){for(var e="",n=0;;){var r=t[n++],i=(r>127)+(r>223)+(r>239);if(n+i>t.length)return[e,P(t,n-1)];i?3==i?(r=((15&r)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536,e+=String.fromCharCode(55296|r>>10,56320|1023&r)):e+=String.fromCharCode(1&i?(31&r)<<6|63&t[n++]:(15&r)<<12|(63&t[n++])<<6|63&t[n++]):e+=String.fromCharCode(r)}},Jt=function(){function t(t){this.ondata=t,Xt?this.t=new TextDecoder:this.p=j}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";if(e||(e=!1),this.t)return this.ondata(this.t.decode(t,{stream:!e}),e);var n=new r(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var i=$t(n),o=i[0],a=i[1];if(e&&a.length)throw"invalid utf-8 data";this.p=a,this.ondata(o,e)},t}();e.DecodeUTF8=Jt;var Yt=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";this.ondata(Qt(t),e||!1)},t}();function Qt(t,e){if(e){for(var n=new r(t.length),i=0;i>1)),s=0,l=function(t){a[s++]=t};for(i=0;ia.length){var c=new r(s+8+(o-i<<1));c.set(a),a=c}var u=t.charCodeAt(i);u<128||e?l(u):u<2048?(l(192|u>>>6),l(128|63&u)):u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++i))>>>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 P(a,0,s)}function Kt(t,e){if(e){for(var n="",r=0;r65535)throw"extra field too long";e+=r+4}return e},oe=function(t,e,n,r,i,o,a,s){var l=r.length,c=n.extra,u=s&&s.length,p=ie(c);dt(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(null==o&&8),t[e++]=i&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var h=new Date(null==n.mtime?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(dt(t,e,2*(d<<24)|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>>1),e+=4,null!=o&&(dt(t,e,n.crc),dt(t,e+4,o),dt(t,e+8,n.size)),dt(t,e+12,l),dt(t,e+14,p),e+=16,null!=a&&(dt(t,e,u),dt(t,e+6,n.attrs),dt(t,e+10,a),e+=14),t.set(r,e),e+=l,p)for(var f in c){var m=c[f],g=m.length;dt(t,e,+f),dt(t,e+2,g),t.set(m,e+4),e+=4+g}return u&&(t.set(s,e),e+=u),e},ae=function(t,e,n,r,i){dt(t,e,101010256),dt(t,e+8,n),dt(t,e+10,n),dt(t,e+12,r),dt(t,e+16,i)},se=function(){function t(t){this.filename=t,this.c=H(),this.size=0,this.compression=0}return t.prototype.process=function(t,e){this.ondata(null,t,e)},t.prototype.push=function(t,e){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},t}();e.ZipPassThrough=se;var le=function(){function t(t,e){var n=this;e||(e={}),se.call(this,t),this.d=new bt(e,(function(t,e){n.ondata(null,t,e)})),this.compression=8,this.flag=te(e.level)}return t.prototype.process=function(t,e){try{this.d.push(t,e)}catch(t){this.ondata(t,null,e)}},t.prototype.push=function(t,e){se.prototype.push.call(this,t,e)},t}();e.ZipDeflate=le;var ce=function(){function t(t,e){var n=this;e||(e={}),se.call(this,t),this.d=new wt(e,(function(t,e,r){n.ondata(t,e,r)})),this.compression=8,this.flag=te(e.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,e){this.d.push(t,e)},t.prototype.push=function(t,e){se.prototype.push.call(this,t,e)},t}();e.AsyncZipDeflate=ce;var ue=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var e=this;if(2&this.d)throw"stream finished";var n=Qt(t.filename),i=n.length,o=t.comment,a=o&&Qt(o),s=i!=t.filename.length||a&&o.length!=a.length,l=i+ie(t.extra)+30;if(i>65535)throw"filename too long";var c=new r(l);oe(c,0,t,n,s);var u=[c],p=function(){for(var t=0,n=u;t65535&&S("filename too long",null),M)if(g<16e4)try{S(null,St(c,f))}catch(t){S(t,null)}else p.push(Mt(c,f,S));else S(null,c)},m=0;m65535)throw"filename too long";var y=p?St(c,u):c,v=y.length,_=H();_.p(c),i.push(X(u,{size:c.length,crc:_.d(),c:y,f:S,m:f,u:h!=s.length||f&&d.length!=m,o:o,compression:p})),o+=30+h+g+v,a+=76+2*(h+g)+(m||0)+v}for(var x=new r(a+22),b=o,w=a-o,M=0;M0){var i=Math.min(this.c,t.length),o=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(o,!this.c):this.k[0].push(o),(t=t.subarray(i)).length)return this.push(t,e)}else{var a=0,s=0,l=void 0,c=void 0;this.p.length?t.length?((c=new r(this.p.length+t.length)).set(this.p),c.set(t,this.p.length)):c=this.p:c=t;for(var u=c.length,p=this.c,h=p&&this.d,d=function(){var t,e=pt(c,s);if(67324752==e){a=1,l=s,f.d=null,f.c=0;var r=ut(c,s+6),i=ut(c,s+8),o=2048&r,h=8&r,d=ut(c,s+26),m=ut(c,s+28);if(u>s+30+d+m){var g=[];f.k.unshift(g),a=2;var y=pt(c,s+18),v=pt(c,s+22),_=Kt(c.subarray(s+30,s+=30+d),!o);4294967295==y?(t=h?[-2]:re(c,s),y=t[0],v=t[1]):h&&(y=-1),s+=m,f.c=y;var x={name:_,compression:i,start:function(){if(!x.ondata)throw"no callback";if(y){var t=n.o[i];if(!t)throw"unknown compression type "+i;var e=y<0?new t(_):new t(_,y,v);e.ondata=function(t,e,n){x.ondata(t,e,n)};for(var r=0,o=g;r=0&&(x.size=y,x.originalSize=v),f.onfile(x)}return"break"}if(p){if(134695760==e)return l=s+=12+(-2==p&&8),a=2,f.c=0,"break";if(33639248==e)return l=s-=4,a=2,f.c=0,"break"}},f=this;s65558)return void e("invalid zip file",null);var s=ut(t,a+8);s||e(null,{});var l=s,c=pt(t,a+16),u=4294967295==c;if(u){if(a=pt(t,a-12),101075792!=pt(t,a))return void e("invalid zip file",null);l=s=pt(t,a+32),c=pt(t,a+48)}for(var p=function(a){var l=ne(t,c,u),p=l[0],h=l[1],d=l[2],f=l[3],m=l[4],g=ee(t,l[5]);c=m;var y=function(t,n){t?(i(),e(t,null)):(o[f]=n,--s||e(null,o))};if(p)if(8==p){var v=t.subarray(g,g+h);if(h<32e4)try{y(null,Ct(v,new r(d)))}catch(t){y(t,null)}else n.push(At(v,{size:d},y))}else y("unknown compression type "+p,null);else y(null,P(t,g,g+h))},h=0;h65558)throw"invalid zip file";var i=ut(t,n+8);if(!i)return{};var o=pt(t,n+16),a=4294967295==o;if(a){if(n=pt(t,n-12),101075792!=pt(t,n))throw"invalid zip file";i=pt(t,n+32),o=pt(t,n+48)}for(var s=0;s0,o="string"==typeof i.Content&&""!==i.Content;if(e||o){const e=this.parseImage(r[t]);n[i.RelativeFilename||i.Filename]=e}}}}for(const t in e){const r=e[t];void 0!==n[r]?e[t]=n[r]:e[t]=e[t].split("\\").pop()}return e}parseImage(t){const e=t.Content,n=t.RelativeFilename||t.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(r){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof e)return"data:"+i+";base64,"+e;{const t=new Uint8Array(e);return window.URL.createObjectURL(new Blob([t],{type:i}))}}parseTextures(e){const n=new Map;if("Texture"in t.Objects){const r=t.Objects.Texture;for(const t in r){const i=this.parseTexture(r[t],e);n.set(parseInt(t),i)}}return n}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const i=t.WrapModeU,o=t.WrapModeV,a=void 0!==i?i.value:0,s=void 0!==o?o.value:0;if(n.wrapS=0===a?r.RepeatWrapping:r.ClampToEdgeWrapping,n.wrapT=0===s?r.RepeatWrapping:r.ClampToEdgeWrapping,"Scaling"in t){const e=t.Scaling.value;n.repeat.x=e[0],n.repeat.y=e[1]}return n}loadTexture(t,n){let i;const o=this.textureLoader.path,a=e.get(t.id).children;let s;void 0!==a&&a.length>0&&void 0!==n[a[0].ID]&&(0!==(i=n[a[0].ID]).indexOf("blob:")&&0!==i.indexOf("data:")||this.textureLoader.setPath(void 0));const l=t.FileName.slice(-3).toLowerCase();if("tga"===l){const e=this.manager.getHandler(".tga");null===e?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),s=new r.Texture):(e.setPath(this.textureLoader.path),s=e.load(i))}else"psd"===l?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),s=new r.Texture):s=this.textureLoader.load(i);return this.textureLoader.setPath(o),s}parseMaterials(e){const n=new Map;if("Material"in t.Objects){const r=t.Objects.Material;for(const t in r){const i=this.parseMaterial(r[t],e);null!==i&&n.set(parseInt(t),i)}}return n}parseMaterial(t,n){const i=t.id,o=t.attrName;let a=t.ShadingModel;if("object"==typeof a&&(a=a.value),!e.has(i))return null;const s=this.parseParameters(t,n,i);let l;switch(a.toLowerCase()){case"phong":l=new r.MeshPhongMaterial;break;case"lambert":l=new r.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to THREE.MeshPhongMaterial.',a),l=new r.MeshPhongMaterial}return l.setValues(s),l.name=o,l}parseParameters(t,n,i){const o={};t.BumpFactor&&(o.bumpScale=t.BumpFactor.value),t.Diffuse?o.color=(new r.Color).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(o.color=(new r.Color).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(o.displacementScale=t.DisplacementFactor.value),t.Emissive?o.emissive=(new r.Color).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(o.emissive=(new r.Color).fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(o.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(o.opacity=parseFloat(t.Opacity.value)),o.opacity<1&&(o.transparent=!0),t.ReflectionFactor&&(o.reflectivity=t.ReflectionFactor.value),t.Shininess&&(o.shininess=t.Shininess.value),t.Specular?o.specular=(new r.Color).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(o.specular=(new r.Color).fromArray(t.SpecularColor.value));const a=this;return e.get(i).children.forEach((function(t){const e=t.relationship;switch(e){case"Bump":o.bumpMap=a.getTexture(n,t.ID);break;case"Maya|TEX_ao_map":o.aoMap=a.getTexture(n,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=a.getTexture(n,t.ID),void 0!==o.map&&(o.map.encoding=r.sRGBEncoding);break;case"DisplacementColor":o.displacementMap=a.getTexture(n,t.ID);break;case"EmissiveColor":o.emissiveMap=a.getTexture(n,t.ID),void 0!==o.emissiveMap&&(o.emissiveMap.encoding=r.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=a.getTexture(n,t.ID);break;case"ReflectionColor":o.envMap=a.getTexture(n,t.ID),void 0!==o.envMap&&(o.envMap.mapping=r.EquirectangularReflectionMapping,o.envMap.encoding=r.sRGBEncoding);break;case"SpecularColor":o.specularMap=a.getTexture(n,t.ID),void 0!==o.specularMap&&(o.specularMap.encoding=r.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=a.getTexture(n,t.ID),o.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",e)}})),o}getTexture(n,r){return"LayeredTexture"in t.Objects&&r in t.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),r=e.get(r).children[0].ID),n.get(r)}parseDeformers(){const n={},r={};if("Deformer"in t.Objects){const i=t.Objects.Deformer;for(const t in i){const o=i[t],a=e.get(parseInt(t));if("Skin"===o.attrType){const e=this.parseSkeleton(a,i);e.ID=t,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),e.geometryID=a.parents[0].ID,n[t]=e}else if("BlendShape"===o.attrType){const e={id:t};e.rawTargets=this.parseMorphTargets(a,i),e.id=t,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),r[t]=e}}}return{skeletons:n,morphTargets:r}}parseSkeleton(t,e){const n=[];return t.children.forEach((function(t){const i=e[t.ID];if("Cluster"!==i.attrType)return;const o={ID:t.ID,indices:[],weights:[],transformLink:(new r.Matrix4).fromArray(i.TransformLink.a)};"Indexes"in i&&(o.indices=i.Indexes.a,o.weights=i.Weights.a),n.push(o)})),{rawBones:n,bones:[]}}parseMorphTargets(t,n){const r=[];for(let i=0;i1?a=s:s.length>0?a=s[0]:(a=new r.MeshPhongMaterial({color:13421772}),s.push(a)),"color"in o.attributes&&s.forEach((function(t){t.vertexColors=!0})),o.FBX_Deformer?(i=new r.SkinnedMesh(o,a)).normalizeSkinWeights():i=new r.Mesh(o,a),i}createCurve(t,e){const n=t.children.reduce((function(t,n){return e.has(n.ID)&&(t=e.get(n.ID)),t}),null),i=new r.LineBasicMaterial({color:3342591,linewidth:1});return new r.Line(n,i)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),n.eulerOrder="RotationOrder"in e?v(e.RotationOrder.value):"ZYX","Lcl_Translation"in e&&(n.translation=e.Lcl_Translation.value),"PreRotation"in e&&(n.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(n.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(n.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(n.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(n.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(n.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(n.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(n.rotationPivot=e.RotationPivot.value),t.userData.transformData=n}setLookAtProperties(i,o){"LookAtProperty"in o&&e.get(i.ID).children.forEach((function(e){if("LookAtProperty"===e.relationship){const o=t.Objects.Model[e.ID];if("Lcl_Translation"in o){const t=o.Lcl_Translation.value;void 0!==i.target?(i.target.position.fromArray(t),n.add(i.target)):i.lookAt((new r.Vector3).fromArray(t))}}}))}bindSkeleton(t,n,i){const o=this.parsePoseNodes();for(const a in t){const s=t[a];e.get(parseInt(s.ID)).parents.forEach((function(t){if(n.has(t.ID)){const n=t.ID;e.get(n).parents.forEach((function(t){i.has(t.ID)&&i.get(t.ID).bind(new r.Skeleton(s.bones),o[t.ID])}))}}))}}parsePoseNodes(){const e={};if("Pose"in t.Objects){const n=t.Objects.Pose;for(const t in n)if("BindPose"===n[t].attrType){const i=n[t].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new r.Matrix4).fromArray(t.Matrix.a)})):e[i.Node]=(new r.Matrix4).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in t&&"AmbientColor"in t.GlobalSettings){const e=t.GlobalSettings.AmbientColor.value,i=e[0],o=e[1],a=e[2];if(0!==i||0!==o||0!==a){const t=new r.Color(i,o,a);n.add(new r.AmbientLight(t,1))}}}}class o{parse(n){const r=new Map;if("Geometry"in t.Objects){const i=t.Objects.Geometry;for(const t in i){const o=e.get(parseInt(t)),a=this.parseGeometry(o,i[t],n);r.set(parseInt(t),a)}}return r}parseGeometry(t,e,n){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,n);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(e,n,r){const i=r.skeletons,o=[],a=e.parents.map((function(e){return t.Objects.Model[e.ID]}));if(0===a.length)return;const s=e.children.reduce((function(t,e){return void 0!==i[e.ID]&&(t=i[e.ID]),t}),null);e.children.forEach((function(t){void 0!==r.morphTargets[t.ID]&&o.push(r.morphTargets[t.ID])}));const l=a[0],c={};"RotationOrder"in l&&(c.eulerOrder=v(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=y(c);return this.genGeometry(n,s,o,u)}genGeometry(t,e,n,i){const o=new r.BufferGeometry;t.attrName&&(o.name=t.attrName);const a=this.parseGeoNode(t,e),s=this.genBuffers(a),l=new r.Float32BufferAttribute(s.vertex,3);if(l.applyMatrix4(i),o.setAttribute("position",l),s.colors.length>0&&o.setAttribute("color",new r.Float32BufferAttribute(s.colors,3)),e&&(o.setAttribute("skinIndex",new r.Uint16BufferAttribute(s.weightsIndices,4)),o.setAttribute("skinWeight",new r.Float32BufferAttribute(s.vertexWeights,4)),o.FBX_Deformer=e),s.normal.length>0){const t=(new r.Matrix3).getNormalMatrix(i),e=new r.Float32BufferAttribute(s.normal,3);e.applyNormalMatrix(t),o.setAttribute("normal",e)}if(s.uvs.forEach((function(t,e){let n="uv"+(e+1).toString();0===e&&(n="uv"),o.setAttribute(n,new r.Float32BufferAttribute(s.uvs[e],2))})),a.material&&"AllSame"!==a.material.mappingType){let t=s.materialIndex[0],e=0;if(s.materialIndex.forEach((function(n,r){n!==t&&(o.addGroup(e,r-e,t),t=n,e=r)})),o.groups.length>0){const e=o.groups[o.groups.length-1],n=e.start+e.count;n!==s.materialIndex.length&&o.addGroup(n,s.materialIndex.length-n,t)}0===o.groups.length&&o.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(o,t,n,i),o}parseGeoNode(t,e){const n={};if(n.vertexPositions=void 0!==t.Vertices?t.Vertices.a:[],n.vertexIndices=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(n.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(n.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(n.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){n.uv=[];let e=0;for(;t.LayerElementUV[e];)t.LayerElementUV[e].UV&&n.uv.push(this.parseUVs(t.LayerElementUV[e])),e++}return n.weightTable={},null!==e&&(n.skeleton=e,e.rawBones.forEach((function(t,e){t.indices.forEach((function(r,i){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:e,weight:t.weights[i]})}))}))),n}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,i=!1,o=[],a=[],s=[],l=[],c=[],u=[];const p=this;return t.vertexIndices.forEach((function(h,d){let m,g=!1;h<0&&(h^=-1,g=!0);let y=[],v=[];if(o.push(3*h,3*h+1,3*h+2),t.color){const e=f(d,n,h,t.color);s.push(e[0],e[1],e[2])}if(t.skeleton){if(void 0!==t.weightTable[h]&&t.weightTable[h].forEach((function(t){v.push(t.weight),y.push(t.id)})),v.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const t=[0,0,0,0],e=[0,0,0,0];v.forEach((function(n,r){let i=n,o=y[r];e.forEach((function(e,n,r){if(i>e){r[n]=i,i=e;const a=t[n];t[n]=o,o=a}}))})),y=t,v=e}for(;v.length<4;)v.push(0),y.push(0);for(let t=0;t<4;++t)c.push(v[t]),u.push(y[t])}if(t.normal){const e=f(d,n,h,t.normal);a.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(m=f(d,n,h,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const r=f(d,n,h,t);void 0===l[e]&&(l[e]=[]),l[e].push(r[0]),l[e].push(r[1])})),r++,g&&(p.genFace(e,t,o,m,a,s,l,c,u,r),n++,r=0,o=[],a=[],s=[],l=[],c=[],u=[])})),e}genFace(t,e,n,r,i,o,a,s,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 a=n.get(o[0].ID);i[t]={name:r[t].attrName,layer:a}}return i}addClip(t){let e=[];const n=this;return t.layer.forEach((function(t){e=e.concat(n.generateTracks(t))})),new r.AnimationClip(t.name,-1,e)}generateTracks(t){const e=[];let n=new r.Vector3,i=new r.Quaternion,o=new r.Vector3;if(t.transform&&t.transform.decompose(n,i,o),n=n.toArray(),i=(new r.Euler).setFromQuaternion(i,t.eulerOrder).toArray(),o=o.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const r=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");void 0!==r&&e.push(r)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const n=this.generateRotationTrack(t.modelName,t.R.curves,i,t.preRotation,t.postRotation,t.eulerOrder);void 0!==n&&e.push(n)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const n=this.generateVectorTrack(t.modelName,t.S.curves,o,"scale");void 0!==n&&e.push(n)}if(void 0!==t.DeformPercent){const n=this.generateMorphTrack(t);void 0!==n&&e.push(n)}return e}generateVectorTrack(t,e,n,i){const o=this.getTimesForAllAxes(e),a=this.getKeyframeTrackValues(o,e,n);return new r.VectorKeyframeTrack(t+"."+i,o,a)}generateRotationTrack(t,e,n,i,o,a){void 0!==e.x&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(r.MathUtils.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(r.MathUtils.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(r.MathUtils.degToRad));const s=this.getTimesForAllAxes(e),l=this.getKeyframeTrackValues(s,e,n);void 0!==i&&((i=i.map(r.MathUtils.degToRad)).push(a),i=(new r.Euler).fromArray(i),i=(new r.Quaternion).setFromEuler(i)),void 0!==o&&((o=o.map(r.MathUtils.degToRad)).push(a),o=(new r.Euler).fromArray(o),o=(new r.Quaternion).setFromEuler(o).invert());const c=new r.Quaternion,u=new r.Euler,p=[];for(let t=0;t1){let t=1,n=e[0];for(let r=1;r=180){const o=i/180,a=r/o;let s=n+a;const l=t.times[e-1],c=(t.times[e]-l)/o;let u=l+c;const p=[],h=[];for(;u1&&(n=t[1].replace(/^(\w+)::/,""),r=t[2]),{id:e,name:n,type:r}}parseNodeProperty(t,e,n){let r=e[1].replace(/^"/,"").replace(/"$/,"").trim(),i=e[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if("Properties70"!==o.name){if("C"===r){const t=i.split(",").slice(1),e=parseInt(t[0]),n=parseInt(t[1]);let a=i.split(",").slice(3);r="connections",function(t,e){for(let n=0,r=t.length,i=e.length;n=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const n={},r=e>=7500?t.getUint64():t.getUint32(),i=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const o=t.getUint8(),a=t.getString(o);if(0===r)return null;const s=[];for(let e=0;e0?s[0]:"",c=s.length>1?s[1]:"",u=s.length>2?s[2]:"";for(n.singleProperty=1===i&&t.getOffset()===r;r>t.getOffset();){const r=this.parseNode(t,e);null!==r&&this.parseSubNode(a,n,r)}return n.propertyList=s,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==u&&(n.attrType=u),""!==a&&(n.name=a),n}parseSubNode(t,e,n){if(!0===n.singleProperty){const t=n.propertyList[0];Array.isArray(t)?(e[n.name]=n,n.a=t):e[n.name]=t}else if("Connections"===t&&"C"===n.name){const t=[];n.propertyList.forEach((function(e,n){0!==n&&t.push(e)})),void 0===e.connections&&(e.connections=[]),e.connections.push(t)}else if("Properties70"===n.name)Object.keys(n).forEach((function(t){e[t]=n[t]}));else if("Properties70"===t&&"P"===n.name){let t=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],o=n.propertyList[3];let a;0===t.indexOf("Lcl ")&&(t=t.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),a="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],e[t]={type:r,type2:i,flag:o,value:a}}else void 0===e[n.name]?"number"==typeof n.id?(e[n.name]={},e[n.name][n.id]=n):e[n.name]=n:"PoseNode"===n.name?(Array.isArray(e[n.name])||(e[n.name]=[e[n.name]]),e[n.name].push(n)):void 0===e[n.name][n.id]&&(e[n.name][n.id]=n)}parseProperty(t){const e=t.getString(1);let n;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return n=t.getUint32(),t.getArrayBuffer(n);case"S":return n=t.getUint32(),t.getString(n);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=t.getUint32(),i=t.getUint32(),o=t.getUint32();if(0===i)switch(e){case"b":case"c":return t.getBooleanArray(r);case"d":return t.getFloat64Array(r);case"f":return t.getFloat32Array(r);case"i":return t.getInt32Array(r);case"l":return t.getInt64Array(r)}void 0===Z&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=Z.unzlibSync(new Uint8Array(t.getArrayBuffer(o))),s=new c(a.buffer);switch(e){case"b":case"c":return s.getBooleanArray(r);case"d":return s.getFloat64Array(r);case"f":return s.getFloat32Array(r);case"i":return s.getInt32Array(r);case"l":return s.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class c{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===e||e}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(t){const e=[];for(let n=0;n=0&&(e=e.slice(0,n)),r.LoaderUtils.decodeText(new Uint8Array(e))}}class u{add(t,e){this[t]=e}}function p(t){const e=t.match(/FBXVersion: (\d+)/);if(e)return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function h(t){return t/46186158e3}const d=[];function f(t,e,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=t;break;case"ByPolygon":i=e;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(i=r.indices[i]);const o=i*r.dataSize,a=o+r.dataSize;return function(t,e,n,r){for(let i=n,o=0;i=e.length&&e===x(t,0,e.length)}(e))t=(new l).parse(e);else{const n=x(e);if(!function(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(e){const r=t[e-1];return t=t.slice(n+e),n++,r}for(let t=0;t=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,o,a)}}class g{constructor(t){this.parser=t,this.name="EXT_texture_webp",this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,r=n.json,i=r.textures[t];if(!i.extensions||!i.extensions[e])return null;const o=i.extensions[e],a=r.images[o.source];let s=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(s=t)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(t,a,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class y{constructor(t){this.name="EXT_meshopt_compression",this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],r=this.parser.getDependency("buffer",t.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,i.ready]).then((function(e){const n=t.byteOffset||0,r=t.byteLength||0,o=t.count,a=t.byteStride,s=new ArrayBuffer(o*a),l=new Uint8Array(e[0],n,r);return i.decodeGltfBuffer(new Uint8Array(s),o,a,l,t.mode,t.filter),s}))}return null}}class v{constructor(t){this.name=e,this.content=null,this.body=null;const n=new DataView(t,0,12);if(this.header={magic:r.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:n.getUint32(4,!0),length:n.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 i=this.header.length-12,o=new DataView(t,12);let a=0;for(;a",e).replace("#include ",n).replace("#include ",i).replace("#include ",o).replace("#include ",a)},Object.defineProperties(this,{specular:{get:function(){return s.specular.value},set:function(t){s.specular.value=t}},specularMap:{get:function(){return s.specularMap.value},set:function(t){s.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return s.glossiness.value},set:function(t){s.glossiness.value=t}},glossinessMap:{get:function(){return s.glossinessMap.value},set:function(t){s.glossinessMap.value=t,t?(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(t)}copy(t){return super.copy(t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class w{constructor(){this.name=i,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(t,e,n){const i=e.extensions[this.name];t.color=new r.Color(1,1,1),t.opacity=1;const o=[];if(Array.isArray(i.diffuseFactor)){const e=i.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==i.diffuseTexture&&o.push(n.assignTexture(t,"map",i.diffuseTexture)),t.emissive=new r.Color(0,0,0),t.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,t.specular=new r.Color(1,1,1),Array.isArray(i.specularFactor)&&t.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const e=i.specularGlossinessTexture;o.push(n.assignTexture(t,"glossinessMap",e)),o.push(n.assignTexture(t,"specularMap",e))}return Promise.all(o)}createMaterial(t){const e=new b(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=r.TangentSpaceNormalMap,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e}}class M{constructor(){this.name=s}}class S extends r.Interpolant{constructor(t,e,n,r){super(t,e,n,r)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=t*r*3+r;for(let t=0;t!==r;t++)e[t]=n[i+t];return e}}S.prototype.beforeStart_=S.prototype.copySampleValue_,S.prototype.afterEnd_=S.prototype.copySampleValue_,S.prototype.interpolate_=function(t,e,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,c=r-e,u=(n-e)/c,p=u*u,h=p*u,d=t*l,f=d-l,m=-2*h+3*p,g=h-p,y=1-m,v=g-p+u;for(let t=0;t!==a;t++){const e=o[f+t+a],n=o[f+t+s]*c,r=o[d+t+a],l=o[d+t]*c;i[t]=y*e+v*n+m*r+g*l}return i};const T=new r.Quaternion;class E extends S{interpolate_(t,e,n,r){const i=super.interpolate_(t,e,n,r);return T.fromArray(i).normalize().toArray(i),i}}const A={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},C={9728:r.NearestFilter,9729:r.LinearFilter,9984:r.NearestMipmapNearestFilter,9985:r.LinearMipmapNearestFilter,9986:r.NearestMipmapLinearFilter,9987:r.LinearMipmapLinearFilter},L={33071:r.ClampToEdgeWrapping,33648:r.MirroredRepeatWrapping,10497:r.RepeatWrapping},P={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},I={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:r.InterpolateLinear,STEP:r.InterpolateDiscrete};function z(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}function D(t,e,n){for(const r in n.extensions)void 0===t[r]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=n.extensions[r])}function O(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function F(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,r=e.weights.length;n=2&&f.setY(e,p[t*a+1]),a>=3&&f.setZ(e,p[t*a+2]),a>=4&&f.setW(e,p[t*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.")}}return f}))}loadTexture(t){const e=this.json,n=this.options,r=e.textures[t],i=e.images[r.source];let o=this.textureLoader;if(i.uri){const t=n.manager.getHandler(i.uri);null!==t&&(o=t)}return this.loadTextureImage(t,i,o)}loadTextureImage(t,e,n){const i=this,o=this.json,a=this.options,s=o.textures[t],l=(e.uri||e.bufferView)+":"+s.sampler;if(this.textureCache[l])return this.textureCache[l];const c=self.URL||self.webkitURL;let u=e.uri||"",p=!1,h=!0;const d=u.search(/\.jpe?g($|\?)/i)>0||0===u.search(/^data\:image\/jpeg/);if(("image/jpeg"===e.mimeType||d)&&(h=!1),void 0!==e.bufferView)u=i.getDependency("bufferView",e.bufferView).then((function(t){if("image/png"===e.mimeType){const e=new DataView(t,25,1).getUint8(0,!1);h=6===e||4===e||3===e}p=!0;const n=new Blob([t],{type:e.mimeType});return u=c.createObjectURL(n)}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const f=Promise.resolve(u).then((function(t){return new Promise((function(e,i){let o=e;!0===n.isImageBitmapLoader&&(o=function(t){const n=new r.Texture(t);n.needsUpdate=!0,e(n)}),n.load(z(t,a.path),o,void 0,i)}))})).then((function(e){!0===p&&c.revokeObjectURL(u),e.flipY=!1,s.name&&(e.name=s.name),h||(e.format=r.RGBFormat);const n=(o.samplers||{})[s.sampler]||{};return e.magFilter=C[n.magFilter]||r.LinearFilter,e.minFilter=C[n.minFilter]||r.LinearMipmapLinearFilter,e.wrapS=L[n.wrapS]||r.RepeatWrapping,e.wrapT=L[n.wrapT]||r.RepeatWrapping,i.associations.set(e,{type:"textures",index:t}),e})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",u),null}));return this.textureCache[l]=f,f}assignTexture(t,e,n){const r=this;return this.getDependency("texture",n.index).then((function(i){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===e&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+e+" not yet supported."),r.extensions[a]){const t=void 0!==n.extensions?n.extensions[a]:void 0;if(t){const e=r.associations.get(i);i=r.extensions[a].extendTexture(i,t),r.associations.set(i,e)}}return t[e]=i,i}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0!==e.attributes.tangent,o=void 0!==e.attributes.color,a=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new r.PointsMaterial,r.Material.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new r.LineBasicMaterial,r.Material.prototype.copy.call(e,n),e.color.copy(n.color),this.cache.add(t,e)),n=e}if(i||o||a){let t="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),i&&(t+="vertex-tangents:"),o&&(t+="vertex-colors:"),a&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),o&&(e.vertexColors=!0),a&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}n.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=n}getMaterialType(){return r.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,a=this.extensions,s=n.materials[t];let l;const c={},u=s.extensions||{},p=[];if(u[i]){const t=a[i];l=t.getMaterialType(),p.push(t.extendParams(c,s,e))}else if(u[o]){const t=a[o];l=t.getMaterialType(),p.push(t.extendParams(c,s,e))}else{const n=s.pbrMetallicRoughness||{};if(c.color=new r.Color(1,1,1),c.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;c.color.fromArray(t),c.opacity=t[3]}void 0!==n.baseColorTexture&&p.push(e.assignTexture(c,"map",n.baseColorTexture)),c.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,c.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(p.push(e.assignTexture(c,"metalnessMap",n.metallicRoughnessTexture)),p.push(e.assignTexture(c,"roughnessMap",n.metallicRoughnessTexture))),l=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),p.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,c)}))))}!0===s.doubleSided&&(c.side=r.DoubleSide);const h=s.alphaMode||"OPAQUE";return"BLEND"===h?(c.transparent=!0,c.depthWrite=!1):(c.format=r.RGBFormat,c.transparent=!1,"MASK"===h&&(c.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&l!==r.MeshBasicMaterial&&(p.push(e.assignTexture(c,"normalMap",s.normalTexture)),c.normalScale=new r.Vector2(1,-1),void 0!==s.normalTexture.scale&&c.normalScale.set(s.normalTexture.scale,-s.normalTexture.scale)),void 0!==s.occlusionTexture&&l!==r.MeshBasicMaterial&&(p.push(e.assignTexture(c,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(c.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&l!==r.MeshBasicMaterial&&(c.emissive=(new r.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&l!==r.MeshBasicMaterial&&p.push(e.assignTexture(c,"emissiveMap",s.emissiveTexture)),Promise.all(p).then((function(){let n;return n=l===b?a[i].createMaterial(c):new l(c),s.name&&(n.name=s.name),n.map&&(n.map.encoding=r.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=r.sRGBEncoding),O(n,s),e.associations.set(n,{type:"materials",index:t}),s.extensions&&D(a,n,s),n}))}createUniqueName(t){const e=r.PropertyBinding.sanitizeNodeName(t||"");let n=e;for(let t=1;this.nodeNamesUsed[n];++t)n=e+"_"+t;return this.nodeNamesUsed[n]=!0,n}loadGeometries(t){const e=this,i=this.extensions,o=this.primitiveCache;function a(t){return i[n].decodePrimitive(t,e).then((function(n){return G(n,t,e)}))}const s=[];for(let i=0,l=t.length;i0&&F(h,o),h.name=e.createUniqueName(o.name||"mesh_"+t),O(h,o),p.extensions&&D(i,h,p),e.assignFinalMaterial(h),c.push(h)}if(1===c.length)return c[0];const u=new r.Group;for(let t=0,e=c.length;t1?new r.Group:1===e.length?e[0]:new r.Object3D)!==e[0])for(let t=0,n=e.length;t=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 t=0;t=0&&void 0===f[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}g.setExtensions(d),g.setPlugins(f),g.parse(u,p)}}}(),$=$=r.GLTFLoader;var J={};r.ColladaLoader=class extends r.Loader{constructor(t){super(t)}load(t,e,n,i){const o=this,a=""===o.path?r.LoaderUtils.extractUrlBase(t):o.path,s=new r.FileLoader(o.manager);s.setPath(o.path),s.setRequestHeader(o.requestHeader),s.setWithCredentials(o.withCredentials),s.load(t,(function(n){try{e(o.parse(n,a))}catch(e){i?i(e):console.error(e),o.manager.itemError(t)}}),n,i)}parse(t,e){function n(t,e){const n=[],r=t.childNodes;for(let t=0,i=r.length;t0&&e.push(new r.VectorKeyframeTrack(i+".position",o,a)),s.length>0&&e.push(new r.QuaternionKeyframeTrack(i+".quaternion",o,s)),l.length>0&&e.push(new r.VectorKeyframeTrack(i+".scale",o,l)),e}function M(t,e,n){let r,i,o,a=!0;for(i=0,o=t.length;i=0;){const r=t[e];if(null!==r.value[n])return r;e--}return null}function T(t,e,n){for(;e>>0));if("tga"===(n=n.toLowerCase()))e=Wt;else e=Ht;return e}(i);if(void 0!==e){const n=e.load(i),o=t.extra;if(void 0!==o&&void 0!==o.technique&&!1===l(o.technique)){const t=o.technique;n.wrapS=t.wrapU?r.RepeatWrapping:r.ClampToEdgeWrapping,n.wrapT=t.wrapV?r.RepeatWrapping:r.ClampToEdgeWrapping,n.offset.set(t.offsetU||0,t.offsetV||0),n.repeat.set(t.repeatU||1,t.repeatV||1)}else n.wrapS=r.RepeatWrapping,n.wrapT=r.RepeatWrapping;return n}return console.warn("THREE.ColladaLoader: THREE.Loader for texture %s not found.",i),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}a.name=t.name||"";const c=i.parameters;for(const t in c){const e=c[t];switch(t){case"diffuse":e.color&&a.color.fromArray(e.color),e.texture&&(a.map=s(e.texture));break;case"specular":e.color&&a.specular&&a.specular.fromArray(e.color),e.texture&&(a.specularMap=s(e.texture));break;case"bump":e.texture&&(a.normalMap=s(e.texture));break;case"ambient":e.texture&&(a.lightMap=s(e.texture));break;case"shininess":e.float&&a.shininess&&(a.shininess=e.float);break;case"emission":e.color&&a.emissive&&a.emissive.fromArray(e.color),e.texture&&(a.emissiveMap=s(e.texture))}}let u=c.transparent,p=c.transparency;if(void 0===p&&u&&(p={float:1}),void 0===u&&p&&(u={opaque:"A_ONE",data:{color:[1,1,1,1]}}),u&&p)if(u.data.texture)a.transparent=!0;else{const t=u.data.color;switch(u.opaque){case"A_ONE":a.opacity=t[3]*p.float;break;case"RGB_ZERO":a.opacity=1-t[0]*p.float;break;case"A_ZERO":a.opacity=1-t[3]*p.float;break;case"RGB_ONE":a.opacity=t[0]*p.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',u.opaque)}a.opacity<1&&(a.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(a.side=r.DoubleSide),a}function $(t){return d($t.materials[t],X)}function J(t){for(let e=0;e0?n+o:n;e.inputs[l]={id:t,offset:i},e.stride=Math.max(e.stride,i+1),"TEXCOORD"===n&&(e.hasUV=!0);break;case"vcount":e.vcount=a(r.textContent);break;case"p":e.p=a(r.textContent)}}return e}function lt(t){let e=0;for(let n=0,r=t.length;n0&&e0&&h.setAttribute("position",new r.Float32BufferAttribute(o.array,o.stride)),a.array.length>0&&h.setAttribute("normal",new r.Float32BufferAttribute(a.array,a.stride)),c.array.length>0&&h.setAttribute("color",new r.Float32BufferAttribute(c.array,c.stride)),s.array.length>0&&h.setAttribute("uv",new r.Float32BufferAttribute(s.array,s.stride)),l.array.length>0&&h.setAttribute("uv2",new r.Float32BufferAttribute(l.array,l.stride)),u.length>0&&h.setAttribute("skinIndex",new r.Float32BufferAttribute(u,4)),p.length>0&&h.setAttribute("skinWeight",new r.Float32BufferAttribute(p,4)),i.data=h,i.type=t[0].type,i.materialKeys=d,i}function pt(t,e,n,r){const i=t.p,o=t.stride,a=t.vcount;function s(t){let e=i[t+n]*c;const o=e+c;for(;e4)for(let e=1,r=n-2;e<=r;e++){const n=t+o*e,r=t+o*(e+1);s(t+0*o),s(n),s(r)}t+=o*n}}else for(let t=0,e=i.length;t=e.limits.max&&(e.static=!0),e.middlePosition=(e.limits.min+e.limits.max)/2,e}function yt(t){const e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;ni.limits.max||e{let i=[];switch(t.type){case"mtl":r=r.children[0];break;case"gltf":case"glb":case"dae":i=r.animations,r=r.scene;break;case"fbx":i=r.animations}r.animations=i;const o=u.types.rotation(t.rotation,[0,0,0]),a=u.types.scale(t.scale,[1,1,1]);r.rotation.set(o[0],o[1],o[2]),r.scale.set(a[0],a[1],a[2]),t.normalize&&r.traverse((function(t){if(t.isMesh){let e;"MeshStandardMaterial"==t.material.type?(t.material.metalness&&(t.material.metalness*=.1),t.material.glossiness&&(t.material.glossiness*=.25),e=new THREE.Color(12,12,12)):"MeshPhongMaterial"==t.material.type&&(t.material.shininess=.1,e=new THREE.Color(20,20,20)),t.material.specular&&t.material.specular.isColor&&(t.material.specular=e)}})),r.name="model";let s=b.prototype._makeGroup(r,t);b.prototype._addMethods(s),s.setAnchor(t.anchor),s.setCenter(t.adjustment),s.raycasted=t.raycasted,n(s),e(s),s.setFixedZoom(t.mapScale),s.idle()}),(()=>null),(e=>{console.error("Could not load model file: "+t.obj+" \n "+e.stack),n("Error loading the model")}))}),(()=>null),(t=>{console.warn("No material file found "+t.stack)}))};var rt={};function it(t){t=u._validate(t,b.prototype._defaults.line);var e=u.lnglatsToWorld(t.geometry),n=u.normalizeVertices(e),i=u.flattenVectors(n.vertices),o=new r.LineGeometry;o.setPositions(i);let a=new r.LineMaterial({color:t.color,linewidth:t.width,dashed:!1,opacity:t.opacity});return a.resolution.set(window.innerWidth,window.innerHeight),a.isMaterial=!0,a.transparent=!0,a.depthWrite=!1,(it=new r.Line2(o,a)).position.copy(n.position),it.computeLineDistances(),it}rt=rt=it,function(){const t=new r.Box3,e=new r.Vector3;class n extends r.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 r.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 r.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new r.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new r.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new r.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new r.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceColorStart",new r.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new r.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new r.WireframeGeometry(t.geometry)),this}fromLineSegments(t){const e=t.geometry;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new r.Box3);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;void 0!==e&&void 0!==n&&(this.boundingBox.setFromBufferAttribute(e),t.setFromBufferAttribute(n),this.boundingBox.union(t))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new r.Sphere),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(void 0!==t&&void 0!==n){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let o=0,a=t.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 t extends r.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:r.UniformsUtils.clone(r.ShaderLib.line.uniforms),vertexShader:r.ShaderLib.line.vertexShader,fragmentShader:r.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set(t){Boolean(t)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("ALPHA_TO_COVERAGE"in this.defines)},set:function(t){Boolean(t)!==Boolean("ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===t?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}t.prototype.isLineMaterial=!0,r.LineMaterial=t}(),function(){const t=new r.Vector3,e=new r.Vector3,n=new r.Vector4,i=new r.Vector4,o=new r.Vector4,a=new r.Vector3,s=new r.Matrix4,l=new r.Line3,c=new r.Vector3,u=new r.Box3,p=new r.Sphere,h=new r.Vector4;class d extends r.Mesh{constructor(t=new r.LineSegmentsGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="LineSegments2"}computeLineDistances(){const n=this.geometry,i=n.attributes.instanceStart,o=n.attributes.instanceEnd,a=new Float32Array(2*i.count);for(let n=0,r=0,s=i.count;nS&&i.z>S)continue;if(n.z>S){const t=n.z-i.z,e=(n.z-S)/t;n.lerp(i,e)}else if(i.z>S){const t=i.z-n.z,e=(i.z-S)/t;i.lerp(n,e)}n.applyMatrix4(g),i.applyMatrix4(g),n.multiplyScalar(1/n.w),i.multiplyScalar(1/i.w),n.x*=x.x/2,n.y*=x.y/2,i.x*=x.x/2,i.y*=x.y/2,l.start.copy(n),l.start.z=0,l.end.copy(i),l.end.z=0;const o=l.closestPointToPointParameter(a,!0);l.at(o,c);const u=r.MathUtils.lerp(n.z,i.z,o),p=u>=-1&&u<=1,h=a.distanceTo(c)<.5*b;if(p&&h){l.start.fromBufferAttribute(w,t),l.end.fromBufferAttribute(M,t),l.start.applyMatrix4(y),l.end.applyMatrix4(y);const n=new r.Vector3,i=new r.Vector3;f.distanceSqToSegment(l.start,l.end,i,n),e.push({point:i,pointOnLine:n,distance:f.origin.distanceTo(i),object:this,face:null,faceIndex:t,uv:null,uv2:null})}}}}}d.prototype.LineSegments2=!0,r.LineSegments2=d}(),function(){class t extends r.LineSegments2{constructor(t=new r.LineGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Line2"}}t.prototype.isLine2=!0,r.Line2=t}(),function(){const t=new r.Vector3,e=new r.Vector3;class n extends r.Mesh{constructor(t=new r.LineSegmentsGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Wireframe"}computeLineDistances(){const n=this.geometry,i=n.attributes.instanceStart,o=n.attributes.instanceEnd,a=new Float32Array(2*i.count);for(let n=0,r=0,s=i.count;n{n.push(new r.Vector3(t[0],t[1],t[2]))}));const i=new r.CatmullRomCurve3(n);let o=new r.TubeGeometry(i,n.length,t.radius,t.sides,!1),a=m(t),s=new r.Mesh(o,a);return new S({obj:s,units:t.units,anchor:t.anchor,adjustment:t.adjustment,bbox:t.bbox,tooltip:t.tooltip,raycasted:t.raycasted})};var at={};at=at=function(t){this.map=t,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(t,e){this.renderer.setSize(t,e)},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(t,e){return this.scene=t,this.camera=e,new Promise((n=>{n(this.renderer.render(t,e))}))},this.toggleLabels=async function(t,e){return new Promise((n=>{n(this.setVisibility(t,e,this.scene,this.camera,this.renderer))}))},this.setVisibility=function(t,e,n,r,i){this.renderer.cacheList.forEach((function(o){o.visible!=e&&o.layer===t&&(e&&o.alwaysVisible||!e)&&(o.visible=e,i.renderObject(o,n,r))}))}};var st={};st=st=class{constructor(t,e){this.id=t.layerId,this.type="custom",this.renderingMode="3d",this.opacity=.5,this.buildingsLayerId=t.buildingsLayerId,this.minAltitude=t.minAltitude||.1,this.tb=e}onAdd(t,e){this.map=t;const n=e.createShader(e.VERTEX_SHADER);e.shaderSource(n,"\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"),e.compileShader(n);const r=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(r,"\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"),e.compileShader(r),this.program=e.createProgram(),e.attachShader(this.program,n),e.attachShader(this.program,r),e.linkProgram(this.program),e.validateProgram(this.program),this.uMatrix=e.getUniformLocation(this.program,"u_matrix"),this.uHeightFactor=e.getUniformLocation(this.program,"u_height_factor"),this.uAltitude=e.getUniformLocation(this.program,"u_altitude"),this.uAzimuth=e.getUniformLocation(this.program,"u_azimuth"),this.aPos=e.getAttribLocation(this.program,"a_pos"),this.aNormal=e.getAttribLocation(this.program,"a_normal_ed"),this.aBase=e.getAttribLocation(this.program,"a_base"),this.aHeight=e.getAttribLocation(this.program,"a_height")}render(t,e){t.useProgram(this.program);const n=this.map.style.sourceCaches.composite,r=n.getVisibleCoordinates().reverse(),i=this.map.getLayer(this.buildingsLayerId),o=this.map.painter.context,{lng:a,lat:s}=this.map.getCenter(),l=this.tb.getSunPosition(this.tb.lightDateTime,[a,s]);t.uniform1f(this.uAltitude,l.altitude>this.minAltitude?l.altitude:0),t.uniform1f(this.uAzimuth,l.azimuth+3*Math.PI/2),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.getExtension("EXT_blend_minmax"),t.disable(t.DEPTH_TEST);for(const e of r){const r=n.getTile(e),a=r.getBucket(i);if(!a)continue;const[s,l]=a.programConfigurations.programConfigurations[this.buildingsLayerId]._buffers;t.uniformMatrix4fv(this.uMatrix,!1,e.posMatrix),t.uniform1f(this.uHeightFactor,Math.pow(2,e.overscaledZ)/r.tileSize/8);for(const e of a.segments.get()){const n=o.currentNumAttributes||0,r=2;for(let e=r;e{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((t=>{this.getLayer(t)&&(this.tb.terrainLayerName=t)}))})),this.map.on("load",(function(){let e;this.selectedObject,this.selectedFeature,this.draggedObject,this.overedObject,this.overedFeature;let n,r=this.getCanvasContainer();this.getCanvasContainer().style.cursor=this.tb.defaultCursor;let i,o,a,s,l=[];function c(t){var e=r.getBoundingClientRect();return{x:t.originalEvent.clientX-e.left-r.clientLeft,y:t.originalEvent.clientY-e.top-r.clientTop}}this.unselectObject=function(){this.selectedObject.selected=!1,this.selectedObject=null},this.outObject=function(){this.overedObject.over=!1,this.overedObject=null},this.unselectFeature=function(t){void 0!==t.id&&(this.setFeatureState({source:t.source,sourceLayer:t.sourceLayer,id:t.id},{select:!1}),this.removeTooltip(t),(t=this.queryRenderedFeatures({layers:[t.layer.id],filter:["==",["id"],t.id]})[0])&&this.fire("SelectedFeatureChange",{detail:t}),this.selectedFeature=null)},this.selectFeature=function(t){this.selectedFeature=t,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(e){this.overedFeature&&void 0!==this.overedFeature&&this.overedFeature.id!=e&&(t.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(t){if(!this.tb.enableTooltips)return;let e=this.tb.getFeatureCenter(t),n=this.tb.tooltip({text:t.properties.name||t.id||t.type,mapboxStyle:!0,feature:t});n.setCoords(e),this.tb.add(n,t.layer.id),t.tooltip=n,t.tooltip.tooltip.visible=!0},this.removeTooltip=function(t){t.tooltip&&(t.tooltip.visibility=!1,this.tb.remove(t.tooltip),t.tooltip=null)},t.onContextMenu=function(t){alert("contextMenu")},this.onClick=function(e){let n,r=[];if(t.tb.enableSelectingObjects&&(r=this.tb.queryRenderedFeatures(e.point)),n="object"==typeof r[0]){let t=ct.prototype.findParent3DObject(r[0]);if(t){if(this.selectedFeature&&this.unselectFeature(this.selectedFeature),this.selectedObject){if(this.selectedObject.uuid!=t.uuid)this.selectedObject.selected=!1,t.selected=!0,this.selectedObject=t;else if(this.selectedObject.uuid==t.uuid)return void this.unselectObject()}else this.selectedObject=t,this.selectedObject.selected=!0;this.selectedObject.dispatchEvent({type:"Wireframed",detail:this.selectedObject}),this.selectedObject.dispatchEvent({type:"IsPlayingChanged",detail:this.selectedObject}),this.repaint=!0,e.preventDefault()}}else{let n=[];if(t.tb.enableSelectingFeatures&&(n=this.queryRenderedFeatures(e.point)),n.length>0&&"fill-extrusion"==n[0].layer.type&&void 0!==n[0].id)if(this.selectedObject&&this.unselectObject(),this.selectedFeature){if(this.selectedFeature.id!=n[0].id)this.unselectFeature(this.selectedFeature),this.selectFeature(n[0]);else if(this.selectedFeature.id==n[0].id)return void this.unselectFeature(this.selectedFeature)}else this.selectFeature(n[0])}},this.onMouseMove=function(r){let l,u=c(r);if(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,r.originalEvent.altKey&&this.draggedObject){if(!t.tb.enableRotatingObjects)return;e="rotate",this.getCanvasContainer().style.cursor="move",Math.min(n.x,u.x),Math.max(n.x,u.x),Math.min(n.y,u.y),Math.max(n.y,u.y);let r={x:0,y:0,z:Math.round(s[2]+~~((u.x-n.x)/this.tb.rotationStep)%360*this.tb.rotationStep%360)};return this.draggedObject.setRotation(r),void this.draggedObject.addHelp("rot: "+r.z+"°")}if(r.originalEvent.shiftKey&&this.draggedObject){if(!t.tb.enableDraggingObjects)return;e="translate",this.getCanvasContainer().style.cursor="move";let n=r.lngLat,a=[Number((n.lng+i).toFixed(this.tb.gridStep)),Number((n.lat+o).toFixed(this.tb.gridStep)),this.draggedObject.modelHeight];return this.draggedObject.setCoords(a),void this.draggedObject.addHelp("lng: "+a[0]+"°, lat: "+a[1]+"°")}if(r.originalEvent.ctrlKey&&this.draggedObject){if(!t.tb.enableDraggingObjects)return;e="altitude",this.getCanvasContainer().style.cursor="move";let n=r.point.y*this.tb.altitudeStep,i=[this.draggedObject.coordinates[0],this.draggedObject.coordinates[1],Number((-n-a).toFixed(this.tb.gridStep))];return this.draggedObject.setCoords(i),void this.draggedObject.addHelp("alt: "+i[2]+"m")}let p=[];if(t.tb.enableSelectingObjects&&(p=this.tb.queryRenderedFeatures(r.point)),l="object"==typeof p[0]){let t=ct.prototype.findParent3DObject(p[0]);t&&(this.outFeature(this.overedFeature),this.getCanvasContainer().style.cursor="pointer",this.selectedObject&&t.uuid==this.selectedObject.uuid?this.selectedObject&&t.uuid==this.selectedObject.uuid&&(t.over=!0,this.overedObject=t):(this.overedObject&&this.overedObject.uuid!=t.uuid&&this.outObject(),t.over=!0,this.overedObject=t),this.repaint=!0,r.preventDefault())}else{this.overedObject&&this.outObject();let e=[];t.tb.enableSelectingFeatures&&(e=this.queryRenderedFeatures(r.point)),e.length>0&&(this.outFeature(e[0]),"fill-extrusion"==e[0].layer.type&&void 0!==e[0].id&&(this.selectedFeature&&this.selectedFeature.id==e[0].id||(this.getCanvasContainer().style.cursor="pointer",this.overedFeature=e[0],this.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!0}),this.overedFeature=t.queryRenderedFeatures({layers:[this.overedFeature.layer.id],filter:["==",["id"],this.overedFeature.id]})[0],this.addTooltip(this.overedFeature))))}},this.onMouseDown=function(e){(e.originalEvent.shiftKey||e.originalEvent.altKey||e.originalEvent.ctrlKey)&&0===e.originalEvent.button&&this.selectedObject&&(t.tb.enableDraggingObjects||t.tb.enableRotatingObjects)&&(e.preventDefault(),t.getCanvasContainer().style.cursor="move",t.once("mouseup",this.onMouseUp),this.draggedObject=this.selectedObject,n=c(e),l=this.draggedObject.coordinates,s=u.degreeify(this.draggedObject.rotation),i=l[0]-e.lngLat.lng,o=l[1]-e.lngLat.lat,a=-this.draggedObject.modelHeight-e.point.y*this.tb.altitudeStep)},this.onMouseUp=function(t){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:e}}),this.draggedObject.removeHelp(),this.draggedObject=null,e=null)},this.onMouseOut=function(t){if(this.overedFeature){let e=this.queryRenderedFeatures(t.point);e.length>0&&this.overedFeature.id!=e[0].id&&(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.outFeature(e[0]))}},this.onZoom=function(t){this.tb.zoomLayers.forEach((t=>{this.tb.toggleLayer(t)})),this.tb.setObjectsScale()};let p=!1,h=!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(t){17!==t.which&&91!==t.which||(p=!0),16===t.which&&(h=!0);let e=this.selectedObject;if(h&&83===t.which&&e){let t=u.toDecimal;if(e.help)e.removeHelp();else{let n=e.modelSize,r=1;"meters"!==e.userData.units&&((r=u.projectedUnitsPerMeter(e.coordinates[1]))||(r=1),r=t(r,7)),e.addHelp("size(m): "+t(n.x/r,3)+" W, "+t(n.y/r,3)+" L, "+t(n.z/r,3)+" H"),this.repaint=!0}return!1}}.bind(this),!0),document.addEventListener("keyup",function(t){17!=t.which&&91!=t.which||(p=!1),16===t.which&&(h=!1)}.bind(this))}))},get sky(){return this.options.sky},set sky(t){t?this.createSkyLayer():this.removeLayer(this.skyLayerName),this.options.sky=t},get terrain(){return this.options.terrain},set terrain(t){if(this.terrainLayerName="",t)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=t},get fov(){return this.options.fov},set fov(t){this.camera instanceof r.PerspectiveCamera&&this.options.fov!==t&&(this.map.transform.fov=t,this.camera.fov=this.map.transform.fov,this.cameraSync.setupCamera(),this.map.repaint=!0,this.options.fov=t)},get orthographic(){return this.options.orthographic},set orthographic(t){const e=this.map.getCanvas().clientHeight,n=this.map.getCanvas().clientWidth;t?(this.map.transform.fov=0,this.camera=new r.OrthographicCamera(n/-2,n/2,e/2,e/-2,.1,1e21)):(this.map.transform.fov=this.fov,this.camera=new r.PerspectiveCamera(this.map.transform.fov,n/e,.1,1e21)),this.camera.layers.enable(0),this.camera.layers.enable(1),this.cameraSync=new h(this.map,this.camera,this.world),this.map.repaint=!0,this.options.orthographic=t},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(t){return this.setDefaultView(t,this.options),T(t,this.world)},line:rt,label:C,tooltip:L,tube:function(t){return this.setDefaultView(t,this.options),ot(t,this.world)},extrusion:function(t){return this.setDefaultView(t,this.options),E(t)},Object3D:function(t){return this.setDefaultView(t,this.options),S(t)},loadObj:async function(t,e){if(this.setDefaultView(t,this.options),!1===t.clone)return new Promise((async n=>{Y(t,e,(async t=>{n(t)}))}));{let n=this.objectsCache.get(t.obj);n?n.promise.then((n=>{e(n.duplicate(t))})).catch((e=>{this.objectsCache.delete(t.obj),console.error("Could not load model file: "+t.obj)})):this.objectsCache.set(t.obj,{promise:new Promise((async(n,r)=>{Y(t,e,(async t=>{t.duplicate?n(t.duplicate()):r(t)}))}))})}},material:function(t){return m(t)},initLights:{ambientLight:null,dirLight:null,dirLightBack:null,dirLightHelper:null,hemiLight:null,pointLight:null},utils:u,SunCalc:f,Constants:i,projectToWorld:function(t){return this.utils.projectToWorld(t)},unprojectFromWorld:function(t){return this.utils.unprojectFromWorld(t)},projectedUnitsPerMeter:function(t){return this.utils.projectedUnitsPerMeter(t)},getFeatureCenter:function(t,e,n){return u.getFeatureCenter(t,e,n)},getObjectHeightOnFloor:function(t,e,n){return u.getObjectHeightOnFloor(t,e,n)},queryRenderedFeatures:function(t){let e=new r.Vector2;return e.x=t.x/this.map.transform.width*2-1,e.y=1-t.y/this.map.transform.height*2,this.raycaster.setFromCamera(e,this.camera),this.raycaster.intersectObjects(this.world.children,!0)},findParent3DObject:function(t){var e;return t.object.traverseAncestors((function(t){t.parent&&"Group"==t.parent.type&&t.userData.obj&&(e=t)})),e},setLayoutProperty:function(t,e,n){this.map.setLayoutProperty(t,e,n),null!=n&&"visibility"===e&&this.world.children.filter((e=>e.layer===t)).forEach((t=>{t.visibility=n}))},setLayerZoomRange:function(t,e,n){this.map.getLayer(t)&&(this.map.setLayerZoomRange(t,e,n),this.zoomLayers.includes(t)||this.zoomLayers.push(t),this.toggleLayer(t))},setLayerHeigthProperty:function(t,e){let n=this.map.getLayer(t);if(n)if("fill-extrusion"==n.type){let t=this.map.getStyle().sources[n.source].data;t.features.forEach((function(t){t.properties.level=e})),this.map.getSource(n.source).setData(t)}else"custom"==n.type&&this.world.children.forEach((function(n){let r=n.userData.feature;if(r&&r.layer===t){let t=this.tb.getFeatureCenter(r,n,e);n.setCoords(t)}}))},setObjectsScale:function(){this.world.children.filter((t=>null!=t.fixedZoom)).forEach((t=>{t.setObjectScale(this.map.transform.scale)}))},setStyle:function(t,e){this.clear().then((()=>{this.map.setStyle(t,e)}))},toggleLayer:function(t,e=!0){let n=this.map.getLayer(t);if(n){if(!e)return void this.toggle(n.id,!1);let t=this.map.getZoom();if(n.minzoom&&t=n.maxzoom)return void this.toggle(n.id,!1);this.toggle(n.id,!0)}},toggle:function(t,e){this.setLayoutProperty(t,"visibility",e?"visible":"none"),this.labelRenderer.toggleLabels(t,e)},update:function(){this.map.repaint&&(this.map.repaint=!1);var t=Date.now();this.objects.animationManager.update(t),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(t,e,n){if(!this.enableTooltips&&t.tooltip&&(t.tooltip.visibility=!1),this.world.add(t),e){t.layer=e,t.source=n;let r=this.map.getLayer(e);if(r){let e=r.visibility,n=void 0===e;t.visibility=!(!n&&"visible"!==e)}}},removeByName:function(t){let e=this.world.getObjectByName(t);e&&this.remove(e)},remove:function(t){this.map.selectedObject&&t.uuid==this.map.selectedObject.uuid&&this.map.unselectObject(),this.map.draggedObject&&t.uuid==this.map.draggedObject.uuid&&(this.map.draggedObject=null),t.dispose&&t.dispose(),this.world.remove(t),t=null},clear:async function(t=null,e=!1){return new Promise(((n,r)=>{let i=[];this.world.children.forEach((function(t){i.push(t)}));for(let e=0;e{t.promise.then((t=>{t.dispose(),t=null}))})),n("clear")}))},removeLayer:function(t){this.clear(t,!0).then((()=>{this.map.removeLayer(t)}))},getSunPosition:function(t,e){return f.getPosition(t||Date.now(),e[1],e[0])},getSunTimes:function(t,e){return f.getTimes(t,e[1],e[0],e[2]?e[2]:0)},setBuildingShadows:function(t){if(this.map.getLayer(t.buildingsLayerId)){let e=new st(t,this);this.map.addLayer(e,t.buildingsLayerId)}else console.warn("The layer '"+t.buildingsLayerId+"' does not exist in the map.")},setSunlight:function(t=new Date,e){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 n=new Date(t.getTime());if(e?e.lng&&e.lat?this.mapCenter=e:this.mapCenter={lng:e[0],lat:e[1]}:this.mapCenter=this.map.getCenter(),this.lightDateTime&&this.lightDateTime.getTime()===n.getTime()&&this.lightLng===this.mapCenter.lng&&this.lightLat===this.mapCenter.lat)return;this.lightDateTime=n,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition=this.getSunPosition(n,[this.mapCenter.lng,this.mapCenter.lat]);let r=this.sunPosition.altitude,o=Math.PI+this.sunPosition.azimuth,a=i.WORLD_SIZE/2,s=Math.sin(r),l=Math.cos(r),c=Math.cos(o)*l,u=Math.sin(o)*l;this.lights.dirLight.position.set(u,c,s),this.lights.dirLight.position.multiplyScalar(a),this.lights.dirLight.intensity=Math.max(s,0),this.lights.hemiLight.intensity=Math.max(1*s,.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(n,this.sunPosition)))},getSunSky:function(t,e){if(!e){var n=this.map.getCenter();e=this.getSunPosition(t||Date.now(),[n.lng,n.lat])}return[180+180*e.azimuth/Math.PI,90-180*e.altitude/Math.PI]},updateSunSky:function(t){this.sky&&this.map.setPaintProperty(this.skyLayerName,"sky-atmosphere-sun",t)},updateSunGround:function(t){""!=this.terrainLayerName&&this.map.setPaintProperty(this.terrainLayerName,"raster-opacity",Math.max(Math.min(1,4*t.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((t=>{t(this.clear(null,!0).then((t=>(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(),t))))}))},defaultLights:function(){this.lights.ambientLight=new r.AmbientLight(new r.Color("hsl(0, 0%, 100%)"),.75),this.scene.add(this.lights.ambientLight),this.lights.dirLightBack=new r.DirectionalLight(new r.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLightBack.position.set(30,100,100),this.scene.add(this.lights.dirLightBack),this.lights.dirLight=new r.DirectionalLight(new r.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLight.position.set(-30,100,-100),this.scene.add(this.lights.dirLight)},realSunlight:function(t=!1){this.renderer.shadowMap.enabled=!0,this.lights.dirLight=new r.DirectionalLight(16777215,1),this.scene.add(this.lights.dirLight),t&&(this.lights.dirLightHelper=new r.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 r.HemisphereLight(new r.Color(16777215),new r.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(t,e){t.bbox=(t.bbox||null==t.bbox)&&e.enableSelectingObjects,t.tooltip=(t.tooltip||null==t.tooltip)&&e.enableTooltips,t.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 ut={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:i.FOV_DEGREES,sky:!1,terrain:!1};lt=lt=ct,window.Threebox=lt,window.THREE=r}();!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).turf=t()}}((function(){return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};e[a][0].call(u.exports,(function(t){return i(e[a][1][t]||t)}),u,u.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a=c&&u===r.length-1);u++){if(c>=e){var p=e-c;if(p){var h=i.default(r[u],r[u-1])-180;return o.default(r[u],p,h,n)}return s.point(r[u])}c+=a.default(r[u],r[u+1],n)}return s.point(r[r.length-1])}},{"@turf/bearing":4,"@turf/destination":8,"@turf/distance":9,"@turf/helpers":11,"@turf/invariant":12}],3:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("@turf/meta");function i(t){var e=[1/0,1/0,-1/0,-1/0];r.coordEach(t,(function(t){e[0]>t[0]&&(e[0]=t[0]);e[1]>t[1]&&(e[1]=t[1]);e[2]=t[0]&&e[3]>=t[1]}(o,l))return!1;"Polygon"===s&&(c=[c]);for(var u=!1,p=0;pt[1]!=c>t[1]&&t[0]<(l-a)*(t[1]-s)/(c-s)+a&&(r=!r)}return r}},{"@turf/invariant":12}],6:[function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0});var i=r(t("@turf/bbox")),o=t("@turf/helpers");n.default=function(t,e){void 0===e&&(e={});var n=i.default(t),r=(n[0]+n[2])/2,a=(n[1]+n[3])/2;return o.point([r,a],e.properties,e)}},{"@turf/bbox":3,"@turf/helpers":11}],7:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});function r(t){var e={type:"Feature"};Object.keys(t).forEach((function(n){switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n]}}));e.properties=i(t.properties);e.geometry=o(t.geometry);return e}function i(t){var e={};if(!t)return e;Object.keys(t).forEach((function(n){var r=t[n];"object"==typeof r?null===r?e[n]=null:Array.isArray(r)?e[n]=r.map((function(t){return t})):e[n]=i(r):e[n]=r}));return e}function o(t){var e={type:t.type};t.bbox&&(e.bbox=t.bbox);if("GeometryCollection"===t.type){e.geometries=t.geometries.map((function(t){return o(t)}));return e}e.coordinates=a(t.coordinates);return e}function a(t){var e=t;return"object"!=typeof e[0]?e.slice():e.map((function(t){return a(t)}))}n.default=function(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return r(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};Object.keys(t).forEach((function(n){switch(n){case"type":case"features":return;default:e[n]=t[n]}}));e.features=t.features.map((function(t){return r(t)}));return e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return o(t);default:throw new Error("unknown GeoJSON type")}}},{}],8:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("@turf/helpers"),i=t("@turf/invariant");n.default=function(t,e,n,o){void 0===o&&(o={});var a=i.getCoord(t),s=r.degreesToRadians(a[0]),l=r.degreesToRadians(a[1]),c=r.degreesToRadians(n),u=r.lengthToRadians(e,o.units),p=Math.asin(Math.sin(l)*Math.cos(u)+Math.cos(l)*Math.sin(u)*Math.cos(c)),h=s+Math.atan2(Math.sin(c)*Math.sin(u)*Math.cos(l),Math.cos(u)-Math.sin(l)*Math.sin(p)),d=r.radiansToDegrees(h),f=r.radiansToDegrees(p);return r.point([d,f],o.properties)}},{"@turf/helpers":11,"@turf/invariant":12}],9:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("@turf/invariant"),i=t("@turf/helpers");n.default=function(t,e,n){void 0===n&&(n={});var o=r.getCoord(t),a=r.getCoord(e),s=i.degreesToRadians(a[1]-o[1]),l=i.degreesToRadians(a[0]-o[0]),c=i.degreesToRadians(o[1]),u=i.degreesToRadians(a[1]),p=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(l/2),2)*Math.cos(c)*Math.cos(u);return i.radiansToLength(2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p)),n.units)}},{"@turf/helpers":11,"@turf/invariant":12}],10:[function(t,e,n){"use strict";var r=t("@turf/meta"),i=t("@turf/helpers");function o(t){var e=[];"FeatureCollection"===t.type?r.featureEach(t,(function(t){r.coordEach(t,(function(n){e.push(i.point(n,t.properties))}))})):r.coordEach(t,(function(n){e.push(i.point(n,t.properties))}));return i.featureCollection(e)}e.exports=o;e.exports.default=o},{"@turf/helpers":11,"@turf/meta":16}],11:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.earthRadius=6371008.8;n.factors={centimeters:100*n.earthRadius,centimetres:100*n.earthRadius,degrees:n.earthRadius/111325,feet:3.28084*n.earthRadius,inches:39.37*n.earthRadius,kilometers:n.earthRadius/1e3,kilometres:n.earthRadius/1e3,meters:n.earthRadius,metres:n.earthRadius,miles:n.earthRadius/1609.344,millimeters:1e3*n.earthRadius,millimetres:1e3*n.earthRadius,nauticalmiles:n.earthRadius/1852,radians:1,yards:1.0936*n.earthRadius};n.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/n.earthRadius,yards:1.0936133};n.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 r(t,e,n){void 0===n&&(n={});var r={type:"Feature"};(0===n.id||n.id)&&(r.id=n.id);n.bbox&&(r.bbox=n.bbox);r.properties=e||{};r.geometry=t;return r}n.feature=r;n.geometry=function(t,e,n){void 0===n&&(n={});switch(t){case"Point":return i(e).geometry;case"LineString":return a(e).geometry;case"Polygon":return o(e).geometry;case"MultiPoint":return c(e).geometry;case"MultiLineString":return l(e).geometry;case"MultiPolygon":return u(e).geometry;default:throw new Error(t+" is invalid")}};function i(t,e,n){void 0===n&&(n={});if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(t[0])||!f(t[1]))throw new Error("coordinates must contain numbers");return r({type:"Point",coordinates:t},e,n)}n.point=i;n.points=function(t,e,n){void 0===n&&(n={});return s(t.map((function(t){return i(t,e)})),n)};function o(t,e,n){void 0===n&&(n={});for(var i=0,o=t;i=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n};function p(t,e){void 0===e&&(e="kilometers");var r=n.factors[e];if(!r)throw new Error(e+" units is invalid");return t*r}n.radiansToLength=p;function h(t,e){void 0===e&&(e="kilometers");var r=n.factors[e];if(!r)throw new Error(e+" units is invalid");return t/r}n.lengthToRadians=h;n.lengthToDegrees=function(t,e){return d(h(t,e))};n.bearingToAzimuth=function(t){var e=t%360;e<0&&(e+=360);return e};function d(t){return 180*(t%(2*Math.PI))/Math.PI}n.radiansToDegrees=d;n.degreesToRadians=function(t){return t%360*Math.PI/180};n.convertLength=function(t,e,n){void 0===e&&(e="kilometers");void 0===n&&(n="kilometers");if(!(t>=0))throw new Error("length must be a positive number");return p(h(t,e),n)};n.convertArea=function(t,e,r){void 0===e&&(e="meters");void 0===r&&(r="kilometers");if(!(t>=0))throw new Error("area must be a positive number");var i=n.areaFactors[e];if(!i)throw new Error("invalid original units");var o=n.areaFactors[r];if(!o)throw new Error("invalid final units");return t/i*o};function f(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}n.isNumber=f;n.isObject=function(t){return!!t&&t.constructor===Object};n.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!f(t))throw new Error("bbox must only contain numbers")}))};n.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}},{}],12:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("@turf/helpers");n.getCoord=function(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")};n.getCoords=function(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")};n.containsNumber=function t(e){if(e.length>1&&r.isNumber(e[0])&&r.isNumber(e[1]))return!0;if(Array.isArray(e[0])&&e[0].length)return t(e[0]);throw new Error("coordinates must only contain numbers")};n.geojsonType=function(t,e,n){if(!e||!n)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.type)};n.featureOf=function(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)};n.collectionOf=function(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+n+", FeatureCollection required");for(var r=0,i=t.features;r line1 must only contain 2 coordinates");if(2!==r.length)throw new Error(" line2 must only contain 2 coordinates");var a=n[0][0],s=n[0][1],l=n[1][0],c=n[1][1],u=r[0][0],p=r[0][1],h=r[1][0],d=r[1][1],f=(d-p)*(l-a)-(h-u)*(c-s),m=(h-u)*(s-p)-(d-p)*(a-u),g=(l-a)*(s-p)-(c-s)*(a-u);if(0===f)return null;var y=m/f,v=g/f;if(y>=0&&y<=1&&v>=0&&v<=1){var _=a+y*(l-a),x=s+y*(c-s);return i.point([_,x])}return null}n.default=function(t,e){var n={},r=[];"LineString"===t.type&&(t=i.feature(t));"LineString"===e.type&&(e=i.feature(e));if("Feature"===t.type&&"Feature"===e.type&&null!==t.geometry&&null!==e.geometry&&"LineString"===t.geometry.type&&"LineString"===e.geometry.type&&2===t.geometry.coordinates.length&&2===e.geometry.coordinates.length){var u=c(t,e);u&&r.push(u);return i.featureCollection(r)}var p=l.default();p.load(a.default(e));s.featureEach(a.default(t),(function(t){s.featureEach(p.search(t),(function(e){var i=c(t,e);if(i){var a=o.getCoords(i).join(",");if(!n[a]){n[a]=!0;r.push(i)}}}))}));return i.featureCollection(r)}},{"@turf/helpers":11,"@turf/invariant":12,"@turf/line-segment":15,"@turf/meta":16,"geojson-rbush":20}],15:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("@turf/helpers"),i=t("@turf/invariant"),o=t("@turf/meta");n.default=function(t){if(!t)throw new Error("geojson is required");var e=[];o.flattenEach(t,(function(t){!function(t,e){var n=[],o=t.geometry;if(null!==o){switch(o.type){case"Polygon":n=i.getCoords(o);break;case"LineString":n=[i.getCoords(o)]}n.forEach((function(n){var i=function(t,e){var n=[];t.reduce((function(t,i){var o,a,s,l,c,u,p=r.lineString([t,i],e);p.bbox=(a=i,s=(o=t)[0],l=o[1],c=a[0],u=a[1],[sc?s:c,l>u?l:u]);n.push(p);return i}));return n}(n,t.properties);i.forEach((function(t){t.id=e.length;e.push(t)}))}))}}(t,e)}));return r.featureCollection(e)}},{"@turf/helpers":11,"@turf/invariant":12,"@turf/meta":16}],16:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("@turf/helpers");function i(t,e,n){if(null!==t)for(var r,o,a,s,l,c,u,p,h=0,d=0,f=t.type,m="FeatureCollection"===f,g="Feature"===f,y=m?t.features.length:1,v=0;vc||d>u||f>p){l=i;c=n;u=d;p=f;a=0}else{var m=r.lineString([l,i],t.properties);if(!1===e(m,n,o,f,a))return!1;a++;l=i}}))&&void 0}}}))}function u(t,e){if(!t)throw new Error("geojson is required");l(t,(function(t,n,i){if(null!==t.geometry){var o=t.geometry.type,a=t.geometry.coordinates;switch(o){case"LineString":if(!1===e(t,n,i,0,0))return!1;break;case"Polygon":for(var s=0;s0){(b=x.features[0]).properties.dist=o.default(e,b,n);b.properties.location=p+o.default(d,b,n)}if(d.properties.disti;){if(o-i>600){var s=o-i+1,l=r-i+1,c=Math.log(s),u=.5*Math.exp(2*c/3),p=.5*Math.sqrt(c*u*(s-u)/s)*(l-s/2<0?-1:1);t(n,r,Math.max(i,Math.floor(r-l*u/s+p)),Math.min(o,Math.floor(r+(s-l)*u/s+p)),a)}var h=n[r],d=i,f=o;for(e(n,i,r),a(n[o],h)>0&&e(n,i,o);d0;)f--}0===a(n[i],h)?e(n,i,f):e(n,++f,o),f<=r&&(i=f+1),r<=f&&(o=f-1)}}(t,r,i||0,o||t.length-1,a||n)}function e(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function n(t,e){return te?1:0}var r=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function i(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r=t.minX&&e.maxY>=t.minY}function f(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(e,n,r,i,o){for(var a=[n,r];a.length;)if(!((r=a.pop())-(n=a.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;t(e,s,n,r,o),a.push(n,s,s,r)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(t){var e=this.data,n=[];if(!d(t,e))return n;for(var r=this.toBBox,i=[];e;){for(var o=0;o=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)},r.prototype._split=function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var a=this._chooseSplitIndex(n,i,r),s=f(n.children.splice(a,n.children.length-a));s.height=n.height,s.leaf=n.leaf,o(n,this.toBBox),o(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},r.prototype._splitRoot=function(t,e){this.data=f([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(t,e,n){for(var r,i,o,s,l,c,p,h=1/0,d=1/0,f=e;f<=n-e;f++){var m=a(t,0,f,this.toBBox),g=a(t,f,n,this.toBBox),y=(i=m,o=g,s=Math.max(i.minX,o.minX),l=Math.max(i.minY,o.minY),c=Math.min(i.maxX,o.maxX),p=Math.min(i.maxY,o.maxY),Math.max(0,c-s)*Math.max(0,p-l)),v=u(m)+u(g);y=e;d--){var f=t.children[d];s(l,t.leaf?i(f):f),c+=p(l)}return c},r.prototype._adjustParentBBoxes=function(t,e,n){for(var r=n;r>=0;r--)s(e[r],t)},r.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():o(t[e],this.toBBox)},r},"object"==typeof n&&void 0!==e?e.exports=i():(r=r||self).RBush=i();var r,i},{}]},{},[1])(1)}));class CustomHTMLControl{constructor(t){this.custom_html=t.custom_html}onAdd(t){this.map=t;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(t,e,n,r){this.interact_with_filters=t.interact_with_filters;this.notify_on_download=t.notify_on_download;this.included_fields=t.included_fields;this.features=e.concat(n.concat(r))}addListeners(){jQuery(document).on("click",".mapster-data-download",(()=>{this.downloadFeatures()}))}downloadFeatures(){let t=this.processFeatures();t.length>0?this.downloadCSV(t):alert("No features selected for download.")}processFeatures(t){let e=[];this.features.forEach((t=>{if(this.interact_with_filters&&window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.indexOf(t.id)>-1)return;let n=t.data.location?t.data.location:t.data.line?t.data.line:t.data.polygon?t.data.polygon:null,r={};r.title=t.title;r.permalink=t.permalink;r.categories=t.categories.map((t=>t.name)).join(",");this.getRecursivePropertyValue(r,t.data.additional_details,"");r.geography=JSON.stringify(n);if(this.included_fields&&""!==this.included_fields){let t={};this.included_fields.split(",").forEach((e=>{let n=e.trim();r[n]&&(t[n]=r[n])}));r=t}e.push(r)}));return e}getRecursivePropertyValue(t,e,n){for(let r in e)Array.isArray(e[r])?t[n+r]=e[r].join(","):"object"==typeof e[r]?this.getRecursivePropertyValue(t,e[r],n+r+"_"):t[n+r]=JSON.stringify(e[r])}downloadCSV(t){const e=(t,e)=>null===e?"":e;let n=[];t.forEach((t=>{for(let e in t)-1===n.indexOf(e)&&n.push(e)}));t.forEach((t=>{n.forEach((e=>{t[e]||(t[e]="")}))}));let r=t.map((t=>n.map((n=>JSON.stringify(t[n],e).replace(/\\"/g,'""'))).join(",")));r.unshift(n.join(","));r=r.join("\r\n");var i=document.createElement("a"),o=new Blob(["\ufeff",r]),a=URL.createObjectURL(o);i.href=a;i.download="map-data-download.csv";document.body.appendChild(i);i.click();document.body.removeChild(i);if(this.notify_on_download){let t=[];jQuery(".mapster-category-control input").each((function(){jQuery(this).is(":checked")&&t.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:t})})}}onAdd(t){this.map=t;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(t,e,n,r,i,o){this.sort_by_distance=t.sort_by_distance;this.show_distance=t.show_distance;this.units=t.units;this.markers=i;this.mapLibrary=o;this.listing_type=t.listing_type;this.number_of_locations=t.number_of_locations;this.store_locator=t.store_locator_options.enable;this.sort_hours_by_day=t.store_locator_options.sort_hours_by_day;this.features=e.concat(n.concat(r));this.currentPage=1;this.storedBounds=null}storeLocatorHTML(t){return"
Upgrade to Mapster Pro to enable this functionality.
"}setHTML(t){const e=new MapsterHelpers;var n="
    ",r=[];this.features.forEach(((t,n)=>{if(!(window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.indexOf(t.id)>-1)){var i=e.makeFeatureJSON(t.data);if(this.show_distance||this.sort_by_distance){var o=turf.distance(turf.center(i).geometry.coordinates,this.getCenter());t.distance=o*("imperial"===this.units?.621371:1)}r.push(t)}}));this.sort_by_distance&&(r=r.sort(((t,e)=>t.distance>e.distance?1:-1)));var i=[];r.forEach(((t,e)=>{"paginate"===this.listing_type?this.number_of_locations*(this.currentPage-1)<=e&&this.number_of_locations*this.currentPage>e&&i.push(t):i=r}));this.store_locator?n=this.storeLocatorHTML(n,i):i.forEach((t=>{n+=`\n
  • \n ${t.title}\n ${t.distance?t.distance.toFixed(2)+("imperial"===this.units?" miles":" km"):""}\n
  • \n `}));n+="
";if("paginate"===this.listing_type){n+='
';this.currentPage>1&&(n+='');this.number_of_locations*this.currentPage');n+="
"}if(t)return n;jQuery(".mapster-list-control-content").html(n)}getStoreHTML(t){return""}getCenter(){return[this.map.getCenter().lng,this.map.getCenter().lat]}addListeners(){var t=this;const e=new MapsterHelpers;jQuery(document).on("click",".mapster-list-control li",(function(n){if(!n.isTrigger){var r=t.features.find((t=>parseInt(t.id)==jQuery(this).data("id"))),i=e.makeFeatureJSON(r.data).features[0];if("Point"===i.geometry.type){const e=t.markers.find((t=>t.mapsterProperties.id===r.id));e&&r.data.enable_popup&&t.openPopup(e,r);!e&&r.data.enable_popup&&t.openPopupNonMarker(r);t.centerMap(i.geometry.coordinates,15)}else{var o=turf.bbox(i);t.fitBounds(o,{padding:20})}if(t.store_locator){jQuery(".mapster-list-control-content").hide();jQuery(".mapster-list-control-single-content").show();jQuery(".mapster-list-control-single-content").html(t.getStoreHTML(r))}}}));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(t,e){const n=new MapsterHelpers;t.setPopup(new this.mapLibrary.Popup(n.returnPopupOptions(e.data)).setHTML(n.getPopupHTML(e.id,e.data))).togglePopup()}openPopupNonMarker(t){let e=this;const n=setInterval((()=>{if(e.map.getBounds().contains(t.data.location.coordinates)){e.map.fire("click",{lngLat:t.data.location.coordinates,originalEvent:{}});clearInterval(n)}}),100)}centerMap(t,e){this.map.flyTo({center:t,zoom:e})}fitBounds(t,e){this.map.fitBounds(t,e)}onAdd(t){this.map=t;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(t){this.map=t;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 t=this.map.getBounds();this.storedBounds=[t.getSouthWest().lng(),t.getSouthWest().lat(),t.getNorthEast().lng(),t.getNorthEast().lat()]}));return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}} ;class PitchToggle{constructor(t=-20,e=70,n=null){this._bearing=-20;this._pitch=70;this._minpitchzoom=n}onAdd(t){this._map=t;let e=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===t.getPitch()){let n={pitch:e._pitch,bearing:e._bearing};e._minpitchzoom&&t.getZoom()>e._minpitchzoom&&(n.zoom=e._minpitchzoom);t.easeTo(n);e._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-2d"}else{t.easeTo({pitch:0,bearing:0});e._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(t,e,n,r,i,o,a,s,l,c,u){this.displayMode=t.category_display;this.checkboxMode=t.checkbox_display;this.initialVisibility=t.initial_visibility;this.preSelectedCategories=t.pre_selected_categories;this.independentChildren=t.independent_children;this.excludedCategories=t.excluded_categories;this.functionality=t.functionality;this.additional_filters=t.additional_filters;this.accordion_layout=t.accordion_layout;this.show_number_of_features=t.show_number_of_features;this.did_one_accordion=!1;this.markers=n;this.map_provider=s;this.circle_clustering=l;this.label_icon_clustering=c;this.marker_clustering=u;this.cluster_options=e;this.features=i.concat(o.concat(a));this.dataLayers=r;this.locations=i;this.lines=o;this.polygons=a}setMarkers(t){this.markers=t}organizeCategories(){var t=[];this.features.forEach((e=>{e.categories.forEach((e=>{-1===t.findIndex((t=>t.id===e.id))&&t.push(e)}))}));return t=this.filterCategories(t)}returnHTML(){return`\n
\n ${this.returnCategoryHTML(this.organizeCategories())}\n
\n `}returnCategoryHTML(t){var e="
    ";t.filter((t=>0===t.parent)).forEach(((n,r)=>{var i=t.filter((t=>t.parent===n.id));e+=this.returnInputHTML(n,i);e+=this.returnChildrenHTML(n,t)}));return e+="
"}returnChildrenHTML(t,e){var n="
    ",r=e.filter((e=>e.parent===t.id));r.forEach((t=>{n+=this.returnInputHTML(t,[]);n+=this.returnChildrenHTML(t,e)}));n+="
";0===r.length&&(n="");return n}returnInputHTML(t,e){var n=!0;!this.initialVisibility&&this.preSelectedCategories&&-1===this.preSelectedCategories.indexOf(t.id)&&(n=!1);return this.returnAccordionHTML(`\n
  • \n ${"checkbox"===this.checkboxMode?`\n \n `:`\n \n `}\n ${"colors"===this.displayMode?`
    `:""}\n ${"icons"===this.displayMode?`
    `:""}\n \n
  • \n `,t,e)}setToggles(t){var e=jQuery(t).data("term"),n=jQuery(t).data("parent"),r=jQuery(t).is(":checked");if(!this.independentChildren)if(0===n)r?jQuery(`.mapster-cat-toggle[data-parent="${e}"]`).prop("checked",!0):jQuery(`.mapster-cat-toggle[data-parent="${e}"]`).prop("checked",!1);else if(r)jQuery(`.mapster-cat-toggle[data-term="${n}"]`).prop("checked",!0);else{var i=!0;jQuery(`.mapster-cat-toggle[data-parent="${n}"]`).each((function(){jQuery(this).is(":checked")&&(i=!1)}));i&&jQuery(`.mapster-cat-toggle[data-term="${n}"]`).prop("checked",!1)}}returnIDsToHideFeatures(t){let e=[];this.features.forEach((n=>{if(n.categories.length>0)if("exclusive"===this.functionality)n.categories.find((e=>t.indexOf(e.id)>-1))&&e.push(n.id);else if("inclusive"===this.functionality){var r=!0;n.categories.forEach((e=>{-1===t.indexOf(e.id)&&(r=!1)}));r&&e.push(n.id)}}));return e}returnNumberOfFeatures(){return!1}adjustMarkers(t){let e=[];this.markers.forEach((n=>{const r=this.returnMarkerProperties(n);if(r.categories.length>0)if("exclusive"===this.functionality)if(r.categories.find((e=>t.indexOf(e.id)>-1))){this.changeMarker("hide",n);e.push(n.mapsterProperties.id)}else this.changeMarker("show",n);else if("inclusive"===this.functionality){var i=!0;if(r.categories.length>0){r.categories.forEach((e=>{-1===t.indexOf(e.id)&&(i=!1)}));if(i){this.changeMarker("hide",n);e.push(n.mapsterProperties.id)}else this.changeMarker("show",n)}}}));this.adjustMarkerClusters(e)}adjustMarkerClusters(t){if(this.marker_clustering){let e=["marker"];(new MapsterHelpers).makeClusters(this.map,this.map_provider,this.cluster_options,e,this.locations,[],[],t)}}returnAccordionHTML(t,e,n){return t}filterCategories(t){return t}changeMarker(t,e){"hide"===t?e.remove():"show"===t&&e.addTo(this.map)}changeLayerVisibility(){var t=[];jQuery(".mapster-cat-toggle").each((function(){jQuery(this).is(":checked")||t.push(jQuery(this).data("term"))}));var e=this.returnIDsToHideFeatures(t);this.setHiddenFeatures(e);this.adjustMarkers(t)}setHiddenFeatures(t){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,t);this.map.setLayoutProperty("symbol","text-size",["case",["in",["get","post_id"],["literal",t]],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",t]],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",t]],0,["has","circle_radius"],["to-number",["get","circle_radius"]],0]);this.map.setPaintProperty("circle","circle-stroke-width",["case",["in",["get","post_id"],["literal",t]],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",t]],0,["has","width"],["to-number",["get","width"]],2]);if(this.map.getLayer("fill")){const e=new MapsterHelpers;let n=this.polygons.filter((e=>-1===t.indexOf(e.id))),r=e.createLayerGeoJSON(this.map,"polygon","fill",[],[],n);this.map.getSource("fill").setData(r)}}returnMarkerProperties(t){return t.mapsterProperties}addListeners(){var t=this;jQuery(document).on("change",".mapster-cat-toggle",(function(){t.setToggles(this);t.changeLayerVisibility()}));jQuery(document).on("click",".mapster-accordion-indicator",(function(){let t=!1;jQuery(this).parent().hasClass("mapster-accordion-indicator-open")&&(t=!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(t)jQuery(this).parent().addClass("mapster-accordion-indicator-closed");else{jQuery(this).parent().addClass("mapster-accordion-indicator-open");jQuery(this).parent().next("ul").slideToggle()}}))}onAdd(t){this.map=t;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(t){this.map=t;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(t){this.toggleable_layers=t.toggleable_layers;this.toggleable_layer_titles=t.toggleable_layer_titles;this.checkbox_type=t.checkbox_type}returnHTML(){let t='
      ';const e=this.toggleable_layers.replace("\r","").split("\n"),n=this.toggleable_layer_titles.replace("\r","").split("\n");e.forEach(((e,r)=>{t+="
    • ";const i=e.split(",");let o=!0,a=!0;i.forEach((t=>{if(""!==t){this.map.getLayer(t.trim())||(o=!1);"hidden"!==this.map.getLayoutProperty(t.trim(),"visibility")&&void 0===this.map.getLayoutProperty(t.trim(),"visibility")||(a=!1)}}));o?"checkbox"===this.checkbox_type?t+=` ${n[r]}`:"radio"===this.checkbox_type?t+=` ${n[r]}`:"switch"===this.checkbox_type&&(t+=` ${n[r]}`):alert("Please double check the layers you've set for the layer control: some don't exist in the style!");t+="
    • "}));t+="
    ";return t}changeLayerVisibility(){let t=this;jQuery(".mapster-layer-toggle").each((function(){jQuery(this).data("layers").split(",").forEach((e=>{jQuery(this).is(":checked")?t.map.setLayoutProperty(e.trim(),"visibility","visible"):t.map.setLayoutProperty(e.trim(),"visibility","none")}))}))}addListeners(){var t=this;jQuery(document).on("change",".mapster-layer-toggle",(function(){t.changeLayerVisibility()}))}onAdd(t){this.map=t;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-layer-control";const e=setInterval((()=>{if(this.map.isStyleLoaded()){this._container.innerHTML=this.returnHTML();clearInterval(e)}}),100);this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class StyleControl{constructor(t){this.toggleable_styles=t.toggleable_styles;this.toggleable_styles_titles=t.toggleable_styles_titles;this.initial_style_title=t.initial_style_title;this.default_style=!1}returnHTML(){let t='
      ';this.default_style=this.map.getStyle();t+=`
    • ${this.initial_style_title}`;const e=this.toggleable_styles.replace("\r","").split("\n"),n=this.toggleable_styles_titles.replace("\r","").split("\n");e.forEach(((e,r)=>{if(""!==e){t+="
    • ";t+=` ${n[r]}`;t+="
    • "}}));t+="
    ";return t}addListeners(){var t=this;new MapsterHelpers;jQuery(document).on("change",".mapster-style-toggle",(function(){const e=jQuery(this).data("index");if("default"!==e){const n=t.toggleable_styles.split("\n");n[e].indexOf("{")>-1?t.map.setStyle(JSON.parse(n[e])):t.map.setStyle(n[e]);t.map.fire("mapster_custom_style_load")}else{t.map.setStyle(t.default_style);t.map.fire("mapster_custom_style_load")}}))}onAdd(t){this.map=t;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-style-control";const e=setInterval((()=>{if(this.map.isStyleLoaded()){this._container.innerHTML=this.returnHTML();clearInterval(e)}}),100);this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class ElevationControl{constructor(t){this.lines=t.lines;this.post_id=t.post_id;this.single_line=t.single_line;this.open_on_load=t.open_on_load;this.profile_color=t.profile_color;this.units=t.units;this.show_line_length=t.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",(t=>{this.last_line_displayed=this.lines.find((e=>e.id===t.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(t){let e=[],n=turf.length(t.data.line);for(let r=0;r""));if(this.show_line_length){a=[];e.forEach(((t,e)=>{let r=n/50;"feet"===this.units&&(r*=.621371);let i=parseInt(e*r*10)/10;a.push(i)}))}new Chart(document.getElementById("mapster-chartjs"),{type:"line",data:{labels:a,datasets:[{label:"Elevation",data:e,fill:!1,borderColor:this.profile_color,pointRadius:0,tension:.2}]},options:o.returnElevationChartOptions(this.units,this.show_line_length),plugins:[o.returnElevationChartPlugin(this.map,t)]})}onAdd(t){this.map=t;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(t,e){return{id:"corsair",afterInit:t=>{t.corsair={x:0,y:0}},afterEvent:(t,e)=>{const{chartArea:{top:n,bottom:r,left:i,right:o}}=t,{event:{x:a,y:s}}=e;if(ao||sr){t.corsair={x:a,y:s,draw:!1};t.draw()}else{t.corsair={x:a,y:s,draw:!0};t.draw()}},afterDatasetsDraw:(n,r,i)=>{const{ctx:o,chartArea:{top:a,bottom:s,left:l,right:c}}=n,{x:u,y:p,draw:h}=n.corsair;if(!h)return;o.lineWidth=i.width||0;o.setLineDash(i.dash||[]);o.strokeStyle=i.color||"black";o.save();o.beginPath();o.moveTo(u,s);o.lineTo(u,a);o.stroke();o.restore();const d=(u-l)/(c-l);let f=turf.length(e.data.line),m=turf.along(e.data.line,f*d);if(t.getSource("elevation-point-along")&&t.getLayer("elevation-point-along-layer")){t.getSource("elevation-point-along").setData(m);t.setLayoutProperty("elevation-point-along-layer","visibility","visible")}else{t.addSource("elevation-point-along",{type:"geojson",data:m});t.addLayer({id:"elevation-point-along-layer",type:"circle",source:"elevation-point-along"})}}}}returnElevationChartOptions(t,e){return{interaction:{intersect:!1,mode:"index"},scales:{x:{title:{display:!!e,text:"meters"===t?"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"===t?"m":"ft"})`},tooltip:{displayColors:!1,callbacks:{label:function(e){return parseInt(10*e.parsed.y)/10+" "+("meters"===t?"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(t,e){return{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{"raster-tiles":{type:"raster",tiles:[t],tileSize:256,attribution:e}},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(t){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 t=!1;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(t=!0);return t}changeCursor(t,e,n){e.data.enable_popup&&(t.getCanvas().style.cursor="on"===n?"pointer":"grab")}formatResponse(t){["location","line","polygon"].forEach((e=>{t[e+"s"].forEach((n=>{this.setObjectProperties(n,t[e+"_template"]);this.setPopupStyles(n,t.popup_styles)}))}));return new Promise((e=>{e(t)}))}getDefaultCenter(){let t=[0,0];"1"===window.mapster_params.activated&&window.mapster_params.mapster_default_lat&&window.mapster_params.mapster_default_lng&&(t=[parseFloat(window.mapster_params.mapster_default_lng),parseFloat(window.mapster_params.mapster_default_lat)]);return t}getDefaultZoom(){let t=2;"1"===window.mapster_params.activated&&window.mapster_params.mapster_default_zoom&&(t=parseFloat(window.mapster_params.mapster_default_zoom));return t}doHover(t,e){let n=e.data.line?"line":e.data.symbol?"symbol":e.data.circle?"circle":e.data.polygon?"fill":[],r="line"===n||"fill"===n?e.data:"circle"===n?e.data.circle:e.data.symbol;if(r.hover_effects&&r.hover_effects.hover_enabled){t.removeFeatureState({source:n});t.setFeatureState({source:n,id:e.id},{hover:!0})}}doHoverOut(t,e){let n=e.data.line?"line":e.data.symbol?"symbol":e.data.circle?"circle":e.data.polygon?"fill":[],r="line"===n||"fill"===n?e.data:"circle"===n?e.data.circle:e.data.symbol;r.hover_effects&&r.hover_effects.hover_enabled&&t.setFeatureState({source:n,id:e.id},{hover:!1})}doMarkerHover(t,e,n){let r=n.mapsterProperties.data;if(r.marker.hover_effects.hover_enabled){const i=new e.Marker({color:r.marker.hover_effects.hover_color,scale:parseFloat(r.marker.hover_effects.hover_scale)/100,rotation:parseFloat(r.marker.hover_effects.hover_rotation),anchor:r.marker.anchor});-1===i._element.className.indexOf("mapster-remove-hover")&&(i._element.className+=" mapster-remove-hover");-1===n._element.className.indexOf("mapster-hide-original")&&(n._element.className+=" mapster-hide-original");i.setLngLat([n._lngLat.lng,n._lngLat.lat]).addTo(t);return i}return!1}doMarkerHoverOut(t,e){e._element.className.indexOf("mapster-hide-original")>-1&&(e._element.className=e._element.className.replace(" mapster-hide-original",""));t.remove()}setMapCompare(t,e,n,r){ }applyProSearchFilter(t,e){ return e}setGeolocationOnLoad(t){ }setMapBreakpointSizes(t,e){ }async getImageData(t){return wp.media.attachment(t).fetch().then((t=>t))}async setCustomImageMap(t,e,n){ }loadModalSteps(t,e,n,r,i,o){const a=new MapsterConstants;let s=!1,l=[];if("create_point"===r){if(i)if(1===i.length){s=i[0].term_id;if(o.submission_interface.include_address_search){c(t);u()}else{u();p()}}else{c(t);jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`).html(`\n
    \n ${i.map((t=>`\n
    \n ${t.icon?`
    `:""}\n ${t.name?`

    ${t.name}

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

    ${t.description}

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

    ${o.custom_texts.search_location}

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

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

    \n
    \n

    ${o.custom_texts.try_again}

    \n ${i?`

    ${o.custom_texts.confirm}

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

    ${o.custom_texts.drag_zoom}

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

    ${o.header_text}

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

    ${o.body_text}

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