UNPKG

mapbox-gl

Version:
1 lines 938 kB
import{i as e,a as t,b as i,c as o,d as r,P as n,e as s,f as a,v as l,g as c,u as h,h as d,j as _,s as u,w as p,p as f,k as m,l as g,I as v,m as y,R as x,n as b,o as w,q as T,r as E,t as S,A as I,E as C,x as R,y as D,z as A,B as L,C as O,D as P,F as M,G as z,H as F,T as k,J as B,K as N,V as U,L as j,M as G,N as V,O as H,Q as W,S as Z,U as q,W as $,X,Y,Z as K,_ as Q,$ as J,a0 as ee,a1 as te,a2 as ie,a3 as oe,a4 as re,a5 as ne,a6 as se,a7 as ae,a8 as le,a9 as ce,aa as he,ab as de,ac as _e,ad as ue,ae as pe,af as fe,ag as me,ah as ge,ai as ve,aj as ye,ak as xe,al as be,am as we,an as Te,ao as Ee,ap as Se,aq as Ie,ar as Ce,as as Re,at as De,au as Ae,av as Le,aw as Oe,ax as Pe,ay as Me,az as ze,aA as Fe,aB as ke,aC as Be,aD as Ne,aE as Ue,aF as je,aG as Ge,aH as Ve,aI as He,aJ as We,aK as Ze,aL as qe,aM as $e,aN as Xe,aO as Ye,aP as Ke,aQ as Qe,aR as Je,aS as et,aT as tt,aU as it,aV as ot,aW as rt,aX as nt,aY as st,aZ as at,a_ as lt,a$ as ct,b0 as ht,b1 as dt,b2 as _t,b3 as ut,b4 as pt,b5 as ft,b6 as mt,b7 as gt,b8 as vt,b9 as yt,ba as xt,bb as bt,bc as wt,bd as Tt,be as Et,bf as St,bg as It,bh as Ct,bi as Rt,bj as Dt,bk as At,bl as Lt,bm as Ot,bn as Pt,bo as Mt,bp as zt,bq as Ft,br as kt,bs as Bt,bt as Nt,bu as Ut,bv as jt,bw as Gt,bx as Vt,by as Ht,bz as Wt,bA as Zt,bB as qt,bC as $t,bD as Xt,bE as Yt,bF as Kt,bG as Qt,bH as Jt,bI as ei,bJ as ti,bK as ii,bL as oi,bM as ri,bN as ni,bO as si,bP as ai,bQ as li,bR as ci,bS as hi,bT as di,bU as _i,bV as ui,bW as pi,bX as fi,bY as mi,bZ as gi,b_ as vi,b$ as yi,c0 as xi,c1 as bi,c2 as wi,c3 as Ti,c4 as Ei,c5 as Si,c6 as Ii,c7 as Ci,c8 as Ri,c9 as Di,ca as Ai,cb as Li,cc as Oi,cd as Pi,ce as Mi,cf as zi,cg as Fi,ch as ki,ci as Bi,cj as Ni,ck as Ui,cl as ji,cm as Gi,cn as Vi,co as Hi,cp as Wi,cq as Zi,cr as qi,cs as $i,ct as Xi,cu as Yi,cv as Ki,cw as Qi,cx as Ji,cy as eo,cz as to,cA as io,cB as oo,cC as ro,cD as no,cE as so,cF as ao,cG as lo,cH as co,cI as ho,cJ as _o,cK as uo,cL as po,cM as fo,cN as mo,cO as go,cP as vo,cQ as yo,cR as xo,cS as bo,cT as wo,cU as To,cV as Eo,cW as So,cX as Io,cY as Co,cZ as Ro,c_ as Do,c$ as Ao,d0 as Lo,d1 as Oo,d2 as Po,d3 as Mo,d4 as zo,d5 as Fo,d6 as ko,d7 as Bo,d8 as No,d9 as Uo,da as jo,db as Go,dc as Vo,dd as Ho,de as Wo,df as Zo,dg as qo,dh as $o,di as Xo,dj as Yo,dk as Ko,dl as Qo,dm as Jo,dn as er,dp as tr,dq as ir,dr as or,ds as rr,dt as nr,du as sr,dv as ar,dw as lr,dx as cr,dy as hr,dz as dr,dA as _r,dB as ur,dC as pr,dD as fr,dE as mr,dF as gr,dG as vr,dH as yr,dI as xr,dJ as br,dK as wr,dL as Tr,dM as Er,dN as Sr,dO as Ir,dP as Cr,dQ as Rr,dR as Dr,dS as Ar,dT as Lr,dU as Or,dV as Pr,dW as Mr,dX as zr,dY as Fr,dZ as kr,d_ as Br,d$ as Nr,e0 as Ur,e1 as jr,e2 as Gr,e3 as Vr,e4 as Hr,e5 as Wr,e6 as Zr,e7 as qr,e8 as $r,e9 as Xr,ea as Yr,eb as Kr,ec as Qr,ed as Jr,ee as en,ef as tn,eg as on,eh as rn,ei as nn,ej as sn,ek as an,el as ln,em as cn,en as hn,eo as dn,ep as _n,eq as un,er as pn,es as fn,et as mn,eu as gn,ev as vn,ew as yn,ex as xn,ey as bn,ez as wn,eA as Tn,eB as En,eC as Sn,eD as In,eE as Cn,eF as Rn,eG as Dn,eH as An,eI as Ln,eJ as On,eK as Pn,eL as Mn,eM as zn,eN as Fn,eO as kn,eP as Bn,eQ as Nn,eR as Un,eS as jn,eT as Gn,eU as Vn,eV as Hn,eW as Wn,eX as Zn,eY as qn,eZ as $n,e_ as Xn,e$ as Yn,f0 as Kn,f1 as Qn,f2 as Jn,f3 as es,f4 as ts,f5 as is,f6 as os,f7 as rs}from"./shared.js";var ns="3.22.0";const ss={create:"create",load:"load",fullLoad:"fullLoad"},as={mark(e){performance.mark(e)},measure(e,t,i){performance.measure(e,t,i)}};function ls(n){const s=n.name.split("?")[0];return t(s)&&s.includes("mapbox-gl.js")?"javascript":t(s)&&s.includes("mapbox-gl.css")?"css":i(s)?"fontRange":o(s)?"sprite":e(s)?"style":r(s)?"tilejson":"other"}var cs,hs={},ds=function(){if(cs)return hs;function e(e){return!t(e)}function t(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(i);try{t=new Worker(o),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(o),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===i[o=t&&t.failIfMajorPerformanceCaveat]&&(i[o]=function(t){var i,o=function(t){var i=document.createElement("canvas"),o=Object.create(e.webGLContextAttributes);return o.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",o)}(t);if(!o)return!1;try{i=o.createShader(o.VERTEX_SHADER)}catch(e){return!1}return!(!i||o.isContextLost())&&(o.shaderSource(i,"void main() {}"),o.compileShader(i),!0===o.getShaderParameter(i,o.COMPILE_STATUS))}(o)),i[o]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var o}cs=1,hs.supported=e,hs.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},hs}();function _s(e,t,i){const o=document.createElement(e);return null!=t&&(o.className=t),i&&i.appendChild(o),o}function us(e,t,i){const o=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))o.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(o),o}const ps="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,fs=ps&&void 0!==ps.userSelect?"userSelect":"WebkitUserSelect";let ms;function gs(){ps&&fs&&(ms=ps[fs],ps[fs]="none")}function vs(){ps&&fs&&(ps[fs]=ms)}function ys(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",ys,!0)}function xs(){window.addEventListener("click",ys,!0),window.setTimeout(()=>{window.removeEventListener("click",ys,!0)},0)}function bs(e,t){const i=e.getBoundingClientRect();return Es(e,i,t)}function ws(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;r<t.length;r++)o.push(Es(e,i,t[r]));return o}function Ts(e){return/firefox/i.test(navigator.userAgent)&&/macintosh/i.test(navigator.userAgent)&&2===e.button&&e.ctrlKey?0:e.button}function Es(e,t,i){const o=e.offsetWidth===t.width?1:e.offsetWidth/t.width;return new n((i.clientX-t.left)*o,(i.clientY-t.top)*o)}const Ss="01",Is="NO_ACCESS_TOKEN";class Cs{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Ss,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!s(e))return e;const i=Ds(e);return i.params.push(`sdk=js-${ns}`),i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!s(e))return e;const i=Ds(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeModelURL(e,t){if(!s(e))return e;const i=Ds(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,o){if(!s(e))return e;const r=Ds(e);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),o&&r.params.push(`worldview=${o}`),this._makeAPIURL(r,this._customAccessToken||t)}normalizeIconsetURL(e,t){const i=Ds(e);return s(e)?(i.path=`/styles/v1${i.path}/iconset.pbf`,this._makeAPIURL(i,this._customAccessToken||t)):As(i)}normalizeSpriteURL(e,t,i,o){const r=Ds(e);return s(e)?(r.path=`/styles/v1${r.path}/sprite${t}${i}`,this._makeAPIURL(r,this._customAccessToken||o)):(r.path+=`${t}${i}`,As(r))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!s(e))return e;const o=Ds(e);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==o.authority&&512===i?"@2x":""}${m.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${c.RASTER_URL_PREFIX}${o.path}`:"rasterarrays"===o.authority?o.path=`/${c.RASTERARRAYS_URL_PREFIX}${o.path}`:"3dtiles"===o.authority?o.path=`/${c.TILES3D_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${c.TILE_URL_VERSION}${o.path}`);const r=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(o.params)||c.ACCESS_TOKEN;return c.REQUIRE_ACCESS_TOKEN&&r&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,r)}canonicalizeTileURL(e,t){const i=Ds(e);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let o="mapbox://";i.path.match(/^\/raster\/v1\//)?o+=`raster/${i.path.replace(`/${c.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?o+=`rasterarrays/${i.path.replace(`/${c.RASTERARRAYS_URL_PREFIX}/`,"")}`:o+=`tiles/${i.path.replace(`/${c.TILE_URL_VERSION}/`,"")}`;let r=i.params;return t&&(r=r.filter(e=>!e.match(/^access_token=/))),r.length&&(o+=`?${r.join("&")}`),o}canonicalizeTileset(e,t){const i=!!t&&s(t),o=[];for(const t of e.tiles||[])a(t)?o.push(this.canonicalizeTileURL(t,i)):o.push(t);return o}_makeAPIURL(e,t){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",o=Ds(c.API_URL);if(e.protocol=o.protocol,e.authority=o.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==o.path&&(e.path=`${o.path}${e.path}`),!c.REQUIRE_ACCESS_TOKEN)return As(e);if(t=t||c.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter(e=>-1===e.indexOf("access_token")),e.params.push(`access_token=${t||""}`),As(e)}}const Rs=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Ds(e){const t=e.match(Rs);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function As(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const Ls="mapbox.eventData";function Os(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(g(t[1]))}catch(e){return null}}function Ps(e){return!(!c.EVENTS_URL||!e&&!c.ACCESS_TOKEN)}class Ms{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=Os(c.ACCESS_TOKEN);let i="";return i=t&&t.u?_(t.u):c.ACCESS_TOKEN||"",e?`${Ls}.${e}:${i}`:`${Ls}:${i}`}fetchEventData(){const e=u("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid"),o=this.getStorageKey("uuidTimestamp");if(e)try{const e=localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const r=localStorage.getItem(i);r&&(this.anonId=r);const n=localStorage.getItem(o);n&&(this.anonIdTimestamp=Number(n));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<s)&&this.refreshUUID()}catch(e){p("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=h(),this.anonIdTimestamp=Date.now()}saveEventData(){const e=u("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid"),o=this.getStorageKey("uuidTimestamp"),r=this.anonId,n=this.anonIdTimestamp;if(e&&r)try{localStorage.setItem(i,r),Object.keys(this.eventData).length>=1&&localStorage.setItem(t,JSON.stringify(this.eventData)),n&&localStorage.setItem(o,n.toString())}catch(e){p("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,o){if(!c.EVENTS_URL)return;const r=Ds(c.EVENTS_URL);r.params.push(`access_token=${o||c.ACCESS_TOKEN||""}`);const n={event:this.type,created:new Date(e).toISOString()},s=t?Object.assign(n,t):n,a={url:As(r),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=f(a,e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(o)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}class zs extends Ms{constructor(e){super("metrics"),e&&(this.data=e)}postMetricsEvent(e){if(!Ps(e))return;this.anonId||this.fetchEventData(),l(this.anonId)||this.refreshUUID();const t=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}}const Fs=new class extends Ms{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){Ps(t)&&Array.isArray(e)&&e.some(e=>s(e)||a(e))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Os(c.ACCESS_TOKEN),i=t?t.u:c.ACCESS_TOKEN;let o=i!==this.eventData.tokenU;l(this.anonId)||(this.refreshUUID(),o=!0);const r=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(r),i=(r-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate()}else o=!0;o?this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:ns,skuId:Ss,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=r,this.eventData.tokenU=i)},e):this.processRequests()}},ks=Fs.postTurnstileEvent.bind(Fs),Bs=new class extends Ms{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,o){this.skuToken=t,this.errorCb=o,c.EVENTS_URL&&(i||c.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Is)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),l(this.anonId)||this.refreshUUID(),this.postEvent(i,{sdkIdentifier:"mapbox-gl-js",sdkVersion:ns,skuId:Ss,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e))}remove(){this.errorCb=null}},Ns=Bs.postMapLoadEvent.bind(Bs),Us=new class extends Ms{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(e){let t=this.mapInstanceIdMap.get(e);return t||(t=h(),this.mapInstanceIdMap.set(e,t)),t}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:o,importedStyles:r}=t;if(!Ps(e))return;const n=this.getMapInstanceId(i),s={mapInstanceId:n,eventId:this.getEventId(n),style:o};r.length&&(s.importedStyles=r),this.queueRequest({timestamp:Date.now(),payload:s},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}},js=Us.postStyleLoadEvent.bind(Us),Gs=new zs({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Vs=Gs.postMetricsEvent.bind(Gs),Hs=new zs({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Ws=Hs.postMetricsEvent.bind(Hs),Zs=new class extends Ms{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){Ps(e)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:i,performanceData:o}=this.queue.shift(),r=function(t){const i=performance.getEntriesByType("resource"),o=performance.getEntriesByType("mark"),r=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const o of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,n=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,o.startTime),t[r]=Math.max(t[r]||-1/0,o.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==o.transferSize&&0===o.transferSize&&a(s),a(n)}return t}(function(e,t){const i={};if(e)for(const o of e){const e=t(o);void 0===i[e]&&(i[e]=[]),i[e].push(o)}return i}(i,ls)),n=window.devicePixelRatio,s=navigator.connection||navigator.mozConnection||navigator.webkitConnection,a=s?s.effectiveType:void 0,l={counters:[],metadata:[],attributes:[]},c=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in r)c(l.counters,e,r[e]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(c(l.counters,"interactionRangeMin",t.interactionRange[0]),c(l.counters,"interactionRangeMax",t.interactionRange[1])),o)for(const e of Object.values(ss)){const t=o.find(t=>t.name===e);t&&c(l.counters,e,t.startTime)}return c(l.counters,"visibilityHidden",t.visibilityHidden),c(l.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(i)),c(l.attributes,"terrainEnabled",t.terrainEnabled?"true":"false"),c(l.attributes,"fogEnabled",t.fogEnabled?"true":"false"),c(l.attributes,"projection",t.projection),c(l.attributes,"zoom",t.zoom),c(l.metadata,"devicePixelRatio",n),c(l.metadata,"connectionEffectiveType",a),c(l.metadata,"navigatorUserAgent",navigator.userAgent),c(l.metadata,"screenWidth",window.screen.width),c(l.metadata,"screenHeight",window.screen.height),c(l.metadata,"windowWidth",window.innerWidth),c(l.metadata,"windowHeight",window.innerHeight),c(l.metadata,"mapWidth",t.width/n),c(l.metadata,"mapHeight",t.height/n),c(l.metadata,"webglRenderer",t.renderer),c(l.metadata,"webglVendor",t.vendor),c(l.metadata,"sdkVersion",ns),c(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(o);for(const e of r.metadata);for(const e of r.counters);for(const e of r.attributes);this.postEvent(i,r,()=>{},t)}},qs=Zs.postPerformanceEvent.bind(Zs),$s=new class extends Ms{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,o){if(!c.API_URL||!c.SESSION_PATH)return;const r=Ds(c.API_URL+c.SESSION_PATH);r.params.push(`sku=${t||""}`),r.params.push(`access_token=${o||c.ACCESS_TOKEN||""}`);const n={url:As(r),headers:{"Content-Type":"text/plain"}};this.pendingRequest=d(n,e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(o)})}getSessionAPI(e,t,i,o){this.skuToken=t,this.errorCb=o,c.EVENTS_URL&&c.SESSION_PATH&&c.API_URL&&(i||c.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Is)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}remove(){this.errorCb=null}},Xs=$s.getSessionAPI.bind($s),Ys=new Set;function Ks(e,t){t?Ys.add(e):Ys.delete(e)}class Qs{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(e,t){this._updatedImages[t]=this._updatedImages[t]||new Set,this._updatedImages[t].add(v.toString(e)),this.setDirty()}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function Js(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}const ea={workerUrl:"",workerClass:null,workerParams:void 0};function ta(){const e=ea.workerUrl?ea.workerUrl:new URL("worker.js",import.meta.url).href,t=new Blob([`import '${e}';`],{type:"application/javascript"});return new Worker(URL.createObjectURL(t),{type:"module"})}const ia="mapboxgl_preloaded_worker_pool";class oa{constructor(e){this.active={},this.name=e}acquire(e,t=oa.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<t;){const e=ta();this.workers.push(e)}return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&0===this.numActive()&&(this.workers.forEach(e=>{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[ia]}numActive(){return Object.keys(this.active).length}}oa.workerCount=2;class ra{constructor(e,t,i="Worker",o=oa.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=E();const r=this.workerPool.acquire(this.id,o);for(let e=0;e<r.length;e++){const o=new ra.Actor(r[e],t,this.id);o.name=`${i} ${e}`,this.actors.push(o)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(e,t,i){S(this.actors,(i,o)=>{i.send(e,t,o)},i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}let na,sa;function aa(){return na||(na=new oa),na}ra.Actor=I;class la extends C{constructor(e){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new R,this.dirty=!0,this.spriteFormat=e,"raster"!==e&&D()&&(this.imageRasterizerDispatcher=new ra((sa||(sa=new oa("ImageRasterizer")),sa),this,"Image Rasterizer Worker",1))}addScope(e){this.loaded.set(e,!1),this.imageProviders.set(e,new Map),this.images.set(e,new Map),this.updatedImages.set(e,new Set),this.callbackDispatchedThisFrame.set(e,new Set),this.imageVersions.set(e,new Map),this.patterns.set(e,new Map),this.atlasImage.set(e,new T({width:1,height:1}))}removeScope(e){this.loaded.delete(e),this.imageProviders.delete(e),this.images.delete(e),this.updatedImages.delete(e),this.callbackDispatchedThisFrame.delete(e),this.imageVersions.delete(e),this.patterns.delete(e),this.atlasImage.delete(e);const t=this.atlasTexture.get(e);t&&(t.destroy(),this.atlasTexture.delete(e))}addImageProvider(e,t){this.imageProviders.has(t)||this.imageProviders.set(t,new Map),this.imageProviders.get(t).set(e.id,e)}removeImageProvider(e,t){this.imageProviders.has(t)&&this.imageProviders.get(t).delete(e)}getPendingImageProviders(){const e=[];for(const t of this.imageProviders.values())for(const i of t.values())i.hasPendingRequests()&&e.push(i);return e}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new A),this._imageRasterizer}isLoaded(){for(const e of this.loaded.keys())if(!this.loaded.get(e))return!1;return!0}setLoaded(e,t){if(this.loaded.get(t)!==e&&(this.loaded.set(t,e),e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[]}}hasImage(e,t){return!!this.getImage(e,t)}getImage(e,t){return this.images.get(t).get(e.toString())}addImage(e,t,i){if(this._validate(e,i)){this.images.get(t).set(e.toString(),i);const o=this.imageVersions.get(t),r=o.get(e.toString())||0;o.set(e.toString(),r+1)}}_validate(e,t){let i=!0;return this._validateStretch(t.stretchX,t.data&&t.data.width)||(this.fire(new L(new Error(`Image "${e.name}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,t.data&&t.data.height)||(this.fire(new L(new Error(`Image "${e.name}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new L(new Error(`Image "${e.name}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(const o of e){if(o[0]<i||o[1]<o[0]||t<o[1])return!1;i=o[1]}return!0}_validateContent(e,t){if(!e)return!0;if(4!==e.length)return!1;if(!t.usvg){if(e[0]<0||t.data.width<e[0])return!1;if(e[1]<0||t.data.height<e[1])return!1;if(e[2]<0||t.data.width<e[2])return!1;if(e[3]<0||t.data.height<e[3])return!1}return!(e[2]<e[0]||e[3]<e[1])}updateImage(e,t,i){const o=this.images.get(t).get(e.toString());i.version=o.version+1,this.images.get(t).set(e.toString(),i),this.updatedImages.get(t).add(e);const r=this.imageVersions.get(t),n=r.get(e.toString())||0;r.set(e.toString(),n+1),this.removeFromImageRasterizerCache(e,t)}clearUpdatedImages(e){this.updatedImages.get(e).clear()}removeFromImageRasterizerCache(e,t){"raster"!==this.spriteFormat&&(D()?this.imageRasterizerDispatcher.getActor().send("removeRasterizedImages",{imageIds:[e],scope:t}):this.imageRasterizer.removeImagesFromCacheByIds([e],t))}removeImage(e,t){const i=this.images.get(t),o=i.get(e.toString());i.delete(e.toString());const r=this.imageVersions.get(t),n=r.get(e.toString())||0;r.set(e.toString(),n+1),this.patterns.get(t).delete(e.toString()),this.removeFromImageRasterizerCache(e,t),o.userImage&&o.userImage.onRemove&&o.userImage.onRemove()}listImages(e){return Array.from(this.images.get(e).keys()).map(e=>v.from(e))}getImageVersions(e){const t=this.imageVersions.get(e);if(t)return t}getImages(e,t,i){const o=[],r=[],n=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){o.push(i);continue}const e=n.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i))}if(0===o.length)return void this._notify(r,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of o)l.has(e.toString())||(s=!1);a||s?this._notify(o,t,i):this.requestors.push({ids:o,scope:t,callback:i})}rasterizeImages(e,t){const i=new Map,{tasks:o,scope:r}=e;for(const[e,t]of o.entries()){const o=this.getImage(t.id,r);o&&i.set(e,{image:o,imageVariant:t})}this._rasterizeImages(r,i,t)}_rasterizeImages(e,t,i){if(D())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:t,scope:e},i);else{const o=new Map;for(const[i,{image:r,imageVariant:n}]of t.entries())o.set(i,this.imageRasterizer.rasterize(n,r,e,0));i(void 0,o)}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(e,t,i){const o=this.images.get(t),r=new Map;for(const t of e){if(!o.get(t.toString())){if(t.iconsetId)continue;this.fire(new O("styleimagemissing",{id:t.name}))}const e=o.get(t.toString());if(!e){p(`Image "${t.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const i={data:e.usvg?null:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,usvg:e.usvg,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)};e.usvg&&Object.assign(i,{width:e.icon.usvg_tree.width,height:e.icon.usvg_tree.height}),r.set(v.toString(t),i)}i(null,{images:r,versions:this.getImageVersions(t)})}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return{width:t,height:i}}getPattern(e,t,i){const o=e.toString(),r=this.patterns.get(t),n=r.get(o),s=this.getImage(e,t);if(!s)return null;if(n){if(n.position.version===s.version)return n.position;n.position.version=s.version}else{if(s.usvg&&!s.data){const r=this.getPatternInFlightId(o,t);if(this.patternsInFlight.has(r))return null;this.patternsInFlight.add(r);const n=new P(e).scaleSelf(w.devicePixelRatio),a=new Map([[n.toString(),{image:s,imageVariant:n}]]);return this._rasterizeImages(t,a,(e,o)=>this.storePatternImage(n,t,s,i,o)),null}this.storePattern(e,t,s)}return this._updatePatternAtlas(t,i),r.get(o).position}getPatternInFlightId(e,t){return M(e,t)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,o,r){const n=e.toString(),s=r?r.get(n):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,o),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)))}storePattern(e,t,i){const o={w:i.data.width+2*F,h:i.data.height+2*F,x:0,y:0},r=new z(o,i,F);this.patterns.get(t).set(e.toString(),{bin:o,position:r})}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear()}bind(e,t){const i=e.gl;let o=this.atlasTexture.get(t);o?this.dirty&&(o.update(this.atlasImage.get(t)),this.dirty=!1):(o=new k(e,this.atlasImage.get(t),i.RGBA8),this.atlasTexture.set(t,o)),o.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(e,t){const i=this.patterns.get(e),o=Array.from(i.values()).map(({bin:e})=>e),{w:r,h:n}=B(o),s=this.atlasImage.get(e);s.resize({width:r||1,height:n||1});const a=this.images.get(e);for(const[e,{bin:o,position:r}]of i.entries()){let i=r.padding;const n=o.x+i,l=o.y+i,c=a.get(e).data,h=c.width,d=c.height;i=i>1?i-1:i,T.copy(c,s,{x:0,y:0},{x:n,y:l},{width:h,height:d},t),T.copy(c,s,{x:0,y:d-i},{x:n,y:l-i},{width:h,height:i},t),T.copy(c,s,{x:0,y:0},{x:n,y:l+d},{width:h,height:i},t),T.copy(c,s,{x:h-i,y:0},{x:n-i,y:l},{width:i,height:d},t),T.copy(c,s,{x:0,y:0},{x:n+h,y:l},{width:i,height:d},t),T.copy(c,s,{x:h-i,y:d-i},{x:n-i,y:l-i},{width:i,height:i},t),T.copy(c,s,{x:0,y:d-i},{x:n+h,y:l-i},{width:i,height:i},t),T.copy(c,s,{x:0,y:0},{x:n+h,y:l+d},{width:i,height:i},t),T.copy(c,s,{x:h-i,y:0},{x:n-i,y:l+d},{width:i,height:i},t)}this.dirty=!0}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set)}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const o of e){if(this.callbackDispatchedThisFrame.get(t).has(o.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(o.toString());const e=i.get(o.toString());Js(e)&&this.updateImage(o,t,e)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function ca(e){const t=e.value,i=e.valueSpec,o=e.style,r=e.styleSpec,n=e.key,s=e.arrayElementValidator||La;if(!Array.isArray(t))return[new U(n,t,`array expected, ${G(t)} found`)];if(i.length&&t.length!==i.length)return[new U(n,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new U(n,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};r.$version<7&&(a.function=i.function),N(i.value)&&(a=i.value);let l=[];for(let e=0;e<t.length;e++)l=l.concat(s({array:t,arrayIndex:e,value:t[e],valueSpec:a,style:o,styleSpec:r,key:`${n}[${e}]`},!0));return l}function ha(e){const t=e.key,i=e.value,o=e.valueSpec;if(!V(i))return[new U(t,i,`number expected, ${G(i)} found`)];if(i!=i)return[new U(t,i,"number expected, NaN found")];if("minimum"in o){let r=o.minimum;if(Array.isArray(o.minimum)&&(r=o.minimum[e.arrayIndex]),i<r)return[new U(t,i,`${i} is less than the minimum value ${r}`)]}if("maximum"in o){let r=o.maximum;if(Array.isArray(o.maximum)&&(r=o.maximum[e.arrayIndex]),i>r)return[new U(t,i,`${i} is greater than the maximum value ${r}`)]}return[]}function da(e){const t=e.key,i=e.value;if(!N(i))return[new U(t,i,`object expected, ${G(i)} found`)];const o=e.valueSpec,r=j(i.type);let n,s,a,l={};const c="categorical"!==r&&void 0===i.property,h=!c,d=function(e){const t=e.stops;return Array.isArray(t)&&Array.isArray(t[0])&&N(t[0][0])}(i),_=Oa({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===r)return[new U(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const i=e.value;return t=t.concat(ca({key:e.key,value:i,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:u})),Array.isArray(i)&&0===i.length&&t.push(new U(e.key,i,"array must have at least one stop")),t},default:function(e){return La({key:e.key,value:e.value,valueSpec:o,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===r&&c&&_.push(new U(e.key,e.value,'missing required property "property"')),"identity"===r||i.stops||_.push(new U(e.key,e.value,'missing required property "stops"')),"exponential"===r&&o.expression&&!H(o)&&_.push(new U(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(h&&!W(o)?_.push(new U(e.key,e.value,"property functions not supported")):c&&!Z(o)&&_.push(new U(e.key,e.value,"zoom functions not supported"))),"categorical"!==r&&!d||void 0!==i.property||_.push(new U(e.key,e.value,'"property" property is required')),_;function u(e){let t=[];const i=e.value,r=e.key;if(!Array.isArray(i))return[new U(r,i,`array expected, ${G(i)} found`)];if(2!==i.length)return[new U(r,i,`array length 2 expected, length ${i.length} found`)];if(d){if(!N(i[0]))return[new U(r,i,`object expected, ${G(i[0])} found`)];const o=i[0];if(void 0===o.zoom)return[new U(r,i,"object stop key must have zoom")];if(void 0===o.value)return[new U(r,i,"object stop key must have value")];const n=j(o.zoom);if("number"!=typeof n)return[new U(r,o.zoom,"stop zoom values must be numbers")];if(a&&a>n)return[new U(r,o.zoom,"stop zoom values must appear in ascending order")];n!==a&&(a=n,s=void 0,l={}),t=t.concat(Oa({key:`${r}[0]`,value:i[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:ha,value:p}}))}else t=t.concat(p({key:`${r}[0]`,value:i[0]},i));return q($(i[1]))?t.concat([new U(`${r}[1]`,i[1],"expressions are not allowed in function stops.")]):t.concat(La({key:`${r}[1]`,value:i[1],valueSpec:o,style:e.style,styleSpec:e.styleSpec}))}function p(e,t){const i=G(e.value),a=j(e.value),c=null!==e.value?e.value:t;if(n){if(i!==n)return[new U(e.key,c,`${i} stop domain type must match previous stop domain type ${n}`)]}else n=i;if("number"!==i&&"string"!==i&&"boolean"!==i&&"number"!=typeof a&&"string"!=typeof a&&"boolean"!=typeof a)return[new U(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==i&&"categorical"!==r){let t=`number expected, ${i} found`;return W(o)&&void 0===r&&(t+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new U(e.key,c,t)]}return"categorical"!==r||"number"!==i||"number"==typeof a&&isFinite(a)&&Math.floor(a)===a?"categorical"!==r&&"number"===i&&"number"==typeof a&&"number"==typeof s&&void 0!==s&&a<s?[new U(e.key,c,"stop domain values must appear in ascending order")]:(s=a,"categorical"===r&&a in l?[new U(e.key,c,"stop domain values must be unique")]:(l[a]=!0,[])):[new U(e.key,c,`integer expected, found ${String(a)}`)]}}function _a(e){const t=("property"===e.expressionContext?Y:X)($(e.value),e.valueSpec);if("error"===t.result)return t.value.map(t=>new U(`${e.key}${t.key}`,e.value,t.message));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new U(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!J(i))return[new U(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return ua(i,e);if("appearance"===e.expressionContext)return pa(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!K(i,["zoom","feature-state"]))return[new U(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Q(i))return[new U(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ua(e,t){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return[];const o=[];return e instanceof ee&&i.has(e.name)?[new U(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild(e=>{o.push(...ua(e,t))}),o)}function pa(e,t){const i=new Set;if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.add(e);if(0===i.size)return[];const o=[];return e instanceof ee&&!i.has(e.name)?[new U(t.key,t.value,`["${e.name}"] is not an allowed parameter`)]:(e.eachChild(e=>{o.push(...pa(e,t))}),o)}function fa(e){const t=e.key,i=e.value,o=e.valueSpec,r=[];return Array.isArray(o.values)?-1===o.values.indexOf(j(i))&&r.push(new U(t,i,`expected one of [${o.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(o.values).indexOf(j(i))&&r.push(new U(t,i,`expected one of [${Object.keys(o.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function ma(e){return re($(e.value))?_a(Object.assign({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):ga(e)}function ga(e){const t=e.value,i=e.key;if(!Array.isArray(t))return[new U(i,t,`array expected, ${G(t)} found`)];if(t.length<1)return[new U(i,t,"filter array must have at least 1 element")];const o=e.styleSpec;let r=fa({key:`${i}[0]`,value:t[0],valueSpec:o.filter_operator});const n=()=>{t.length>=2&&(ie(t[1])||r.push(new U(`${i}[1]`,t[1],`string expected, ${G(t[1])} found`)));for(let e=2;e<t.length;e++)"$type"===j(t[1])?r=r.concat(fa({key:`${i}[${e}]`,value:t[e],valueSpec:o.geometry_type})):ie(t[e])||V(t[e])||te(t[e])||r.push(new U(`${i}[${e}]`,t[e],`string, number, or boolean expected, ${G(t[e])} found.`))};switch(j(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===j(t[1])&&r.push(new U(i,t,`"$type" cannot be use with operator "${t[0]}"`)),3!==t.length&&r.push(new U(i,t,`filter array for operator "${t[0]}" must have 3 elements`)),n();break;case"==":case"!=":3!==t.length&&r.push(new U(i,t,`filter array for operator "${t[0]}" must have 3 elements`)),n();break;case"in":case"!in":n();break;case"any":case"all":case"none":for(let o=1;o<t.length;o++)r=r.concat(ga({key:`${i}[${o}]`,value:t[o],styleSpec:e.styleSpec}));break;case"has":case"!has":2!==t.length?r.push(new U(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):ie(t[1])||r.push(new U(`${i}[1]`,t[1],`string expected, ${G(t[1])} found`))}return r}function va(e,t){const i=e.key,o=e.style,r=e.layer,n=e.styleSpec,s=e.value,a=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];const c=a.match(/^(.*)-use-theme$/);if(c&&l[c[1]])return q($(s))?[].concat(La({key:i,value:s,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:o,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:a})):La({key:i,value:s,valueSpec:{type:"string"},style:o,styleSpec:n});const h=a.match(/^(.*)-transition$/);if("paint"===t&&h&&l[h[1]]&&l[h[1]].transition)return La({key:i,value:s,valueSpec:n.transition,style:o,styleSpec:n});const d=e.valueSpec||l[a];if(!d)return[new ne(i,s,`unknown property "${a}"`)];let _;if(ie(s)&&W(d)&&!d.tokens&&(_=/^{([^}]+)}$/.exec(s))){const e=`\`{ "type": "identity", "property": ${_?JSON.stringify(_[1]):'"_"'} }\``;return[new U(i,s,`"${a}" does not support interpolation syntax\nUse an identity property function instead: ${e}.`)]}const u=[];if("symbol"===e.layerType)"text-field"!==a||!o||o.glyphs||o.imports||u.push(new U(i,s,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&se($(s))&&"identity"===j(s.type)&&u.push(new U(i,s,'"text-font" does not support identity functions'));else if("model"===e.layerType&&"paint"===t&&r&&r.layout&&r.layout.hasOwnProperty("model-id")&&W(d)&&(ae(d)||Z(d))){const e=Y($(s),d).value,t="expression"in e&&e.expression||"_styleExpression"in e&&e._styleExpression&&e._styleExpression.expression;t&&!K(t,["measure-light"])&&("model-emissive-strength"===a&&Q(t)&&J(t)||u.push(new U(i,s,`${a} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return u.concat(La({key:e.key,value:s,valueSpec:d,style:o,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:a}))}function ya(e){return va(e,"paint")}function xa(e){return va(e,"layout")}function ba(e){let t=[];const i=e.value,o=e.key,r=e.style,n=e.styleSpec;if(!N(i))return[new U(o,i,"object expected")];i.type||i.ref||t.push(new U(o,i,'either "type" or "ref" is required'));let s=j(i.type);const a=j(i.ref);if(i.id){const n=j(i.id);for(let s=0;s<e.arrayIndex;s++){const e=r.layers[s];j(e.id)===n&&t.push(new U(o,i.id,`duplicate layer id "${n}", previously used at line ${e.id.__line__}`))}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach(e=>{e in i&&t.push(new U(o,i[e],`"${e}" is prohibited for ref layers`))}),r.layers.forEach(t=>{j(t.id)===a&&(e=t)}),e?e.ref?t.push(new U(o,i.ref,"ref cannot reference another ref layer")):s=j(e.type):"string"==typeof a&&t.push(new U(o,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s&&"slot"!==s)if(i.source)if(ie(i.source)){const e=r.sources&&r.sources[i.source],n=e&&j(e.type);e?"vector"===n&&"raster"===s?t.push(new U(o,i.source,`layer "${i.id}" requires a raster source`)):"raster"===n&&"raster"!==s?t.push(new U(o,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==s?t.push(new U(o,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==n||["raster","raster-particle"].includes(s)?"line"===s&&i.paint&&(i.paint["line-gradient"]||i.paint["line-trim-offset"])&&"geojson"===n&&!e.lineMetrics?t.push(new U(o,i,`layer "${i.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===s&&"raster-array"!==n&&t.push(new U(o,i.source,`layer "${i.id}" requires a 'raster-array' source.`)):t.push(new U(o,i.source,"raster-array source can only be used with layer type 'raster'.")):t.push(new U(o,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new U(o,i.source,`source "${i.source}" not found`))}else t.push(new U(`${o}.source`,i.source,'"source" must be a string'));else t.push(new U(o,i,'missing required property "source"'));return t=t.concat(Oa({key:o,value:i,valueSpec:n.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>La({key:`${o}.type`,value:i.type,valueSpec:n.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>ma(Object.assign({layerType:s},e)),layout:e=>Oa({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>xa(Object.assign({layerType:s},e))}}),paint:e=>Oa({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ya(Object.assign({layerType:s,layer:i},e))}}),appearances(e){const t=ca({key:e.key,value:e.value,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:e=>function(e){const{key:t,layer:i,layerType:o}=e,r=j(e.value),n=j(r.name),s=j(r.condition),a=Oa({key:t,value:r,valueSpec:e.styleSpec.appearance,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{condition:e=>function(e){const t=[];return t.push(..._a({key:e.key,value:e.object.condition,valueSpec:le.appearance.condition,expressionContext:"appearance"})),t}(Object.assign({layer:i,layerType:o},e)),properties:e=>function(e){const t=[],{styleSpec:i,layer:o,layerType:r}=e,n=i[`paint_${r}`],s=i[`layout_${r}`],a=e.object[e.objectKey];for(const i in a){const l=i in n?"paint":i in s?"layout":void 0;if(!l){t.push(new U(e.key,i,`unknown property "${i}" for layer type "${r}"`));continue}const c=Object.assign({},e,{key:`${e.key}.${i}`,object:a,objectKey:i,layer:o,layerType:r,value:a[i],valueSpec:"paint"===l?n[i]:s[i]});t.push(...va(c,l))}return t}(Object.assign({layer:i,layerType:o},e))}});return"hidden"!==n&&void 0===s&&a.push(new U(e.key,"name",'Appearance with name different than "hidden" must have a condition')),a}(Object.assign({layerType:s,layer:i},e))}),o=Array.isArray(e.value)?e.value:[],r=new Set;return o.forEach((o,n)=>{const s=j(o.name);if(s)if(r.has(s)){const o=j(i.id);t.push(new U(e.key,s,`Duplicated appearance name "${s}" for layer "${o}"`))}else r.add(s)}),t}}})),t}function wa({key:e,value:t}){return ie(t)?[]:[new U(e,t,`string expected, ${G(t)} found`)]}const Ta={promoteId:function e({key:t,value:i}){if(ie(i))return wa({key:t,value:i});if(Array.isArray(i)){const e=[],o=$(i),r=X(o);return"error"===r.result?(r.value.forEach(i=>{e.push(new U(`${t}${i.key}`,null,`${i.message}`))}),e):(K(r.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||e.push(new U(`${t}`,null,"promoteId expression should be only feature dependent")),e)}if(!N(i))return[new U(t,i,`string, expression or object expected, "${G(i)}" found`)];const o=[];for(const r in i)o.push(...e({key:`${t}.${r}`,value:i[r]}));return o}};function Ea(e){const t=e.value,i=e.key,o=e.styleSpec,r=e.style;if(!N(t))return[new U(i,t,`object expected, ${G(t)} found`)];if(!("type"in t))return[new U(i,t,'"type" is required')];const n=j(t.type);let s=[];switch(["vector","raster","raster-dem","raster-array"].includes(n)&&("url"in t||"tiles"in t||s.push(new ne(i,t,'Either "url" or "tiles" is required.'))),n){case"vector":case"raster":case"raster-dem":case"raster-array":return s=s.concat(Oa({key:i,value:t,valueSpec:o[`source_${n.replace("-","_")}`],style:e.style,styleSpec:o,objectElementValidators:Ta})),s;case"geojson":if(s=Oa({key:i,value:t,valueSpec:o.source_geojson,style:r,styleSpec:o,objectElementValidators:Ta}),"cluster"in t&&"clusterProperties"in t){if(!N(t.clusterProperties))return[new U(`${i}.clusterProperties`,t,`object expected, ${G(t)} found`)];for(const e in t.clusterProperties){const o=t.clusterProperties[e];if(!Array.isArray(o))return[new U(`${i}.clusterProperties.${e}`,o,"array expected")];const[r,n]=o,a="string"==typeof r?[r,["accumulated"],["get",e]]:r;s.push(..._a({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),s.push(..._a({key:`${i}.${e}.reduce`,value:a,expressionContext:"cluster-reduce"}))}}return s;case"video":return Oa({key:i,value:t,valueSpec:o.source_video,style:r,styleSpec:o});case"image":return Oa({key:i,value:t,valueSpec:o.source_image,style:r,styleSpec:o});case"canvas":return[new U(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return fa({key:`${i}.type`,value:t.type,valueSpec:{values:Sa(o)}})}}function Sa(e){return e.source.reduce((t,i)=>{const o=e[i];return"enum"===o.type.type&&(t=t.concat(Object.keys(o.type.values||{}))),t},[])}function Ia(e){const t=e.value,i=e.styleSpec,o=i.light,r=e.style;if(void 0===t)return[];if(!N(t))return[new U("light",t,`object expected, ${G(t)} found`)];let n=[];for(const e in t){const s=e.match(/^(.*)-transition$/),a=e.match(/^(.*)-use-theme$/);n=n.concat(a&&o[a[1]]?La({key:e,value:t[e],valueSpec:{type:"string"},style:r,styleSpec:i}):s&&o[s[1]]&&o[s[1]].transition?La({key:e,value:t[e],valueSpec:i.transition,style:r,styleSpec:i}):o[e]?La({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:i}):[new U(e,t[e],`unknown property "${e}"`)])}return n}function Ca(e){const t=e.value;if(!t)return[];const i=e.key;if(!N(t))return[new U(i,t,`object expected, ${G(t)} found`)];let o=[];const r=e.styleSpec,n=r["light-3d"],s=e.style,a=e.style.lights;for(const e of["type","id"])if(!(e in t))return o=o.concat([new U(i,t,`missing property "${e}"`)]),o;if(!ie(t.type))return o=o.concat([new U(`${i}.type`,t.type,"string expected")]),o;if(a)for(let r=0;r<e.arrayIndex;r++){const e=j(t.type),n=a[r];j(n.type)===e&&o.push(new U(i,t.id,`duplicate light type "${t.type}", previously defined at line ${n.id.__line__}`))}const l=`properties_light_${t.type}`;if(!(l in r))return o=o.concat([new U(`${i}.type`,t,`Invalid light type ${t.type}`)]),o;const c=r[l];for(const i in t)if("properties"===i){const n=t[i];if(!N(n))return o=o.concat([new U("properties",n,`object expected, ${G(n)} found`)]),o;for(const a in n){const l=a.match(/^(.*)-transition$/),h=a.match(/^(.*)-use-theme$/);o=o.concat(h&&c[h[1]]?La({key:i,value:n[a],valueSpec:{type:"string"},style:s,styleSpec:r}):l&&c[l[1]]&&c[l[1]].transition?La({key:i,value:t[i],valueSpec:r.transition,style:s,styleSpec:r}):c[a]?La({key:a,value:n[a],valueSpec:c[a],style:s,styleSpec:r}):[new ne(e.key,n[a],`unknown property "${a}"`)])}}else o=o.concat(n[i]?La({key:i,value:t[i],valueSpec:n[i],style:s,styleSpec:r}):[new ne(i,t[i],`unknown property "${i}"`)]);return o}function Ra(e){const t=e.value,i=e.key,o=e.style,r=e.styleSpec,n=r.terrain;if(null==t)return[];if(!N(t))return[new U("terrain",t,`object expected, ${G(t)} found`)];let s=[];for(const e in t){const i=e.match(/^(.*)-transition$/),a=e.match(/^(.*)-use-theme$/);s=s.concat(a&&n[a[1]]?La({key:e,value:t[e],valueSpec:{type:"string"},style:o,styleSpec:r}):i&&n[i[1]]&&n[i[1]].transition?La({key:e,value:t[e],valueSpec:r.transition,style:o,styleSpec: