@object-ui/plugin-map 0.3.1 β 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +36 -0
- package/dist/index.css +1 -0
- package/dist/index.js +3736 -321
- package/dist/index.umd.cjs +847 -2
- package/dist/maplibre-gl-CNsW26De.js +24161 -0
- package/dist/src/ObjectMap.d.ts +1 -0
- package/dist/src/ObjectMap.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +11 -7
- package/src/ObjectMap.test.tsx +110 -0
- package/src/ObjectMap.tsx +160 -96
- package/src/index.test.tsx +27 -0
- package/src/index.tsx +6 -2
- package/vite.config.ts +4 -0
- package/vitest.config.ts +13 -0
- package/vitest.setup.ts +78 -0
package/dist/index.umd.cjs
CHANGED
|
@@ -1,6 +1,851 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(nn,Je){typeof exports=="object"&&typeof module<"u"?Je(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@object-ui/core","@object-ui/react","react-dom"],Je):(nn=typeof globalThis<"u"?globalThis:nn||self,Je(nn.ObjectUIPluginMap={},nn.React,nn.ObjectUICore,nn.ObjectUIReact,nn.ReactDOM))})(this,(function(nn,Je,Ig,Mg,Qd){"use strict";function Eg(p){const y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const T in p)if(T!=="default"){const M=Object.getOwnPropertyDescriptor(p,T);Object.defineProperty(y,T,M.get?M:{enumerable:!0,get:()=>p[T]})}}return y.default=p,Object.freeze(y)}function Cg(p,y){for(var T=0;T<y.length;T++){const M=y[T];if(typeof M!="string"&&!Array.isArray(M)){for(const A in M)if(A!=="default"&&!(A in p)){const V=Object.getOwnPropertyDescriptor(M,A);V&&Object.defineProperty(p,A,V.get?V:{enumerable:!0,get:()=>M[A]})}}}return Object.freeze(Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}))}const qs=Eg(Je);function Ag(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}var Pc={exports:{}},nl={};var ep;function zg(){if(ep)return nl;ep=1;var p=Symbol.for("react.transitional.element"),y=Symbol.for("react.fragment");function T(M,A,V){var S=null;if(V!==void 0&&(S=""+V),A.key!==void 0&&(S=""+A.key),"key"in A){V={};for(var l in A)l!=="key"&&(V[l]=A[l])}else V=A;return A=V.ref,{$$typeof:p,type:M,key:S,ref:A!==void 0?A:null,props:V}}return nl.Fragment=y,nl.jsx=T,nl.jsxs=T,nl}var sl={};var tp;function Dg(){return tp||(tp=1,process.env.NODE_ENV!=="production"&&(function(){function p(De){if(De==null)return null;if(typeof De=="function")return De.$$typeof===Hr?null:De.displayName||De.name||null;if(typeof De=="string")return De;switch(De){case me:return"Fragment";case bt:return"Profiler";case Vt:return"StrictMode";case Et:return"Suspense";case mt:return"SuspenseList";case ei:return"Activity"}if(typeof De=="object")switch(typeof De.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),De.$$typeof){case Qe:return"Portal";case pt:return De.displayName||"Context";case tt:return(De._context.displayName||"Context")+".Consumer";case It:var at=De.render;return De=De.displayName,De||(De=at.displayName||at.name||"",De=De!==""?"ForwardRef("+De+")":"ForwardRef"),De;case Qt:return at=De.displayName||null,at!==null?at:p(De.type)||"Memo";case wr:at=De._payload,De=De._init;try{return p(De(at))}catch{}}return null}function y(De){return""+De}function T(De){try{y(De);var at=!1}catch{at=!0}if(at){at=console;var zt=at.error,$t=typeof Symbol=="function"&&Symbol.toStringTag&&De[Symbol.toStringTag]||De.constructor.name||"Object";return zt.call(at,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",$t),y(De)}}function M(De){if(De===me)return"<>";if(typeof De=="object"&&De!==null&&De.$$typeof===wr)return"<...>";try{var at=p(De);return at?"<"+at+">":"<...>"}catch{return"<...>"}}function A(){var De=nr.A;return De===null?null:De.getOwner()}function V(){return Error("react-stack-top-frame")}function S(De){if(mi.call(De,"key")){var at=Object.getOwnPropertyDescriptor(De,"key").get;if(at&&at.isReactWarning)return!1}return De.key!==void 0}function l(De,at){function zt(){Rn||(Rn=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",at))}zt.isReactWarning=!0,Object.defineProperty(De,"key",{get:zt,configurable:!0})}function ne(){var De=p(this.type);return At[De]||(At[De]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),De=this.props.ref,De!==void 0?De:null}function Se(De,at,zt,$t,ai,sr){var kt=zt.ref;return De={$$typeof:wt,type:De,key:at,props:zt,_owner:$t},(kt!==void 0?kt:null)!==null?Object.defineProperty(De,"ref",{enumerable:!1,get:ne}):Object.defineProperty(De,"ref",{enumerable:!1,value:null}),De._store={},Object.defineProperty(De._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(De,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(De,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ai}),Object.defineProperty(De,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:sr}),Object.freeze&&(Object.freeze(De.props),Object.freeze(De)),De}function Le(De,at,zt,$t,ai,sr){var kt=at.children;if(kt!==void 0)if($t)if(kn(kt)){for($t=0;$t<kt.length;$t++)He(kt[$t]);Object.freeze&&Object.freeze(kt)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else He(kt);if(mi.call(at,"key")){kt=p(De);var fr=Object.keys(at).filter(function(Xi){return Xi!=="key"});$t=0<fr.length?"{key: someKey, "+fr.join(": ..., ")+": ...}":"{key: someKey}",Di[kt+$t]||(fr=0<fr.length?"{"+fr.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,u,d,y,d),Z[d+u]=!0)}if(d=null,c!==void 0&&(o(c),d=""+c),_(r)&&(o(r.key),d=""+r.key),"key"in r){c={};for(var W in r)W!=="key"&&(c[W]=r[W])}else c=r;return d&&j(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),F(e,d,c,l(),P,U)}function k(e){S(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===D&&(e._payload.status==="fulfilled"?S(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function S(e){return typeof e=="object"&&e!==null&&e.$$typeof===x}var R=m,x=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),f=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),le=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),I=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=Object.prototype.hasOwnProperty,ue=Array.isArray,Y=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var q,B={},H=R.react_stack_bottom_frame.bind(R,b)(),Q=Y(s(b)),Z={};T.Fragment=E,T.jsx=function(e,r,c){var u=1e4>I.recentlyCreatedOwnerStacks++;return M(e,r,c,!1,u?Error("react-stack-top-frame"):H,u?Y(s(e)):Q)},T.jsxs=function(e,r,c){var u=1e4>I.recentlyCreatedOwnerStacks++;return M(e,r,c,!0,u?Error("react-stack-top-frame"):H,u?Y(s(e)):Q)}})()),T}var J;function te(){return J||(J=1,process.env.NODE_ENV==="production"?O.exports=K():O.exports=ee()),O.exports}var n=te();function re(t){return t.data?t.data:t.staticData?{provider:"value",items:t.staticData}:t.objectName?{provider:"object",object:t.objectName}:null}function ne(t){if(t){if(typeof t=="string"){const i=t.split(" "),o=i[0],s=i[1]?.toLowerCase()==="desc"?"desc":"asc";return{[o]:s}}if(Array.isArray(t))return t.reduce((i,o)=>(o.field&&o.order&&(i[o.field]=o.order),i),{})}}function oe(t){return t.filter&&typeof t.filter=="object"&&"map"in t.filter?t.filter.map:t.map?t.map:{latitudeField:"latitude",longitudeField:"longitude",locationField:"location",titleField:"name",descriptionField:"description",zoom:10,center:[0,0]}}function ae(t,i){if(i.latitudeField&&i.longitudeField){const o=t[i.latitudeField],s=t[i.longitudeField];if(typeof o=="number"&&typeof s=="number")return[o,s]}if(i.locationField){const o=t[i.locationField];if(typeof o=="object"&&o!==null){const s=o.lat||o.latitude,l=o.lng||o.lon||o.longitude;if(typeof s=="number"&&typeof l=="number")return[s,l]}if(typeof o=="string"){const s=o.split(",").map(l=>parseFloat(l.trim()));if(s.length===2&&!isNaN(s[0])&&!isNaN(s[1]))return[s[0],s[1]]}if(Array.isArray(o)&&o.length===2){const s=parseFloat(o[0]),l=parseFloat(o[1]);if(!isNaN(s)&&!isNaN(l))return[s,l]}}return null}const G=({schema:t,dataSource:i,className:o,onMarkerClick:s})=>{const[l,b]=m.useState([]),[_,j]=m.useState(!0),[w,F]=m.useState(null),[M,k]=m.useState(null),[S,R]=m.useState(null),x=re(t),p=oe(t),E=x?.provider==="value";m.useEffect(()=>{(async()=>{try{if(j(!0),E&&x?.provider==="value"){b(x.items),j(!1);return}if(!i)throw new Error("DataSource required for object/api providers");if(x?.provider==="object"){const f=x.object,v=await i.find(f,{$filter:t.filter,$orderby:ne(t.sort)});b(v?.data||[])}else x?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectMap"),b([]));j(!1)}catch(f){F(f),j(!1)}})()},[x,i,E,t.filter,t.sort]),m.useEffect(()=>{!E&&i&&(async()=>{try{if(!i)return;const f=x?.provider==="object"?x.object:t.objectName;if(!f)return;const v=await i.getObjectSchema(f);k(v)}catch(f){console.error("Failed to fetch object schema:",f)}})()},[t.objectName,i,E,x]);const g=m.useMemo(()=>l.map((a,f)=>{const v=ae(a,p);if(!v)return null;const C=p.titleField?a[p.titleField]:"Marker",L=p.descriptionField?a[p.descriptionField]:void 0;return{id:a.id||a._id||`marker-${f}`,title:C,description:L,coordinates:v,data:a}}).filter(a=>a!==null),[l,p]),A=m.useMemo(()=>{if(!g.length)return{center:p.center||[0,0],minLat:(p.center?.[0]||0)-.1,maxLat:(p.center?.[0]||0)+.1,minLng:(p.center?.[1]||0)-.1,maxLng:(p.center?.[1]||0)+.1};const a=g.map(v=>v.coordinates[0]),f=g.map(v=>v.coordinates[1]);return{center:[(Math.min(...a)+Math.max(...a))/2,(Math.min(...f)+Math.max(...f))/2],minLat:Math.min(...a),maxLat:Math.max(...a),minLng:Math.min(...f),maxLng:Math.max(...f)}},[g,p.center]);return _?n.jsx("div",{className:o,children:n.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg",children:n.jsx("div",{className:"text-muted-foreground",children:"Loading map..."})})}):w?n.jsx("div",{className:o,children:n.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg",children:n.jsxs("div",{className:"text-destructive",children:["Error: ",w.message]})})}):n.jsx("div",{className:o,children:n.jsxs("div",{className:"relative border rounded-lg overflow-hidden bg-muted",style:{height:"600px"},children:[n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gradient-to-br from-blue-50 to-green-50 dark:from-blue-950 dark:to-green-950",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-4xl mb-2",children:"πΊοΈ"}),n.jsx("div",{className:"text-sm text-muted-foreground mb-4",children:"Map Visualization (Placeholder)"}),n.jsxs("div",{className:"text-xs text-muted-foreground max-w-md mx-auto",children:["This is a basic map placeholder. For production, integrate with Mapbox, Leaflet, or Google Maps.",n.jsx("br",{}),n.jsx("br",{}),n.jsx("strong",{children:"Map Info:"}),n.jsx("br",{}),"Center: [",A.center[0].toFixed(4),", ",A.center[1].toFixed(4),"]",n.jsx("br",{}),"Markers: ",g.length]})]})}),n.jsxs("div",{className:"absolute top-4 right-4 w-64 bg-background border rounded-lg shadow-lg max-h-96 overflow-y-auto",children:[n.jsxs("div",{className:"p-3 border-b font-semibold bg-muted",children:["Locations (",g.length,")"]}),g.length===0?n.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No locations found with valid coordinates"}):n.jsx("div",{children:g.map(a=>n.jsxs("div",{className:`p-3 border-b hover:bg-muted/50 cursor-pointer transition-colors ${S===a.id?"bg-muted":""}`,onClick:()=>{R(a.id),s?.(a.data)},children:[n.jsx("div",{className:"font-medium text-sm",children:a.title}),a.description&&n.jsx("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:a.description}),n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["π ",a.coordinates[0].toFixed(4),", ",a.coordinates[1].toFixed(4)]})]},a.id))})]}),n.jsxs("div",{className:"absolute bottom-4 left-4 bg-background border rounded-lg shadow-lg p-3",children:[n.jsx("div",{className:"text-xs font-semibold mb-2",children:"Legend"}),n.jsx("div",{className:"text-xs space-y-1",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full bg-blue-500"}),n.jsx("span",{children:"Location Marker"})]})})]})]})})},ie=({schema:t})=>n.jsx(G,{schema:t,dataSource:null});$.ComponentRegistry.register("object-map",ie,{label:"Object Map",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"map",type:"object",label:"Map Config",description:"latitudeField, longitudeField, titleField"}]}),h.ObjectMap=G,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,$t,kt,fr,kt),Di[kt+$t]=!0)}if(kt=null,zt!==void 0&&(T(zt),kt=""+zt),S(at)&&(T(at.key),kt=""+at.key),"key"in at){zt={};for(var Hi in at)Hi!=="key"&&(zt[Hi]=at[Hi])}else zt=at;return kt&&l(zt,typeof De=="function"?De.displayName||De.name||"Unknown":De),Se(De,kt,zt,A(),ai,sr)}function He(De){qe(De)?De._store&&(De._store.validated=1):typeof De=="object"&&De!==null&&De.$$typeof===wr&&(De._payload.status==="fulfilled"?qe(De._payload.value)&&De._payload.value._store&&(De._payload.value._store.validated=1):De._store&&(De._store.validated=1))}function qe(De){return typeof De=="object"&&De!==null&&De.$$typeof===wt}var Ze=Je,wt=Symbol.for("react.transitional.element"),Qe=Symbol.for("react.portal"),me=Symbol.for("react.fragment"),Vt=Symbol.for("react.strict_mode"),bt=Symbol.for("react.profiler"),tt=Symbol.for("react.consumer"),pt=Symbol.for("react.context"),It=Symbol.for("react.forward_ref"),Et=Symbol.for("react.suspense"),mt=Symbol.for("react.suspense_list"),Qt=Symbol.for("react.memo"),wr=Symbol.for("react.lazy"),ei=Symbol.for("react.activity"),Hr=Symbol.for("react.client.reference"),nr=Ze.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,mi=Object.prototype.hasOwnProperty,kn=Array.isArray,zi=console.createTask?console.createTask:function(){return null};Ze={react_stack_bottom_frame:function(De){return De()}};var Rn,At={},Wi=Ze.react_stack_bottom_frame.bind(Ze,V)(),Tt=zi(M(V)),Di={};sl.Fragment=me,sl.jsx=function(De,at,zt){var $t=1e4>nr.recentlyCreatedOwnerStacks++;return Le(De,at,zt,!1,$t?Error("react-stack-top-frame"):Wi,$t?zi(M(De)):Tt)},sl.jsxs=function(De,at,zt){var $t=1e4>nr.recentlyCreatedOwnerStacks++;return Le(De,at,zt,!0,$t?Error("react-stack-top-frame"):Wi,$t?zi(M(De)):Tt)}})()),sl}var rp;function kg(){return rp||(rp=1,process.env.NODE_ENV==="production"?Pc.exports=zg():Pc.exports=Dg()),Pc.exports}var Lr=kg();function Ae(p,y,T){function M(l,ne){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:ne,constr:S,traits:new Set},enumerable:!1}),l._zod.traits.has(p))return;l._zod.traits.add(p),y(l,ne);const Se=S.prototype,Le=Object.keys(Se);for(let He=0;He<Le.length;He++){const qe=Le[He];qe in l||(l[qe]=Se[qe].bind(l))}}const A=T?.Parent??Object;class V extends A{}Object.defineProperty(V,"name",{value:p});function S(l){var ne;const Se=T?.Parent?new V:this;M(Se,l),(ne=Se._zod).deferred??(ne.deferred=[]);for(const Le of Se._zod.deferred)Le();return Se}return Object.defineProperty(S,"init",{value:M}),Object.defineProperty(S,Symbol.hasInstance,{value:l=>T?.Parent&&l instanceof T.Parent?!0:l?._zod?.traits?.has(p)}),Object.defineProperty(S,"name",{value:p}),S}class Wo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ip extends Error{constructor(y){super(`Encountered unidirectional transform during encode: ${y}`),this.name="ZodEncodeError"}}const np={};function Ws(p){return np}function sp(p){const y=Object.values(p).filter(M=>typeof M=="number");return Object.entries(p).filter(([M,A])=>y.indexOf(+M)===-1).map(([M,A])=>A)}function mh(p,y){return typeof y=="bigint"?y.toString():y}function gh(p){return{get value(){{const y=p();return Object.defineProperty(this,"value",{value:y}),y}}}}function _h(p){return p==null}function yh(p){const y=p.startsWith("^")?1:0,T=p.endsWith("$")?p.length-1:p.length;return p.slice(y,T)}function Rg(p,y){const T=(p.toString().split(".")[1]||"").length,M=y.toString();let A=(M.split(".")[1]||"").length;if(A===0&&/\d?e-\d?/.test(M)){const ne=M.match(/\d?e-(\d?)/);ne?.[1]&&(A=Number.parseInt(ne[1]))}const V=T>A?T:A,S=Number.parseInt(p.toFixed(V).replace(".","")),l=Number.parseInt(y.toFixed(V).replace(".",""));return S%l/10**V}const op=Symbol("evaluating");function Nt(p,y,T){let M;Object.defineProperty(p,y,{get(){if(M!==op)return M===void 0&&(M=op,M=T()),M},set(A){Object.defineProperty(p,y,{value:A})},configurable:!0})}function Hs(p,y,T){Object.defineProperty(p,y,{value:T,writable:!0,enumerable:!0,configurable:!0})}function as(...p){const y={};for(const T of p){const M=Object.getOwnPropertyDescriptors(T);Object.assign(y,M)}return Object.defineProperties({},y)}function ap(p){return JSON.stringify(p)}function Fg(p){return p.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const lp="captureStackTrace"in Error?Error.captureStackTrace:(...p)=>{};function Ic(p){return typeof p=="object"&&p!==null&&!Array.isArray(p)}const Lg=gh(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const p=Function;return new p(""),!0}catch{return!1}});function ol(p){if(Ic(p)===!1)return!1;const y=p.constructor;if(y===void 0||typeof y!="function")return!0;const T=y.prototype;return!(Ic(T)===!1||Object.prototype.hasOwnProperty.call(T,"isPrototypeOf")===!1)}function cp(p){return ol(p)?{...p}:Array.isArray(p)?[...p]:p}const Og=new Set(["string","number","symbol"]);function Mc(p){return p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ls(p,y,T){const M=new p._zod.constr(y??p._zod.def);return(!y||T?.parent)&&(M._zod.parent=p),M}function it(p){const y=p;if(!y)return{};if(typeof y=="string")return{error:()=>y};if(y?.message!==void 0){if(y?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");y.error=y.message}return delete y.message,typeof y.error=="string"?{...y,error:()=>y.error}:y}function Bg(p){return Object.keys(p).filter(y=>p[y]._zod.optin==="optional"&&p[y]._zod.optout==="optional")}const jg={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ng(p,y){const T=p._zod.def,M=T.checks;if(M&&M.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const V=as(p._zod.def,{get shape(){const S={};for(const l in y){if(!(l in T.shape))throw new Error(`Unrecognized key: "${l}"`);y[l]&&(S[l]=T.shape[l])}return Hs(this,"shape",S),S},checks:[]});return ls(p,V)}function Vg(p,y){const T=p._zod.def,M=T.checks;if(M&&M.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const V=as(p._zod.def,{get shape(){const S={...p._zod.def.shape};for(const l in y){if(!(l in T.shape))throw new Error(`Unrecognized key: "${l}"`);y[l]&&delete S[l]}return Hs(this,"shape",S),S},checks:[]});return ls(p,V)}function $g(p,y){if(!ol(y))throw new Error("Invalid input to extend: expected a plain object");const T=p._zod.def.checks;if(T&&T.length>0){const V=p._zod.def.shape;for(const S in y)if(Object.getOwnPropertyDescriptor(V,S)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const A=as(p._zod.def,{get shape(){const V={...p._zod.def.shape,...y};return Hs(this,"shape",V),V}});return ls(p,A)}function Zg(p,y){if(!ol(y))throw new Error("Invalid input to safeExtend: expected a plain object");const T=as(p._zod.def,{get shape(){const M={...p._zod.def.shape,...y};return Hs(this,"shape",M),M}});return ls(p,T)}function Ug(p,y){const T=as(p._zod.def,{get shape(){const M={...p._zod.def.shape,...y._zod.def.shape};return Hs(this,"shape",M),M},get catchall(){return y._zod.def.catchall},checks:[]});return ls(p,T)}function Gg(p,y,T){const A=y._zod.def.checks;if(A&&A.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const S=as(y._zod.def,{get shape(){const l=y._zod.def.shape,ne={...l};if(T)for(const Se in T){if(!(Se in l))throw new Error(`Unrecognized key: "${Se}"`);T[Se]&&(ne[Se]=p?new p({type:"optional",innerType:l[Se]}):l[Se])}else for(const Se in l)ne[Se]=p?new p({type:"optional",innerType:l[Se]}):l[Se];return Hs(this,"shape",ne),ne},checks:[]});return ls(y,S)}function qg(p,y,T){const M=as(y._zod.def,{get shape(){const A=y._zod.def.shape,V={...A};if(T)for(const S in T){if(!(S in V))throw new Error(`Unrecognized key: "${S}"`);T[S]&&(V[S]=new p({type:"nonoptional",innerType:A[S]}))}else for(const S in A)V[S]=new p({type:"nonoptional",innerType:A[S]});return Hs(this,"shape",V),V}});return ls(y,M)}function Ho(p,y=0){if(p.aborted===!0)return!0;for(let T=y;T<p.issues.length;T++)if(p.issues[T]?.continue!==!0)return!0;return!1}function vh(p,y){return y.map(T=>{var M;return(M=T).path??(M.path=[]),T.path.unshift(p),T})}function Ec(p){return typeof p=="string"?p:p?.message}function Xs(p,y,T){const M={...p,path:p.path??[]};if(!p.message){const A=Ec(p.inst?._zod.def?.error?.(p))??Ec(y?.error?.(p))??Ec(T.customError?.(p))??Ec(T.localeError?.(p))??"Invalid input";M.message=A}return delete M.inst,delete M.continue,y?.reportInput||delete M.input,M}function xh(p){return Array.isArray(p)?"array":typeof p=="string"?"string":"unknown"}function al(...p){const[y,T,M]=p;return typeof y=="string"?{message:y,code:"custom",input:T,inst:M}:{...y}}const up=(p,y)=>{p.name="$ZodError",Object.defineProperty(p,"_zod",{value:p._zod,enumerable:!1}),Object.defineProperty(p,"issues",{value:y,enumerable:!1}),p.message=JSON.stringify(y,mh,2),Object.defineProperty(p,"toString",{value:()=>p.message,enumerable:!1})},hp=Ae("$ZodError",up),dp=Ae("$ZodError",up,{Parent:Error});function Wg(p,y=T=>T.message){const T={},M=[];for(const A of p.issues)A.path.length>0?(T[A.path[0]]=T[A.path[0]]||[],T[A.path[0]].push(y(A))):M.push(y(A));return{formErrors:M,fieldErrors:T}}function Hg(p,y=T=>T.message){const T={_errors:[]},M=A=>{for(const V of A.issues)if(V.code==="invalid_union"&&V.errors.length)V.errors.map(S=>M({issues:S}));else if(V.code==="invalid_key")M({issues:V.issues});else if(V.code==="invalid_element")M({issues:V.issues});else if(V.path.length===0)T._errors.push(y(V));else{let S=T,l=0;for(;l<V.path.length;){const ne=V.path[l];l===V.path.length-1?(S[ne]=S[ne]||{_errors:[]},S[ne]._errors.push(y(V))):S[ne]=S[ne]||{_errors:[]},S=S[ne],l++}}};return M(p),T}const bh=p=>(y,T,M,A)=>{const V=M?Object.assign(M,{async:!1}):{async:!1},S=y._zod.run({value:T,issues:[]},V);if(S instanceof Promise)throw new Wo;if(S.issues.length){const l=new(A?.Err??p)(S.issues.map(ne=>Xs(ne,V,Ws())));throw lp(l,A?.callee),l}return S.value},wh=p=>async(y,T,M,A)=>{const V=M?Object.assign(M,{async:!0}):{async:!0};let S=y._zod.run({value:T,issues:[]},V);if(S instanceof Promise&&(S=await S),S.issues.length){const l=new(A?.Err??p)(S.issues.map(ne=>Xs(ne,V,Ws())));throw lp(l,A?.callee),l}return S.value},Cc=p=>(y,T,M)=>{const A=M?{...M,async:!1}:{async:!1},V=y._zod.run({value:T,issues:[]},A);if(V instanceof Promise)throw new Wo;return V.issues.length?{success:!1,error:new(p??hp)(V.issues.map(S=>Xs(S,A,Ws())))}:{success:!0,data:V.value}},Xg=Cc(dp),Ac=p=>async(y,T,M)=>{const A=M?Object.assign(M,{async:!0}):{async:!0};let V=y._zod.run({value:T,issues:[]},A);return V instanceof Promise&&(V=await V),V.issues.length?{success:!1,error:new p(V.issues.map(S=>Xs(S,A,Ws())))}:{success:!0,data:V.value}},Yg=Ac(dp),Kg=p=>(y,T,M)=>{const A=M?Object.assign(M,{direction:"backward"}):{direction:"backward"};return bh(p)(y,T,A)},Jg=p=>(y,T,M)=>bh(p)(y,T,M),Qg=p=>async(y,T,M)=>{const A=M?Object.assign(M,{direction:"backward"}):{direction:"backward"};return wh(p)(y,T,A)},e_=p=>async(y,T,M)=>wh(p)(y,T,M),t_=p=>(y,T,M)=>{const A=M?Object.assign(M,{direction:"backward"}):{direction:"backward"};return Cc(p)(y,T,A)},r_=p=>(y,T,M)=>Cc(p)(y,T,M),i_=p=>async(y,T,M)=>{const A=M?Object.assign(M,{direction:"backward"}):{direction:"backward"};return Ac(p)(y,T,A)},n_=p=>async(y,T,M)=>Ac(p)(y,T,M),s_=/^[cC][^\s-]{8,}$/,o_=/^[0-9a-z]+$/,a_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,l_=/^[0-9a-vA-V]{20}$/,c_=/^[A-Za-z0-9]{27}$/,u_=/^[a-zA-Z0-9_-]{21}$/,h_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,d_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pp=p=>p?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${p}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,p_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,f_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function m_(){return new RegExp(f_,"u")}const g_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,__=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,y_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,v_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,x_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fp=/^[A-Za-z0-9_-]*$/,b_=/^\+[1-9]\d{6,14}$/,mp="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",w_=new RegExp(`^${mp}$`);function gp(p){const y="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof p.precision=="number"?p.precision===-1?`${y}`:p.precision===0?`${y}:[0-5]\\d`:`${y}:[0-5]\\d\\.\\d{${p.precision}}`:`${y}(?::[0-5]\\d(?:\\.\\d+)?)?`}function T_(p){return new RegExp(`^${gp(p)}$`)}function S_(p){const y=gp({precision:p.precision}),T=["Z"];p.local&&T.push(""),p.offset&&T.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const M=`${y}(?:${T.join("|")})`;return new RegExp(`^${mp}T(?:${M})$`)}const P_=p=>{const y=p?`[\\s\\S]{${p?.minimum??0},${p?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${y}$`)},I_=/^-?\d+$/,M_=/^-?\d+(?:\.\d+)?$/,E_=/^[^A-Z]*$/,C_=/^[^a-z]*$/,Ti=Ae("$ZodCheck",(p,y)=>{var T;p._zod??(p._zod={}),p._zod.def=y,(T=p._zod).onattach??(T.onattach=[])}),_p={number:"number",bigint:"bigint",object:"date"},yp=Ae("$ZodCheckLessThan",(p,y)=>{Ti.init(p,y);const T=_p[typeof y.value];p._zod.onattach.push(M=>{const A=M._zod.bag,V=(y.inclusive?A.maximum:A.exclusiveMaximum)??Number.POSITIVE_INFINITY;y.value<V&&(y.inclusive?A.maximum=y.value:A.exclusiveMaximum=y.value)}),p._zod.check=M=>{(y.inclusive?M.value<=y.value:M.value<y.value)||M.issues.push({origin:T,code:"too_big",maximum:typeof y.value=="object"?y.value.getTime():y.value,input:M.value,inclusive:y.inclusive,inst:p,continue:!y.abort})}}),vp=Ae("$ZodCheckGreaterThan",(p,y)=>{Ti.init(p,y);const T=_p[typeof y.value];p._zod.onattach.push(M=>{const A=M._zod.bag,V=(y.inclusive?A.minimum:A.exclusiveMinimum)??Number.NEGATIVE_INFINITY;y.value>V&&(y.inclusive?A.minimum=y.value:A.exclusiveMinimum=y.value)}),p._zod.check=M=>{(y.inclusive?M.value>=y.value:M.value>y.value)||M.issues.push({origin:T,code:"too_small",minimum:typeof y.value=="object"?y.value.getTime():y.value,input:M.value,inclusive:y.inclusive,inst:p,continue:!y.abort})}}),A_=Ae("$ZodCheckMultipleOf",(p,y)=>{Ti.init(p,y),p._zod.onattach.push(T=>{var M;(M=T._zod.bag).multipleOf??(M.multipleOf=y.value)}),p._zod.check=T=>{if(typeof T.value!=typeof y.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof T.value=="bigint"?T.value%y.value===BigInt(0):Rg(T.value,y.value)===0)||T.issues.push({origin:typeof T.value,code:"not_multiple_of",divisor:y.value,input:T.value,inst:p,continue:!y.abort})}}),z_=Ae("$ZodCheckNumberFormat",(p,y)=>{Ti.init(p,y),y.format=y.format||"float64";const T=y.format?.includes("int"),M=T?"int":"number",[A,V]=jg[y.format];p._zod.onattach.push(S=>{const l=S._zod.bag;l.format=y.format,l.minimum=A,l.maximum=V,T&&(l.pattern=I_)}),p._zod.check=S=>{const l=S.value;if(T){if(!Number.isInteger(l)){S.issues.push({expected:M,format:y.format,code:"invalid_type",continue:!1,input:l,inst:p});return}if(!Number.isSafeInteger(l)){l>0?S.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:p,origin:M,inclusive:!0,continue:!y.abort}):S.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:p,origin:M,inclusive:!0,continue:!y.abort});return}}l<A&&S.issues.push({origin:"number",input:l,code:"too_small",minimum:A,inclusive:!0,inst:p,continue:!y.abort}),l>V&&S.issues.push({origin:"number",input:l,code:"too_big",maximum:V,inclusive:!0,inst:p,continue:!y.abort})}}),D_=Ae("$ZodCheckMaxLength",(p,y)=>{var T;Ti.init(p,y),(T=p._zod.def).when??(T.when=M=>{const A=M.value;return!_h(A)&&A.length!==void 0}),p._zod.onattach.push(M=>{const A=M._zod.bag.maximum??Number.POSITIVE_INFINITY;y.maximum<A&&(M._zod.bag.maximum=y.maximum)}),p._zod.check=M=>{const A=M.value;if(A.length<=y.maximum)return;const S=xh(A);M.issues.push({origin:S,code:"too_big",maximum:y.maximum,inclusive:!0,input:A,inst:p,continue:!y.abort})}}),k_=Ae("$ZodCheckMinLength",(p,y)=>{var T;Ti.init(p,y),(T=p._zod.def).when??(T.when=M=>{const A=M.value;return!_h(A)&&A.length!==void 0}),p._zod.onattach.push(M=>{const A=M._zod.bag.minimum??Number.NEGATIVE_INFINITY;y.minimum>A&&(M._zod.bag.minimum=y.minimum)}),p._zod.check=M=>{const A=M.value;if(A.length>=y.minimum)return;const S=xh(A);M.issues.push({origin:S,code:"too_small",minimum:y.minimum,inclusive:!0,input:A,inst:p,continue:!y.abort})}}),R_=Ae("$ZodCheckLengthEquals",(p,y)=>{var T;Ti.init(p,y),(T=p._zod.def).when??(T.when=M=>{const A=M.value;return!_h(A)&&A.length!==void 0}),p._zod.onattach.push(M=>{const A=M._zod.bag;A.minimum=y.length,A.maximum=y.length,A.length=y.length}),p._zod.check=M=>{const A=M.value,V=A.length;if(V===y.length)return;const S=xh(A),l=V>y.length;M.issues.push({origin:S,...l?{code:"too_big",maximum:y.length}:{code:"too_small",minimum:y.length},inclusive:!0,exact:!0,input:M.value,inst:p,continue:!y.abort})}}),zc=Ae("$ZodCheckStringFormat",(p,y)=>{var T,M;Ti.init(p,y),p._zod.onattach.push(A=>{const V=A._zod.bag;V.format=y.format,y.pattern&&(V.patterns??(V.patterns=new Set),V.patterns.add(y.pattern))}),y.pattern?(T=p._zod).check??(T.check=A=>{y.pattern.lastIndex=0,!y.pattern.test(A.value)&&A.issues.push({origin:"string",code:"invalid_format",format:y.format,input:A.value,...y.pattern?{pattern:y.pattern.toString()}:{},inst:p,continue:!y.abort})}):(M=p._zod).check??(M.check=()=>{})}),F_=Ae("$ZodCheckRegex",(p,y)=>{zc.init(p,y),p._zod.check=T=>{y.pattern.lastIndex=0,!y.pattern.test(T.value)&&T.issues.push({origin:"string",code:"invalid_format",format:"regex",input:T.value,pattern:y.pattern.toString(),inst:p,continue:!y.abort})}}),L_=Ae("$ZodCheckLowerCase",(p,y)=>{y.pattern??(y.pattern=E_),zc.init(p,y)}),O_=Ae("$ZodCheckUpperCase",(p,y)=>{y.pattern??(y.pattern=C_),zc.init(p,y)}),B_=Ae("$ZodCheckIncludes",(p,y)=>{Ti.init(p,y);const T=Mc(y.includes),M=new RegExp(typeof y.position=="number"?`^.{${y.position}}${T}`:T);y.pattern=M,p._zod.onattach.push(A=>{const V=A._zod.bag;V.patterns??(V.patterns=new Set),V.patterns.add(M)}),p._zod.check=A=>{A.value.includes(y.includes,y.position)||A.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:y.includes,input:A.value,inst:p,continue:!y.abort})}}),j_=Ae("$ZodCheckStartsWith",(p,y)=>{Ti.init(p,y);const T=new RegExp(`^${Mc(y.prefix)}.*`);y.pattern??(y.pattern=T),p._zod.onattach.push(M=>{const A=M._zod.bag;A.patterns??(A.patterns=new Set),A.patterns.add(T)}),p._zod.check=M=>{M.value.startsWith(y.prefix)||M.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:y.prefix,input:M.value,inst:p,continue:!y.abort})}}),N_=Ae("$ZodCheckEndsWith",(p,y)=>{Ti.init(p,y);const T=new RegExp(`.*${Mc(y.suffix)}$`);y.pattern??(y.pattern=T),p._zod.onattach.push(M=>{const A=M._zod.bag;A.patterns??(A.patterns=new Set),A.patterns.add(T)}),p._zod.check=M=>{M.value.endsWith(y.suffix)||M.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:y.suffix,input:M.value,inst:p,continue:!y.abort})}}),V_=Ae("$ZodCheckOverwrite",(p,y)=>{Ti.init(p,y),p._zod.check=T=>{T.value=y.tx(T.value)}});class $_{constructor(y=[]){this.content=[],this.indent=0,this&&(this.args=y)}indented(y){this.indent+=1,y(this),this.indent-=1}write(y){if(typeof y=="function"){y(this,{execution:"sync"}),y(this,{execution:"async"});return}const M=y.split(`
|
|
7
|
+
`).filter(S=>S),A=Math.min(...M.map(S=>S.length-S.trimStart().length)),V=M.map(S=>S.slice(A)).map(S=>" ".repeat(this.indent*2)+S);for(const S of V)this.content.push(S)}compile(){const y=Function,T=this?.args,A=[...(this?.content??[""]).map(V=>` ${V}`)];return new y(...T,A.join(`
|
|
8
|
+
`))}}const Z_={major:4,minor:3,patch:6},Ir=Ae("$ZodType",(p,y)=>{var T;p??(p={}),p._zod.def=y,p._zod.bag=p._zod.bag||{},p._zod.version=Z_;const M=[...p._zod.def.checks??[]];p._zod.traits.has("$ZodCheck")&&M.unshift(p);for(const A of M)for(const V of A._zod.onattach)V(p);if(M.length===0)(T=p._zod).deferred??(T.deferred=[]),p._zod.deferred?.push(()=>{p._zod.run=p._zod.parse});else{const A=(S,l,ne)=>{let Se=Ho(S),Le;for(const He of l){if(He._zod.def.when){if(!He._zod.def.when(S))continue}else if(Se)continue;const qe=S.issues.length,Ze=He._zod.check(S);if(Ze instanceof Promise&&ne?.async===!1)throw new Wo;if(Le||Ze instanceof Promise)Le=(Le??Promise.resolve()).then(async()=>{await Ze,S.issues.length!==qe&&(Se||(Se=Ho(S,qe)))});else{if(S.issues.length===qe)continue;Se||(Se=Ho(S,qe))}}return Le?Le.then(()=>S):S},V=(S,l,ne)=>{if(Ho(S))return S.aborted=!0,S;const Se=A(l,M,ne);if(Se instanceof Promise){if(ne.async===!1)throw new Wo;return Se.then(Le=>p._zod.parse(Le,ne))}return p._zod.parse(Se,ne)};p._zod.run=(S,l)=>{if(l.skipChecks)return p._zod.parse(S,l);if(l.direction==="backward"){const Se=p._zod.parse({value:S.value,issues:[]},{...l,skipChecks:!0});return Se instanceof Promise?Se.then(Le=>V(Le,S,l)):V(Se,S,l)}const ne=p._zod.parse(S,l);if(ne instanceof Promise){if(l.async===!1)throw new Wo;return ne.then(Se=>A(Se,M,l))}return A(ne,M,l)}}Nt(p,"~standard",()=>({validate:A=>{try{const V=Xg(p,A);return V.success?{value:V.data}:{issues:V.error?.issues}}catch{return Yg(p,A).then(S=>S.success?{value:S.data}:{issues:S.error?.issues})}},vendor:"zod",version:1}))}),Th=Ae("$ZodString",(p,y)=>{Ir.init(p,y),p._zod.pattern=[...p?._zod.bag?.patterns??[]].pop()??P_(p._zod.bag),p._zod.parse=(T,M)=>{if(y.coerce)try{T.value=String(T.value)}catch{}return typeof T.value=="string"||T.issues.push({expected:"string",code:"invalid_type",input:T.value,inst:p}),T}}),pr=Ae("$ZodStringFormat",(p,y)=>{zc.init(p,y),Th.init(p,y)}),U_=Ae("$ZodGUID",(p,y)=>{y.pattern??(y.pattern=d_),pr.init(p,y)}),G_=Ae("$ZodUUID",(p,y)=>{if(y.version){const M={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[y.version];if(M===void 0)throw new Error(`Invalid UUID version: "${y.version}"`);y.pattern??(y.pattern=pp(M))}else y.pattern??(y.pattern=pp());pr.init(p,y)}),q_=Ae("$ZodEmail",(p,y)=>{y.pattern??(y.pattern=p_),pr.init(p,y)}),W_=Ae("$ZodURL",(p,y)=>{pr.init(p,y),p._zod.check=T=>{try{const M=T.value.trim(),A=new URL(M);y.hostname&&(y.hostname.lastIndex=0,y.hostname.test(A.hostname)||T.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:y.hostname.source,input:T.value,inst:p,continue:!y.abort})),y.protocol&&(y.protocol.lastIndex=0,y.protocol.test(A.protocol.endsWith(":")?A.protocol.slice(0,-1):A.protocol)||T.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:y.protocol.source,input:T.value,inst:p,continue:!y.abort})),y.normalize?T.value=A.href:T.value=M;return}catch{T.issues.push({code:"invalid_format",format:"url",input:T.value,inst:p,continue:!y.abort})}}}),H_=Ae("$ZodEmoji",(p,y)=>{y.pattern??(y.pattern=m_()),pr.init(p,y)}),X_=Ae("$ZodNanoID",(p,y)=>{y.pattern??(y.pattern=u_),pr.init(p,y)}),Y_=Ae("$ZodCUID",(p,y)=>{y.pattern??(y.pattern=s_),pr.init(p,y)}),K_=Ae("$ZodCUID2",(p,y)=>{y.pattern??(y.pattern=o_),pr.init(p,y)}),J_=Ae("$ZodULID",(p,y)=>{y.pattern??(y.pattern=a_),pr.init(p,y)}),Q_=Ae("$ZodXID",(p,y)=>{y.pattern??(y.pattern=l_),pr.init(p,y)}),ey=Ae("$ZodKSUID",(p,y)=>{y.pattern??(y.pattern=c_),pr.init(p,y)}),ty=Ae("$ZodISODateTime",(p,y)=>{y.pattern??(y.pattern=S_(y)),pr.init(p,y)}),ry=Ae("$ZodISODate",(p,y)=>{y.pattern??(y.pattern=w_),pr.init(p,y)}),iy=Ae("$ZodISOTime",(p,y)=>{y.pattern??(y.pattern=T_(y)),pr.init(p,y)}),ny=Ae("$ZodISODuration",(p,y)=>{y.pattern??(y.pattern=h_),pr.init(p,y)}),sy=Ae("$ZodIPv4",(p,y)=>{y.pattern??(y.pattern=g_),pr.init(p,y),p._zod.bag.format="ipv4"}),oy=Ae("$ZodIPv6",(p,y)=>{y.pattern??(y.pattern=__),pr.init(p,y),p._zod.bag.format="ipv6",p._zod.check=T=>{try{new URL(`http://[${T.value}]`)}catch{T.issues.push({code:"invalid_format",format:"ipv6",input:T.value,inst:p,continue:!y.abort})}}}),ay=Ae("$ZodCIDRv4",(p,y)=>{y.pattern??(y.pattern=y_),pr.init(p,y)}),ly=Ae("$ZodCIDRv6",(p,y)=>{y.pattern??(y.pattern=v_),pr.init(p,y),p._zod.check=T=>{const M=T.value.split("/");try{if(M.length!==2)throw new Error;const[A,V]=M;if(!V)throw new Error;const S=Number(V);if(`${S}`!==V)throw new Error;if(S<0||S>128)throw new Error;new URL(`http://[${A}]`)}catch{T.issues.push({code:"invalid_format",format:"cidrv6",input:T.value,inst:p,continue:!y.abort})}}});function xp(p){if(p==="")return!0;if(p.length%4!==0)return!1;try{return atob(p),!0}catch{return!1}}const cy=Ae("$ZodBase64",(p,y)=>{y.pattern??(y.pattern=x_),pr.init(p,y),p._zod.bag.contentEncoding="base64",p._zod.check=T=>{xp(T.value)||T.issues.push({code:"invalid_format",format:"base64",input:T.value,inst:p,continue:!y.abort})}});function uy(p){if(!fp.test(p))return!1;const y=p.replace(/[-_]/g,M=>M==="-"?"+":"/"),T=y.padEnd(Math.ceil(y.length/4)*4,"=");return xp(T)}const hy=Ae("$ZodBase64URL",(p,y)=>{y.pattern??(y.pattern=fp),pr.init(p,y),p._zod.bag.contentEncoding="base64url",p._zod.check=T=>{uy(T.value)||T.issues.push({code:"invalid_format",format:"base64url",input:T.value,inst:p,continue:!y.abort})}}),dy=Ae("$ZodE164",(p,y)=>{y.pattern??(y.pattern=b_),pr.init(p,y)});function py(p,y=null){try{const T=p.split(".");if(T.length!==3)return!1;const[M]=T;if(!M)return!1;const A=JSON.parse(atob(M));return!("typ"in A&&A?.typ!=="JWT"||!A.alg||y&&(!("alg"in A)||A.alg!==y))}catch{return!1}}const fy=Ae("$ZodJWT",(p,y)=>{pr.init(p,y),p._zod.check=T=>{py(T.value,y.alg)||T.issues.push({code:"invalid_format",format:"jwt",input:T.value,inst:p,continue:!y.abort})}}),bp=Ae("$ZodNumber",(p,y)=>{Ir.init(p,y),p._zod.pattern=p._zod.bag.pattern??M_,p._zod.parse=(T,M)=>{if(y.coerce)try{T.value=Number(T.value)}catch{}const A=T.value;if(typeof A=="number"&&!Number.isNaN(A)&&Number.isFinite(A))return T;const V=typeof A=="number"?Number.isNaN(A)?"NaN":Number.isFinite(A)?void 0:"Infinity":void 0;return T.issues.push({expected:"number",code:"invalid_type",input:A,inst:p,...V?{received:V}:{}}),T}}),my=Ae("$ZodNumberFormat",(p,y)=>{z_.init(p,y),bp.init(p,y)}),gy=Ae("$ZodUnknown",(p,y)=>{Ir.init(p,y),p._zod.parse=T=>T}),_y=Ae("$ZodNever",(p,y)=>{Ir.init(p,y),p._zod.parse=(T,M)=>(T.issues.push({expected:"never",code:"invalid_type",input:T.value,inst:p}),T)});function wp(p,y,T){p.issues.length&&y.issues.push(...vh(T,p.issues)),y.value[T]=p.value}const yy=Ae("$ZodArray",(p,y)=>{Ir.init(p,y),p._zod.parse=(T,M)=>{const A=T.value;if(!Array.isArray(A))return T.issues.push({expected:"array",code:"invalid_type",input:A,inst:p}),T;T.value=Array(A.length);const V=[];for(let S=0;S<A.length;S++){const l=A[S],ne=y.element._zod.run({value:l,issues:[]},M);ne instanceof Promise?V.push(ne.then(Se=>wp(Se,T,S))):wp(ne,T,S)}return V.length?Promise.all(V).then(()=>T):T}});function Dc(p,y,T,M,A){if(p.issues.length){if(A&&!(T in M))return;y.issues.push(...vh(T,p.issues))}p.value===void 0?T in M&&(y.value[T]=void 0):y.value[T]=p.value}function Tp(p){const y=Object.keys(p.shape);for(const M of y)if(!p.shape?.[M]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${M}": expected a Zod schema`);const T=Bg(p.shape);return{...p,keys:y,keySet:new Set(y),numKeys:y.length,optionalKeys:new Set(T)}}function Sp(p,y,T,M,A,V){const S=[],l=A.keySet,ne=A.catchall._zod,Se=ne.def.type,Le=ne.optout==="optional";for(const He in y){if(l.has(He))continue;if(Se==="never"){S.push(He);continue}const qe=ne.run({value:y[He],issues:[]},M);qe instanceof Promise?p.push(qe.then(Ze=>Dc(Ze,T,He,y,Le))):Dc(qe,T,He,y,Le)}return S.length&&T.issues.push({code:"unrecognized_keys",keys:S,input:y,inst:V}),p.length?Promise.all(p).then(()=>T):T}const vy=Ae("$ZodObject",(p,y)=>{if(Ir.init(p,y),!Object.getOwnPropertyDescriptor(y,"shape")?.get){const l=y.shape;Object.defineProperty(y,"shape",{get:()=>{const ne={...l};return Object.defineProperty(y,"shape",{value:ne}),ne}})}const M=gh(()=>Tp(y));Nt(p._zod,"propValues",()=>{const l=y.shape,ne={};for(const Se in l){const Le=l[Se]._zod;if(Le.values){ne[Se]??(ne[Se]=new Set);for(const He of Le.values)ne[Se].add(He)}}return ne});const A=Ic,V=y.catchall;let S;p._zod.parse=(l,ne)=>{S??(S=M.value);const Se=l.value;if(!A(Se))return l.issues.push({expected:"object",code:"invalid_type",input:Se,inst:p}),l;l.value={};const Le=[],He=S.shape;for(const qe of S.keys){const Ze=He[qe],wt=Ze._zod.optout==="optional",Qe=Ze._zod.run({value:Se[qe],issues:[]},ne);Qe instanceof Promise?Le.push(Qe.then(me=>Dc(me,l,qe,Se,wt))):Dc(Qe,l,qe,Se,wt)}return V?Sp(Le,Se,l,ne,M.value,p):Le.length?Promise.all(Le).then(()=>l):l}}),xy=Ae("$ZodObjectJIT",(p,y)=>{vy.init(p,y);const T=p._zod.parse,M=gh(()=>Tp(y)),A=qe=>{const Ze=new $_(["shape","payload","ctx"]),wt=M.value,Qe=tt=>{const pt=ap(tt);return`shape[${pt}]._zod.run({ value: input[${pt}], issues: [] }, ctx)`};Ze.write("const input = payload.value;");const me=Object.create(null);let Vt=0;for(const tt of wt.keys)me[tt]=`key_${Vt++}`;Ze.write("const newResult = {};");for(const tt of wt.keys){const pt=me[tt],It=ap(tt),mt=qe[tt]?._zod?.optout==="optional";Ze.write(`const ${pt} = ${Qe(tt)};`),mt?Ze.write(`
|
|
9
|
+
if (${pt}.issues.length) {
|
|
10
|
+
if (${It} in input) {
|
|
11
|
+
payload.issues = payload.issues.concat(${pt}.issues.map(iss => ({
|
|
12
|
+
...iss,
|
|
13
|
+
path: iss.path ? [${It}, ...iss.path] : [${It}]
|
|
14
|
+
})));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (${pt}.value === undefined) {
|
|
19
|
+
if (${It} in input) {
|
|
20
|
+
newResult[${It}] = undefined;
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
newResult[${It}] = ${pt}.value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
`):Ze.write(`
|
|
27
|
+
if (${pt}.issues.length) {
|
|
28
|
+
payload.issues = payload.issues.concat(${pt}.issues.map(iss => ({
|
|
29
|
+
...iss,
|
|
30
|
+
path: iss.path ? [${It}, ...iss.path] : [${It}]
|
|
31
|
+
})));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (${pt}.value === undefined) {
|
|
35
|
+
if (${It} in input) {
|
|
36
|
+
newResult[${It}] = undefined;
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
newResult[${It}] = ${pt}.value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
`)}Ze.write("payload.value = newResult;"),Ze.write("return payload;");const bt=Ze.compile();return(tt,pt)=>bt(qe,tt,pt)};let V;const S=Ic,l=!np.jitless,Se=l&&Lg.value,Le=y.catchall;let He;p._zod.parse=(qe,Ze)=>{He??(He=M.value);const wt=qe.value;return S(wt)?l&&Se&&Ze?.async===!1&&Ze.jitless!==!0?(V||(V=A(y.shape)),qe=V(qe,Ze),Le?Sp([],wt,qe,Ze,He,p):qe):T(qe,Ze):(qe.issues.push({expected:"object",code:"invalid_type",input:wt,inst:p}),qe)}});function Pp(p,y,T,M){for(const V of p)if(V.issues.length===0)return y.value=V.value,y;const A=p.filter(V=>!Ho(V));return A.length===1?(y.value=A[0].value,A[0]):(y.issues.push({code:"invalid_union",input:y.value,inst:T,errors:p.map(V=>V.issues.map(S=>Xs(S,M,Ws())))}),y)}const by=Ae("$ZodUnion",(p,y)=>{Ir.init(p,y),Nt(p._zod,"optin",()=>y.options.some(A=>A._zod.optin==="optional")?"optional":void 0),Nt(p._zod,"optout",()=>y.options.some(A=>A._zod.optout==="optional")?"optional":void 0),Nt(p._zod,"values",()=>{if(y.options.every(A=>A._zod.values))return new Set(y.options.flatMap(A=>Array.from(A._zod.values)))}),Nt(p._zod,"pattern",()=>{if(y.options.every(A=>A._zod.pattern)){const A=y.options.map(V=>V._zod.pattern);return new RegExp(`^(${A.map(V=>yh(V.source)).join("|")})$`)}});const T=y.options.length===1,M=y.options[0]._zod.run;p._zod.parse=(A,V)=>{if(T)return M(A,V);let S=!1;const l=[];for(const ne of y.options){const Se=ne._zod.run({value:A.value,issues:[]},V);if(Se instanceof Promise)l.push(Se),S=!0;else{if(Se.issues.length===0)return Se;l.push(Se)}}return S?Promise.all(l).then(ne=>Pp(ne,A,p,V)):Pp(l,A,p,V)}}),wy=Ae("$ZodIntersection",(p,y)=>{Ir.init(p,y),p._zod.parse=(T,M)=>{const A=T.value,V=y.left._zod.run({value:A,issues:[]},M),S=y.right._zod.run({value:A,issues:[]},M);return V instanceof Promise||S instanceof Promise?Promise.all([V,S]).then(([ne,Se])=>Ip(T,ne,Se)):Ip(T,V,S)}});function Sh(p,y){if(p===y)return{valid:!0,data:p};if(p instanceof Date&&y instanceof Date&&+p==+y)return{valid:!0,data:p};if(ol(p)&&ol(y)){const T=Object.keys(y),M=Object.keys(p).filter(V=>T.indexOf(V)!==-1),A={...p,...y};for(const V of M){const S=Sh(p[V],y[V]);if(!S.valid)return{valid:!1,mergeErrorPath:[V,...S.mergeErrorPath]};A[V]=S.data}return{valid:!0,data:A}}if(Array.isArray(p)&&Array.isArray(y)){if(p.length!==y.length)return{valid:!1,mergeErrorPath:[]};const T=[];for(let M=0;M<p.length;M++){const A=p[M],V=y[M],S=Sh(A,V);if(!S.valid)return{valid:!1,mergeErrorPath:[M,...S.mergeErrorPath]};T.push(S.data)}return{valid:!0,data:T}}return{valid:!1,mergeErrorPath:[]}}function Ip(p,y,T){const M=new Map;let A;for(const l of y.issues)if(l.code==="unrecognized_keys"){A??(A=l);for(const ne of l.keys)M.has(ne)||M.set(ne,{}),M.get(ne).l=!0}else p.issues.push(l);for(const l of T.issues)if(l.code==="unrecognized_keys")for(const ne of l.keys)M.has(ne)||M.set(ne,{}),M.get(ne).r=!0;else p.issues.push(l);const V=[...M].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(V.length&&A&&p.issues.push({...A,keys:V}),Ho(p))return p;const S=Sh(y.value,T.value);if(!S.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(S.mergeErrorPath)}`);return p.value=S.data,p}const Ty=Ae("$ZodTuple",(p,y)=>{Ir.init(p,y);const T=y.items;p._zod.parse=(M,A)=>{const V=M.value;if(!Array.isArray(V))return M.issues.push({input:V,inst:p,expected:"tuple",code:"invalid_type"}),M;M.value=[];const S=[],l=[...T].reverse().findIndex(Le=>Le._zod.optin!=="optional"),ne=l===-1?0:T.length-l;if(!y.rest){const Le=V.length>T.length,He=V.length<ne-1;if(Le||He)return M.issues.push({...Le?{code:"too_big",maximum:T.length,inclusive:!0}:{code:"too_small",minimum:T.length},input:V,inst:p,origin:"array"}),M}let Se=-1;for(const Le of T){if(Se++,Se>=V.length&&Se>=ne)continue;const He=Le._zod.run({value:V[Se],issues:[]},A);He instanceof Promise?S.push(He.then(qe=>kc(qe,M,Se))):kc(He,M,Se)}if(y.rest){const Le=V.slice(T.length);for(const He of Le){Se++;const qe=y.rest._zod.run({value:He,issues:[]},A);qe instanceof Promise?S.push(qe.then(Ze=>kc(Ze,M,Se))):kc(qe,M,Se)}}return S.length?Promise.all(S).then(()=>M):M}});function kc(p,y,T){p.issues.length&&y.issues.push(...vh(T,p.issues)),y.value[T]=p.value}const Sy=Ae("$ZodEnum",(p,y)=>{Ir.init(p,y);const T=sp(y.entries),M=new Set(T);p._zod.values=M,p._zod.pattern=new RegExp(`^(${T.filter(A=>Og.has(typeof A)).map(A=>typeof A=="string"?Mc(A):A.toString()).join("|")})$`),p._zod.parse=(A,V)=>{const S=A.value;return M.has(S)||A.issues.push({code:"invalid_value",values:T,input:S,inst:p}),A}}),Py=Ae("$ZodTransform",(p,y)=>{Ir.init(p,y),p._zod.parse=(T,M)=>{if(M.direction==="backward")throw new ip(p.constructor.name);const A=y.transform(T.value,T);if(M.async)return(A instanceof Promise?A:Promise.resolve(A)).then(S=>(T.value=S,T));if(A instanceof Promise)throw new Wo;return T.value=A,T}});function Mp(p,y){return p.issues.length&&y===void 0?{issues:[],value:void 0}:p}const Ep=Ae("$ZodOptional",(p,y)=>{Ir.init(p,y),p._zod.optin="optional",p._zod.optout="optional",Nt(p._zod,"values",()=>y.innerType._zod.values?new Set([...y.innerType._zod.values,void 0]):void 0),Nt(p._zod,"pattern",()=>{const T=y.innerType._zod.pattern;return T?new RegExp(`^(${yh(T.source)})?$`):void 0}),p._zod.parse=(T,M)=>{if(y.innerType._zod.optin==="optional"){const A=y.innerType._zod.run(T,M);return A instanceof Promise?A.then(V=>Mp(V,T.value)):Mp(A,T.value)}return T.value===void 0?T:y.innerType._zod.run(T,M)}}),Iy=Ae("$ZodExactOptional",(p,y)=>{Ep.init(p,y),Nt(p._zod,"values",()=>y.innerType._zod.values),Nt(p._zod,"pattern",()=>y.innerType._zod.pattern),p._zod.parse=(T,M)=>y.innerType._zod.run(T,M)}),My=Ae("$ZodNullable",(p,y)=>{Ir.init(p,y),Nt(p._zod,"optin",()=>y.innerType._zod.optin),Nt(p._zod,"optout",()=>y.innerType._zod.optout),Nt(p._zod,"pattern",()=>{const T=y.innerType._zod.pattern;return T?new RegExp(`^(${yh(T.source)}|null)$`):void 0}),Nt(p._zod,"values",()=>y.innerType._zod.values?new Set([...y.innerType._zod.values,null]):void 0),p._zod.parse=(T,M)=>T.value===null?T:y.innerType._zod.run(T,M)}),Ey=Ae("$ZodDefault",(p,y)=>{Ir.init(p,y),p._zod.optin="optional",Nt(p._zod,"values",()=>y.innerType._zod.values),p._zod.parse=(T,M)=>{if(M.direction==="backward")return y.innerType._zod.run(T,M);if(T.value===void 0)return T.value=y.defaultValue,T;const A=y.innerType._zod.run(T,M);return A instanceof Promise?A.then(V=>Cp(V,y)):Cp(A,y)}});function Cp(p,y){return p.value===void 0&&(p.value=y.defaultValue),p}const Cy=Ae("$ZodPrefault",(p,y)=>{Ir.init(p,y),p._zod.optin="optional",Nt(p._zod,"values",()=>y.innerType._zod.values),p._zod.parse=(T,M)=>(M.direction==="backward"||T.value===void 0&&(T.value=y.defaultValue),y.innerType._zod.run(T,M))}),Ay=Ae("$ZodNonOptional",(p,y)=>{Ir.init(p,y),Nt(p._zod,"values",()=>{const T=y.innerType._zod.values;return T?new Set([...T].filter(M=>M!==void 0)):void 0}),p._zod.parse=(T,M)=>{const A=y.innerType._zod.run(T,M);return A instanceof Promise?A.then(V=>Ap(V,p)):Ap(A,p)}});function Ap(p,y){return!p.issues.length&&p.value===void 0&&p.issues.push({code:"invalid_type",expected:"nonoptional",input:p.value,inst:y}),p}const zy=Ae("$ZodCatch",(p,y)=>{Ir.init(p,y),Nt(p._zod,"optin",()=>y.innerType._zod.optin),Nt(p._zod,"optout",()=>y.innerType._zod.optout),Nt(p._zod,"values",()=>y.innerType._zod.values),p._zod.parse=(T,M)=>{if(M.direction==="backward")return y.innerType._zod.run(T,M);const A=y.innerType._zod.run(T,M);return A instanceof Promise?A.then(V=>(T.value=V.value,V.issues.length&&(T.value=y.catchValue({...T,error:{issues:V.issues.map(S=>Xs(S,M,Ws()))},input:T.value}),T.issues=[]),T)):(T.value=A.value,A.issues.length&&(T.value=y.catchValue({...T,error:{issues:A.issues.map(V=>Xs(V,M,Ws()))},input:T.value}),T.issues=[]),T)}}),Dy=Ae("$ZodPipe",(p,y)=>{Ir.init(p,y),Nt(p._zod,"values",()=>y.in._zod.values),Nt(p._zod,"optin",()=>y.in._zod.optin),Nt(p._zod,"optout",()=>y.out._zod.optout),Nt(p._zod,"propValues",()=>y.in._zod.propValues),p._zod.parse=(T,M)=>{if(M.direction==="backward"){const V=y.out._zod.run(T,M);return V instanceof Promise?V.then(S=>Rc(S,y.in,M)):Rc(V,y.in,M)}const A=y.in._zod.run(T,M);return A instanceof Promise?A.then(V=>Rc(V,y.out,M)):Rc(A,y.out,M)}});function Rc(p,y,T){return p.issues.length?(p.aborted=!0,p):y._zod.run({value:p.value,issues:p.issues},T)}const ky=Ae("$ZodReadonly",(p,y)=>{Ir.init(p,y),Nt(p._zod,"propValues",()=>y.innerType._zod.propValues),Nt(p._zod,"values",()=>y.innerType._zod.values),Nt(p._zod,"optin",()=>y.innerType?._zod?.optin),Nt(p._zod,"optout",()=>y.innerType?._zod?.optout),p._zod.parse=(T,M)=>{if(M.direction==="backward")return y.innerType._zod.run(T,M);const A=y.innerType._zod.run(T,M);return A instanceof Promise?A.then(zp):zp(A)}});function zp(p){return p.value=Object.freeze(p.value),p}const Ry=Ae("$ZodCustom",(p,y)=>{Ti.init(p,y),Ir.init(p,y),p._zod.parse=(T,M)=>T,p._zod.check=T=>{const M=T.value,A=y.fn(M);if(A instanceof Promise)return A.then(V=>Dp(V,T,M,p));Dp(A,T,M,p)}});function Dp(p,y,T,M){if(!p){const A={code:"custom",input:T,inst:M,path:[...M._zod.def.path??[]],continue:!M._zod.def.abort};M._zod.def.params&&(A.params=M._zod.def.params),y.issues.push(al(A))}}var kp;class Fy{constructor(){this._map=new WeakMap,this._idmap=new Map}add(y,...T){const M=T[0];return this._map.set(y,M),M&&typeof M=="object"&&"id"in M&&this._idmap.set(M.id,y),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(y){const T=this._map.get(y);return T&&typeof T=="object"&&"id"in T&&this._idmap.delete(T.id),this._map.delete(y),this}get(y){const T=y._zod.parent;if(T){const M={...this.get(T)??{}};delete M.id;const A={...M,...this._map.get(y)};return Object.keys(A).length?A:void 0}return this._map.get(y)}has(y){return this._map.has(y)}}function Ly(){return new Fy}(kp=globalThis).__zod_globalRegistry??(kp.__zod_globalRegistry=Ly());const ll=globalThis.__zod_globalRegistry;function Oy(p,y){return new p({type:"string",...it(y)})}function By(p,y){return new p({type:"string",format:"email",check:"string_format",abort:!1,...it(y)})}function Rp(p,y){return new p({type:"string",format:"guid",check:"string_format",abort:!1,...it(y)})}function jy(p,y){return new p({type:"string",format:"uuid",check:"string_format",abort:!1,...it(y)})}function Ny(p,y){return new p({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...it(y)})}function Vy(p,y){return new p({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...it(y)})}function $y(p,y){return new p({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...it(y)})}function Zy(p,y){return new p({type:"string",format:"url",check:"string_format",abort:!1,...it(y)})}function Uy(p,y){return new p({type:"string",format:"emoji",check:"string_format",abort:!1,...it(y)})}function Gy(p,y){return new p({type:"string",format:"nanoid",check:"string_format",abort:!1,...it(y)})}function qy(p,y){return new p({type:"string",format:"cuid",check:"string_format",abort:!1,...it(y)})}function Wy(p,y){return new p({type:"string",format:"cuid2",check:"string_format",abort:!1,...it(y)})}function Hy(p,y){return new p({type:"string",format:"ulid",check:"string_format",abort:!1,...it(y)})}function Xy(p,y){return new p({type:"string",format:"xid",check:"string_format",abort:!1,...it(y)})}function Yy(p,y){return new p({type:"string",format:"ksuid",check:"string_format",abort:!1,...it(y)})}function Ky(p,y){return new p({type:"string",format:"ipv4",check:"string_format",abort:!1,...it(y)})}function Jy(p,y){return new p({type:"string",format:"ipv6",check:"string_format",abort:!1,...it(y)})}function Qy(p,y){return new p({type:"string",format:"cidrv4",check:"string_format",abort:!1,...it(y)})}function ev(p,y){return new p({type:"string",format:"cidrv6",check:"string_format",abort:!1,...it(y)})}function tv(p,y){return new p({type:"string",format:"base64",check:"string_format",abort:!1,...it(y)})}function rv(p,y){return new p({type:"string",format:"base64url",check:"string_format",abort:!1,...it(y)})}function iv(p,y){return new p({type:"string",format:"e164",check:"string_format",abort:!1,...it(y)})}function nv(p,y){return new p({type:"string",format:"jwt",check:"string_format",abort:!1,...it(y)})}function sv(p,y){return new p({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...it(y)})}function ov(p,y){return new p({type:"string",format:"date",check:"string_format",...it(y)})}function av(p,y){return new p({type:"string",format:"time",check:"string_format",precision:null,...it(y)})}function lv(p,y){return new p({type:"string",format:"duration",check:"string_format",...it(y)})}function cv(p,y){return new p({type:"number",checks:[],...it(y)})}function uv(p,y){return new p({type:"number",check:"number_format",abort:!1,format:"safeint",...it(y)})}function hv(p){return new p({type:"unknown"})}function dv(p,y){return new p({type:"never",...it(y)})}function Fp(p,y){return new yp({check:"less_than",...it(y),value:p,inclusive:!1})}function Ph(p,y){return new yp({check:"less_than",...it(y),value:p,inclusive:!0})}function Lp(p,y){return new vp({check:"greater_than",...it(y),value:p,inclusive:!1})}function Ih(p,y){return new vp({check:"greater_than",...it(y),value:p,inclusive:!0})}function Op(p,y){return new A_({check:"multiple_of",...it(y),value:p})}function Bp(p,y){return new D_({check:"max_length",...it(y),maximum:p})}function Fc(p,y){return new k_({check:"min_length",...it(y),minimum:p})}function jp(p,y){return new R_({check:"length_equals",...it(y),length:p})}function pv(p,y){return new F_({check:"string_format",format:"regex",...it(y),pattern:p})}function fv(p){return new L_({check:"string_format",format:"lowercase",...it(p)})}function mv(p){return new O_({check:"string_format",format:"uppercase",...it(p)})}function gv(p,y){return new B_({check:"string_format",format:"includes",...it(y),includes:p})}function _v(p,y){return new j_({check:"string_format",format:"starts_with",...it(y),prefix:p})}function yv(p,y){return new N_({check:"string_format",format:"ends_with",...it(y),suffix:p})}function Xo(p){return new V_({check:"overwrite",tx:p})}function vv(p){return Xo(y=>y.normalize(p))}function xv(){return Xo(p=>p.trim())}function bv(){return Xo(p=>p.toLowerCase())}function wv(){return Xo(p=>p.toUpperCase())}function Tv(){return Xo(p=>Fg(p))}function Sv(p,y,T){return new p({type:"array",element:y,...it(T)})}function Pv(p,y,T){return new p({type:"custom",check:"custom",fn:y,...it(T)})}function Iv(p){const y=Mv(T=>(T.addIssue=M=>{if(typeof M=="string")T.issues.push(al(M,T.value,y._zod.def));else{const A=M;A.fatal&&(A.continue=!1),A.code??(A.code="custom"),A.input??(A.input=T.value),A.inst??(A.inst=y),A.continue??(A.continue=!y._zod.def.abort),T.issues.push(al(A))}},p(T.value,T)));return y}function Mv(p,y){const T=new Ti({check:"custom",...it(y)});return T._zod.check=p,T}function Np(p){let y=p?.target??"draft-2020-12";return y==="draft-4"&&(y="draft-04"),y==="draft-7"&&(y="draft-07"),{processors:p.processors??{},metadataRegistry:p?.metadata??ll,target:y,unrepresentable:p?.unrepresentable??"throw",override:p?.override??(()=>{}),io:p?.io??"output",counter:0,seen:new Map,cycles:p?.cycles??"ref",reused:p?.reused??"inline",external:p?.external??void 0}}function Gr(p,y,T={path:[],schemaPath:[]}){var M;const A=p._zod.def,V=y.seen.get(p);if(V)return V.count++,T.schemaPath.includes(p)&&(V.cycle=T.path),V.schema;const S={schema:{},count:1,cycle:void 0,path:T.path};y.seen.set(p,S);const l=p._zod.toJSONSchema?.();if(l)S.schema=l;else{const Le={...T,schemaPath:[...T.schemaPath,p],path:T.path};if(p._zod.processJSONSchema)p._zod.processJSONSchema(y,S.schema,Le);else{const qe=S.schema,Ze=y.processors[A.type];if(!Ze)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${A.type}`);Ze(p,y,qe,Le)}const He=p._zod.parent;He&&(S.ref||(S.ref=He),Gr(He,y,Le),y.seen.get(He).isParent=!0)}const ne=y.metadataRegistry.get(p);return ne&&Object.assign(S.schema,ne),y.io==="input"&&fi(p)&&(delete S.schema.examples,delete S.schema.default),y.io==="input"&&S.schema._prefault&&((M=S.schema).default??(M.default=S.schema._prefault)),delete S.schema._prefault,y.seen.get(p).schema}function Vp(p,y){const T=p.seen.get(y);if(!T)throw new Error("Unprocessed schema. This is a bug in Zod.");const M=new Map;for(const S of p.seen.entries()){const l=p.metadataRegistry.get(S[0])?.id;if(l){const ne=M.get(l);if(ne&&ne!==S[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);M.set(l,S[0])}}const A=S=>{const l=p.target==="draft-2020-12"?"$defs":"definitions";if(p.external){const He=p.external.registry.get(S[0])?.id,qe=p.external.uri??(wt=>wt);if(He)return{ref:qe(He)};const Ze=S[1].defId??S[1].schema.id??`schema${p.counter++}`;return S[1].defId=Ze,{defId:Ze,ref:`${qe("__shared")}#/${l}/${Ze}`}}if(S[1]===T)return{ref:"#"};const Se=`#/${l}/`,Le=S[1].schema.id??`__schema${p.counter++}`;return{defId:Le,ref:Se+Le}},V=S=>{if(S[1].schema.$ref)return;const l=S[1],{ref:ne,defId:Se}=A(S);l.def={...l.schema},Se&&(l.defId=Se);const Le=l.schema;for(const He in Le)delete Le[He];Le.$ref=ne};if(p.cycles==="throw")for(const S of p.seen.entries()){const l=S[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/<root>
|
|
43
|
+
|
|
44
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const S of p.seen.entries()){const l=S[1];if(y===S[0]){V(S);continue}if(p.external){const Se=p.external.registry.get(S[0])?.id;if(y!==S[0]&&Se){V(S);continue}}if(p.metadataRegistry.get(S[0])?.id){V(S);continue}if(l.cycle){V(S);continue}if(l.count>1&&p.reused==="ref"){V(S);continue}}}function $p(p,y){const T=p.seen.get(y);if(!T)throw new Error("Unprocessed schema. This is a bug in Zod.");const M=S=>{const l=p.seen.get(S);if(l.ref===null)return;const ne=l.def??l.schema,Se={...ne},Le=l.ref;if(l.ref=null,Le){M(Le);const qe=p.seen.get(Le),Ze=qe.schema;if(Ze.$ref&&(p.target==="draft-07"||p.target==="draft-04"||p.target==="openapi-3.0")?(ne.allOf=ne.allOf??[],ne.allOf.push(Ze)):Object.assign(ne,Ze),Object.assign(ne,Se),S._zod.parent===Le)for(const Qe in ne)Qe==="$ref"||Qe==="allOf"||Qe in Se||delete ne[Qe];if(Ze.$ref&&qe.def)for(const Qe in ne)Qe==="$ref"||Qe==="allOf"||Qe in qe.def&&JSON.stringify(ne[Qe])===JSON.stringify(qe.def[Qe])&&delete ne[Qe]}const He=S._zod.parent;if(He&&He!==Le){M(He);const qe=p.seen.get(He);if(qe?.schema.$ref&&(ne.$ref=qe.schema.$ref,qe.def))for(const Ze in ne)Ze==="$ref"||Ze==="allOf"||Ze in qe.def&&JSON.stringify(ne[Ze])===JSON.stringify(qe.def[Ze])&&delete ne[Ze]}p.override({zodSchema:S,jsonSchema:ne,path:l.path??[]})};for(const S of[...p.seen.entries()].reverse())M(S[0]);const A={};if(p.target==="draft-2020-12"?A.$schema="https://json-schema.org/draft/2020-12/schema":p.target==="draft-07"?A.$schema="http://json-schema.org/draft-07/schema#":p.target==="draft-04"?A.$schema="http://json-schema.org/draft-04/schema#":p.target,p.external?.uri){const S=p.external.registry.get(y)?.id;if(!S)throw new Error("Schema is missing an `id` property");A.$id=p.external.uri(S)}Object.assign(A,T.def??T.schema);const V=p.external?.defs??{};for(const S of p.seen.entries()){const l=S[1];l.def&&l.defId&&(V[l.defId]=l.def)}p.external||Object.keys(V).length>0&&(p.target==="draft-2020-12"?A.$defs=V:A.definitions=V);try{const S=JSON.parse(JSON.stringify(A));return Object.defineProperty(S,"~standard",{value:{...y["~standard"],jsonSchema:{input:Lc(y,"input",p.processors),output:Lc(y,"output",p.processors)}},enumerable:!1,writable:!1}),S}catch{throw new Error("Error converting schema to JSON.")}}function fi(p,y){const T=y??{seen:new Set};if(T.seen.has(p))return!1;T.seen.add(p);const M=p._zod.def;if(M.type==="transform")return!0;if(M.type==="array")return fi(M.element,T);if(M.type==="set")return fi(M.valueType,T);if(M.type==="lazy")return fi(M.getter(),T);if(M.type==="promise"||M.type==="optional"||M.type==="nonoptional"||M.type==="nullable"||M.type==="readonly"||M.type==="default"||M.type==="prefault")return fi(M.innerType,T);if(M.type==="intersection")return fi(M.left,T)||fi(M.right,T);if(M.type==="record"||M.type==="map")return fi(M.keyType,T)||fi(M.valueType,T);if(M.type==="pipe")return fi(M.in,T)||fi(M.out,T);if(M.type==="object"){for(const A in M.shape)if(fi(M.shape[A],T))return!0;return!1}if(M.type==="union"){for(const A of M.options)if(fi(A,T))return!0;return!1}if(M.type==="tuple"){for(const A of M.items)if(fi(A,T))return!0;return!!(M.rest&&fi(M.rest,T))}return!1}const Ev=(p,y={})=>T=>{const M=Np({...T,processors:y});return Gr(p,M),Vp(M,p),$p(M,p)},Lc=(p,y,T={})=>M=>{const{libraryOptions:A,target:V}=M??{},S=Np({...A??{},target:V,io:y,processors:T});return Gr(p,S),Vp(S,p),$p(S,p)},Cv={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Av=(p,y,T,M)=>{const A=T;A.type="string";const{minimum:V,maximum:S,format:l,patterns:ne,contentEncoding:Se}=p._zod.bag;if(typeof V=="number"&&(A.minLength=V),typeof S=="number"&&(A.maxLength=S),l&&(A.format=Cv[l]??l,A.format===""&&delete A.format,l==="time"&&delete A.format),Se&&(A.contentEncoding=Se),ne&&ne.size>0){const Le=[...ne];Le.length===1?A.pattern=Le[0].source:Le.length>1&&(A.allOf=[...Le.map(He=>({...y.target==="draft-07"||y.target==="draft-04"||y.target==="openapi-3.0"?{type:"string"}:{},pattern:He.source}))])}},zv=(p,y,T,M)=>{const A=T,{minimum:V,maximum:S,format:l,multipleOf:ne,exclusiveMaximum:Se,exclusiveMinimum:Le}=p._zod.bag;typeof l=="string"&&l.includes("int")?A.type="integer":A.type="number",typeof Le=="number"&&(y.target==="draft-04"||y.target==="openapi-3.0"?(A.minimum=Le,A.exclusiveMinimum=!0):A.exclusiveMinimum=Le),typeof V=="number"&&(A.minimum=V,typeof Le=="number"&&y.target!=="draft-04"&&(Le>=V?delete A.minimum:delete A.exclusiveMinimum)),typeof Se=="number"&&(y.target==="draft-04"||y.target==="openapi-3.0"?(A.maximum=Se,A.exclusiveMaximum=!0):A.exclusiveMaximum=Se),typeof S=="number"&&(A.maximum=S,typeof Se=="number"&&y.target!=="draft-04"&&(Se<=S?delete A.maximum:delete A.exclusiveMaximum)),typeof ne=="number"&&(A.multipleOf=ne)},Dv=(p,y,T,M)=>{T.not={}},kv=(p,y,T,M)=>{},Rv=(p,y,T,M)=>{const A=p._zod.def,V=sp(A.entries);V.every(S=>typeof S=="number")&&(T.type="number"),V.every(S=>typeof S=="string")&&(T.type="string"),T.enum=V},Fv=(p,y,T,M)=>{if(y.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Lv=(p,y,T,M)=>{if(y.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ov=(p,y,T,M)=>{const A=T,V=p._zod.def,{minimum:S,maximum:l}=p._zod.bag;typeof S=="number"&&(A.minItems=S),typeof l=="number"&&(A.maxItems=l),A.type="array",A.items=Gr(V.element,y,{...M,path:[...M.path,"items"]})},Bv=(p,y,T,M)=>{const A=T,V=p._zod.def;A.type="object",A.properties={};const S=V.shape;for(const Se in S)A.properties[Se]=Gr(S[Se],y,{...M,path:[...M.path,"properties",Se]});const l=new Set(Object.keys(S)),ne=new Set([...l].filter(Se=>{const Le=V.shape[Se]._zod;return y.io==="input"?Le.optin===void 0:Le.optout===void 0}));ne.size>0&&(A.required=Array.from(ne)),V.catchall?._zod.def.type==="never"?A.additionalProperties=!1:V.catchall?V.catchall&&(A.additionalProperties=Gr(V.catchall,y,{...M,path:[...M.path,"additionalProperties"]})):y.io==="output"&&(A.additionalProperties=!1)},jv=(p,y,T,M)=>{const A=p._zod.def,V=A.inclusive===!1,S=A.options.map((l,ne)=>Gr(l,y,{...M,path:[...M.path,V?"oneOf":"anyOf",ne]}));V?T.oneOf=S:T.anyOf=S},Nv=(p,y,T,M)=>{const A=p._zod.def,V=Gr(A.left,y,{...M,path:[...M.path,"allOf",0]}),S=Gr(A.right,y,{...M,path:[...M.path,"allOf",1]}),l=Se=>"allOf"in Se&&Object.keys(Se).length===1,ne=[...l(V)?V.allOf:[V],...l(S)?S.allOf:[S]];T.allOf=ne},Vv=(p,y,T,M)=>{const A=T,V=p._zod.def;A.type="array";const S=y.target==="draft-2020-12"?"prefixItems":"items",l=y.target==="draft-2020-12"||y.target==="openapi-3.0"?"items":"additionalItems",ne=V.items.map((qe,Ze)=>Gr(qe,y,{...M,path:[...M.path,S,Ze]})),Se=V.rest?Gr(V.rest,y,{...M,path:[...M.path,l,...y.target==="openapi-3.0"?[V.items.length]:[]]}):null;y.target==="draft-2020-12"?(A.prefixItems=ne,Se&&(A.items=Se)):y.target==="openapi-3.0"?(A.items={anyOf:ne},Se&&A.items.anyOf.push(Se),A.minItems=ne.length,Se||(A.maxItems=ne.length)):(A.items=ne,Se&&(A.additionalItems=Se));const{minimum:Le,maximum:He}=p._zod.bag;typeof Le=="number"&&(A.minItems=Le),typeof He=="number"&&(A.maxItems=He)},$v=(p,y,T,M)=>{const A=p._zod.def,V=Gr(A.innerType,y,M),S=y.seen.get(p);y.target==="openapi-3.0"?(S.ref=A.innerType,T.nullable=!0):T.anyOf=[V,{type:"null"}]},Zv=(p,y,T,M)=>{const A=p._zod.def;Gr(A.innerType,y,M);const V=y.seen.get(p);V.ref=A.innerType},Uv=(p,y,T,M)=>{const A=p._zod.def;Gr(A.innerType,y,M);const V=y.seen.get(p);V.ref=A.innerType,T.default=JSON.parse(JSON.stringify(A.defaultValue))},Gv=(p,y,T,M)=>{const A=p._zod.def;Gr(A.innerType,y,M);const V=y.seen.get(p);V.ref=A.innerType,y.io==="input"&&(T._prefault=JSON.parse(JSON.stringify(A.defaultValue)))},qv=(p,y,T,M)=>{const A=p._zod.def;Gr(A.innerType,y,M);const V=y.seen.get(p);V.ref=A.innerType;let S;try{S=A.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}T.default=S},Wv=(p,y,T,M)=>{const A=p._zod.def,V=y.io==="input"?A.in._zod.def.type==="transform"?A.out:A.in:A.out;Gr(V,y,M);const S=y.seen.get(p);S.ref=V},Hv=(p,y,T,M)=>{const A=p._zod.def;Gr(A.innerType,y,M);const V=y.seen.get(p);V.ref=A.innerType,T.readOnly=!0},Zp=(p,y,T,M)=>{const A=p._zod.def;Gr(A.innerType,y,M);const V=y.seen.get(p);V.ref=A.innerType},Xv=Ae("ZodISODateTime",(p,y)=>{ty.init(p,y),br.init(p,y)});function Yv(p){return sv(Xv,p)}const Kv=Ae("ZodISODate",(p,y)=>{ry.init(p,y),br.init(p,y)});function Jv(p){return ov(Kv,p)}const Qv=Ae("ZodISOTime",(p,y)=>{iy.init(p,y),br.init(p,y)});function ex(p){return av(Qv,p)}const tx=Ae("ZodISODuration",(p,y)=>{ny.init(p,y),br.init(p,y)});function rx(p){return lv(tx,p)}const qi=Ae("ZodError",(p,y)=>{hp.init(p,y),p.name="ZodError",Object.defineProperties(p,{format:{value:T=>Hg(p,T)},flatten:{value:T=>Wg(p,T)},addIssue:{value:T=>{p.issues.push(T),p.message=JSON.stringify(p.issues,mh,2)}},addIssues:{value:T=>{p.issues.push(...T),p.message=JSON.stringify(p.issues,mh,2)}},isEmpty:{get(){return p.issues.length===0}}})},{Parent:Error}),ix=bh(qi),nx=wh(qi),sx=Cc(qi),ox=Ac(qi),ax=Kg(qi),lx=Jg(qi),cx=Qg(qi),ux=e_(qi),hx=t_(qi),dx=r_(qi),px=i_(qi),fx=n_(qi),Ar=Ae("ZodType",(p,y)=>(Ir.init(p,y),Object.assign(p["~standard"],{jsonSchema:{input:Lc(p,"input"),output:Lc(p,"output")}}),p.toJSONSchema=Ev(p,{}),p.def=y,p.type=y.type,Object.defineProperty(p,"_def",{value:y}),p.check=(...T)=>p.clone(as(y,{checks:[...y.checks??[],...T.map(M=>typeof M=="function"?{_zod:{check:M,def:{check:"custom"},onattach:[]}}:M)]}),{parent:!0}),p.with=p.check,p.clone=(T,M)=>ls(p,T,M),p.brand=()=>p,p.register=((T,M)=>(T.add(p,M),p)),p.parse=(T,M)=>ix(p,T,M,{callee:p.parse}),p.safeParse=(T,M)=>sx(p,T,M),p.parseAsync=async(T,M)=>nx(p,T,M,{callee:p.parseAsync}),p.safeParseAsync=async(T,M)=>ox(p,T,M),p.spa=p.safeParseAsync,p.encode=(T,M)=>ax(p,T,M),p.decode=(T,M)=>lx(p,T,M),p.encodeAsync=async(T,M)=>cx(p,T,M),p.decodeAsync=async(T,M)=>ux(p,T,M),p.safeEncode=(T,M)=>hx(p,T,M),p.safeDecode=(T,M)=>dx(p,T,M),p.safeEncodeAsync=async(T,M)=>px(p,T,M),p.safeDecodeAsync=async(T,M)=>fx(p,T,M),p.refine=(T,M)=>p.check(u0(T,M)),p.superRefine=T=>p.check(h0(T)),p.overwrite=T=>p.check(Xo(T)),p.optional=()=>Yp(p),p.exactOptional=()=>Kx(p),p.nullable=()=>Kp(p),p.nullish=()=>Yp(Kp(p)),p.nonoptional=T=>i0(p,T),p.array=()=>Bx(p),p.or=T=>$x([p,T]),p.and=T=>Ux(p,T),p.transform=T=>Qp(p,Xx(T)),p.default=T=>e0(p,T),p.prefault=T=>r0(p,T),p.catch=T=>s0(p,T),p.pipe=T=>Qp(p,T),p.readonly=()=>l0(p),p.describe=T=>{const M=p.clone();return ll.add(M,{description:T}),M},Object.defineProperty(p,"description",{get(){return ll.get(p)?.description},configurable:!0}),p.meta=(...T)=>{if(T.length===0)return ll.get(p);const M=p.clone();return ll.add(M,T[0]),M},p.isOptional=()=>p.safeParse(void 0).success,p.isNullable=()=>p.safeParse(null).success,p.apply=T=>T(p),p)),Up=Ae("_ZodString",(p,y)=>{Th.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(M,A,V)=>Av(p,M,A);const T=p._zod.bag;p.format=T.format??null,p.minLength=T.minimum??null,p.maxLength=T.maximum??null,p.regex=(...M)=>p.check(pv(...M)),p.includes=(...M)=>p.check(gv(...M)),p.startsWith=(...M)=>p.check(_v(...M)),p.endsWith=(...M)=>p.check(yv(...M)),p.min=(...M)=>p.check(Fc(...M)),p.max=(...M)=>p.check(Bp(...M)),p.length=(...M)=>p.check(jp(...M)),p.nonempty=(...M)=>p.check(Fc(1,...M)),p.lowercase=M=>p.check(fv(M)),p.uppercase=M=>p.check(mv(M)),p.trim=()=>p.check(xv()),p.normalize=(...M)=>p.check(vv(...M)),p.toLowerCase=()=>p.check(bv()),p.toUpperCase=()=>p.check(wv()),p.slugify=()=>p.check(Tv())}),mx=Ae("ZodString",(p,y)=>{Th.init(p,y),Up.init(p,y),p.email=T=>p.check(By(gx,T)),p.url=T=>p.check(Zy(_x,T)),p.jwt=T=>p.check(nv(Dx,T)),p.emoji=T=>p.check(Uy(yx,T)),p.guid=T=>p.check(Rp(Gp,T)),p.uuid=T=>p.check(jy(Oc,T)),p.uuidv4=T=>p.check(Ny(Oc,T)),p.uuidv6=T=>p.check(Vy(Oc,T)),p.uuidv7=T=>p.check($y(Oc,T)),p.nanoid=T=>p.check(Gy(vx,T)),p.guid=T=>p.check(Rp(Gp,T)),p.cuid=T=>p.check(qy(xx,T)),p.cuid2=T=>p.check(Wy(bx,T)),p.ulid=T=>p.check(Hy(wx,T)),p.base64=T=>p.check(tv(Cx,T)),p.base64url=T=>p.check(rv(Ax,T)),p.xid=T=>p.check(Xy(Tx,T)),p.ksuid=T=>p.check(Yy(Sx,T)),p.ipv4=T=>p.check(Ky(Px,T)),p.ipv6=T=>p.check(Jy(Ix,T)),p.cidrv4=T=>p.check(Qy(Mx,T)),p.cidrv6=T=>p.check(ev(Ex,T)),p.e164=T=>p.check(iv(zx,T)),p.datetime=T=>p.check(Yv(T)),p.date=T=>p.check(Jv(T)),p.time=T=>p.check(ex(T)),p.duration=T=>p.check(rx(T))});function cl(p){return Oy(mx,p)}const br=Ae("ZodStringFormat",(p,y)=>{pr.init(p,y),Up.init(p,y)}),gx=Ae("ZodEmail",(p,y)=>{q_.init(p,y),br.init(p,y)}),Gp=Ae("ZodGUID",(p,y)=>{U_.init(p,y),br.init(p,y)}),Oc=Ae("ZodUUID",(p,y)=>{G_.init(p,y),br.init(p,y)}),_x=Ae("ZodURL",(p,y)=>{W_.init(p,y),br.init(p,y)}),yx=Ae("ZodEmoji",(p,y)=>{H_.init(p,y),br.init(p,y)}),vx=Ae("ZodNanoID",(p,y)=>{X_.init(p,y),br.init(p,y)}),xx=Ae("ZodCUID",(p,y)=>{Y_.init(p,y),br.init(p,y)}),bx=Ae("ZodCUID2",(p,y)=>{K_.init(p,y),br.init(p,y)}),wx=Ae("ZodULID",(p,y)=>{J_.init(p,y),br.init(p,y)}),Tx=Ae("ZodXID",(p,y)=>{Q_.init(p,y),br.init(p,y)}),Sx=Ae("ZodKSUID",(p,y)=>{ey.init(p,y),br.init(p,y)}),Px=Ae("ZodIPv4",(p,y)=>{sy.init(p,y),br.init(p,y)}),Ix=Ae("ZodIPv6",(p,y)=>{oy.init(p,y),br.init(p,y)}),Mx=Ae("ZodCIDRv4",(p,y)=>{ay.init(p,y),br.init(p,y)}),Ex=Ae("ZodCIDRv6",(p,y)=>{ly.init(p,y),br.init(p,y)}),Cx=Ae("ZodBase64",(p,y)=>{cy.init(p,y),br.init(p,y)}),Ax=Ae("ZodBase64URL",(p,y)=>{hy.init(p,y),br.init(p,y)}),zx=Ae("ZodE164",(p,y)=>{dy.init(p,y),br.init(p,y)}),Dx=Ae("ZodJWT",(p,y)=>{fy.init(p,y),br.init(p,y)}),qp=Ae("ZodNumber",(p,y)=>{bp.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(M,A,V)=>zv(p,M,A),p.gt=(M,A)=>p.check(Lp(M,A)),p.gte=(M,A)=>p.check(Ih(M,A)),p.min=(M,A)=>p.check(Ih(M,A)),p.lt=(M,A)=>p.check(Fp(M,A)),p.lte=(M,A)=>p.check(Ph(M,A)),p.max=(M,A)=>p.check(Ph(M,A)),p.int=M=>p.check(Wp(M)),p.safe=M=>p.check(Wp(M)),p.positive=M=>p.check(Lp(0,M)),p.nonnegative=M=>p.check(Ih(0,M)),p.negative=M=>p.check(Fp(0,M)),p.nonpositive=M=>p.check(Ph(0,M)),p.multipleOf=(M,A)=>p.check(Op(M,A)),p.step=(M,A)=>p.check(Op(M,A)),p.finite=()=>p;const T=p._zod.bag;p.minValue=Math.max(T.minimum??Number.NEGATIVE_INFINITY,T.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,p.maxValue=Math.min(T.maximum??Number.POSITIVE_INFINITY,T.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,p.isInt=(T.format??"").includes("int")||Number.isSafeInteger(T.multipleOf??.5),p.isFinite=!0,p.format=T.format??null});function Mh(p){return cv(qp,p)}const kx=Ae("ZodNumberFormat",(p,y)=>{my.init(p,y),qp.init(p,y)});function Wp(p){return uv(kx,p)}const Rx=Ae("ZodUnknown",(p,y)=>{gy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>kv()});function Hp(){return hv(Rx)}const Fx=Ae("ZodNever",(p,y)=>{_y.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Dv(p,T,M)});function Lx(p){return dv(Fx,p)}const Ox=Ae("ZodArray",(p,y)=>{yy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Ov(p,T,M,A),p.element=y.element,p.min=(T,M)=>p.check(Fc(T,M)),p.nonempty=T=>p.check(Fc(1,T)),p.max=(T,M)=>p.check(Bp(T,M)),p.length=(T,M)=>p.check(jp(T,M)),p.unwrap=()=>p.element});function Bx(p,y){return Sv(Ox,p,y)}const jx=Ae("ZodObject",(p,y)=>{xy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Bv(p,T,M,A),Nt(p,"shape",()=>y.shape),p.keyof=()=>Wx(Object.keys(p._zod.def.shape)),p.catchall=T=>p.clone({...p._zod.def,catchall:T}),p.passthrough=()=>p.clone({...p._zod.def,catchall:Hp()}),p.loose=()=>p.clone({...p._zod.def,catchall:Hp()}),p.strict=()=>p.clone({...p._zod.def,catchall:Lx()}),p.strip=()=>p.clone({...p._zod.def,catchall:void 0}),p.extend=T=>$g(p,T),p.safeExtend=T=>Zg(p,T),p.merge=T=>Ug(p,T),p.pick=T=>Ng(p,T),p.omit=T=>Vg(p,T),p.partial=(...T)=>Gg(Xp,p,T[0]),p.required=(...T)=>qg(Jp,p,T[0])});function Nx(p,y){const T={type:"object",shape:p??{},...it(y)};return new jx(T)}const Vx=Ae("ZodUnion",(p,y)=>{by.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>jv(p,T,M,A),p.options=y.options});function $x(p,y){return new Vx({type:"union",options:p,...it(y)})}const Zx=Ae("ZodIntersection",(p,y)=>{wy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Nv(p,T,M,A)});function Ux(p,y){return new Zx({type:"intersection",left:p,right:y})}const Gx=Ae("ZodTuple",(p,y)=>{Ty.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Vv(p,T,M,A),p.rest=T=>p.clone({...p._zod.def,rest:T})});function qx(p,y,T){const M=y instanceof Ir,A=M?T:y,V=M?y:null;return new Gx({type:"tuple",items:p,rest:V,...it(A)})}const Eh=Ae("ZodEnum",(p,y)=>{Sy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(M,A,V)=>Rv(p,M,A),p.enum=y.entries,p.options=Object.values(y.entries);const T=new Set(Object.keys(y.entries));p.extract=(M,A)=>{const V={};for(const S of M)if(T.has(S))V[S]=y.entries[S];else throw new Error(`Key ${S} not found in enum`);return new Eh({...y,checks:[],...it(A),entries:V})},p.exclude=(M,A)=>{const V={...y.entries};for(const S of M)if(T.has(S))delete V[S];else throw new Error(`Key ${S} not found in enum`);return new Eh({...y,checks:[],...it(A),entries:V})}});function Wx(p,y){const T=Array.isArray(p)?Object.fromEntries(p.map(M=>[M,M])):p;return new Eh({type:"enum",entries:T,...it(y)})}const Hx=Ae("ZodTransform",(p,y)=>{Py.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Lv(p,T),p._zod.parse=(T,M)=>{if(M.direction==="backward")throw new ip(p.constructor.name);T.addIssue=V=>{if(typeof V=="string")T.issues.push(al(V,T.value,y));else{const S=V;S.fatal&&(S.continue=!1),S.code??(S.code="custom"),S.input??(S.input=T.value),S.inst??(S.inst=p),T.issues.push(al(S))}};const A=y.transform(T.value,T);return A instanceof Promise?A.then(V=>(T.value=V,T)):(T.value=A,T)}});function Xx(p){return new Hx({type:"transform",transform:p})}const Xp=Ae("ZodOptional",(p,y)=>{Ep.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Zp(p,T,M,A),p.unwrap=()=>p._zod.def.innerType});function Yp(p){return new Xp({type:"optional",innerType:p})}const Yx=Ae("ZodExactOptional",(p,y)=>{Iy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Zp(p,T,M,A),p.unwrap=()=>p._zod.def.innerType});function Kx(p){return new Yx({type:"optional",innerType:p})}const Jx=Ae("ZodNullable",(p,y)=>{My.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>$v(p,T,M,A),p.unwrap=()=>p._zod.def.innerType});function Kp(p){return new Jx({type:"nullable",innerType:p})}const Qx=Ae("ZodDefault",(p,y)=>{Ey.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Uv(p,T,M,A),p.unwrap=()=>p._zod.def.innerType,p.removeDefault=p.unwrap});function e0(p,y){return new Qx({type:"default",innerType:p,get defaultValue(){return typeof y=="function"?y():cp(y)}})}const t0=Ae("ZodPrefault",(p,y)=>{Cy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Gv(p,T,M,A),p.unwrap=()=>p._zod.def.innerType});function r0(p,y){return new t0({type:"prefault",innerType:p,get defaultValue(){return typeof y=="function"?y():cp(y)}})}const Jp=Ae("ZodNonOptional",(p,y)=>{Ay.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Zv(p,T,M,A),p.unwrap=()=>p._zod.def.innerType});function i0(p,y){return new Jp({type:"nonoptional",innerType:p,...it(y)})}const n0=Ae("ZodCatch",(p,y)=>{zy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>qv(p,T,M,A),p.unwrap=()=>p._zod.def.innerType,p.removeCatch=p.unwrap});function s0(p,y){return new n0({type:"catch",innerType:p,catchValue:typeof y=="function"?y:()=>y})}const o0=Ae("ZodPipe",(p,y)=>{Dy.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Wv(p,T,M,A),p.in=y.in,p.out=y.out});function Qp(p,y){return new o0({type:"pipe",in:p,out:y})}const a0=Ae("ZodReadonly",(p,y)=>{ky.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Hv(p,T,M,A),p.unwrap=()=>p._zod.def.innerType});function l0(p){return new a0({type:"readonly",innerType:p})}const c0=Ae("ZodCustom",(p,y)=>{Ry.init(p,y),Ar.init(p,y),p._zod.processJSONSchema=(T,M,A)=>Fv(p,T)});function u0(p,y={}){return Pv(c0,p,y)}function h0(p){return Iv(p)}const d0=qs.createContext(null);function p0(p,y){const T=Array.isArray(p)?p[0]:p?p.x:0,M=Array.isArray(p)?p[1]:p?p.y:0,A=Array.isArray(y)?y[0]:y?y.x:0,V=Array.isArray(y)?y[1]:y?y.y:0;return T===A&&M===V}function gn(p,y){if(p===y)return!0;if(!p||!y)return!1;if(Array.isArray(p)){if(!Array.isArray(y)||p.length!==y.length)return!1;for(let T=0;T<p.length;T++)if(!gn(p[T],y[T]))return!1;return!0}else if(Array.isArray(y))return!1;if(typeof p=="object"&&typeof y=="object"){const T=Object.keys(p),M=Object.keys(y);if(T.length!==M.length)return!1;for(const A of T)if(!y.hasOwnProperty(A)||!gn(p[A],y[A]))return!1;return!0}return!1}function ef(p){return{longitude:p.center.lng,latitude:p.center.lat,zoom:p.zoom,pitch:p.pitch,bearing:p.bearing,padding:p.padding}}function tf(p,y){const T=y.viewState||y,M={};if("longitude"in T&&"latitude"in T&&(T.longitude!==p.center.lng||T.latitude!==p.center.lat)){const A=p.center.constructor;M.center=new A(T.longitude,T.latitude)}return"zoom"in T&&T.zoom!==p.zoom&&(M.zoom=T.zoom),"bearing"in T&&T.bearing!==p.bearing&&(M.bearing=T.bearing),"pitch"in T&&T.pitch!==p.pitch&&(M.pitch=T.pitch),T.padding&&p.padding&&!gn(T.padding,p.padding)&&(M.padding=T.padding),M}const f0=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function rf(p){if(!p)return null;if(typeof p=="string"||("toJS"in p&&(p=p.toJS()),!p.layers))return p;const y={};for(const M of p.layers)y[M.id]=M;const T=p.layers.map(M=>{let A=null;"interactive"in M&&(A=Object.assign({},M),delete A.interactive);const V=y[M.ref];if(V){A=A||Object.assign({},M),delete A.ref;for(const S of f0)S in V&&(A[S]=V[S])}return A||M});return{...p,layers:T}}const nf={version:8,sources:{},layers:[]},sf={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},of={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},af={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},m0=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],g0=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class Yo{constructor(y,T,M){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=A=>{const V=this.props[af[A.type]];V?V(A):A.type==="error"&&console.error(A.error)},this._onCameraEvent=A=>{if(this._internalUpdate)return;A.viewState=this._propsedCameraUpdate||ef(this._map.transform);const V=this.props[of[A.type]];V&&V(A)},this._onCameraUpdate=A=>this._internalUpdate?A:(this._propsedCameraUpdate=ef(A),tf(A,this.props)),this._onPointerEvent=A=>{(A.type==="mousemove"||A.type==="mouseout")&&this._updateHover(A);const V=this.props[sf[A.type]];V&&(this.props.interactiveLayerIds&&A.type!=="mouseover"&&A.type!=="mouseout"&&(A.features=this._hoveredFeatures||this._queryRenderedFeatures(A.point)),V(A),delete A.features)},this._MapClass=y,this.props=T,this._initialize(M)}get map(){return this._map}setProps(y){const T=this.props;this.props=y;const M=this._updateSettings(y,T),A=this._updateSize(y),V=this._updateViewState(y);this._updateStyle(y,T),this._updateStyleComponents(y),this._updateHandlers(y,T),(M||A||V&&!this._map.isMoving())&&this.redraw()}static reuse(y,T){const M=Yo.savedMaps.pop();if(!M)return null;const A=M.map,V=A.getContainer();for(T.className=V.className;V.childNodes.length>0;)T.appendChild(V.childNodes[0]);A._container=T;const S=A._resizeObserver;S&&(S.disconnect(),S.observe(T)),M.setProps({...y,styleDiffing:!1}),A.resize();const{initialViewState:l}=y;return l&&(l.bounds?A.fitBounds(l.bounds,{...l.fitBoundsOptions,duration:0}):M._updateViewState(l)),A.isStyleLoaded()?A.fire("load"):A.once("style.load",()=>A.fire("load")),A._update(),M}_initialize(y){const{props:T}=this,{mapStyle:M=nf}=T,A={...T,...T.initialViewState,container:y,style:rf(M)},V=A.initialViewState||A.viewState||A;if(Object.assign(A,{center:[V.longitude||0,V.latitude||0],zoom:V.zoom||0,pitch:V.pitch||0,bearing:V.bearing||0}),T.gl){const l=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=l,T.gl)}const S=new this._MapClass(A);V.padding&&S.setPadding(V.padding),T.cursor&&(S.getCanvas().style.cursor=T.cursor),S.transformCameraUpdate=this._onCameraUpdate,S.on("style.load",()=>{this._styleComponents={light:S.getLight(),sky:S.getSky(),projection:S.getProjection?.(),terrain:S.getTerrain()},this._updateStyleComponents(this.props)}),S.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const l in sf)S.on(l,this._onPointerEvent);for(const l in of)S.on(l,this._onCameraEvent);for(const l in af)S.on(l,this._onEvent);this._map=S}recycle(){this.map.getContainer().querySelector("[mapboxgl-children]")?.remove(),Yo.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const y=this._map;y.style&&(y._frame&&(y._frame.cancel(),y._frame=null),y._render())}_updateSize(y){const{viewState:T}=y;if(T){const M=this._map;if(T.width!==M.transform.width||T.height!==M.transform.height)return M.resize(),!0}return!1}_updateViewState(y){const T=this._map,M=T.transform;if(!T.isMoving()){const V=tf(M,y);if(Object.keys(V).length>0)return this._internalUpdate=!0,T.jumpTo(V),this._internalUpdate=!1,!0}return!1}_updateSettings(y,T){const M=this._map;let A=!1;for(const V of m0)V in y&&!gn(y[V],T[V])&&(A=!0,M[`set${V[0].toUpperCase()}${V.slice(1)}`]?.call(M,y[V]));return A}_updateStyle(y,T){if(y.cursor!==T.cursor&&(this._map.getCanvas().style.cursor=y.cursor||""),y.mapStyle!==T.mapStyle){const{mapStyle:M=nf,styleDiffing:A=!0}=y,V={diff:A};"localIdeographFontFamily"in y&&(V.localIdeographFontFamily=y.localIdeographFontFamily),this._map.setStyle(rf(M),V)}}_updateStyleComponents({light:y,projection:T,sky:M,terrain:A}){const V=this._map,S=this._styleComponents;V.style._loaded&&(y&&!gn(y,S.light)&&(S.light=y,V.setLight(y)),T&&!gn(T,S.projection)&&T!==S.projection?.type&&(S.projection=typeof T=="string"?{type:T}:T,V.setProjection?.(S.projection)),M&&!gn(M,S.sky)&&(S.sky=M,V.setSky(M)),A!==void 0&&!gn(A,S.terrain)&&(!A||V.getSource(A.source))&&(S.terrain=A,V.setTerrain(A)))}_updateHandlers(y,T){const M=this._map;for(const A of g0){const V=y[A]??!0,S=T[A]??!0;gn(V,S)||(V?M[A].enable(V):M[A].disable())}}_queryRenderedFeatures(y){const T=this._map,{interactiveLayerIds:M=[]}=this.props;try{return T.queryRenderedFeatures(y,{layers:M.filter(T.getLayer.bind(T))})}catch{return[]}}_updateHover(y){const{props:T}=this;if(T.interactiveLayerIds&&(T.onMouseMove||T.onMouseEnter||T.onMouseLeave)){const A=y.type,V=this._hoveredFeatures?.length>0,S=this._queryRenderedFeatures(y.point),l=S.length>0;!l&&V&&(y.type="mouseleave",this._onPointerEvent(y)),this._hoveredFeatures=S,l&&!V&&(y.type="mouseenter",this._onPointerEvent(y)),y.type=A}else this._hoveredFeatures=null}}Yo.savedMaps=[];const _0=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function y0(p){if(!p)return null;const y=p.map,T={getMap:()=>y};for(const M of v0(y))!(M in T)&&!_0.includes(M)&&(T[M]=y[M].bind(y));return T}function v0(p){const y=new Set;let T=p;for(;T;){for(const M of Object.getOwnPropertyNames(T))M[0]!=="_"&&typeof p[M]=="function"&&M!=="fire"&&M!=="setEventedParent"&&y.add(M);T=Object.getPrototypeOf(T)}return Array.from(y)}const x0=typeof document<"u"?Je.useLayoutEffect:Je.useEffect;function b0(p,y){const{RTLTextPlugin:T,maxParallelImageRequests:M,workerCount:A,workerUrl:V}=y;if(T&&p.getRTLTextPluginStatus&&p.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:S,lazy:l=!0}=typeof T=="string"?{pluginUrl:T}:T;p.setRTLTextPlugin(S,ne=>{ne&&console.error(ne)},l)}M!==void 0&&p.setMaxParallelImageRequests(M),A!==void 0&&p.setWorkerCount(A),V!==void 0&&p.setWorkerUrl(V)}const Bc=qs.createContext(null);function w0(p,y){const T=Je.useContext(d0),[M,A]=Je.useState(null),V=Je.useRef(),{current:S}=Je.useRef({mapLib:null,map:null});Je.useEffect(()=>{const Se=p.mapLib;let Le=!0,He;return Promise.resolve(Se||Promise.resolve().then(()=>$0)).then(qe=>{if(!Le)return;if(!qe)throw new Error("Invalid mapLib");const Ze="Map"in qe?qe:qe.default;if(!Ze.Map)throw new Error("Invalid mapLib");b0(Ze,p),p.reuseMaps&&(He=Yo.reuse(p,V.current)),He||(He=new Yo(Ze.Map,p,V.current)),S.map=y0(He),S.mapLib=Ze,A(He),T?.onMapMount(S.map,p.id)}).catch(qe=>{const{onError:Ze}=p;Ze?Ze({type:"error",target:null,originalEvent:null,error:qe}):console.error(qe)}),()=>{Le=!1,He&&(T?.onMapUnmount(p.id),p.reuseMaps?He.recycle():He.destroy())}},[]),x0(()=>{M&&M.setProps(p)}),Je.useImperativeHandle(y,()=>S.map,[M]);const l=Je.useMemo(()=>({position:"relative",width:"100%",height:"100%",...p.style}),[p.style]),ne={height:"100%"};return qs.createElement("div",{id:p.id,ref:V,style:l},M&&qs.createElement(Bc.Provider,{value:S},qs.createElement("div",{"mapboxgl-children":"",style:ne},p.children)))}const T0=qs.forwardRef(w0),S0=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function Dn(p,y){if(!p||!y)return;const T=p.style;for(const M in y){const A=y[M];Number.isFinite(A)&&!S0.test(M)?T[M]=`${A}px`:T[M]=A}}function lf(p,y){if(p===y)return null;const T=cf(p),M=cf(y),A=[];for(const V of M)T.has(V)||A.push(V);for(const V of T)M.has(V)||A.push(V);return A.length===0?null:A}function cf(p){return new Set(p?p.trim().split(/\s+/):[])}const P0=Je.memo(Je.forwardRef((p,y)=>{const{map:T,mapLib:M}=Je.useContext(Bc),A=Je.useRef({props:p}),V=Je.useMemo(()=>{let Vt=!1;qs.Children.forEach(p.children,pt=>{pt&&(Vt=!0)});const bt={...p,element:Vt?document.createElement("div"):void 0},tt=new M.Marker(bt);return tt.setLngLat([p.longitude,p.latitude]),tt.getElement().addEventListener("click",pt=>{A.current.props.onClick?.({type:"click",target:tt,originalEvent:pt})}),tt.on("dragstart",pt=>{const It=pt;It.lngLat=V.getLngLat(),A.current.props.onDragStart?.(It)}),tt.on("drag",pt=>{const It=pt;It.lngLat=V.getLngLat(),A.current.props.onDrag?.(It)}),tt.on("dragend",pt=>{const It=pt;It.lngLat=V.getLngLat(),A.current.props.onDragEnd?.(It)}),tt},[]);Je.useEffect(()=>(V.addTo(T.getMap()),()=>{V.remove()}),[]);const{longitude:S,latitude:l,offset:ne,style:Se,draggable:Le=!1,popup:He=null,rotation:qe=0,rotationAlignment:Ze="auto",pitchAlignment:wt="auto"}=p;Je.useEffect(()=>{Dn(V.getElement(),Se)},[Se]),Je.useImperativeHandle(y,()=>V,[]);const Qe=A.current.props;(V.getLngLat().lng!==S||V.getLngLat().lat!==l)&&V.setLngLat([S,l]),ne&&!p0(V.getOffset(),ne)&&V.setOffset(ne),V.isDraggable()!==Le&&V.setDraggable(Le),V.getRotation()!==qe&&V.setRotation(qe),V.getRotationAlignment()!==Ze&&V.setRotationAlignment(Ze),V.getPitchAlignment()!==wt&&V.setPitchAlignment(wt),V.getPopup()!==He&&V.setPopup(He);const me=lf(Qe.className,p.className);if(me)for(const Vt of me)V.toggleClassName(Vt);return A.current.props=p,Qd.createPortal(p.children,V.getElement())})),I0=Je.memo(Je.forwardRef((p,y)=>{const{map:T,mapLib:M}=Je.useContext(Bc),A=Je.useMemo(()=>document.createElement("div"),[]),V=Je.useRef({props:p}),S=Je.useMemo(()=>{const l={...p},ne=new M.Popup(l);return ne.setLngLat([p.longitude,p.latitude]),ne.once("open",Se=>{V.current.props.onOpen?.(Se)}),ne},[]);if(Je.useEffect(()=>{const l=ne=>{V.current.props.onClose?.(ne)};return S.on("close",l),S.setDOMContent(A).addTo(T.getMap()),()=>{S.off("close",l),S.isOpen()&&S.remove()}},[]),Je.useEffect(()=>{Dn(S.getElement(),p.style)},[p.style]),Je.useImperativeHandle(y,()=>S,[]),S.isOpen()){const l=V.current.props;(S.getLngLat().lng!==p.longitude||S.getLngLat().lat!==p.latitude)&&S.setLngLat([p.longitude,p.latitude]),p.offset&&!gn(l.offset,p.offset)&&S.setOffset(p.offset),(l.anchor!==p.anchor||l.maxWidth!==p.maxWidth)&&(S.options.anchor=p.anchor,S.setMaxWidth(p.maxWidth));const ne=lf(l.className,p.className);if(ne)for(const Se of ne)S.toggleClassName(Se);V.current.props=p}return Qd.createPortal(p.children,A)}));function Ys(p,y,T,M){const A=Je.useContext(Bc),V=Je.useMemo(()=>p(A),[]);return Je.useEffect(()=>{const S=y,l=null,ne=typeof y=="function"?y:null,{map:Se}=A;return Se.hasControl(V)||(Se.addControl(V,S?.position),l&&l(A)),()=>{ne&&ne(A),Se.hasControl(V)&&Se.removeControl(V)}},[]),V}function M0(p){const y=Ys(({mapLib:T})=>new T.AttributionControl(p),{position:p.position});return Je.useEffect(()=>{Dn(y._container,p.style)},[p.style]),null}Je.memo(M0);function E0(p){const y=Ys(({mapLib:T})=>new T.FullscreenControl({container:p.containerId&&document.getElementById(p.containerId)}),{position:p.position});return Je.useEffect(()=>{Dn(y._controlContainer,p.style)},[p.style]),null}Je.memo(E0);function C0(p,y){const T=Je.useRef({props:p}),M=Ys(({mapLib:A})=>{const V=new A.GeolocateControl(p),S=V._setupUI;return V._setupUI=()=>{V._container.hasChildNodes()||S()},V.on("geolocate",l=>{T.current.props.onGeolocate?.(l)}),V.on("error",l=>{T.current.props.onError?.(l)}),V.on("outofmaxbounds",l=>{T.current.props.onOutOfMaxBounds?.(l)}),V.on("trackuserlocationstart",l=>{T.current.props.onTrackUserLocationStart?.(l)}),V.on("trackuserlocationend",l=>{T.current.props.onTrackUserLocationEnd?.(l)}),V},{position:p.position});return T.current.props=p,Je.useImperativeHandle(y,()=>M,[]),Je.useEffect(()=>{Dn(M._container,p.style)},[p.style]),null}Je.memo(Je.forwardRef(C0));function A0(p){const y=Ys(({mapLib:T})=>new T.NavigationControl(p),{position:p.position});return Je.useEffect(()=>{Dn(y._container,p.style)},[p.style]),null}const z0=Je.memo(A0);function D0(p){const y=Ys(({mapLib:V})=>new V.ScaleControl(p),{position:p.position}),T=Je.useRef(p),M=T.current;T.current=p;const{style:A}=p;return p.maxWidth!==void 0&&p.maxWidth!==M.maxWidth&&(y.options.maxWidth=p.maxWidth),p.unit!==void 0&&p.unit!==M.unit&&y.setUnit(p.unit),Je.useEffect(()=>{Dn(y._container,A)},[A]),null}Je.memo(D0);function k0(p){const y=Ys(({mapLib:T})=>new T.TerrainControl(p),{position:p.position});return Je.useEffect(()=>{Dn(y._container,p.style)},[p.style]),null}Je.memo(k0);function R0(p){const y=Ys(({mapLib:T})=>new T.LogoControl(p),{position:p.position});return Je.useEffect(()=>{Dn(y._container,p.style)},[p.style]),null}Je.memo(R0);const F0=Nx({latitudeField:cl().optional(),longitudeField:cl().optional(),locationField:cl().optional(),titleField:cl().optional(),descriptionField:cl().optional(),zoom:Mh().optional(),center:qx([Mh(),Mh()]).optional()});function L0(p){return p.data?p.data:p.staticData?{provider:"value",items:p.staticData}:p.objectName?{provider:"object",object:p.objectName}:null}function O0(p){if(p){if(typeof p=="string"){const y=p.split(" "),T=y[0],M=y[1]?.toLowerCase()==="desc"?"desc":"asc";return{[T]:M}}if(Array.isArray(p))return p.reduce((y,T)=>(T.field&&T.order&&(y[T.field]=T.order),y),{})}}function B0(p){if(p.locationField||p.latitudeField)return{locationField:p.locationField,latitudeField:p.latitudeField,longitudeField:p.longitudeField,titleField:p.titleField||"name",descriptionField:p.descriptionField,zoom:p.zoom,center:p.center};let y=null;if(p.filter&&typeof p.filter=="object"&&"map"in p.filter?y=p.filter.map:p.map&&(y=p.map),y){const T=F0.safeParse(y);return T.success||console.warn("[ObjectMap] Invalid map configuration:",T.error.format()),y}return{latitudeField:"latitude",longitudeField:"longitude",locationField:"location",titleField:"name",descriptionField:"description",zoom:10,center:[0,0]}}function j0(p,y){if(y.latitudeField&&y.longitudeField){const T=p[y.latitudeField],M=p[y.longitudeField];if(typeof T=="number"&&typeof M=="number")return[T,M]}if(y.locationField){const T=p[y.locationField];if(typeof T=="object"&&T!==null){const M=T.lat||T.latitude,A=T.lng||T.lon||T.longitude;if(typeof M=="number"&&typeof A=="number")return[M,A]}if(typeof T=="string"){const M=T.split(",").map(A=>parseFloat(A.trim()));if(M.length===2&&!isNaN(M[0])&&!isNaN(M[1]))return[M[0],M[1]]}if(Array.isArray(T)&&T.length===2){const M=parseFloat(T[0]),A=parseFloat(T[1]);if(!isNaN(M)&&!isNaN(A))return[M,A]}}return null}const uf=({schema:p,dataSource:y,className:T,onMarkerClick:M,...A})=>{const[V,S]=Je.useState([]),[l,ne]=Je.useState(!0),[Se,Le]=Je.useState(null),[He,qe]=Je.useState(null),[Ze,wt]=Je.useState(null),Qe=L0(p),me=Je.useMemo(()=>Qe,[JSON.stringify(Qe)]),Vt=B0(p),bt=me?.provider==="value";Je.useEffect(()=>{(async()=>{try{if(ne(!0),A.data){const mt=A.data;if(Array.isArray(mt)){S(mt),ne(!1);return}}if(p.data){const mt=p.data;if(Array.isArray(mt)){S(mt),ne(!1);return}}if(bt&&me?.provider==="value"){S(me.items),ne(!1);return}if(!y)throw new Error("DataSource required for object/api providers");if(me?.provider==="object"){const mt=me.object,Qt=await y.find(mt,{$filter:p.filter,$orderby:O0(p.sort)});let wr=[];Array.isArray(Qt)?wr=Qt:Qt&&typeof Qt=="object"&&(Array.isArray(Qt.data)?wr=Qt.data:Array.isArray(Qt.value)&&(wr=Qt.value)),S(wr)}else me?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectMap"),S([]));ne(!1)}catch(mt){Le(mt),ne(!1)}})()},[me,y,bt,p.filter,p.sort]),Je.useEffect(()=>{!bt&&y&&(async()=>{try{if(!y)return;const mt=me?.provider==="object"?me.object:p.objectName;if(!mt)return;const Qt=await y.getObjectSchema(mt);qe(Qt)}catch(mt){console.error("Failed to fetch object schema:",mt)}})()},[p.objectName,y,bt,me]);const tt=Je.useMemo(()=>V.map((Et,mt)=>{const Qt=j0(Et,Vt);if(!Qt)return null;const wr=Vt.titleField?Et[Vt.titleField]:"Marker",ei=Vt.descriptionField?Et[Vt.descriptionField]:void 0,[Hr,nr]=Qt;return Hr<-90||Hr>90||nr<-180||nr>180?(console.warn(`Invalid coordinates for marker ${mt}: [${Hr}, ${nr}]`),null):{id:Et.id||Et._id||`marker-${mt}`,title:wr,description:ei,coordinates:[nr,Hr],data:Et}}).filter(Et=>Et!==null),[V,Vt]),pt=Je.useMemo(()=>tt.find(Et=>Et.id===Ze),[tt,Ze]),It=Je.useMemo(()=>{if(!tt.length)return{longitude:Vt.center?.[1]||0,latitude:Vt.center?.[0]||0,zoom:Vt.zoom||2};const Et=tt.map(nr=>nr.coordinates[0]),mt=tt.map(nr=>nr.coordinates[1]),Qt=Math.min(...Et),wr=Math.max(...Et),ei=Math.min(...mt),Hr=Math.max(...mt);return{longitude:(Qt+wr)/2,latitude:(ei+Hr)/2,zoom:Vt.zoom||3}},[tt,Vt]);return l?Lr.jsx("div",{className:T,children:Lr.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg border",children:Lr.jsx("div",{className:"text-muted-foreground",children:"Loading map..."})})}):Se?Lr.jsx("div",{className:T,children:Lr.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg border",children:Lr.jsxs("div",{className:"text-destructive",children:["Error: ",Se.message]})})}):Lr.jsx("div",{className:T,children:Lr.jsx("div",{className:"relative border rounded-lg overflow-hidden bg-muted",style:{height:"600px",width:"100%"},children:Lr.jsxs(T0,{initialViewState:It,style:{width:"100%",height:"100%"},mapStyle:"https://demotiles.maplibre.org/style.json",children:[Lr.jsx(z0,{position:"top-right"}),tt.map(Et=>Lr.jsx(P0,{longitude:Et.coordinates[0],latitude:Et.coordinates[1],anchor:"bottom",onClick:mt=>{mt.originalEvent.stopPropagation(),wt(Et.id),M?.(Et.data)},children:Lr.jsx("div",{className:"text-2xl cursor-pointer hover:scale-110 transition-transform",children:"π"})},Et.id)),pt&&Lr.jsx(I0,{longitude:pt.coordinates[0],latitude:pt.coordinates[1],anchor:"top",onClose:()=>wt(null),closeOnClick:!1,children:Lr.jsxs("div",{className:"p-2 min-w-[200px]",children:[Lr.jsx("h3",{className:"font-bold text-sm mb-1",children:pt.title}),pt.description&&Lr.jsx("p",{className:"text-xs text-muted-foreground",children:pt.description}),Lr.jsxs("div",{className:"mt-2 text-xs flex gap-2",children:[onEdit&&Lr.jsx("button",{className:"text-blue-500 hover:underline",onClick:()=>onEdit(pt.data),children:"Edit"}),onDelete&&Lr.jsx("button",{className:"text-red-500 hover:underline",onClick:()=>onDelete(pt.data),children:"Delete"})]})]})})]})})})},hf=({schema:p,...y})=>{const{dataSource:T}=Mg.useSchemaContext();return Lr.jsx(uf,{schema:p,dataSource:T,...y})};console.log("Registering object-map..."),Ig.ComponentRegistry.register("object-map",hf,{namespace:"plugin-map",label:"Object Map",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"map",type:"object",label:"Map Config",description:"latitudeField, longitudeField, titleField"}]});var jc={exports:{}};var N0=jc.exports,df;function V0(){return df||(df=1,(function(p,y){(function(T,M){p.exports=M()})(N0,(function(){var T={},M={};function A(S,l,ne){if(M[S]=ne,S==="index"){var Se="var sharedModule = {}; ("+M.shared+")(sharedModule); ("+M.worker+")(sharedModule);",Le={};return M.shared(Le),M.index(T,Le),typeof window<"u"&&T.setWorkerUrl(window.URL.createObjectURL(new Blob([Se],{type:"text/javascript"}))),T}}A("shared",["exports"],(function(S){function l(i,e,r,s){return new(r||(r=Promise))((function(a,u){function h(x){try{_(s.next(x))}catch(w){u(w)}}function m(x){try{_(s.throw(x))}catch(w){u(w)}}function _(x){var w;x.done?a(x.value):(w=x.value,w instanceof r?w:new r((function(I){I(w)}))).then(h,m)}_((s=s.apply(i,e||[])).next())}))}function ne(i,e){this.x=i,this.y=e}function Se(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Le,He;typeof SuppressedError=="function"&&SuppressedError,ne.prototype={clone(){return new ne(this.x,this.y)},add(i){return this.clone()._add(i)},sub(i){return this.clone()._sub(i)},multByPoint(i){return this.clone()._multByPoint(i)},divByPoint(i){return this.clone()._divByPoint(i)},mult(i){return this.clone()._mult(i)},div(i){return this.clone()._div(i)},rotate(i){return this.clone()._rotate(i)},rotateAround(i,e){return this.clone()._rotateAround(i,e)},matMult(i){return this.clone()._matMult(i)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(i){return this.x===i.x&&this.y===i.y},dist(i){return Math.sqrt(this.distSqr(i))},distSqr(i){const e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith(i){return this.angleWithSep(i.x,i.y)},angleWithSep(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult(i){const e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add(i){return this.x+=i.x,this.y+=i.y,this},_sub(i){return this.x-=i.x,this.y-=i.y,this},_mult(i){return this.x*=i,this.y*=i,this},_div(i){return this.x/=i,this.y/=i,this},_multByPoint(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint(i){return this.x/=i.x,this.y/=i.y,this},_unit(){return this._div(this.mag()),this},_perp(){const i=this.y;return this.y=this.x,this.x=-i,this},_rotate(i){const e=Math.cos(i),r=Math.sin(i),s=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=s,this},_rotateAround(i,e){const r=Math.cos(i),s=Math.sin(i),a=e.y+s*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-s*(this.y-e.y),this.y=a,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ne},ne.convert=function(i){if(i instanceof ne)return i;if(Array.isArray(i))return new ne(+i[0],+i[1]);if(i.x!==void 0&&i.y!==void 0)return new ne(+i.x,+i.y);throw new Error("Expected [x, y] or {x, y} point format")};var qe=(function(){if(He)return Le;function i(e,r,s,a){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*r,this.by=3*(a-r)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=r,this.p2x=s,this.p2y=a}return He=1,Le=i,i.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,r){if(r===void 0&&(r=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,a=0;a<8;a++){var u=this.sampleCurveX(s)-e;if(Math.abs(u)<r)return s;var h=this.sampleCurveDerivativeX(s);if(Math.abs(h)<1e-6)break;s-=u/h}var m=0,_=1;for(s=e,a=0;a<20&&(u=this.sampleCurveX(s),!(Math.abs(u-e)<r));a++)e>u?m=s:_=s,s=.5*(_-m)+m;return s},solve:function(e,r){return this.sampleCurveY(this.solveCurveX(e,r))}},Le})(),Ze=Se(qe);let wt,Qe;function me(){return wt==null&&(wt=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),wt}function Vt(){if(Qe==null&&(Qe=!1,me())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let s=0;s<25;s++){const a=4*s;e.fillStyle=`rgb(${a},${a+1},${a+2})`,e.fillRect(s%5,Math.floor(s/5),1,1)}const r=e.getImageData(0,0,5,5).data;for(let s=0;s<100;s++)if(s%4!=3&&r[s]!==s){Qe=!0;break}}}return Qe||!1}var bt=1e-6,tt=typeof Float32Array<"u"?Float32Array:Array;function pt(){var i=new tt(9);return tt!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[5]=0,i[6]=0,i[7]=0),i[0]=1,i[4]=1,i[8]=1,i}function It(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function Et(){var i=new tt(3);return tt!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function mt(i){var e=i[0],r=i[1],s=i[2];return Math.sqrt(e*e+r*r+s*s)}function Qt(i,e,r){var s=new tt(3);return s[0]=i,s[1]=e,s[2]=r,s}function wr(i,e,r){return i[0]=e[0]+r[0],i[1]=e[1]+r[1],i[2]=e[2]+r[2],i}function ei(i,e,r){return i[0]=e[0]*r,i[1]=e[1]*r,i[2]=e[2]*r,i}function Hr(i,e,r){var s=e[0],a=e[1],u=e[2],h=r[0],m=r[1],_=r[2];return i[0]=a*_-u*m,i[1]=u*h-s*_,i[2]=s*m-a*h,i}var nr,mi=mt;function kn(i,e,r){var s=e[0],a=e[1],u=e[2],h=e[3];return i[0]=r[0]*s+r[4]*a+r[8]*u+r[12]*h,i[1]=r[1]*s+r[5]*a+r[9]*u+r[13]*h,i[2]=r[2]*s+r[6]*a+r[10]*u+r[14]*h,i[3]=r[3]*s+r[7]*a+r[11]*u+r[15]*h,i}function zi(){var i=new tt(4);return tt!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i[3]=1,i}function Rn(i,e,r,s){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",u=Math.PI/360;e*=u,s*=u,r*=u;var h=Math.sin(e),m=Math.cos(e),_=Math.sin(r),x=Math.cos(r),w=Math.sin(s),I=Math.cos(s);switch(a){case"xyz":i[0]=h*x*I+m*_*w,i[1]=m*_*I-h*x*w,i[2]=m*x*w+h*_*I,i[3]=m*x*I-h*_*w;break;case"xzy":i[0]=h*x*I-m*_*w,i[1]=m*_*I-h*x*w,i[2]=m*x*w+h*_*I,i[3]=m*x*I+h*_*w;break;case"yxz":i[0]=h*x*I+m*_*w,i[1]=m*_*I-h*x*w,i[2]=m*x*w-h*_*I,i[3]=m*x*I+h*_*w;break;case"yzx":i[0]=h*x*I+m*_*w,i[1]=m*_*I+h*x*w,i[2]=m*x*w-h*_*I,i[3]=m*x*I-h*_*w;break;case"zxy":i[0]=h*x*I-m*_*w,i[1]=m*_*I+h*x*w,i[2]=m*x*w+h*_*I,i[3]=m*x*I-h*_*w;break;case"zyx":i[0]=h*x*I-m*_*w,i[1]=m*_*I+h*x*w,i[2]=m*x*w-h*_*I,i[3]=m*x*I+h*_*w;break;default:throw new Error("Unknown angle order "+a)}return i}function At(){var i=new tt(2);return tt!=Float32Array&&(i[0]=0,i[1]=0),i}function Wi(i,e){var r=new tt(2);return r[0]=i,r[1]=e,r}Et(),nr=new tt(4),tt!=Float32Array&&(nr[0]=0,nr[1]=0,nr[2]=0,nr[3]=0),Et(),Qt(1,0,0),Qt(0,1,0),zi(),zi(),pt(),At();const Tt=8192;function Di(i,e,r){return e*(Tt/(i.tileSize*Math.pow(2,r-i.tileID.overscaledZ)))}function De(i,e){return(i%e+e)%e}function at(i,e,r){return i*(1-r)+e*r}function zt(i){if(i<=0)return 0;if(i>=1)return 1;const e=i*i,r=e*i;return 4*(i<.5?r:3*(i-e)+r-.75)}function $t(i,e,r,s){const a=new Ze(i,e,r,s);return u=>a.solve(u)}const ai=$t(.25,.1,.25,1);function sr(i,e,r){return Math.min(r,Math.max(e,i))}function kt(i,e,r){const s=r-e,a=((i-e)%s+s)%s+e;return a===e?r:a}function fr(i,...e){for(const r of e)for(const s in r)i[s]=r[s];return i}let Hi=1;function Xi(i,e,r){const s={};for(const a in i)s[a]=e.call(this,i[a],a,i);return s}function Yi(i,e,r){const s={};for(const a in i)e.call(this,i[a],a,i)&&(s[a]=i[a]);return s}function ki(i){return Array.isArray(i)?i.map(ki):typeof i=="object"&&i?Xi(i,ki):i}const Ko={};function Or(i){Ko[i]||(typeof console<"u"&&console.warn(i),Ko[i]=!0)}function Si(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function Ri(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let er=null;function sn(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}const cs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function us(i,e,r,s,a){return l(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const u=new VideoFrame(i,{timestamp:0});try{const h=u?.format;if(!h||!h.startsWith("BGR")&&!h.startsWith("RGB"))throw new Error(`Unrecognized format ${h}`);const m=h.startsWith("BGR"),_=new Uint8ClampedArray(s*a*4);if(yield u.copyTo(_,(function(x,w,I,C,z){const R=4*Math.max(-w,0),F=(Math.max(0,I)-I)*C*4+R,O=4*C,Z=Math.max(0,w),X=Math.max(0,I);return{rect:{x:Z,y:X,width:Math.min(x.width,w+C)-Z,height:Math.min(x.height,I+z)-X},layout:[{offset:F,stride:O}]}})(i,e,r,s,a)),m)for(let x=0;x<_.length;x+=4){const w=_[x];_[x]=_[x+2],_[x+2]=w}return _}finally{u.close()}}))}let Ki,on;function Fn(i,e,r,s){return i.addEventListener(e,r,s),{unsubscribe:()=>{i.removeEventListener(e,r,s)}}}function hs(i){return i*Math.PI/180}function gi(i){return i/Math.PI*180}const _n={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Ks={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},ds="AbortError";class ps extends Error{constructor(e=ds){super(e instanceof Error?e.message:e),this.name=ds,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function ce(i){return i.name===ds}const B={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function j(i){return B.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}const $="global-dispatcher";class ee extends Error{constructor(e,r,s,a){super(`AJAXError: ${r} (${e}): ${s}`),this.status=e,this.statusText=r,this.url=s,this.body=a}}const se=()=>Ri(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,pe=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){const s=j(i.url);if(s)return s(i,e);if(Ri(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:$},e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(se())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(s,a){return l(this,void 0,void 0,(function*(){const u=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:se(),signal:a.signal});let h,m;s.type!=="json"||u.headers.has("Accept")||u.headers.set("Accept","application/json");try{h=yield fetch(u)}catch(x){throw ce(x)?x:new ee(0,x.message,s.url,new Blob)}if(!h.ok){const x=yield h.blob();throw new ee(h.status,h.statusText,s.url,x)}m=s.type==="arrayBuffer"||s.type==="image"?h.arrayBuffer():s.type==="json"?h.json():h.text();const _=yield m;return a.signal.throwIfAborted(),{data:_,cacheControl:h.headers.get("Cache-Control"),expires:h.headers.get("Expires")}}))})(i,e);if(Ri(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:$},e)}var r;return(function(s,a){return new Promise(((u,h)=>{var m;const _=new XMLHttpRequest;_.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(_.responseType="arraybuffer");for(const x in s.headers)_.setRequestHeader(x,s.headers[x]);s.type==="json"&&(_.responseType="text",!((m=s.headers)===null||m===void 0)&&m.Accept||_.setRequestHeader("Accept","application/json")),_.withCredentials=s.credentials==="include",_.onerror=()=>{h(new Error(_.statusText))},_.onload=()=>{if(!a.signal.aborted)if((_.status>=200&&_.status<300||_.status===0)&&_.response!==null){let x=_.response;if(s.type==="json")try{x=JSON.parse(_.response)}catch(w){return void h(w)}u({data:x,cacheControl:_.getResponseHeader("Cache-Control"),expires:_.getResponseHeader("Expires")})}else{const x=new Blob([_.response],{type:_.getResponseHeader("Content-Type")});h(new ee(_.status,_.statusText,s.url,x))}},a.signal.addEventListener("abort",(()=>{_.abort(),h(new ps(a.signal.reason))})),_.send(s.body)}))})(i,e)};function de(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const e=new URL(i),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function ue(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function he(i,e,r){if(r&&r[i]){const s=r[i].indexOf(e);s!==-1&&r[i].splice(s,1)}}class Ce{constructor(e,r={}){fr(this,r),this.type=e}}class be extends Ce{constructor(e,r={}){super("error",fr({error:e},r))}}class ke{on(e,r){return this._listeners=this._listeners||{},ue(e,r,this._listeners),{unsubscribe:()=>{this.off(e,r)}}}off(e,r){return he(e,r,this._listeners),he(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},ue(e,r,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,r){typeof e=="string"&&(e=new Ce(e,r||{}));const s=e.type;if(this.listens(s)){e.target=this;const a=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const m of a)m.call(this,e);const u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const m of u)he(s,m,this._oneTimeListeners),m.call(this,e);const h=this._eventedParent;h&&(fr(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),h.fire(e))}else e instanceof be&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var le={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},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},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{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:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},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:{},"color-relief":{},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_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},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:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"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:{},"viewport-glyph":{},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-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"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",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},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:"expression_name",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}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","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","feature"]},"property-type":"cross-faded-data-driven"},"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:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,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:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",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"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},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"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const nt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Rt(i,e){const r={};for(const s in i)s!=="ref"&&(r[s]=i[s]);return nt.forEach((s=>{s in e&&(r[s]=e[s])})),r}function We(i,e){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let r=0;r<i.length;r++)if(!We(i[r],e[r]))return!1;return!0}if(typeof i=="object"&&i!==null&&e!==null){if(typeof e!="object"||Object.keys(i).length!==Object.keys(e).length)return!1;for(const r in i)if(!We(i[r],e[r]))return!1;return!0}return i===e}function Ke(i,e){i.push(e)}function lt(i,e,r){Ke(r,{command:"addSource",args:[i,e[i]]})}function or(i,e,r){Ke(e,{command:"removeSource",args:[i]}),r[i]=!0}function Zt(i,e,r,s){or(i,r,s),lt(i,e,r)}function zr(i,e,r){let s;for(s in i[r])if(Object.prototype.hasOwnProperty.call(i[r],s)&&s!=="data"&&!We(i[r][s],e[r][s]))return!1;for(s in e[r])if(Object.prototype.hasOwnProperty.call(e[r],s)&&s!=="data"&&!We(i[r][s],e[r][s]))return!1;return!0}function Dr(i,e,r,s,a,u){i=i||{},e=e||{};for(const h in i)Object.prototype.hasOwnProperty.call(i,h)&&(We(i[h],e[h])||r.push({command:u,args:[s,h,e[h],a]}));for(const h in e)Object.prototype.hasOwnProperty.call(e,h)&&!Object.prototype.hasOwnProperty.call(i,h)&&(We(i[h],e[h])||r.push({command:u,args:[s,h,e[h],a]}))}function ar(i){return i.id}function kr(i,e){return i[e.id]=e,i}class Me{constructor(e,r,s,a){this.message=(e?`${e}: `:"")+s,a&&(this.identifier=a),r!=null&&r.__line__&&(this.line=r.__line__)}}function Tr(i,...e){for(const r of e)for(const s in r)i[s]=r[s];return i}class li extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class Ln{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[s,a]of r)this.bindings[s]=a}concat(e){return new Ln(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const mr={kind:"null"},Be={kind:"number"},ot={kind:"string"},ht={kind:"boolean"},_i={kind:"color"},Jo={kind:"projectionDefinition"},an={kind:"object"},ct={kind:"value"},Js={kind:"collator"},Qs={kind:"formatted"},Qo={kind:"padding"},fs={kind:"colorArray"},eo={kind:"numberArray"},ms={kind:"resolvedImage"},to={kind:"variableAnchorOffsetCollection"};function ti(i,e){return{kind:"array",itemType:i,N:e}}function Ct(i){if(i.kind==="array"){const e=Ct(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const ea=[mr,Be,ot,ht,_i,Jo,Qs,an,ti(ct),Qo,eo,fs,ms,to];function gs(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!gs(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const r of ea)if(!gs(r,e))return null}}return`Expected ${Ct(i)} but found ${Ct(e)} instead.`}function ro(i,e){return e.some((r=>r.kind===i.kind))}function On(i,e){return e.some((r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i))}function Fi(i,e){return i.kind==="array"&&e.kind==="array"?i.itemType.kind===e.itemType.kind&&typeof i.N=="number":i.kind===e.kind}const Nc=.96422,Bn=.82521,ta=4/29,lr=6/29,Vc=3*lr*lr,$c=lr*lr*lr,io=Math.PI/180,Zc=180/Math.PI;function Uc(i){return(i%=360)<0&&(i+=360),i}function Gc([i,e,r,s]){let a,u;const h=ul((.2225045*(i=ra(i))+.7168786*(e=ra(e))+.0606169*(r=ra(r)))/1);i===e&&e===r?a=u=h:(a=ul((.4360747*i+.3850649*e+.1430804*r)/Nc),u=ul((.0139322*i+.0971045*e+.7141733*r)/Bn));const m=116*h-16;return[m<0?0:m,500*(a-h),200*(h-u),s]}function ra(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function ul(i){return i>$c?Math.pow(i,1/3):i/Vc+ta}function hl([i,e,r,s]){let a=(i+16)/116,u=isNaN(e)?a:a+e/500,h=isNaN(r)?a:a-r/200;return a=1*pl(a),u=Nc*pl(u),h=Bn*pl(h),[dl(3.1338561*u-1.6168667*a-.4906146*h),dl(-.9787684*u+1.9161415*a+.033454*h),dl(.0719453*u-.2289914*a+1.4052427*h),s]}function dl(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function pl(i){return i>lr?i*i*i:Vc*(i-ta)}const Ch=Object.hasOwn||function(i,e){return Object.prototype.hasOwnProperty.call(i,e)};function no(i,e){return Ch(i,e)?i[e]:void 0}function ia(i){return parseInt(i.padEnd(2,i),16)/255}function qc(i,e){return _s(e?i/100:i,0,1)}function _s(i,e,r){return Math.min(Math.max(e,i),r)}function fl(i){return!i.some(Number.isNaN)}const so={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function yn(i,e,r){return i+r*(e-i)}function ys(i,e,r){return i.map(((s,a)=>yn(s,e[a],r)))}class dt{constructor(e,r,s,a=1,u=!0){this.r=e,this.g=r,this.b=s,this.a=a,u||(this.r*=a,this.g*=a,this.b*=a,a||this.overwriteGetter("rgb",[e,r,s,a]))}static parse(e){if(e instanceof dt)return e;if(typeof e!="string")return;const r=(function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const a=no(so,s);if(a){const[h,m,_]=a;return[h/255,m/255,_/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const h=s.length<6?1:2;let m=1;return[ia(s.slice(m,m+=h)),ia(s.slice(m,m+=h)),ia(s.slice(m,m+=h)),ia(s.slice(m,m+h)||"ff")]}if(s.startsWith("rgb")){const h=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(h){const[m,_,x,w,I,C,z,R,F,O,Z,X]=h,U=[w||" ",z||" ",O].join("");if(U===" "||U===" /"||U===",,"||U===",,,"){const G=[x,C,F].join(""),J=G==="%%%"?100:G===""?255:0;if(J){const ie=[_s(+_/J,0,1),_s(+I/J,0,1),_s(+R/J,0,1),Z?qc(+Z,X):1];if(fl(ie))return ie}}return}}const u=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){const[h,m,_,x,w,I,C,z,R]=u,F=[_||" ",w||" ",C].join("");if(F===" "||F===" /"||F===",,"||F===",,,"){const O=[+m,_s(+x,0,100),_s(+I,0,100),z?qc(+z,R):1];if(fl(O))return(function([Z,X,U,G]){function J(ie){const fe=(ie+Z/30)%12,Pe=X*Math.min(U,1-U);return U-Pe*Math.max(-1,Math.min(fe-3,9-fe,1))}return Z=Uc(Z),X/=100,U/=100,[J(0),J(8),J(4),G]})(O)}}})(e);return r?new dt(...r,!1):void 0}get rgb(){const{r:e,g:r,b:s,a}=this,u=a||1/0;return this.overwriteGetter("rgb",[e/u,r/u,s/u,a])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[r,s,a,u]=Gc(e),h=Math.sqrt(s*s+a*a);return[Math.round(1e4*h)?Uc(Math.atan2(a,s)*Zc):NaN,h,r,u]})(this.rgb))}get lab(){return this.overwriteGetter("lab",Gc(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,s,a]=this.rgb;return`rgba(${[e,r,s].map((u=>Math.round(255*u))).join(",")},${a})`}static interpolate(e,r,s,a="rgb"){switch(a){case"rgb":{const[u,h,m,_]=ys(e.rgb,r.rgb,s);return new dt(u,h,m,_,!1)}case"hcl":{const[u,h,m,_]=e.hcl,[x,w,I,C]=r.hcl;let z,R;if(isNaN(u)||isNaN(x))isNaN(u)?isNaN(x)?z=NaN:(z=x,m!==1&&m!==0||(R=w)):(z=u,I!==1&&I!==0||(R=h));else{let U=x-u;x>u&&U>180?U-=360:x<u&&u-x>180&&(U+=360),z=u+s*U}const[F,O,Z,X]=(function([U,G,J,ie]){return U=isNaN(U)?0:U*io,hl([J,Math.cos(U)*G,Math.sin(U)*G,ie])})([z,R??yn(h,w,s),yn(m,I,s),yn(_,C,s)]);return new dt(F,O,Z,X,!1)}case"lab":{const[u,h,m,_]=hl(ys(e.lab,r.lab,s));return new dt(u,h,m,_,!1)}}}}dt.black=new dt(0,0,0,1),dt.white=new dt(1,1,1,1),dt.transparent=new dt(0,0,0,0),dt.red=new dt(1,0,0,1);class ml{constructor(e,r,s){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Ah=["bottom","center","top"];class gl{constructor(e,r,s,a,u,h){this.text=e,this.image=r,this.scale=s,this.fontStack=a,this.textColor=u,this.verticalAlign=h}}class ci{constructor(e){this.sections=e}static fromString(e){return new ci([new gl(e,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((e=>e.text.length!==0||e.image&&e.image.name.length!==0))}static factory(e){return e instanceof ci?e:ci.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class Xr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Xr)return e;if(typeof e=="number")return new Xr([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if(typeof r!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Xr(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,s){return new Xr(ys(e.values,r.values,s))}}class tr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof tr)return e;if(typeof e=="number")return new tr([e]);if(Array.isArray(e)){for(const r of e)if(typeof r!="number")return;return new tr(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,s){return new tr(ys(e.values,r.values,s))}}class rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof rt)return e;if(typeof e=="string"){const s=dt.parse(e);return s?new rt([s]):void 0}if(!Array.isArray(e))return;const r=[];for(const s of e){if(typeof s!="string")return;const a=dt.parse(s);if(!a)return;r.push(a)}return new rt(r)}toString(){return JSON.stringify(this.values)}static interpolate(e,r,s,a="rgb"){const u=[];if(e.values.length!=r.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${r.values.length}), cannot interpolate.`);for(let h=0;h<e.values.length;h++)u.push(dt.interpolate(e.values[h],r.values[h],s,a));return new rt(u)}}class Ft extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const vn=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class ri{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ri)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r<e.length;r+=2){const s=e[r],a=e[r+1];if(typeof s!="string"||!vn.has(s)||!Array.isArray(a)||a.length!==2||typeof a[0]!="number"||typeof a[1]!="number")return}return new ri(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,s){const a=e.values,u=r.values;if(a.length!==u.length)throw new Ft(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${r.toString()}`);const h=[];for(let m=0;m<a.length;m+=2){if(a[m]!==u[m])throw new Ft(`Cannot interpolate values containing mismatched anchors. from[${m}]: ${a[m]}, to[${m}]: ${u[m]}`);h.push(a[m]);const[_,x]=a[m+1],[w,I]=u[m+1];h.push([yn(_,w,s),yn(x,I,s)])}return new ri(h)}}class yi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new yi({name:e,available:!1}):null}}class ii{constructor(e,r,s){this.from=e,this.to=r,this.transition=s}static interpolate(e,r,s){return new ii(e,r,s)}static parse(e){return e instanceof ii?e:Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"?new ii(e[0],e[1],e[2]):typeof e=="object"&&typeof e.from=="string"&&typeof e.to=="string"&&typeof e.transition=="number"?new ii(e.from,e.to,e.transition):typeof e=="string"?new ii(e,e,1):void 0}}function vs(i,e,r,s){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[i,e,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[i,e,r,s]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function xn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof ii||i instanceof dt||i instanceof ml||i instanceof ci||i instanceof Xr||i instanceof tr||i instanceof rt||i instanceof ri||i instanceof yi)return!0;if(Array.isArray(i)){for(const e of i)if(!xn(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!xn(i[e]))return!1;return!0}return!1}function gr(i){if(i===null)return mr;if(typeof i=="string")return ot;if(typeof i=="boolean")return ht;if(typeof i=="number")return Be;if(i instanceof dt)return _i;if(i instanceof ii)return Jo;if(i instanceof ml)return Js;if(i instanceof ci)return Qs;if(i instanceof Xr)return Qo;if(i instanceof tr)return eo;if(i instanceof rt)return fs;if(i instanceof ri)return to;if(i instanceof yi)return ms;if(Array.isArray(i)){const e=i.length;let r;for(const s of i){const a=gr(s);if(r){if(r===a)continue;r=ct;break}r=a}return ti(r||ct,e)}return an}function jn(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof dt||i instanceof ii||i instanceof ci||i instanceof Xr||i instanceof tr||i instanceof rt||i instanceof ri||i instanceof yi?i.toString():JSON.stringify(i)}class Ji{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!xn(e[1]))return r.error("invalid value");const s=e[1];let a=gr(s);const u=r.expectedType;return a.kind!=="array"||a.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(a=u),new Ji(a,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const na={string:ot,number:Be,boolean:ht,object:an};class ui{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let s,a=1;const u=e[0];if(u==="array"){let m,_;if(e.length>2){const x=e[1];if(typeof x!="string"||!(x in na)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);m=na[x],a++}else m=ct;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);_=e[2],a++}s=ti(m,_)}else{if(!na[u])throw new Error(`Types doesn't contain name = ${u}`);s=na[u]}const h=[];for(;a<e.length;a++){const m=r.parse(e[a],a,ct);if(!m)return null;h.push(m)}return new ui(s,h)}evaluate(e){for(let r=0;r<this.args.length;r++){const s=this.args[r].evaluate(e);if(!gs(this.type,gr(s)))return s;if(r===this.args.length-1)throw new Ft(`Expected value to be of type ${Ct(this.type)}, but found ${Ct(gr(s))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Nn={"to-boolean":ht,"to-color":_i,"to-number":Be,"to-string":ot};class ln{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const s=e[0];if(!Nn[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&e.length!==2)return r.error("Expected one argument.");const a=Nn[s],u=[];for(let h=1;h<e.length;h++){const m=r.parse(e[h],h,ct);if(!m)return null;u.push(m)}return new ln(a,u)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let r,s;for(const a of this.args){if(r=a.evaluate(e),s=null,r instanceof dt)return r;if(typeof r=="string"){const u=e.parseColor(r);if(u)return u}else if(Array.isArray(r)&&(s=r.length<3||r.length>4?`Invalid rgba value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:vs(r[0],r[1],r[2],r[3]),!s))return new dt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Ft(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const s of this.args){r=s.evaluate(e);const a=Xr.parse(r);if(a)return a}throw new Ft(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"numberArray":{let r;for(const s of this.args){r=s.evaluate(e);const a=tr.parse(r);if(a)return a}throw new Ft(`Could not parse numberArray from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"colorArray":{let r;for(const s of this.args){r=s.evaluate(e);const a=rt.parse(r);if(a)return a}throw new Ft(`Could not parse colorArray from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const s of this.args){r=s.evaluate(e);const a=ri.parse(r);if(a)return a}throw new Ft(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const s of this.args){if(r=s.evaluate(e),r===null)return 0;const a=Number(r);if(!isNaN(a))return a}throw new Ft(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return ci.fromString(jn(this.args[0].evaluate(e)));case"resolvedImage":return yi.fromString(jn(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return jn(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Wc=["Unknown","Point","LineString","Polygon"];class _l{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Wc[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let r=this._parseColorCache.get(e);return r||(r=dt.parse(e),this._parseColorCache.set(e,r)),r}}class Vn{constructor(e,r,s=[],a,u=new Ln,h=[]){this.registry=e,this.path=s,this.key=s.map((m=>`[${m}]`)).join(""),this.scope=u,this.errors=h,this.expectedType=a,this._isConstant=r}parse(e,r,s,a,u={}){return r?this.concat(r,s,a)._parse(e,u):this._parse(e,u)}_parse(e,r){function s(a,u,h){return h==="assert"?new ui(u,[a]):h==="coerce"?new ln(u,[a]):a}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const a=e[0];if(typeof a!="string")return this.error(`Expression name must be a string, but found ${typeof a} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const u=this.registry[a];if(u){let h=u.parse(e,this);if(!h)return null;if(this.expectedType){const m=this.expectedType,_=h.type;if(m.kind!=="string"&&m.kind!=="number"&&m.kind!=="boolean"&&m.kind!=="object"&&m.kind!=="array"||_.kind!=="value"){if(m.kind==="projectionDefinition"&&["string","array"].includes(_.kind)||["color","formatted","resolvedImage"].includes(m.kind)&&["value","string"].includes(_.kind)||["padding","numberArray"].includes(m.kind)&&["value","number","array"].includes(_.kind)||m.kind==="colorArray"&&["value","string","array"].includes(_.kind)||m.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(_.kind))h=s(h,m,r.typeAnnotation||"coerce");else if(this.checkSubtype(m,_))return null}else h=s(h,m,r.typeAnnotation||"assert")}if(!(h instanceof Ji)&&h.type.kind!=="resolvedImage"&&this._isConstant(h)){const m=new _l;try{h=new Ji(h.type,h.evaluate(m))}catch(_){return this.error(_.message),null}}return h}return this.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,s){const a=typeof e=="number"?this.path.concat(e):this.path,u=s?this.scope.concat(s):this.scope;return new Vn(this.registry,this._isConstant,a,r||null,u,this.errors)}error(e,...r){const s=`${this.key}${r.map((a=>`[${a}]`)).join("")}`;this.errors.push(new li(s,e))}checkSubtype(e,r){const s=gs(e,r);return s&&this.error(s),s}}class Lt{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const s=[];for(let u=1;u<e.length-1;u+=2){const h=e[u];if(typeof h!="string")return r.error(`Expected string, but found ${typeof h} instead.`,u);if(/[^a-zA-Z0-9_]/.test(h))return r.error("Variable names must contain only alphanumeric characters or '_'.",u);const m=r.parse(e[u+1],u+1);if(!m)return null;s.push([h,m])}const a=r.parse(e[e.length-1],e.length-1,r.expectedType,s);return a?new Lt(s,a):null}outputDefined(){return this.result.outputDefined()}}class xs{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const s=e[1];return r.scope.has(s)?new xs(s,r.scope.get(s)):r.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class yt{constructor(e,r,s){this.type=e,this.index=r,this.input=s}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,Be),a=r.parse(e[2],2,ti(r.expectedType||ct));return s&&a?new yt(a.type.itemType,s,a):null}evaluate(e){const r=this.index.evaluate(e),s=this.input.evaluate(e);if(r<0)throw new Ft(`Array index out of bounds: ${r} < 0.`);if(r>=s.length)throw new Ft(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new Ft(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ut{constructor(e,r){this.type=ht,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,ct),a=r.parse(e[2],2,ct);return s&&a?ro(s.type,[ht,ot,Be,mr,ct])?new ut(s,a):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(s.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!s)return!1;if(!On(r,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(gr(r))} instead.`);if(!On(s,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${Ct(gr(s))} instead.`);return s.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class bs{constructor(e,r,s){this.type=Be,this.needle=e,this.haystack=r,this.fromIndex=s}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,ct),a=r.parse(e[2],2,ct);if(!s||!a)return null;if(!ro(s.type,[ht,ot,Be,mr,ct]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(s.type)} instead`);if(e.length===4){const u=r.parse(e[3],3,Be);return u?new bs(s,a,u):null}return new bs(s,a)}evaluate(e){const r=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!On(r,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(gr(r))} instead.`);let a;if(this.fromIndex&&(a=this.fromIndex.evaluate(e)),On(s,["string"])){const u=s.indexOf(r,a);return u===-1?-1:[...s.slice(0,u)].length}if(On(s,["array"]))return s.indexOf(r,a);throw new Ft(`Expected second argument to be of type array or string, but found ${Ct(gr(s))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class vt{constructor(e,r,s,a,u,h){this.inputType=e,this.type=r,this.input=s,this.cases=a,this.outputs=u,this.otherwise=h}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let s,a;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);const u={},h=[];for(let x=2;x<e.length-1;x+=2){let w=e[x];const I=e[x+1];Array.isArray(w)||(w=[w]);const C=r.concat(x);if(w.length===0)return C.error("Expected at least one branch label.");for(const R of w){if(typeof R!="number"&&typeof R!="string")return C.error("Branch labels must be numbers or strings.");if(typeof R=="number"&&Math.abs(R)>Number.MAX_SAFE_INTEGER)return C.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof R=="number"&&Math.floor(R)!==R)return C.error("Numeric branch labels must be integer values.");if(s){if(C.checkSubtype(s,gr(R)))return null}else s=gr(R);if(u[String(R)]!==void 0)return C.error("Branch labels must be unique.");u[String(R)]=h.length}const z=r.parse(I,x,a);if(!z)return null;a=a||z.type,h.push(z)}const m=r.parse(e[1],1,ct);if(!m)return null;const _=r.parse(e[e.length-1],e.length-1,a);return _?m.type.kind!=="value"&&r.concat(1).checkSubtype(s,m.type)?null:new vt(s,a,m,u,h,_):null}evaluate(e){const r=this.input.evaluate(e);return(gr(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class oo{constructor(e,r,s){this.type=e,this.branches=r,this.otherwise=s}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);const a=[];for(let h=1;h<e.length-1;h+=2){const m=r.parse(e[h],h,ht);if(!m)return null;const _=r.parse(e[h+1],h+1,s);if(!_)return null;a.push([m,_]),s=s||_.type}const u=r.parse(e[e.length-1],e.length-1,s);if(!u)return null;if(!s)throw new Error("Can't infer output type");return new oo(s,a,u)}evaluate(e){for(const[r,s]of this.branches)if(r.evaluate(e))return s.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,s]of this.branches)e(r),e(s);e(this.otherwise)}outputDefined(){return this.branches.every((([e,r])=>r.outputDefined()))&&this.otherwise.outputDefined()}}class Pi{constructor(e,r,s,a){this.type=e,this.input=r,this.beginIndex=s,this.endIndex=a}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const s=r.parse(e[1],1,ct),a=r.parse(e[2],2,Be);if(!s||!a)return null;if(!ro(s.type,[ti(ct),ot,ct]))return r.error(`Expected first argument to be of type array or string, but found ${Ct(s.type)} instead`);if(e.length===4){const u=r.parse(e[3],3,Be);return u?new Pi(s.type,s,a,u):null}return new Pi(s.type,s,a)}evaluate(e){const r=this.input.evaluate(e),s=this.beginIndex.evaluate(e);let a;if(this.endIndex&&(a=this.endIndex.evaluate(e)),On(r,["string"]))return[...r].slice(s,a).join("");if(On(r,["array"]))return r.slice(s,a);throw new Ft(`Expected first argument to be of type array or string, but found ${Ct(gr(r))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function ws(i,e){const r=i.length-1;let s,a,u=0,h=r,m=0;for(;u<=h;)if(m=Math.floor((u+h)/2),s=i[m],a=i[m+1],s<=e){if(m===r||e<a)return m;u=m+1}else{if(!(s>e))throw new Ft("Input is not a number.");h=m-1}return 0}class bn{constructor(e,r,s){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[a,u]of s)this.labels.push(a),this.outputs.push(u)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const s=r.parse(e[1],1,Be);if(!s)return null;const a=[];let u=null;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);for(let h=1;h<e.length;h+=2){const m=h===1?-1/0:e[h],_=e[h+1],x=h,w=h+1;if(typeof m!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',x);if(a.length&&a[a.length-1][0]>=m)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);const I=r.parse(_,w,u);if(!I)return null;u=u||I.type,a.push([m,I])}return new bn(u,s,a)}evaluate(e){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(e);const a=this.input.evaluate(e);if(a<=r[0])return s[0].evaluate(e);const u=r.length;return a>=r[u-1]?s[u-1].evaluate(e):s[ws(r,a)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Hc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ao,yl,zh=(function(){if(yl)return ao;function i(e,r,s,a){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*r,this.by=3*(a-r)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=r,this.p2x=s,this.p2y=a}return yl=1,ao=i,i.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,r){if(r===void 0&&(r=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,a=0;a<8;a++){var u=this.sampleCurveX(s)-e;if(Math.abs(u)<r)return s;var h=this.sampleCurveDerivativeX(s);if(Math.abs(h)<1e-6)break;s-=u/h}var m=0,_=1;for(s=e,a=0;a<20&&(u=this.sampleCurveX(s),!(Math.abs(u-e)<r));a++)e>u?m=s:_=s,s=.5*(_-m)+m;return s},solve:function(e,r){return this.sampleCurveY(this.solveCurveX(e,r))}},ao})(),Xc=Hc(zh);class ni{constructor(e,r,s,a,u){this.type=e,this.operator=r,this.interpolation=s,this.input=a,this.labels=[],this.outputs=[];for(const[h,m]of u)this.labels.push(h),this.outputs.push(m)}static interpolationFactor(e,r,s,a){let u=0;if(e.name==="exponential")u=Qi(r,e.base,s,a);else if(e.name==="linear")u=Qi(r,1,s,a);else if(e.name==="cubic-bezier"){const h=e.controlPoints;u=new Xc(h[0],h[1],h[2],h[3]).solve(Qi(r,1,s,a))}return u}static parse(e,r){let[s,a,u,...h]=e;if(!Array.isArray(a)||a.length===0)return r.error("Expected an interpolation type expression.",1);if(a[0]==="linear")a={name:"linear"};else if(a[0]==="exponential"){const x=a[1];if(typeof x!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:x}}else{if(a[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(a[0])}`,1,0);{const x=a.slice(1);if(x.length!==4||x.some((w=>typeof w!="number"||w<0||w>1)))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:x}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(u=r.parse(u,2,Be),!u)return null;const m=[];let _=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||r.expectedType==fs?r.expectedType&&r.expectedType.kind!=="value"&&(_=r.expectedType):_=_i;for(let x=0;x<h.length;x+=2){const w=h[x],I=h[x+1],C=x+3,z=x+4;if(typeof w!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',C);if(m.length&&m[m.length-1][0]>=w)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',C);const R=r.parse(I,z,_);if(!R)return null;_=_||R.type,m.push([w,R])}return Fi(_,Be)||Fi(_,Jo)||Fi(_,_i)||Fi(_,Qo)||Fi(_,eo)||Fi(_,fs)||Fi(_,to)||Fi(_,ti(Be))?new ni(_,s,a,u,m):r.error(`Type ${Ct(_)} is not interpolatable.`)}evaluate(e){const r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(e);const a=this.input.evaluate(e);if(a<=r[0])return s[0].evaluate(e);const u=r.length;if(a>=r[u-1])return s[u-1].evaluate(e);const h=ws(r,a),m=ni.interpolationFactor(this.interpolation,a,r[h],r[h+1]),_=s[h].evaluate(e),x=s[h+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return yn(_,x,m);case"color":return dt.interpolate(_,x,m);case"padding":return Xr.interpolate(_,x,m);case"colorArray":return rt.interpolate(_,x,m);case"numberArray":return tr.interpolate(_,x,m);case"variableAnchorOffsetCollection":return ri.interpolate(_,x,m);case"array":return ys(_,x,m);case"projectionDefinition":return ii.interpolate(_,x,m)}case"interpolate-hcl":switch(this.type.kind){case"color":return dt.interpolate(_,x,m,"hcl");case"colorArray":return rt.interpolate(_,x,m,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return dt.interpolate(_,x,m,"lab");case"colorArray":return rt.interpolate(_,x,m,"lab")}}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Qi(i,e,r,s){const a=s-r,u=i-r;return a===0?0:e===1?u/a:(Math.pow(e,u)-1)/(Math.pow(e,a)-1)}const Ht={color:dt.interpolate,number:yn,padding:Xr.interpolate,numberArray:tr.interpolate,colorArray:rt.interpolate,variableAnchorOffsetCollection:ri.interpolate,array:ys};class $n{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let s=null;const a=r.expectedType;a&&a.kind!=="value"&&(s=a);const u=[];for(const m of e.slice(1)){const _=r.parse(m,1+u.length,s,void 0,{typeAnnotation:"omit"});if(!_)return null;s=s||_.type,u.push(_)}if(!s)throw new Error("No output type");const h=a&&u.some((m=>gs(a,m.type)));return new $n(h?ct:s,u)}evaluate(e){let r,s=null,a=0;for(const u of this.args)if(a++,s=u.evaluate(e),s&&s instanceof yi&&!s.available&&(r||(r=s.name),s=null,a===this.args.length&&(s=r)),s!==null)break;return s}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function vl(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function lo(i,e,r,s){return s.compare(e,r)===0}function cr(i,e,r){const s=i!=="=="&&i!=="!=";return class Pg{constructor(u,h,m){this.type=ht,this.lhs=u,this.rhs=h,this.collator=m,this.hasUntypedArgument=u.type.kind==="value"||h.type.kind==="value"}static parse(u,h){if(u.length!==3&&u.length!==4)return h.error("Expected two or three arguments.");const m=u[0];let _=h.parse(u[1],1,ct);if(!_)return null;if(!vl(m,_.type))return h.concat(1).error(`"${m}" comparisons are not supported for type '${Ct(_.type)}'.`);let x=h.parse(u[2],2,ct);if(!x)return null;if(!vl(m,x.type))return h.concat(2).error(`"${m}" comparisons are not supported for type '${Ct(x.type)}'.`);if(_.type.kind!==x.type.kind&&_.type.kind!=="value"&&x.type.kind!=="value")return h.error(`Cannot compare types '${Ct(_.type)}' and '${Ct(x.type)}'.`);s&&(_.type.kind==="value"&&x.type.kind!=="value"?_=new ui(x.type,[_]):_.type.kind!=="value"&&x.type.kind==="value"&&(x=new ui(_.type,[x])));let w=null;if(u.length===4){if(_.type.kind!=="string"&&x.type.kind!=="string"&&_.type.kind!=="value"&&x.type.kind!=="value")return h.error("Cannot use collator to compare non-string types.");if(w=h.parse(u[3],3,Js),!w)return null}return new Pg(_,x,w)}evaluate(u){const h=this.lhs.evaluate(u),m=this.rhs.evaluate(u);if(s&&this.hasUntypedArgument){const _=gr(h),x=gr(m);if(_.kind!==x.kind||_.kind!=="string"&&_.kind!=="number")throw new Ft(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${_.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const _=gr(h),x=gr(m);if(_.kind!=="string"||x.kind!=="string")return e(u,h,m)}return this.collator?r(u,h,m,this.collator.evaluate(u)):e(u,h,m)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}const Yc=cr("==",(function(i,e,r){return e===r}),lo),xl=cr("!=",(function(i,e,r){return e!==r}),(function(i,e,r,s){return!lo(0,e,r,s)})),Kc=cr("<",(function(i,e,r){return e<r}),(function(i,e,r,s){return s.compare(e,r)<0})),Dh=cr(">",(function(i,e,r){return e>r}),(function(i,e,r,s){return s.compare(e,r)>0})),Ts=cr("<=",(function(i,e,r){return e<=r}),(function(i,e,r,s){return s.compare(e,r)<=0})),sa=cr(">=",(function(i,e,r){return e>=r}),(function(i,e,r,s){return s.compare(e,r)>=0}));class Ss{constructor(e,r,s){this.type=Js,this.locale=s,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const s=e[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");const a=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,ht);if(!a)return null;const u=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,ht);if(!u)return null;let h=null;return s.locale&&(h=r.parse(s.locale,1,ot),!h)?null:new Ss(a,u,h)}evaluate(e){return new ml(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class bl{constructor(e,r,s,a,u){this.type=ot,this.number=e,this.locale=r,this.currency=s,this.minFractionDigits=a,this.maxFractionDigits=u}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const s=r.parse(e[1],1,Be);if(!s)return null;const a=e[2];if(typeof a!="object"||Array.isArray(a))return r.error("NumberFormat options argument must be an object.");let u=null;if(a.locale&&(u=r.parse(a.locale,1,ot),!u))return null;let h=null;if(a.currency&&(h=r.parse(a.currency,1,ot),!h))return null;let m=null;if(a["min-fraction-digits"]&&(m=r.parse(a["min-fraction-digits"],1,Be),!m))return null;let _=null;return a["max-fraction-digits"]&&(_=r.parse(a["max-fraction-digits"],1,Be),!_)?null:new bl(s,u,h,m,_)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class co{constructor(e){this.type=Qs,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const s=e[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");const a=[];let u=!1;for(let h=1;h<=e.length-1;++h){const m=e[h];if(u&&typeof m=="object"&&!Array.isArray(m)){u=!1;let _=null;if(m["font-scale"]&&(_=r.parse(m["font-scale"],1,Be),!_))return null;let x=null;if(m["text-font"]&&(x=r.parse(m["text-font"],1,ti(ot)),!x))return null;let w=null;if(m["text-color"]&&(w=r.parse(m["text-color"],1,_i),!w))return null;let I=null;if(m["vertical-align"]){if(typeof m["vertical-align"]=="string"&&!Ah.includes(m["vertical-align"]))return r.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${m["vertical-align"]}' instead.`);if(I=r.parse(m["vertical-align"],1,ot),!I)return null}const C=a[a.length-1];C.scale=_,C.font=x,C.textColor=w,C.verticalAlign=I}else{const _=r.parse(e[h],1,ct);if(!_)return null;const x=_.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,a.push({content:_,scale:null,font:null,textColor:null,verticalAlign:null})}}return new co(a)}evaluate(e){return new ci(this.sections.map((r=>{const s=r.content.evaluate(e);return gr(s)===ms?new gl("",s,null,null,null,r.verticalAlign?r.verticalAlign.evaluate(e):null):new gl(jn(s),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null,r.verticalAlign?r.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor),r.verticalAlign&&e(r.verticalAlign)}outputDefined(){return!1}}class Ps{constructor(e){this.type=ms,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const s=r.parse(e[1],1,ot);return s?new Ps(s):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),s=yi.fromString(r);return s&&e.availableImages&&(s.available=e.availableImages.indexOf(r)>-1),s}eachChild(e){e(this.input)}outputDefined(){return!1}}class Is{constructor(e){this.type=Be,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=r.parse(e[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${Ct(s.type)} instead.`):new Is(s):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new Ft(`Expected value to be of type string or array, but found ${Ct(gr(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Mr=8192;function Jc(i,e){const r=(180+i[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,a=Math.pow(2,e.z);return[Math.round(r*a*Mr),Math.round(s*a*Mr)]}function Ms(i,e){const r=Math.pow(2,e.z);return[(a=(i[0]/Mr+e.x)/r,360*a-180),(s=(i[1]/Mr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,a}function uo(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function Zn(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function kh(i,e,r){const s=i[0]-e[0],a=i[1]-e[1],u=i[0]-r[0],h=i[1]-r[1];return s*h-u*a==0&&s*u<=0&&a*h<=0}function oa(i,e,r,s){return(a=[s[0]-r[0],s[1]-r[1]])[0]*(u=[e[0]-i[0],e[1]-i[1]])[1]-a[1]*u[0]!=0&&!(!wl(i,e,r,s)||!wl(r,s,i,e));var a,u}function Rh(i,e,r){for(const s of r)for(let a=0;a<s.length-1;++a)if(oa(i,e,s[a],s[a+1]))return!0;return!1}function Es(i,e,r=!1){let s=!1;for(const m of e)for(let _=0;_<m.length-1;_++){if(kh(i,m[_],m[_+1]))return r;(u=m[_])[1]>(a=i)[1]!=(h=m[_+1])[1]>a[1]&&a[0]<(h[0]-u[0])*(a[1]-u[1])/(h[1]-u[1])+u[0]&&(s=!s)}var a,u,h;return s}function aa(i,e){for(const r of e)if(Es(i,r))return!0;return!1}function Qc(i,e){for(const r of i)if(!Es(r,e))return!1;for(let r=0;r<i.length-1;++r)if(Rh(i[r],i[r+1],e))return!1;return!0}function eu(i,e){for(const r of e)if(Qc(i,r))return!0;return!1}function wl(i,e,r,s){const a=s[0]-r[0],u=s[1]-r[1],h=(i[0]-r[0])*u-a*(i[1]-r[1]),m=(e[0]-r[0])*u-a*(e[1]-r[1]);return h>0&&m<0||h<0&&m>0}function Tl(i,e,r){const s=[];for(let a=0;a<i.length;a++){const u=[];for(let h=0;h<i[a].length;h++){const m=Jc(i[a][h],r);uo(e,m),u.push(m)}s.push(u)}return s}function Sl(i,e,r){const s=[];for(let a=0;a<i.length;a++){const u=Tl(i[a],e,r);s.push(u)}return s}function tu(i,e,r,s){if(i[0]<r[0]||i[0]>r[2]){const a=.5*s;let u=i[0]-r[0]>a?-s:r[0]-i[0]>a?s:0;u===0&&(u=i[0]-r[2]>a?-s:r[2]-i[0]>a?s:0),i[0]+=u}uo(e,i)}function ru(i,e,r,s){const a=Math.pow(2,s.z)*Mr,u=[s.x*Mr,s.y*Mr],h=[];for(const m of i)for(const _ of m){const x=[_.x+u[0],_.y+u[1]];tu(x,e,r,a),h.push(x)}return h}function iu(i,e,r,s){const a=Math.pow(2,s.z)*Mr,u=[s.x*Mr,s.y*Mr],h=[];for(const _ of i){const x=[];for(const w of _){const I=[w.x+u[0],w.y+u[1]];uo(e,I),x.push(I)}h.push(x)}if(e[2]-e[0]<=a/2){(m=e)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const _ of h)for(const x of _)tu(x,e,r,a)}var m;return h}class Un{constructor(e,r){this.type=ht,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(xn(e[1])){const s=e[1];if(s.type==="FeatureCollection"){const a=[];for(const u of s.features){const{type:h,coordinates:m}=u.geometry;h==="Polygon"&&a.push(m),h==="MultiPolygon"&&a.push(...m)}if(a.length)return new Un(s,{type:"MultiPolygon",coordinates:a})}else if(s.type==="Feature"){const a=s.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new Un(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Un(s,s)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(r,s){const a=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],h=r.canonicalID();if(s.type==="Polygon"){const m=Tl(s.coordinates,u,h),_=ru(r.geometry(),a,u,h);if(!Zn(a,u))return!1;for(const x of _)if(!Es(x,m))return!1}if(s.type==="MultiPolygon"){const m=Sl(s.coordinates,u,h),_=ru(r.geometry(),a,u,h);if(!Zn(a,u))return!1;for(const x of _)if(!aa(x,m))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,s){const a=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],h=r.canonicalID();if(s.type==="Polygon"){const m=Tl(s.coordinates,u,h),_=iu(r.geometry(),a,u,h);if(!Zn(a,u))return!1;for(const x of _)if(!Qc(x,m))return!1}if(s.type==="MultiPolygon"){const m=Sl(s.coordinates,u,h),_=iu(r.geometry(),a,u,h);if(!Zn(a,u))return!1;for(const x of _)if(!eu(x,m))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let nu=class{constructor(i=[],e=(r,s)=>r<s?-1:r>s?1:0){if(this.data=i,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(i){this.data.push(i),this._up(this.length++)}pop(){if(this.length===0)return;const i=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:e,compare:r}=this,s=e[i];for(;i>0;){const a=i-1>>1,u=e[a];if(r(s,u)>=0)break;e[i]=u,i=a}e[i]=s}_down(i){const{data:e,compare:r}=this,s=this.length>>1,a=e[i];for(;i<s;){let u=1+(i<<1);const h=u+1;if(h<this.length&&r(e[h],e[u])<0&&(u=h),r(e[u],a)>=0)break;e[i]=e[u],i=u}e[i]=a}};function Pl(i,e,r=0,s=i.length-1,a=su){for(;s>r;){if(s-r>600){const _=s-r+1,x=e-r+1,w=Math.log(_),I=.5*Math.exp(2*w/3),C=.5*Math.sqrt(w*I*(_-I)/_)*(x-_/2<0?-1:1);Pl(i,e,Math.max(r,Math.floor(e-x*I/_+C)),Math.min(s,Math.floor(e+(_-x)*I/_+C)),a)}const u=i[e];let h=r,m=s;for(Cs(i,r,e),a(i[s],u)>0&&Cs(i,r,s);h<m;){for(Cs(i,h,m),h++,m--;a(i[h],u)<0;)h++;for(;a(i[m],u)>0;)m--}a(i[r],u)===0?Cs(i,r,m):(m++,Cs(i,m,s)),m<=e&&(r=m+1),e<=m&&(s=m-1)}}function Cs(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}function su(i,e){return i<e?-1:i>e?1:0}function la(i,e){if(i.length<=1)return[i];const r=[];let s,a;for(const u of i){const h=Lh(u);h!==0&&(u.area=Math.abs(h),a===void 0&&(a=h<0),a===h<0?(s&&r.push(s),s=[u]):s.push(u))}if(s&&r.push(s),e>1)for(let u=0;u<r.length;u++)r[u].length<=e||(Pl(r[u],e,1,r[u].length-1,Fh),r[u]=r[u].slice(0,e));return r}function Fh(i,e){return e.area-i.area}function Lh(i){let e=0;for(let r,s,a=0,u=i.length,h=u-1;a<u;h=a++)r=i[a],s=i[h],e+=(s.x-r.x)*(r.y+s.y);return e}const ou=1/298.257223563,ho=ou*(2-ou),au=Math.PI/180;class Il{constructor(e){const r=6378.137*au*1e3,s=Math.cos(e*au),a=1/(1-ho*(1-s*s)),u=Math.sqrt(a);this.kx=r*u*s,this.ky=r*u*a*(1-ho)}distance(e,r){const s=this.wrap(e[0]-r[0])*this.kx,a=(e[1]-r[1])*this.ky;return Math.sqrt(s*s+a*a)}pointOnLine(e,r){let s,a,u,h,m=1/0;for(let _=0;_<e.length-1;_++){let x=e[_][0],w=e[_][1],I=this.wrap(e[_+1][0]-x)*this.kx,C=(e[_+1][1]-w)*this.ky,z=0;I===0&&C===0||(z=(this.wrap(r[0]-x)*this.kx*I+(r[1]-w)*this.ky*C)/(I*I+C*C),z>1?(x=e[_+1][0],w=e[_+1][1]):z>0&&(x+=I/this.kx*z,w+=C/this.ky*z)),I=this.wrap(r[0]-x)*this.kx,C=(r[1]-w)*this.ky;const R=I*I+C*C;R<m&&(m=R,s=x,a=w,u=_,h=z)}return{point:[s,a],index:u,t:Math.max(0,Math.min(1,h))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function lu(i,e){return e[0]-i[0]}function ca(i){return i[1]-i[0]+1}function Li(i,e){return i[1]>=i[0]&&i[1]<e}function ua(i,e){if(i[0]>i[1])return[null,null];const r=ca(i);if(e){if(r===2)return[i,null];const a=Math.floor(r/2);return[[i[0],i[0]+a],[i[0]+a,i[1]]]}if(r===1)return[i,null];const s=Math.floor(r/2)-1;return[[i[0],i[0]+s],[i[0]+s+1,i[1]]]}function Ml(i,e){if(!Li(e,i.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let s=e[0];s<=e[1];++s)uo(r,i[s]);return r}function El(i){const e=[1/0,1/0,-1/0,-1/0];for(const r of i)for(const s of r)uo(e,s);return e}function Cl(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function ha(i,e,r){if(!Cl(i)||!Cl(e))return NaN;let s=0,a=0;return i[2]<e[0]&&(s=e[0]-i[2]),i[0]>e[2]&&(s=i[0]-e[2]),i[1]>e[3]&&(a=i[1]-e[3]),i[3]<e[1]&&(a=e[1]-i[3]),r.distance([0,0],[s,a])}function Gn(i,e,r){const s=r.pointOnLine(e,i);return r.distance(i,s.point)}function Al(i,e,r,s,a){const u=Math.min(Gn(i,[r,s],a),Gn(e,[r,s],a)),h=Math.min(Gn(r,[i,e],a),Gn(s,[i,e],a));return Math.min(u,h)}function Oh(i,e,r,s,a){if(!Li(e,i.length)||!Li(s,r.length))return 1/0;let u=1/0;for(let h=e[0];h<e[1];++h){const m=i[h],_=i[h+1];for(let x=s[0];x<s[1];++x){const w=r[x],I=r[x+1];if(oa(m,_,w,I))return 0;u=Math.min(u,Al(m,_,w,I,a))}}return u}function cu(i,e,r,s,a){if(!Li(e,i.length)||!Li(s,r.length))return NaN;let u=1/0;for(let h=e[0];h<=e[1];++h)for(let m=s[0];m<=s[1];++m)if(u=Math.min(u,a.distance(i[h],r[m])),u===0)return u;return u}function Bh(i,e,r){if(Es(i,e,!0))return 0;let s=1/0;for(const a of e){const u=a[0],h=a[a.length-1];if(u!==h&&(s=Math.min(s,Gn(i,[h,u],r)),s===0))return s;const m=r.pointOnLine(a,i);if(s=Math.min(s,r.distance(i,m.point)),s===0)return s}return s}function jh(i,e,r,s){if(!Li(e,i.length))return NaN;for(let u=e[0];u<=e[1];++u)if(Es(i[u],r,!0))return 0;let a=1/0;for(let u=e[0];u<e[1];++u){const h=i[u],m=i[u+1];for(const _ of r)for(let x=0,w=_.length,I=w-1;x<w;I=x++){const C=_[I],z=_[x];if(oa(h,m,C,z))return 0;a=Math.min(a,Al(h,m,C,z,s))}}return a}function uu(i,e){for(const r of i)for(const s of r)if(Es(s,e,!0))return!0;return!1}function Nh(i,e,r,s=1/0){const a=El(i),u=El(e);if(s!==1/0&&ha(a,u,r)>=s)return s;if(Zn(a,u)){if(uu(i,e))return 0}else if(uu(e,i))return 0;let h=1/0;for(const m of i)for(let _=0,x=m.length,w=x-1;_<x;w=_++){const I=m[w],C=m[_];for(const z of e)for(let R=0,F=z.length,O=F-1;R<F;O=R++){const Z=z[O],X=z[R];if(oa(I,C,Z,X))return 0;h=Math.min(h,Al(I,C,Z,X,r))}}return h}function St(i,e,r,s,a,u){if(!u)return;const h=ha(Ml(s,u),a,r);h<e&&i.push([h,u,[0,0]])}function da(i,e,r,s,a,u,h){if(!u||!h)return;const m=ha(Ml(s,u),Ml(a,h),r);m<e&&i.push([m,u,h])}function pa(i,e,r,s,a=1/0){let u=Math.min(s.distance(i[0],r[0][0]),a);if(u===0)return u;const h=new nu([[0,[0,i.length-1],[0,0]]],lu),m=El(r);for(;h.length>0;){const _=h.pop();if(_[0]>=u)continue;const x=_[1],w=e?50:100;if(ca(x)<=w){if(!Li(x,i.length))return NaN;if(e){const I=jh(i,x,r,s);if(isNaN(I)||I===0)return I;u=Math.min(u,I)}else for(let I=x[0];I<=x[1];++I){const C=Bh(i[I],r,s);if(u=Math.min(u,C),u===0)return 0}}else{const I=ua(x,e);St(h,u,s,i,m,I[0]),St(h,u,s,i,m,I[1])}}return u}function fa(i,e,r,s,a,u=1/0){let h=Math.min(u,a.distance(i[0],r[0]));if(h===0)return h;const m=new nu([[0,[0,i.length-1],[0,r.length-1]]],lu);for(;m.length>0;){const _=m.pop();if(_[0]>=h)continue;const x=_[1],w=_[2],I=e?50:100,C=s?50:100;if(ca(x)<=I&&ca(w)<=C){if(!Li(x,i.length)&&Li(w,r.length))return NaN;let z;if(e&&s)z=Oh(i,x,r,w,a),h=Math.min(h,z);else if(e&&!s){const R=i.slice(x[0],x[1]+1);for(let F=w[0];F<=w[1];++F)if(z=Gn(r[F],R,a),h=Math.min(h,z),h===0)return h}else if(!e&&s){const R=r.slice(w[0],w[1]+1);for(let F=x[0];F<=x[1];++F)if(z=Gn(i[F],R,a),h=Math.min(h,z),h===0)return h}else z=cu(i,x,r,w,a),h=Math.min(h,z)}else{const z=ua(x,e),R=ua(w,s);da(m,h,a,i,r,z[0],R[0]),da(m,h,a,i,r,z[0],R[1]),da(m,h,a,i,r,z[1],R[0]),da(m,h,a,i,r,z[1],R[1])}}return h}function zl(i){return i.type==="MultiPolygon"?i.coordinates.map((e=>({type:"Polygon",coordinates:e}))):i.type==="MultiLineString"?i.coordinates.map((e=>({type:"LineString",coordinates:e}))):i.type==="MultiPoint"?i.coordinates.map((e=>({type:"Point",coordinates:e}))):[i]}class qn{constructor(e,r){this.type=Be,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(xn(e[1])){const s=e[1];if(s.type==="FeatureCollection")return new qn(s,s.features.map((a=>zl(a.geometry))).flat());if(s.type==="Feature")return new qn(s,zl(s.geometry));if("type"in s&&"coordinates"in s)return new qn(s,zl(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(r,s){const a=r.geometry(),u=a.flat().map((_=>Ms([_.x,_.y],r.canonical)));if(a.length===0)return NaN;const h=new Il(u[0][1]);let m=1/0;for(const _ of s){switch(_.type){case"Point":m=Math.min(m,fa(u,!1,[_.coordinates],!1,h,m));break;case"LineString":m=Math.min(m,fa(u,!1,_.coordinates,!0,h,m));break;case"Polygon":m=Math.min(m,pa(u,!1,_.coordinates,h,m))}if(m===0)return m}return m})(e,this.geometries);if(e.geometryType()==="LineString")return(function(r,s){const a=r.geometry(),u=a.flat().map((_=>Ms([_.x,_.y],r.canonical)));if(a.length===0)return NaN;const h=new Il(u[0][1]);let m=1/0;for(const _ of s){switch(_.type){case"Point":m=Math.min(m,fa(u,!0,[_.coordinates],!1,h,m));break;case"LineString":m=Math.min(m,fa(u,!0,_.coordinates,!0,h,m));break;case"Polygon":m=Math.min(m,pa(u,!0,_.coordinates,h,m))}if(m===0)return m}return m})(e,this.geometries);if(e.geometryType()==="Polygon")return(function(r,s){const a=r.geometry();if(a.length===0||a[0].length===0)return NaN;const u=la(a,0).map((_=>_.map((x=>x.map((w=>Ms([w.x,w.y],r.canonical))))))),h=new Il(u[0][0][0][1]);let m=1/0;for(const _ of s)for(const x of u){switch(_.type){case"Point":m=Math.min(m,pa([_.coordinates],!1,x,h,m));break;case"LineString":m=Math.min(m,pa(_.coordinates,!0,x,h,m));break;case"Polygon":m=Math.min(m,Nh(x,_.coordinates,h,m))}if(m===0)return m}return m})(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class po{constructor(e){this.type=ct,this.key=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=e[1];return s==null?r.error("Global state property must be defined."):typeof s!="string"?r.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new po(s)}evaluate(e){var r;const s=(r=e.globals)===null||r===void 0?void 0:r.globalState;return s&&Object.keys(s).length!==0?no(s,this.key):null}eachChild(){}outputDefined(){return!1}}const As={"==":Yc,"!=":xl,">":Dh,"<":Kc,">=":sa,"<=":Ts,array:ui,at:yt,boolean:ui,case:oo,coalesce:$n,collator:Ss,format:co,image:Ps,in:ut,"index-of":bs,interpolate:ni,"interpolate-hcl":ni,"interpolate-lab":ni,length:Is,let:Lt,literal:Ji,match:vt,number:ui,"number-format":bl,object:ui,slice:Pi,step:bn,string:ui,"to-boolean":ln,"to-color":ln,"to-number":ln,"to-string":ln,var:xs,within:Un,distance:qn,"global-state":po};class Ii{constructor(e,r,s,a){this.name=e,this.type=r,this._evaluate=s,this.args=a}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const s=e[0],a=Ii.definitions[s];if(!a)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const u=Array.isArray(a)?a[0]:a.type,h=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,m=h.filter((([x])=>!Array.isArray(x)||x.length===e.length-1));let _=null;for(const[x,w]of m){_=new Vn(r.registry,ma,r.path,null,r.scope);const I=[];let C=!1;for(let z=1;z<e.length;z++){const R=e[z],F=Array.isArray(x)?x[z-1]:x.type,O=_.parse(R,1+I.length,F);if(!O){C=!0;break}I.push(O)}if(!C)if(Array.isArray(x)&&x.length!==I.length)_.error(`Expected ${x.length} arguments, but found ${I.length} instead.`);else{for(let z=0;z<I.length;z++){const R=Array.isArray(x)?x[z]:x.type,F=I[z];_.concat(z+1).checkSubtype(R,F.type)}if(_.errors.length===0)return new Ii(s,u,w,I)}}if(m.length===1)r.errors.push(..._.errors);else{const x=(m.length?m:h).map((([I])=>{return C=I,Array.isArray(C)?`(${C.map(Ct).join(", ")})`:`(${Ct(C.type)}...)`;var C})).join(" | "),w=[];for(let I=1;I<e.length;I++){const C=r.parse(e[I],1+w.length);if(!C)return null;w.push(Ct(C.type))}r.error(`Expected arguments of type ${x}, but found (${w.join(", ")}) instead.`)}return null}static register(e,r){Ii.definitions=r;for(const s in r)e[s]=Ii}}function hu(i,[e,r,s,a]){e=e.evaluate(i),r=r.evaluate(i),s=s.evaluate(i);const u=a?a.evaluate(i):1,h=vs(e,r,s,u);if(h)throw new Ft(h);return new dt(e/255,r/255,s/255,u,!1)}function du(i,e){return i in e}function Dl(i,e){const r=e[i];return r===void 0?null:r}function Wn(i){return{type:i}}function ma(i){if(i instanceof xs)return ma(i.boundExpression);if(i instanceof Ii&&i.name==="error"||i instanceof Ss||i instanceof Un||i instanceof qn||i instanceof po)return!1;const e=i instanceof ln||i instanceof ui;let r=!0;return i.eachChild((s=>{r=e?r&&ma(s):r&&s instanceof Ji})),!!r&&ga(i)&&_a(i,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function ga(i){if(i instanceof Ii&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof Un||i instanceof qn)return!1;let e=!0;return i.eachChild((r=>{e&&!ga(r)&&(e=!1)})),e}function fo(i){if(i instanceof Ii&&i.name==="feature-state")return!1;let e=!0;return i.eachChild((r=>{e&&!fo(r)&&(e=!1)})),e}function _a(i,e){if(i instanceof Ii&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild((s=>{r&&!_a(s,e)&&(r=!1)})),r}function pu(i){return{result:"success",value:i}}function zs(i){return{result:"error",value:i}}function Ds(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function fu(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function kl(i){return!!i.expression&&i.expression.interpolated}function ft(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function ya(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)&&gr(i)===an}function Vh(i){return i}function mu(i,e){const r=i.stops&&typeof i.stops[0][0]=="object",s=r||!(r||i.property!==void 0),a=i.type||(kl(e)?"exponential":"interval"),u=(function(w){switch(w.type){case"color":return dt.parse;case"padding":return Xr.parse;case"numberArray":return tr.parse;case"colorArray":return rt.parse;default:return null}})(e);if(u&&((i=Tr({},i)).stops&&(i.stops=i.stops.map((w=>[w[0],u(w[1])]))),i.default=u(i.default?i.default:e.default)),i.colorSpace&&(h=i.colorSpace)!=="rgb"&&h!=="hcl"&&h!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var h;const m=(function(w){switch(w){case"exponential":return gu;case"interval":return Zh;case"categorical":return $h;case"identity":return Uh;default:throw new Error(`Unknown function type "${w}"`)}})(a);let _,x;if(a==="categorical"){_=Object.create(null);for(const w of i.stops)_[w[0]]=w[1];x=typeof i.stops[0][0]}if(r){const w={},I=[];for(let R=0;R<i.stops.length;R++){const F=i.stops[R],O=F[0].zoom;w[O]===void 0&&(w[O]={zoom:O,type:i.type,property:i.property,default:i.default,stops:[]},I.push(O)),w[O].stops.push([F[0].value,F[1]])}const C=[];for(const R of I)C.push([w[R].zoom,mu(w[R],e)]);const z={name:"linear"};return{kind:"composite",interpolationType:z,interpolationFactor:ni.interpolationFactor.bind(void 0,z),zoomStops:C.map((R=>R[0])),evaluate:({zoom:R},F)=>gu({stops:C,base:i.base},e,R).evaluate(R,F)}}if(s){const w=a==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:w,interpolationFactor:ni.interpolationFactor.bind(void 0,w),zoomStops:i.stops.map((I=>I[0])),evaluate:({zoom:I})=>m(i,e,I,_,x)}}return{kind:"source",evaluate(w,I){const C=I&&I.properties?I.properties[i.property]:void 0;return C===void 0?mo(i.default,e.default):m(i,e,C,_,x)}}}function mo(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function $h(i,e,r,s,a){return mo(typeof r===a?s[r]:void 0,i.default,e.default)}function Zh(i,e,r){if(ft(r)!=="number")return mo(i.default,e.default);const s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];const a=ws(i.stops.map((u=>u[0])),r);return i.stops[a][1]}function gu(i,e,r){const s=i.base!==void 0?i.base:1;if(ft(r)!=="number")return mo(i.default,e.default);const a=i.stops.length;if(a===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[a-1][0])return i.stops[a-1][1];const u=ws(i.stops.map((w=>w[0])),r),h=(function(w,I,C,z){const R=z-C,F=w-C;return R===0?0:I===1?F/R:(Math.pow(I,F)-1)/(Math.pow(I,R)-1)})(r,s,i.stops[u][0],i.stops[u+1][0]),m=i.stops[u][1],_=i.stops[u+1][1],x=Ht[e.type]||Vh;return typeof m.evaluate=="function"?{evaluate(...w){const I=m.evaluate.apply(void 0,w),C=_.evaluate.apply(void 0,w);if(I!==void 0&&C!==void 0)return x(I,C,h,i.colorSpace)}}:x(m,_,h,i.colorSpace)}function Uh(i,e,r){switch(e.type){case"color":r=dt.parse(r);break;case"formatted":r=ci.fromString(r.toString());break;case"resolvedImage":r=yi.fromString(r.toString());break;case"padding":r=Xr.parse(r);break;case"colorArray":r=rt.parse(r);break;case"numberArray":r=tr.parse(r);break;default:ft(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return mo(r,i.default,e.default)}Ii.register(As,{error:[{kind:"error"},[ot],(i,[e])=>{throw new Ft(e.evaluate(i))}],typeof:[ot,[ct],(i,[e])=>Ct(gr(e.evaluate(i)))],"to-rgba":[ti(Be,4),[_i],(i,[e])=>{const[r,s,a,u]=e.evaluate(i).rgb;return[255*r,255*s,255*a,u]}],rgb:[_i,[Be,Be,Be],hu],rgba:[_i,[Be,Be,Be,Be],hu],has:{type:ht,overloads:[[[ot],(i,[e])=>du(e.evaluate(i),i.properties())],[[ot,an],(i,[e,r])=>du(e.evaluate(i),r.evaluate(i))]]},get:{type:ct,overloads:[[[ot],(i,[e])=>Dl(e.evaluate(i),i.properties())],[[ot,an],(i,[e,r])=>Dl(e.evaluate(i),r.evaluate(i))]]},"feature-state":[ct,[ot],(i,[e])=>Dl(e.evaluate(i),i.featureState||{})],properties:[an,[],i=>i.properties()],"geometry-type":[ot,[],i=>i.geometryType()],id:[ct,[],i=>i.id()],zoom:[Be,[],i=>i.globals.zoom],"heatmap-density":[Be,[],i=>i.globals.heatmapDensity||0],elevation:[Be,[],i=>i.globals.elevation||0],"line-progress":[Be,[],i=>i.globals.lineProgress||0],accumulated:[ct,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Be,Wn(Be),(i,e)=>{let r=0;for(const s of e)r+=s.evaluate(i);return r}],"*":[Be,Wn(Be),(i,e)=>{let r=1;for(const s of e)r*=s.evaluate(i);return r}],"-":{type:Be,overloads:[[[Be,Be],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[Be],(i,[e])=>-e.evaluate(i)]]},"/":[Be,[Be,Be],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[Be,[Be,Be],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[Be,[],()=>Math.LN2],pi:[Be,[],()=>Math.PI],e:[Be,[],()=>Math.E],"^":[Be,[Be,Be],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[Be,[Be],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[Be,[Be],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[Be,[Be],(i,[e])=>Math.log(e.evaluate(i))],log2:[Be,[Be],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[Be,[Be],(i,[e])=>Math.sin(e.evaluate(i))],cos:[Be,[Be],(i,[e])=>Math.cos(e.evaluate(i))],tan:[Be,[Be],(i,[e])=>Math.tan(e.evaluate(i))],asin:[Be,[Be],(i,[e])=>Math.asin(e.evaluate(i))],acos:[Be,[Be],(i,[e])=>Math.acos(e.evaluate(i))],atan:[Be,[Be],(i,[e])=>Math.atan(e.evaluate(i))],min:[Be,Wn(Be),(i,e)=>Math.min(...e.map((r=>r.evaluate(i))))],max:[Be,Wn(Be),(i,e)=>Math.max(...e.map((r=>r.evaluate(i))))],abs:[Be,[Be],(i,[e])=>Math.abs(e.evaluate(i))],round:[Be,[Be],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Be,[Be],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[Be,[Be],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[ht,[ot,ct],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[ht,[ct],(i,[e])=>i.id()===e.value],"filter-type-==":[ht,[ot],(i,[e])=>i.geometryType()===e.value],"filter-<":[ht,[ot,ct],(i,[e,r])=>{const s=i.properties()[e.value],a=r.value;return typeof s==typeof a&&s<a}],"filter-id-<":[ht,[ct],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r<s}],"filter->":[ht,[ot,ct],(i,[e,r])=>{const s=i.properties()[e.value],a=r.value;return typeof s==typeof a&&s>a}],"filter-id->":[ht,[ct],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r>s}],"filter-<=":[ht,[ot,ct],(i,[e,r])=>{const s=i.properties()[e.value],a=r.value;return typeof s==typeof a&&s<=a}],"filter-id-<=":[ht,[ct],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r<=s}],"filter->=":[ht,[ot,ct],(i,[e,r])=>{const s=i.properties()[e.value],a=r.value;return typeof s==typeof a&&s>=a}],"filter-id->=":[ht,[ct],(i,[e])=>{const r=i.id(),s=e.value;return typeof r==typeof s&&r>=s}],"filter-has":[ht,[ct],(i,[e])=>e.value in i.properties()],"filter-has-id":[ht,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[ht,[ti(ot)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[ht,[ti(ct)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[ht,[ot,ti(ct)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[ht,[ot,ti(ct)],(i,[e,r])=>(function(s,a,u,h){for(;u<=h;){const m=u+h>>1;if(a[m]===s)return!0;a[m]>s?h=m-1:u=m+1}return!1})(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:ht,overloads:[[[ht,ht],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Wn(ht),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:ht,overloads:[[[ht,ht],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Wn(ht),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[ht,[ht],(i,[e])=>!e.evaluate(i)],"is-supported-script":[ht,[ot],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[ot,[ot],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[ot,[ot],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[ot,Wn(ct),(i,e)=>e.map((r=>jn(r.evaluate(i)))).join("")],"resolved-locale":[ot,[Js],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Rl{constructor(e,r,s){this.expression=e,this._warningHistory={},this._evaluator=new _l,this._defaultValue=r?(function(a){if(a.type==="color"&&ya(a.default))return new dt(0,0,0,0);switch(a.type){case"color":return dt.parse(a.default)||null;case"padding":return Xr.parse(a.default)||null;case"numberArray":return tr.parse(a.default)||null;case"colorArray":return rt.parse(a.default)||null;case"variableAnchorOffsetCollection":return ri.parse(a.default)||null;case"projectionDefinition":return ii.parse(a.default)||null;default:return a.default===void 0?null:a.default}})(r):null,this._enumValues=r&&r.type==="enum"?r.values:null,this._globalState=s}evaluateWithoutErrorHandling(e,r,s,a,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=a,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=h,this.expression.evaluate(this._evaluator)}evaluate(e,r,s,a,u,h){this._globalState&&(e=Hn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=a,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=h||null;try{const m=this.expression.evaluate(this._evaluator);if(m==null||typeof m=="number"&&m!=m)return this._defaultValue;if(this._enumValues&&!(m in this._enumValues))throw new Ft(`Expected value to be one of ${Object.keys(this._enumValues).map((_=>JSON.stringify(_))).join(", ")}, but found ${JSON.stringify(m)} instead.`);return m}catch(m){return this._warningHistory[m.message]||(this._warningHistory[m.message]=!0,typeof console<"u"&&console.warn(m.message)),this._defaultValue}}}function ks(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in As}function go(i,e,r){const s=new Vn(As,ma,[],e?(function(u){const h={color:_i,string:ot,number:Be,enum:ot,boolean:ht,formatted:Qs,padding:Qo,numberArray:eo,colorArray:fs,projectionDefinition:Jo,resolvedImage:ms,variableAnchorOffsetCollection:to};return u.type==="array"?ti(h[u.value]||ct,u.length):h[u.type]})(e):void 0),a=s.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?pu(new Rl(a,e,r)):zs(s.errors)}class va{constructor(e,r,s){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!fo(r.expression),this.globalStateRefs=wn(r.expression),this._globalState=s}evaluateWithoutErrorHandling(e,r,s,a,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,r,s,a,u,h)}evaluate(e,r,s,a,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._styleExpression.evaluate(e,r,s,a,u,h)}}class Fl{constructor(e,r,s,a,u){this.kind=e,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!fo(r.expression),this.globalStateRefs=wn(r.expression),this.interpolationType=a,this._globalState=u}evaluateWithoutErrorHandling(e,r,s,a,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,r,s,a,u,h)}evaluate(e,r,s,a,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._styleExpression.evaluate(e,r,s,a,u,h)}interpolationFactor(e,r,s){return this.interpolationType?ni.interpolationFactor(this.interpolationType,e,r,s):0}}function Ll(i,e,r){const s=go(i,e,r);if(s.result==="error")return s;const a=s.value.expression,u=ga(a);if(!u&&!Ds(e))return zs([new li("","data expressions not supported")]);const h=_a(a,["zoom"]);if(!h&&!fu(e))return zs([new li("","zoom expressions not supported")]);const m=ba(a);return m||h?m instanceof li?zs([m]):m instanceof ni&&!kl(e)?zs([new li("",'"interpolate" expressions cannot be used with this property')]):pu(m?new Fl(u?"camera":"composite",s.value,m.labels,m instanceof ni?m.interpolation:void 0,r):new va(u?"constant":"source",s.value,r)):zs([new li("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class xa{constructor(e,r){this._parameters=e,this._specification=r,Tr(this,mu(this._parameters,this._specification))}static deserialize(e){return new xa(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ba(i){let e=null;if(i instanceof Lt)e=ba(i.result);else if(i instanceof $n){for(const r of i.args)if(e=ba(r),e)break}else(i instanceof bn||i instanceof ni)&&i.input instanceof Ii&&i.input.name==="zoom"&&(e=i);return e instanceof li||i.eachChild((r=>{const s=ba(r);s instanceof li?e=s:!e&&s?e=new li("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&s&&e!==s&&(e=new li("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function wn(i,e=new Set){return i instanceof po&&e.add(i.key),i.eachChild((r=>{wn(r,e)})),e}function Hn(i,e){const{zoom:r,heatmapDensity:s,elevation:a,lineProgress:u,isSupportedScript:h,accumulated:m}=i??{};return{zoom:r,heatmapDensity:s,elevation:a,lineProgress:u,isSupportedScript:h,accumulated:m,globalState:e}}function Ol(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const e of i.slice(1))if(!Ol(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Gh={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function _o(i,e){if(i==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Ol(i)||(i=yo(i));const r=go(i,Gh,e);if(r.result==="error")throw new Error(r.value.map((s=>`${s.key}: ${s.message}`)).join(", "));return{filter:(s,a,u)=>r.value.evaluate(s,a,{},u),needGeometry:_u(i),getGlobalStateRefs:()=>wn(r.value.expression)}}function qh(i,e){return i<e?-1:i>e?1:0}function _u(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let e=1;e<i.length;e++)if(_u(i[e]))return!0;return!1}function yo(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?wa(i[1],i[2],"=="):e==="!="?vo(wa(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?wa(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(yo))):e==="all"?["all"].concat(i.slice(1).map(yo)):e==="none"?["all"].concat(i.slice(1).map(yo).map(vo)):e==="in"?yu(i[1],i.slice(2)):e==="!in"?vo(yu(i[1],i.slice(2))):e==="has"?vu(i[1]):e!=="!has"||vo(vu(i[1]));var r}function wa(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function yu(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((r=>typeof r!=typeof e[0]))?["filter-in-large",i,["literal",e.sort(qh)]]:["filter-in-small",i,["literal",e]]}}function vu(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function vo(i){return["!",i]}function Ta(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let a="[";for(const u of i)a+=`${Ta(u)},`;return`${a}]`}const r=Object.keys(i).sort();let s="{";for(let a=0;a<r.length;a++)s+=`${JSON.stringify(r[a])}:${Ta(i[r[a]])},`;return`${s}}`}function xu(i){let e="";for(const r of nt)e+=`/${Ta(i[r])}`;return e}function bu(i){const e=i.value;return e?[new Me(i.key,e,"constants have been deprecated as of v8")]:[]}function _r(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function Xn(i){if(Array.isArray(i))return i.map(Xn);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={};for(const r in i)e[r]=Xn(i[r]);return e}return _r(i)}function vi(i){const e=i.key,r=i.value,s=i.valueSpec||{},a=i.objectElementValidators||{},u=i.style,h=i.styleSpec,m=i.validateSpec;let _=[];const x=ft(r);if(x!=="object")return[new Me(e,r,`object expected, ${x} found`)];for(const w in r){const I=w.split(".")[0],C=no(s,I)||s["*"];let z;if(no(a,I))z=a[I];else if(no(s,I)){if(r[w]===void 0)continue;z=m}else if(a["*"])z=a["*"];else{if(!s["*"]){_.push(new Me(e,r[w],`unknown property "${w}"`));continue}z=m}_=_.concat(z({key:(e&&`${e}.`)+w,value:r[w],valueSpec:C,style:u,styleSpec:h,object:r,objectKey:w,validateSpec:m},r))}for(const w in s)a[w]||s[w].required&&s[w].default===void 0&&r[w]===void 0&&_.push(new Me(e,r,`missing required property "${w}"`));return _}function Sa(i){const e=i.value,r=i.valueSpec,s=i.style,a=i.styleSpec,u=i.key,h=i.arrayElementValidator||i.validateSpec;if(ft(e)!=="array")return[new Me(u,e,`array expected, ${ft(e)} found`)];if(r.length&&e.length!==r.length)return[new Me(u,e,`array length ${r.length} expected, length ${e.length} found`)];let m={type:r.value,values:r.values};a.$version<7&&(m.function=r.function),ft(r.value)==="object"&&(m=r.value);let _=[];for(let x=0;x<e.length;x++)_=_.concat(h({array:e,arrayIndex:x,value:e[x],valueSpec:m,validateSpec:i.validateSpec,style:s,styleSpec:a,key:`${u}[${x}]`}));return _}function xo(i){const e=i.key,r=i.value,s=i.valueSpec;let a=ft(r);return a==="number"&&r!=r&&(a="NaN"),a!=="number"?[new Me(e,r,`number expected, ${a} found`)]:"minimum"in s&&r<s.minimum?[new Me(e,r,`${r} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&r>s.maximum?[new Me(e,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function Pa(i){const e=i.valueSpec,r=_r(i.value.type);let s,a,u,h={};const m=r!=="categorical"&&i.value.property===void 0,_=!m,x=ft(i.value.stops)==="array"&&ft(i.value.stops[0])==="array"&&ft(i.value.stops[0][0])==="object",w=vi({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(z){if(r==="identity")return[new Me(z.key,z.value,'identity function may not have a "stops" property')];let R=[];const F=z.value;return R=R.concat(Sa({key:z.key,value:F,valueSpec:z.valueSpec,validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec,arrayElementValidator:I})),ft(F)==="array"&&F.length===0&&R.push(new Me(z.key,F,"array must have at least one stop")),R},default:function(z){return z.validateSpec({key:z.key,value:z.value,valueSpec:e,validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec})}}});return r==="identity"&&m&&w.push(new Me(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||w.push(new Me(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!kl(i.valueSpec)&&w.push(new Me(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(_&&!Ds(i.valueSpec)?w.push(new Me(i.key,i.value,"property functions not supported")):m&&!fu(i.valueSpec)&&w.push(new Me(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||w.push(new Me(i.key,i.value,'"property" property is required')),w;function I(z){let R=[];const F=z.value,O=z.key;if(ft(F)!=="array")return[new Me(O,F,`array expected, ${ft(F)} found`)];if(F.length!==2)return[new Me(O,F,`array length 2 expected, length ${F.length} found`)];if(x){if(ft(F[0])!=="object")return[new Me(O,F,`object expected, ${ft(F[0])} found`)];if(F[0].zoom===void 0)return[new Me(O,F,"object stop key must have zoom")];if(F[0].value===void 0)return[new Me(O,F,"object stop key must have value")];if(u&&u>_r(F[0].zoom))return[new Me(O,F[0].zoom,"stop zoom values must appear in ascending order")];_r(F[0].zoom)!==u&&(u=_r(F[0].zoom),a=void 0,h={}),R=R.concat(vi({key:`${O}[0]`,value:F[0],valueSpec:{zoom:{}},validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec,objectElementValidators:{zoom:xo,value:C}}))}else R=R.concat(C({key:`${O}[0]`,value:F[0],validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec},F));return ks(Xn(F[1]))?R.concat([new Me(`${O}[1]`,F[1],"expressions are not allowed in function stops.")]):R.concat(z.validateSpec({key:`${O}[1]`,value:F[1],valueSpec:e,validateSpec:z.validateSpec,style:z.style,styleSpec:z.styleSpec}))}function C(z,R){const F=ft(z.value),O=_r(z.value),Z=z.value!==null?z.value:R;if(s){if(F!==s)return[new Me(z.key,Z,`${F} stop domain type must match previous stop domain type ${s}`)]}else s=F;if(F!=="number"&&F!=="string"&&F!=="boolean")return[new Me(z.key,Z,"stop domain value must be a number, string, or boolean")];if(F!=="number"&&r!=="categorical"){let X=`number expected, ${F} found`;return Ds(e)&&r===void 0&&(X+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Me(z.key,Z,X)]}return r!=="categorical"||F!=="number"||isFinite(O)&&Math.floor(O)===O?r!=="categorical"&&F==="number"&&a!==void 0&&O<a?[new Me(z.key,Z,"stop domain values must appear in ascending order")]:(a=O,r==="categorical"&&O in h?[new Me(z.key,Z,"stop domain values must be unique")]:(h[O]=!0,[])):[new Me(z.key,Z,`integer expected, found ${O}`)]}}function Tn(i){const e=(i.expressionContext==="property"?Ll:go)(Xn(i.value),i.valueSpec);if(e.result==="error")return e.value.map((s=>new Me(`${i.key}${s.key}`,i.value,s.message)));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new Me(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!fo(r))return[new Me(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!fo(r))return[new Me(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!_a(r,["zoom","feature-state"]))return[new Me(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!ga(r))return[new Me(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function bo(i){const e=i.key,r=i.value,s=ft(r);return s!=="string"?[new Me(e,r,`color expected, ${s} found`)]:dt.parse(String(r))?[]:[new Me(e,r,`color expected, "${r}" found`)]}function Yn(i){const e=i.key,r=i.value,s=i.valueSpec,a=[];return Array.isArray(s.values)?s.values.indexOf(_r(r))===-1&&a.push(new Me(e,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(_r(r))===-1&&a.push(new Me(e,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),a}function Rs(i){return Ol(Xn(i.value))?Tn(Tr({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):wu(i)}function wu(i){const e=i.value,r=i.key;if(ft(e)!=="array")return[new Me(r,e,`array expected, ${ft(e)} found`)];const s=i.styleSpec;let a,u=[];if(e.length<1)return[new Me(r,e,"filter array must have at least 1 element")];switch(u=u.concat(Yn({key:`${r}[0]`,value:e[0],valueSpec:s.filter_operator,style:i.style,styleSpec:i.styleSpec})),_r(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&_r(e[1])==="$type"&&u.push(new Me(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&u.push(new Me(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(a=ft(e[1]),a!=="string"&&u.push(new Me(`${r}[1]`,e[1],`string expected, ${a} found`)));for(let h=2;h<e.length;h++)a=ft(e[h]),_r(e[1])==="$type"?u=u.concat(Yn({key:`${r}[${h}]`,value:e[h],valueSpec:s.geometry_type,style:i.style,styleSpec:i.styleSpec})):a!=="string"&&a!=="number"&&a!=="boolean"&&u.push(new Me(`${r}[${h}]`,e[h],`string, number, or boolean expected, ${a} found`));break;case"any":case"all":case"none":for(let h=1;h<e.length;h++)u=u.concat(wu({key:`${r}[${h}]`,value:e[h],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":a=ft(e[1]),e.length!==2?u.push(new Me(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):a!=="string"&&u.push(new Me(`${r}[1]`,e[1],`string expected, ${a} found`))}return u}function Tu(i,e){const r=i.key,s=i.validateSpec,a=i.style,u=i.styleSpec,h=i.value,m=i.objectKey,_=u[`${e}_${i.layerType}`];if(!_)return[];const x=m.match(/^(.*)-transition$/);if(e==="paint"&&x&&_[x[1]]&&_[x[1]].transition)return s({key:r,value:h,valueSpec:u.transition,style:a,styleSpec:u});const w=i.valueSpec||_[m];if(!w)return[new Me(r,h,`unknown property "${m}"`)];let I;if(ft(h)==="string"&&Ds(w)&&!w.tokens&&(I=/^{([^}]+)}$/.exec(h)))return[new Me(r,h,`"${m}" does not support interpolation syntax
|
|
45
|
+
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(I[1])} }\`.`)];const C=[];return i.layerType==="symbol"&&m==="text-font"&&ya(Xn(h))&&_r(h.type)==="identity"&&C.push(new Me(r,h,'"text-font" does not support identity functions')),C.concat(s({key:i.key,value:h,valueSpec:w,style:a,styleSpec:u,expressionContext:"property",propertyType:e,propertyKey:m}))}function Su(i){return Tu(i,"paint")}function Pu(i){return Tu(i,"layout")}function Iu(i){let e=[];const r=i.value,s=i.key,a=i.style,u=i.styleSpec;if(ft(r)!=="object")return[new Me(s,r,`object expected, ${ft(r)} found`)];r.type||r.ref||e.push(new Me(s,r,'either "type" or "ref" is required'));let h=_r(r.type);const m=_r(r.ref);if(r.id){const _=_r(r.id);for(let x=0;x<i.arrayIndex;x++){const w=a.layers[x];_r(w.id)===_&&e.push(new Me(s,r.id,`duplicate layer id "${r.id}", previously used at line ${w.id.__line__}`))}}if("ref"in r){let _;["type","source","source-layer","filter","layout"].forEach((x=>{x in r&&e.push(new Me(s,r[x],`"${x}" is prohibited for ref layers`))})),a.layers.forEach((x=>{_r(x.id)===m&&(_=x)})),_?_.ref?e.push(new Me(s,r.ref,"ref cannot reference another ref layer")):h=_r(_.type):e.push(new Me(s,r.ref,`ref layer "${m}" not found`))}else if(h!=="background")if(r.source){const _=a.sources&&a.sources[r.source],x=_&&_r(_.type);_?x==="vector"&&h==="raster"?e.push(new Me(s,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&h==="hillshade"||x!=="raster-dem"&&h==="color-relief"?e.push(new Me(s,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&h!=="raster"?e.push(new Me(s,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&h!=="hillshade"&&h!=="color-relief"?e.push(new Me(s,r.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):h!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&_.lineMetrics||e.push(new Me(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Me(s,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Me(s,r.source,`source "${r.source}" not found`))}else e.push(new Me(s,r,'missing required property "source"'));return e=e.concat(vi({key:s,value:r,valueSpec:u.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${s}.type`,value:r.type,valueSpec:u.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:Rs,layout:_=>vi({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Pu(Tr({layerType:h},x))}}),paint:_=>vi({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Su(Tr({layerType:h},x))}})}})),e}function Sn(i){const e=i.value,r=i.key,s=ft(e);return s!=="string"?[new Me(r,e,`string expected, ${s} found`)]:[]}const Bl={promoteId:function({key:i,value:e}){if(ft(e)==="string")return Sn({key:i,value:e});{const r=[];for(const s in e)r.push(...Sn({key:`${i}.${s}`,value:e[s]}));return r}}};function jl(i){const e=i.value,r=i.key,s=i.styleSpec,a=i.style,u=i.validateSpec;if(!e.type)return[new Me(r,e,'"type" is required')];const h=_r(e.type);let m;switch(h){case"vector":case"raster":return m=vi({key:r,value:e,valueSpec:s[`source_${h.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:Bl,validateSpec:u}),m;case"raster-dem":return m=(function(_){var x;const w=(x=_.sourceName)!==null&&x!==void 0?x:"",I=_.value,C=_.styleSpec,z=C.source_raster_dem,R=_.style;let F=[];const O=ft(I);if(I===void 0)return F;if(O!=="object")return F.push(new Me("source_raster_dem",I,`object expected, ${O} found`)),F;const Z=_r(I.encoding)==="custom",X=["redFactor","greenFactor","blueFactor","baseShift"],U=_.value.encoding?`"${_.value.encoding}"`:"Default";for(const G in I)!Z&&X.includes(G)?F.push(new Me(G,I[G],`In "${w}": "${G}" is only valid when "encoding" is set to "custom". ${U} encoding found`)):z[G]?F=F.concat(_.validateSpec({key:G,value:I[G],valueSpec:z[G],validateSpec:_.validateSpec,style:R,styleSpec:C})):F.push(new Me(G,I[G],`unknown property "${G}"`));return F})({sourceName:r,value:e,style:i.style,styleSpec:s,validateSpec:u}),m;case"geojson":if(m=vi({key:r,value:e,valueSpec:s.source_geojson,style:a,styleSpec:s,validateSpec:u,objectElementValidators:Bl}),e.cluster)for(const _ in e.clusterProperties){const[x,w]=e.clusterProperties[_],I=typeof x=="string"?[x,["accumulated"],["get",_]]:x;m.push(...Tn({key:`${r}.${_}.map`,value:w,expressionContext:"cluster-map"})),m.push(...Tn({key:`${r}.${_}.reduce`,value:I,expressionContext:"cluster-reduce"}))}return m;case"video":return vi({key:r,value:e,valueSpec:s.source_video,style:a,validateSpec:u,styleSpec:s});case"image":return vi({key:r,value:e,valueSpec:s.source_image,style:a,validateSpec:u,styleSpec:s});case"canvas":return[new Me(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Yn({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function wo(i){const e=i.value,r=i.styleSpec,s=r.light,a=i.style;let u=[];const h=ft(e);if(e===void 0)return u;if(h!=="object")return u=u.concat([new Me("light",e,`object expected, ${h} found`)]),u;for(const m in e){const _=m.match(/^(.*)-transition$/);u=u.concat(_&&s[_[1]]&&s[_[1]].transition?i.validateSpec({key:m,value:e[m],valueSpec:r.transition,validateSpec:i.validateSpec,style:a,styleSpec:r}):s[m]?i.validateSpec({key:m,value:e[m],valueSpec:s[m],validateSpec:i.validateSpec,style:a,styleSpec:r}):[new Me(m,e[m],`unknown property "${m}"`)])}return u}function Mu(i){const e=i.value,r=i.styleSpec,s=r.sky,a=i.style,u=ft(e);if(e===void 0)return[];if(u!=="object")return[new Me("sky",e,`object expected, ${u} found`)];let h=[];for(const m in e)h=h.concat(s[m]?i.validateSpec({key:m,value:e[m],valueSpec:s[m],style:a,styleSpec:r}):[new Me(m,e[m],`unknown property "${m}"`)]);return h}function Nl(i){const e=i.value,r=i.styleSpec,s=r.terrain,a=i.style;let u=[];const h=ft(e);if(e===void 0)return u;if(h!=="object")return u=u.concat([new Me("terrain",e,`object expected, ${h} found`)]),u;for(const m in e)u=u.concat(s[m]?i.validateSpec({key:m,value:e[m],valueSpec:s[m],validateSpec:i.validateSpec,style:a,styleSpec:r}):[new Me(m,e[m],`unknown property "${m}"`)]);return u}function Vl(i){let e=[];const r=i.value,s=i.key;if(Array.isArray(r)){const a=[],u=[];for(const h in r)r[h].id&&a.includes(r[h].id)&&e.push(new Me(s,r,`all the sprites' ids must be unique, but ${r[h].id} is duplicated`)),a.push(r[h].id),r[h].url&&u.includes(r[h].url)&&e.push(new Me(s,r,`all the sprites' URLs must be unique, but ${r[h].url} is duplicated`)),u.push(r[h].url),e=e.concat(vi({key:`${s}[${h}]`,value:r[h],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return Sn({key:s,value:r})}function Eu(i){return!!i&&i.constructor===Object}function $l(i){return Eu(i.value)?[]:[new Me(i.key,i.value,`object expected, ${ft(i.value)} found`)]}const Zl={"*":()=>[],array:Sa,boolean:function(i){const e=i.value,r=i.key,s=ft(e);return s!=="boolean"?[new Me(r,e,`boolean expected, ${s} found`)]:[]},number:xo,color:bo,constants:bu,enum:Yn,filter:Rs,function:Pa,layer:Iu,object:vi,source:jl,light:wo,sky:Mu,terrain:Nl,projection:function(i){const e=i.value,r=i.styleSpec,s=r.projection,a=i.style,u=ft(e);if(e===void 0)return[];if(u!=="object")return[new Me("projection",e,`object expected, ${u} found`)];let h=[];for(const m in e)h=h.concat(s[m]?i.validateSpec({key:m,value:e[m],valueSpec:s[m],style:a,styleSpec:r}):[new Me(m,e[m],`unknown property "${m}"`)]);return h},projectionDefinition:function(i){const e=i.key;let r=i.value;r=r instanceof String?r.valueOf():r;const s=ft(r);return s!=="array"||(function(a){return Array.isArray(a)&&a.length===3&&typeof a[0]=="string"&&typeof a[1]=="string"&&typeof a[2]=="number"})(r)||(function(a){return!!["interpolate","step","literal"].includes(a[0])})(r)?["array","string"].includes(s)?[]:[new Me(e,r,`projection expected, invalid type "${s}" found`)]:[new Me(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:Sn,formatted:function(i){return Sn(i).length===0?[]:Tn(i)},resolvedImage:function(i){return Sn(i).length===0?[]:Tn(i)},padding:function(i){const e=i.key,r=i.value;if(ft(r)==="array"){if(r.length<1||r.length>4)return[new Me(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const s={type:"number"};let a=[];for(let u=0;u<r.length;u++)a=a.concat(i.validateSpec({key:`${e}[${u}]`,value:r[u],validateSpec:i.validateSpec,valueSpec:s}));return a}return xo({key:e,value:r,valueSpec:{}})},numberArray:function(i){const e=i.key,r=i.value;if(ft(r)==="array"){const s={type:"number"};if(r.length<1)return[new Me(e,r,"array length at least 1 expected, length 0 found")];let a=[];for(let u=0;u<r.length;u++)a=a.concat(i.validateSpec({key:`${e}[${u}]`,value:r[u],validateSpec:i.validateSpec,valueSpec:s}));return a}return xo({key:e,value:r,valueSpec:{}})},colorArray:function(i){const e=i.key,r=i.value;if(ft(r)==="array"){if(r.length<1)return[new Me(e,r,"array length at least 1 expected, length 0 found")];let s=[];for(let a=0;a<r.length;a++)s=s.concat(bo({key:`${e}[${a}]`,value:r[a]}));return s}return bo({key:e,value:r})},variableAnchorOffsetCollection:function(i){const e=i.key,r=i.value,s=ft(r),a=i.styleSpec;if(s!=="array"||r.length<1||r.length%2!=0)return[new Me(e,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let u=[];for(let h=0;h<r.length;h+=2)u=u.concat(Yn({key:`${e}[${h}]`,value:r[h],valueSpec:a.layout_symbol["text-anchor"]})),u=u.concat(Sa({key:`${e}[${h+1}]`,value:r[h+1],valueSpec:{length:2,value:"number"},validateSpec:i.validateSpec,style:i.style,styleSpec:a}));return u},sprite:Vl,state:$l,fontFaces:function(i){const e=i.key,r=i.value,s=i.validateSpec,a=i.styleSpec,u=i.style;if(!Eu(r))return[new Me(e,r,`object expected, ${ft(r)} found`)];const h=[];for(const m in r){const _=r[m],x=ft(_);if(x==="string")h.push(...Sn({key:`${e}.${m}`,value:_}));else if(x==="array"){const w={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[I,C]of _.entries())h.push(...vi({key:`${e}.${m}[${I}]`,value:C,valueSpec:w,styleSpec:a,style:u,validateSpec:s}))}else h.push(new Me(`${e}.${m}`,_,`string or array expected, ${x} found`))}return h}};function Pn(i){const e=i.value,r=i.valueSpec,s=i.styleSpec;return i.validateSpec=Pn,r.expression&&ya(_r(e))?Pa(i):r.expression&&ks(Xn(e))?Tn(i):r.type&&Zl[r.type]?Zl[r.type](i):vi(Tr({},i,{valueSpec:r.type?s[r.type]:r}))}function Cu(i){const e=i.value,r=i.key,s=Sn(i);return s.length||(e.indexOf("{fontstack}")===-1&&s.push(new Me(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&s.push(new Me(r,e,'"glyphs" url must include a "{range}" token'))),s}function Mi(i,e=le){let r=[];return r=r.concat(Pn({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,validateSpec:Pn,objectElementValidators:{glyphs:Cu,"*":()=>[]}})),i.constants&&(r=r.concat(bu({key:"constants",value:i.constants}))),Au(r)}function Oi(i){return function(e){return i(Object.assign({},e,{validateSpec:Pn}))}}function Au(i){return[].concat(i).sort(((e,r)=>e.line-r.line))}function Bi(i){return function(...e){return Au(i.apply(this,e))}}Mi.source=Bi(Oi(jl)),Mi.sprite=Bi(Oi(Vl)),Mi.glyphs=Bi(Oi(Cu)),Mi.light=Bi(Oi(wo)),Mi.sky=Bi(Oi(Mu)),Mi.terrain=Bi(Oi(Nl)),Mi.state=Bi(Oi($l)),Mi.layer=Bi(Oi(Iu)),Mi.filter=Bi(Oi(Rs)),Mi.paintProperty=Bi(Oi(Su)),Mi.layoutProperty=Bi(Oi(Pu));const Wh={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class To{constructor(e,r){this._globalState=r,this.setValue(e)}evaluate(){var e;return(e=this._literalValue)!==null&&e!==void 0?e:this._compiledValue.evaluate({})}setValue(e){if(e==null||e==="visible"||e==="none")return this._literalValue=e==="none"?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const r=go(e,Wh,this._globalState);if(r.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,new Error(r.value.map((s=>`${s.key}: ${s.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=r.value,this._globalStateRefs=wn(r.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const So=le,Br=Mi,Po=Br.light,zu=Br.sky,Hh=Br.paintProperty,Xh=Br.layoutProperty;function Fs(i,e){let r=!1;if(e&&e.length)for(const s of e)i.fire(new be(new Error(s.message))),r=!0;return r}class Ls{constructor(e,r,s){const a=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const h=new Int32Array(this.arrayBuffer);e=h[0],this.d=(r=h[1])+2*(s=h[2]);for(let _=0;_<this.d*this.d;_++){const x=h[3+_],w=h[3+_+1];a.push(x===w?null:h.subarray(x,w))}const m=h[3+a.length+1];this.keys=h.subarray(h[3+a.length],m),this.bboxes=h.subarray(m),this.insert=this._insertReadonly}else{this.d=r+2*s;for(let h=0;h<this.d*this.d;h++)a.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=s,this.scale=r/e,this.uid=0;const u=s/r*e;this.min=-u,this.max=e+u}insert(e,r,s,a,u){this._forEachCell(r,s,a,u,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(s),this.bboxes.push(a),this.bboxes.push(u)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,s,a,u,h){this.cells[u].push(h)}query(e,r,s,a,u){const h=this.min,m=this.max;if(e<=h&&r<=h&&m<=s&&m<=a&&!u)return Array.prototype.slice.call(this.keys);{const _=[];return this._forEachCell(e,r,s,a,this._queryCell,_,{},u),_}}_queryCell(e,r,s,a,u,h,m,_){const x=this.cells[u];if(x!==null){const w=this.keys,I=this.bboxes;for(let C=0;C<x.length;C++){const z=x[C];if(m[z]===void 0){const R=4*z;(_?_(I[R+0],I[R+1],I[R+2],I[R+3]):e<=I[R+2]&&r<=I[R+3]&&s>=I[R+0]&&a>=I[R+1])?(m[z]=!0,h.push(w[z])):m[z]=!1}}}}_forEachCell(e,r,s,a,u,h,m,_){const x=this._convertToCellCoord(e),w=this._convertToCellCoord(r),I=this._convertToCellCoord(s),C=this._convertToCellCoord(a);for(let z=x;z<=I;z++)for(let R=w;R<=C;R++){const F=this.d*R+z;if((!_||_(this._convertFromCellCoord(z),this._convertFromCellCoord(R),this._convertFromCellCoord(z+1),this._convertFromCellCoord(R+1)))&&u.call(this,e,r,s,a,F,h,m,_))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let s=0;for(let h=0;h<this.cells.length;h++)s+=this.cells[h].length;const a=new Int32Array(r+s+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;let u=r;for(let h=0;h<e.length;h++){const m=e[h];a[3+h]=u,a.set(m,u),u+=m.length}return a[3+e.length]=u,a.set(this.keys,u),u+=this.keys.length,a[3+e.length+1]=u,a.set(this.bboxes,u),u+=this.bboxes.length,a.buffer}static serialize(e,r){const s=e.toArrayBuffer();return r&&r.push(s),{buffer:s}}static deserialize(e){return new Ls(e.buffer)}}const ji={};function Ue(i,e,r={}){if(ji[i])throw new Error(`${i} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:i,writeable:!1}),ji[i]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}Ue("Object",Object),Ue("Set",Set),Ue("TransferableGridIndex",Ls),Ue("Color",dt),Ue("Error",Error),Ue("AJAXError",ee),Ue("ResolvedImage",yi),Ue("StylePropertyFunction",xa),Ue("StyleExpression",Rl,{omit:["_evaluator"]}),Ue("ZoomDependentExpression",Fl),Ue("ZoomConstantExpression",va),Ue("CompoundExpression",Ii,{omit:["_evaluate"]});for(const i in As)As[i]._classRegistryKey||Ue(`Expression_${i}`,As[i]);function Ia(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function Ul(i){return i.$name||i.constructor._classRegistryKey}function Os(i){return!(function(e){if(e===null||typeof e!="object")return!1;const r=Ul(e);return!(!r||r==="Object")})(i)&&(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||i instanceof Error||Ia(i)||sn(i)||ArrayBuffer.isView(i)||i instanceof ImageData)}function Io(i,e){if(Os(i))return(Ia(i)||sn(i))&&e&&e.push(i),ArrayBuffer.isView(i)&&e&&e.push(i.buffer),i instanceof ImageData&&e&&e.push(i.data.buffer),i;if(Array.isArray(i)){const u=[];for(const h of i)u.push(Io(h,e));return u}if(typeof i!="object")throw new Error("can't serialize object of type "+typeof i);const r=Ul(i);if(!r)throw new Error(`can't serialize object of unregistered class ${i.constructor.name}`);if(!ji[r])throw new Error(`${r} is not registered.`);const{klass:s}=ji[r],a=s.serialize?s.serialize(i,e):{};if(s.serialize){if(e&&a===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const u in i){if(!i.hasOwnProperty(u)||ji[r].omit.indexOf(u)>=0)continue;const h=i[u];a[u]=ji[r].shallow.indexOf(u)>=0?h:Io(h,e)}i instanceof Error&&(a.message=i.message)}if(a.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(a.$name=r),a}function Mo(i){if(Os(i))return i;if(Array.isArray(i))return i.map(Mo);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);const e=Ul(i)||"Object";if(!ji[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=ji[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const s=Object.create(r.prototype);for(const a of Object.keys(i)){if(a==="$name")continue;const u=i[a];s[a]=ji[e].shallow.indexOf(a)>=0?u:Mo(u)}return s}class Gl{constructor(){this.first=!0}update(e,r){const s=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=s,!0))}}function Eo(i){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(i))}function ql(i){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(i))}function Du(i){return/\s/u.test(String.fromCodePoint(i))}function Bs(i){for(const e of i)if(ql(e.codePointAt(0)))return!0;return!1}function Yh(i){for(const e of i)if(!ku(e.codePointAt(0)))return!1;return!0}function Ma(i){const e=i.map((r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}})).filter((r=>r));return new RegExp(e.join("|"),"u")}const Ea=Ma(["Arab","Dupl","Mong","Ougr","Syrc"]);function ku(i){return!Ea.test(String.fromCodePoint(i))}function Wl(i){return!(ql(i)||(e=i,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))));var e}const Ru=Ma(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Hl(i){return Ru.test(String.fromCodePoint(i))}function Xl(i,e){return!(!e&&Hl(i)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(i)))}function Fu(i){for(const e of i)if(Hl(e.codePointAt(0)))return!0;return!1}const In=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(i){this.pluginStatus=i.pluginStatus,this.pluginURL=i.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(i){if(In.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=i.applyArabicShaping,this.processBidirectionalText=i.processBidirectionalText,this.processStyledBidirectionalText=i.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(i,e){return l(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if(i.pluginStatus!=="loading")return this.setState(i),i;const r=i.pluginURL,s=new Promise((u=>{this.loadScriptResolve=u}));e(r);const a=new Promise((u=>setTimeout((()=>u()),this.TIMEOUT)));if(yield Promise.race([s,a]),this.isParsed()){const u={pluginStatus:"loaded",pluginURL:r};return this.setState(u),u}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${r}`)}))}};class Dt{constructor(e,r){this.isSupportedScript=Kh,this.zoom=e,r?(this.now=r.now||0,this.fadeDuration=r.fadeDuration||0,this.zoomHistory=r.zoomHistory||new Gl,this.transition=r.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Gl,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),s=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}function Kh(i){return(function(e,r){for(const s of e)if(!Xl(s.codePointAt(0),r))return!1;return!0})(i,In.getRTLTextPluginStatus()==="loaded")}const Co="-transition";class Ca{constructor(e,r,s){this.property=e,this.value=r,this.expression=(function(a,u,h){if(ya(a))return new xa(a,u);if(ks(a)){const m=Ll(a,u,h);if(m.result==="error")throw new Error(m.value.map((_=>`${_.key}: ${_.message}`)).join(", "));return m.value}{let m=a;return u.type==="color"&&typeof a=="string"?m=dt.parse(a):u.type!=="padding"||typeof a!="number"&&!Array.isArray(a)?u.type!=="numberArray"||typeof a!="number"&&!Array.isArray(a)?u.type!=="colorArray"||typeof a!="string"&&!Array.isArray(a)?u.type==="variableAnchorOffsetCollection"&&Array.isArray(a)?m=ri.parse(a):u.type==="projectionDefinition"&&typeof a=="string"&&(m=ii.parse(a)):m=rt.parse(a):m=tr.parse(a):m=Xr.parse(a),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>m}}})(r===void 0?e.specification.default:r,e.specification,s)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,r,s){return this.property.possiblyEvaluate(this,e,r,s)}}class Aa{constructor(e,r){this.property=e,this.value=new Ca(e,void 0,r)}transitioned(e,r){return new Lu(this.property,this.value,r,fr({},e.transition,this.transition),e.now)}untransitioned(){return new Lu(this.property,this.value,null,{},0)}}class Yl{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=r}getValue(e){return ki(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Aa(this._values[e].property,this._globalState)),this._values[e].value=new Ca(this._values[e].property,r===null?void 0:ki(r),this._globalState)}getTransition(e){return ki(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Aa(this._values[e].property,this._globalState)),this._values[e].transition=ki(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(e[r]=s);const a=this.getTransition(r);a!==void 0&&(e[`${r}${Co}`]=a)}return e}transitioned(e,r){const s=new Ou(this._properties);for(const a of Object.keys(this._values))s._values[a]=this._values[a].transitioned(e,r._values[a]);return s}untransitioned(){const e=new Ou(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Lu{constructor(e,r,s,a,u){this.property=e,this.value=r,this.begin=u+a.delay||0,this.end=this.begin+a.duration||0,e.specification.transition&&(a.delay||a.duration)&&(this.prior=s)}possiblyEvaluate(e,r,s){const a=e.now||0,u=this.value.possiblyEvaluate(e,r,s),h=this.prior;if(h){if(a>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(a<this.begin)return h.possiblyEvaluate(e,r,s);{const m=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(h.possiblyEvaluate(e,r,s),u,zt(m))}}return u}}class Ou{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,s){const a=new Ao(this._properties);for(const u of Object.keys(this._values))a._values[u]=this._values[u].possiblyEvaluate(e,r,s);return a}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Bu{constructor(e,r){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=r}hasValue(e){return this._values[e].value!==void 0}getValue(e){return ki(this._values[e].value)}setValue(e,r){this._values[e]=new Ca(this._values[e].property,r===null?void 0:ki(r),this._globalState)}serialize(){const e={};for(const r of Object.keys(this._values)){const s=this.getValue(r);s!==void 0&&(e[r]=s)}return e}possiblyEvaluate(e,r,s){const a=new Ao(this._properties);for(const u of Object.keys(this._values))a._values[u]=this._values[u].possiblyEvaluate(e,r,s);return a}}class Ni{constructor(e,r,s){this.property=e,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,s,a){return this.property.evaluate(this.value,this.parameters,e,r,s,a)}}class Ao{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Xe{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,s){const a=Ht[this.specification.type];return a?a(e,r,s):e}}class et{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,s,a){return new Ni(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},s,a)}:e.expression,r)}interpolate(e,r,s){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new Ni(this,{kind:"constant",value:void 0},e.parameters);const a=Ht[this.specification.type];if(a){const u=a(e.value.value,r.value.value,s);return new Ni(this,{kind:"constant",value:u},e.parameters)}return e}evaluate(e,r,s,a,u,h){return e.kind==="constant"?e.value:e.evaluate(r,s,a,u,h)}}class zo extends et{possiblyEvaluate(e,r,s,a){if(e.value===void 0)return new Ni(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const u=e.expression.evaluate(r,null,{},s,a),h=e.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,m=this._calculate(h,h,h,r);return new Ni(this,{kind:"constant",value:m},r)}if(e.expression.kind==="camera"){const u=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new Ni(this,{kind:"constant",value:u},r)}return new Ni(this,e.expression,r)}evaluate(e,r,s,a,u,h){if(e.kind==="source"){const m=e.evaluate(r,s,a,u,h);return this._calculate(m,m,m,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},s,a),e.evaluate({zoom:Math.floor(r.zoom)},s,a),e.evaluate({zoom:Math.floor(r.zoom)+1},s,a),r):e.value}_calculate(e,r,s,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:s,to:r}}interpolate(e){return e}}class za{constructor(e){this.specification=e}possiblyEvaluate(e,r,s,a){if(e.value!==void 0){if(e.expression.kind==="constant"){const u=e.expression.evaluate(r,null,{},s,a);return this._calculate(u,u,u,r)}return this._calculate(e.expression.evaluate(new Dt(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Dt(Math.floor(r.zoom),r)),e.expression.evaluate(new Dt(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,s,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:s,to:r}}interpolate(e){return e}}class Da{constructor(e){this.specification=e}possiblyEvaluate(e,r,s,a){return!!e.expression.evaluate(r,null,{},s,a)}interpolate(){return!1}}class si{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const s=e[r];s.specification.overridable&&this.overridableProperties.push(r);const a=this.defaultPropertyValues[r]=new Ca(s,void 0,void 0),u=this.defaultTransitionablePropertyValues[r]=new Aa(s,void 0);this.defaultTransitioningPropertyValues[r]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=a.possiblyEvaluate({})}}}Ue("DataDrivenProperty",et),Ue("DataConstantProperty",Xe),Ue("CrossFadedDataDrivenProperty",zo),Ue("CrossFadedProperty",za),Ue("ColorRampProperty",Da);class Ei extends ke{constructor(e,r,s){if(super(),this.id=e.id,this.type=e.type,this._globalState=s,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=(function(a,u){return new To(a,u)})(this.visibility,s),e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=_o(e.filter,s)),r.layout&&(this._unevaluatedLayout=new Bu(r.layout,s)),r.paint)){this._transitionablePaint=new Yl(r.paint,s);for(const a in e.paint)this.setPaintProperty(a,e.paint[a],{validate:!1});for(const a in e.layout)this.setLayoutProperty(a,e.layout[a],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ao(r.paint)}}setFilter(e){this.filter=e,this._featureFilter=_o(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const r of this._visibilityExpression.getGlobalStateRefs())e.add(r);if(this._unevaluatedLayout)for(const r in this._unevaluatedLayout._values){const s=this._unevaluatedLayout._values[r];for(const a of s.getGlobalStateRefs())e.add(a)}for(const r of this._featureFilter.getGlobalStateRefs())e.add(r);return e}getPaintAffectingGlobalStateRefs(){var e;const r=new globalThis.Map;if(this._transitionablePaint)for(const s in this._transitionablePaint._values){const a=this._transitionablePaint._values[s].value;for(const u of a.getGlobalStateRefs()){const h=(e=r.get(u))!==null&&e!==void 0?e:[];h.push({name:s,value:a.value}),r.set(u,h)}}return r}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,r,s={}){if(r==null||!this._validate(Xh,`layers.${this.id}.layout.${e}`,e,r,s))return e==="visibility"?(this.visibility=r,this._visibilityExpression.setValue(r),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,r)}getPaintProperty(e){return e.endsWith(Co)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,s={}){if(r!=null&&this._validate(Hh,`layers.${this.id}.paint.${e}`,e,r,s))return!1;if(e.endsWith(Co))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const a=this._transitionablePaint._values[e],u=a.property.specification["property-type"]==="cross-faded-data-driven",h=a.value.isDataDriven(),m=a.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const _=this._transitionablePaint._values[e].value;return _.isDataDriven()||h||u||this._handleOverridablePaintPropertyUpdate(e,m,_)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,s){return!1}isHidden(e=this.minzoom,r=!1){return!!(this.minzoom&&e<(r?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||this._evaluatedVisibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),Yi(e,((r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length)))}_validate(e,r,s,a,u={}){return(!u||u.validate!==!1)&&Fs(this,e.call(Br,{key:r,layerType:this.type,objectKey:s,value:a,styleSpec:le,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof Ni&&Ds(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}let Kl;var ju={get paint(){return Kl=Kl||new si({"raster-opacity":new Xe(le.paint_raster["raster-opacity"]),"raster-hue-rotate":new Xe(le.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Xe(le.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Xe(le.paint_raster["raster-brightness-max"]),"raster-saturation":new Xe(le.paint_raster["raster-saturation"]),"raster-contrast":new Xe(le.paint_raster["raster-contrast"]),"raster-resampling":new Xe(le.paint_raster["raster-resampling"]),"raster-fade-duration":new Xe(le.paint_raster["raster-fade-duration"])})}};class Jh extends Ei{constructor(e,r){super(e,ju,r)}}const Qh={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Do{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class rr{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function yr(i,e=1){let r=0,s=0;return{members:i.map((a=>{const u=Qh[a.type].BYTES_PER_ELEMENT,h=r=Kn(r,Math.max(e,u)),m=a.components||1;return s=Math.max(s,u),r+=u*m,{name:a.name,type:a.type,components:m,offset:h}})),size:Kn(r,Math.max(s,e)),alignment:e}}function Kn(i,e){return Math.ceil(i/e)*e}class ko extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const a=2*e;return this.int16[a+0]=r,this.int16[a+1]=s,e}}ko.prototype.bytesPerElement=4,Ue("StructArrayLayout2i4",ko);class ka extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,s)}emplace(e,r,s,a){const u=3*e;return this.int16[u+0]=r,this.int16[u+1]=s,this.int16[u+2]=a,e}}ka.prototype.bytesPerElement=6,Ue("StructArrayLayout3i6",ka);class Jl extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,a){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,s,a)}emplace(e,r,s,a,u){const h=4*e;return this.int16[h+0]=r,this.int16[h+1]=s,this.int16[h+2]=a,this.int16[h+3]=u,e}}Jl.prototype.bytesPerElement=8,Ue("StructArrayLayout4i8",Jl);class Ra extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u,h){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,s,a,u,h)}emplace(e,r,s,a,u,h,m){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=s,this.int16[_+2]=a,this.int16[_+3]=u,this.int16[_+4]=h,this.int16[_+5]=m,e}}Ra.prototype.bytesPerElement=12,Ue("StructArrayLayout2i4i12",Ra);class Ql extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u,h){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,s,a,u,h)}emplace(e,r,s,a,u,h,m){const _=4*e,x=8*e;return this.int16[_+0]=r,this.int16[_+1]=s,this.uint8[x+4]=a,this.uint8[x+5]=u,this.uint8[x+6]=h,this.uint8[x+7]=m,e}}Ql.prototype.bytesPerElement=8,Ue("StructArrayLayout2i4ub8",Ql);class Ro extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const a=2*e;return this.float32[a+0]=r,this.float32[a+1]=s,e}}Ro.prototype.bytesPerElement=8,Ue("StructArrayLayout2f8",Ro);class cn extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u,h,m,_,x,w){const I=this.length;return this.resize(I+1),this.emplace(I,e,r,s,a,u,h,m,_,x,w)}emplace(e,r,s,a,u,h,m,_,x,w,I){const C=10*e;return this.uint16[C+0]=r,this.uint16[C+1]=s,this.uint16[C+2]=a,this.uint16[C+3]=u,this.uint16[C+4]=h,this.uint16[C+5]=m,this.uint16[C+6]=_,this.uint16[C+7]=x,this.uint16[C+8]=w,this.uint16[C+9]=I,e}}cn.prototype.bytesPerElement=20,Ue("StructArrayLayout10ui20",cn);class Fa extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u,h,m,_){const x=this.length;return this.resize(x+1),this.emplace(x,e,r,s,a,u,h,m,_)}emplace(e,r,s,a,u,h,m,_,x){const w=8*e;return this.uint16[w+0]=r,this.uint16[w+1]=s,this.uint16[w+2]=a,this.uint16[w+3]=u,this.uint16[w+4]=h,this.uint16[w+5]=m,this.uint16[w+6]=_,this.uint16[w+7]=x,e}}Fa.prototype.bytesPerElement=16,Ue("StructArrayLayout8ui16",Fa);class Fo extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u,h,m,_,x,w,I,C){const z=this.length;return this.resize(z+1),this.emplace(z,e,r,s,a,u,h,m,_,x,w,I,C)}emplace(e,r,s,a,u,h,m,_,x,w,I,C,z){const R=12*e;return this.int16[R+0]=r,this.int16[R+1]=s,this.int16[R+2]=a,this.int16[R+3]=u,this.uint16[R+4]=h,this.uint16[R+5]=m,this.uint16[R+6]=_,this.uint16[R+7]=x,this.int16[R+8]=w,this.int16[R+9]=I,this.int16[R+10]=C,this.int16[R+11]=z,e}}Fo.prototype.bytesPerElement=24,Ue("StructArrayLayout4i4ui4i24",Fo);class La extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,s)}emplace(e,r,s,a){const u=3*e;return this.float32[u+0]=r,this.float32[u+1]=s,this.float32[u+2]=a,e}}La.prototype.bytesPerElement=12,Ue("StructArrayLayout3f12",La);class Lo extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}Lo.prototype.bytesPerElement=4,Ue("StructArrayLayout1ul4",Lo);class ec extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u,h,m,_,x){const w=this.length;return this.resize(w+1),this.emplace(w,e,r,s,a,u,h,m,_,x)}emplace(e,r,s,a,u,h,m,_,x,w){const I=10*e,C=5*e;return this.int16[I+0]=r,this.int16[I+1]=s,this.int16[I+2]=a,this.int16[I+3]=u,this.int16[I+4]=h,this.int16[I+5]=m,this.uint32[C+3]=_,this.uint16[I+8]=x,this.uint16[I+9]=w,e}}ec.prototype.bytesPerElement=20,Ue("StructArrayLayout6i1ul2ui20",ec);class js extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u,h){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,s,a,u,h)}emplace(e,r,s,a,u,h,m){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=s,this.int16[_+2]=a,this.int16[_+3]=u,this.int16[_+4]=h,this.int16[_+5]=m,e}}js.prototype.bytesPerElement=12,Ue("StructArrayLayout2i2i2i12",js);class Jn extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,s,a,u)}emplace(e,r,s,a,u,h){const m=4*e,_=8*e;return this.float32[m+0]=r,this.float32[m+1]=s,this.float32[m+2]=a,this.int16[_+6]=u,this.int16[_+7]=h,e}}Jn.prototype.bytesPerElement=16,Ue("StructArrayLayout2f1f2i16",Jn);class tc extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,s,a,u,h){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,s,a,u,h)}emplace(e,r,s,a,u,h,m){const _=16*e,x=4*e,w=8*e;return this.uint8[_+0]=r,this.uint8[_+1]=s,this.float32[x+1]=a,this.float32[x+2]=u,this.int16[w+6]=h,this.int16[w+7]=m,e}}tc.prototype.bytesPerElement=16,Ue("StructArrayLayout2ub2f2i16",tc);class Oo extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,s)}emplace(e,r,s,a){const u=3*e;return this.uint16[u+0]=r,this.uint16[u+1]=s,this.uint16[u+2]=a,e}}Oo.prototype.bytesPerElement=6,Ue("StructArrayLayout3ui6",Oo);class Qn extends rr{_refreshViews(){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)}emplaceBack(e,r,s,a,u,h,m,_,x,w,I,C,z,R,F,O,Z){const X=this.length;return this.resize(X+1),this.emplace(X,e,r,s,a,u,h,m,_,x,w,I,C,z,R,F,O,Z)}emplace(e,r,s,a,u,h,m,_,x,w,I,C,z,R,F,O,Z,X){const U=24*e,G=12*e,J=48*e;return this.int16[U+0]=r,this.int16[U+1]=s,this.uint16[U+2]=a,this.uint16[U+3]=u,this.uint32[G+2]=h,this.uint32[G+3]=m,this.uint32[G+4]=_,this.uint16[U+10]=x,this.uint16[U+11]=w,this.uint16[U+12]=I,this.float32[G+7]=C,this.float32[G+8]=z,this.uint8[J+36]=R,this.uint8[J+37]=F,this.uint8[J+38]=O,this.uint32[G+10]=Z,this.int16[U+22]=X,e}}Qn.prototype.bytesPerElement=48,Ue("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Qn);class rc extends rr{_refreshViews(){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)}emplaceBack(e,r,s,a,u,h,m,_,x,w,I,C,z,R,F,O,Z,X,U,G,J,ie,fe,Pe,Te,Ie,Oe,ze){const we=this.length;return this.resize(we+1),this.emplace(we,e,r,s,a,u,h,m,_,x,w,I,C,z,R,F,O,Z,X,U,G,J,ie,fe,Pe,Te,Ie,Oe,ze)}emplace(e,r,s,a,u,h,m,_,x,w,I,C,z,R,F,O,Z,X,U,G,J,ie,fe,Pe,Te,Ie,Oe,ze,we){const xe=32*e,$e=16*e;return this.int16[xe+0]=r,this.int16[xe+1]=s,this.int16[xe+2]=a,this.int16[xe+3]=u,this.int16[xe+4]=h,this.int16[xe+5]=m,this.int16[xe+6]=_,this.int16[xe+7]=x,this.uint16[xe+8]=w,this.uint16[xe+9]=I,this.uint16[xe+10]=C,this.uint16[xe+11]=z,this.uint16[xe+12]=R,this.uint16[xe+13]=F,this.uint16[xe+14]=O,this.uint16[xe+15]=Z,this.uint16[xe+16]=X,this.uint16[xe+17]=U,this.uint16[xe+18]=G,this.uint16[xe+19]=J,this.uint16[xe+20]=ie,this.uint16[xe+21]=fe,this.uint16[xe+22]=Pe,this.uint32[$e+12]=Te,this.float32[$e+13]=Ie,this.float32[$e+14]=Oe,this.uint16[xe+30]=ze,this.uint16[xe+31]=we,e}}rc.prototype.bytesPerElement=64,Ue("StructArrayLayout8i15ui1ul2f2ui64",rc);class Oa extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}Oa.prototype.bytesPerElement=4,Ue("StructArrayLayout1f4",Oa);class Ba extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,s)}emplace(e,r,s,a){const u=3*e;return this.uint16[6*e+0]=r,this.float32[u+1]=s,this.float32[u+2]=a,e}}Ba.prototype.bytesPerElement=12,Ue("StructArrayLayout1ui2f12",Ba);class ic extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,r,s)}emplace(e,r,s,a){const u=4*e;return this.uint32[2*e+0]=r,this.uint16[u+2]=s,this.uint16[u+3]=a,e}}ic.prototype.bytesPerElement=8,Ue("StructArrayLayout1ul2ui8",ic);class d extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const s=this.length;return this.resize(s+1),this.emplace(s,e,r)}emplace(e,r,s){const a=2*e;return this.uint16[a+0]=r,this.uint16[a+1]=s,e}}d.prototype.bytesPerElement=4,Ue("StructArrayLayout2ui4",d);class t extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}t.prototype.bytesPerElement=2,Ue("StructArrayLayout1ui2",t);class n extends rr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,s,a){const u=this.length;return this.resize(u+1),this.emplace(u,e,r,s,a)}emplace(e,r,s,a,u){const h=4*e;return this.float32[h+0]=r,this.float32[h+1]=s,this.float32[h+2]=a,this.float32[h+3]=u,e}}n.prototype.bytesPerElement=16,Ue("StructArrayLayout4f16",n);class o extends Do{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new ne(this.anchorPointX,this.anchorPointY)}}o.prototype.size=20;class c extends ec{get(e){return new o(this,e)}}Ue("CollisionBoxArray",c);class f extends Do{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}f.prototype.size=48;class g extends Qn{get(e){return new f(this,e)}}Ue("PlacedSymbolArray",g);class v extends Do{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}v.prototype.size=64;class b extends rc{get(e){return new v(this,e)}}Ue("SymbolInstanceArray",b);class P extends Oa{getoffsetX(e){return this.float32[1*e+0]}}Ue("GlyphOffsetArray",P);class E extends ka{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Ue("SymbolLineVertexArray",E);class k extends Do{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}k.prototype.size=12;class D extends Ba{get(e){return new k(this,e)}}Ue("TextAnchorOffsetArray",D);class L extends Do{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}L.prototype.size=8;class N extends ic{get(e){return new L(this,e)}}Ue("FeatureIndexArray",N);class q extends ko{}class H extends ko{}class W extends ko{}class K extends Ra{}class re extends Ql{}class Y extends Ro{}class te extends cn{}class oe extends Fa{}class Q extends Fo{}class ae extends La{}class ve extends Lo{}class ge extends js{}class _e extends tc{}class ye extends Oo{}class Re extends d{}const Fe=yr([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ee}=Fe;class je{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,r,s,a){const u=this.segments[this.segments.length-1];return e>je.MAX_VERTEX_ARRAY_LENGTH&&Or(`Max vertices per segment is ${je.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${je.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!u||u.vertexLength+e>je.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==a?this.createNewSegment(r,s,a):u}createNewSegment(e,r,s){const a={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(a.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(a),a}getOrCreateLatestSegment(e,r,s){return this.prepareSegment(0,e,r,s)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,s,a){return new je([{vertexOffset:e,primitiveOffset:r,vertexLength:s,primitiveLength:a,vaos:{},sortKey:0}])}}function st(i,e){return 256*(i=sr(Math.floor(i),0,255))+sr(Math.floor(e),0,255)}je.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ue("SegmentVector",je);const Mt=yr([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),qt=yr([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Ot,Xt,Bt,ur={exports:{}},Yt={exports:{}},jr={exports:{}},Sr=(function(){if(Bt)return ur.exports;Bt=1;var i=(Ot||(Ot=1,Yt.exports=function(r,s){var a,u,h,m,_,x,w,I;for(u=r.length-(a=3&r.length),h=s,_=3432918353,x=461845907,I=0;I<u;)w=255&r.charCodeAt(I)|(255&r.charCodeAt(++I))<<8|(255&r.charCodeAt(++I))<<16|(255&r.charCodeAt(++I))<<24,++I,h=27492+(65535&(m=5*(65535&(h=(h^=w=(65535&(w=(w=(65535&w)*_+(((w>>>16)*_&65535)<<16)&4294967295)<<15|w>>>17))*x+(((w>>>16)*x&65535)<<16)&4294967295)<<13|h>>>19))+((5*(h>>>16)&65535)<<16)&4294967295))+((58964+(m>>>16)&65535)<<16);switch(w=0,a){case 3:w^=(255&r.charCodeAt(I+2))<<16;case 2:w^=(255&r.charCodeAt(I+1))<<8;case 1:h^=w=(65535&(w=(w=(65535&(w^=255&r.charCodeAt(I)))*_+(((w>>>16)*_&65535)<<16)&4294967295)<<15|w>>>17))*x+(((w>>>16)*x&65535)<<16)&4294967295}return h^=r.length,h=2246822507*(65535&(h^=h>>>16))+((2246822507*(h>>>16)&65535)<<16)&4294967295,h=3266489909*(65535&(h^=h>>>13))+((3266489909*(h>>>16)&65535)<<16)&4294967295,(h^=h>>>16)>>>0}),Yt.exports),e=(Xt||(Xt=1,jr.exports=function(r,s){for(var a,u=r.length,h=s^u,m=0;u>=4;)a=1540483477*(65535&(a=255&r.charCodeAt(m)|(255&r.charCodeAt(++m))<<8|(255&r.charCodeAt(++m))<<16|(255&r.charCodeAt(++m))<<24))+((1540483477*(a>>>16)&65535)<<16),h=1540483477*(65535&h)+((1540483477*(h>>>16)&65535)<<16)^(a=1540483477*(65535&(a^=a>>>24))+((1540483477*(a>>>16)&65535)<<16)),u-=4,++m;switch(u){case 3:h^=(255&r.charCodeAt(m+2))<<16;case 2:h^=(255&r.charCodeAt(m+1))<<8;case 1:h=1540483477*(65535&(h^=255&r.charCodeAt(m)))+((1540483477*(h>>>16)&65535)<<16)}return h=1540483477*(65535&(h^=h>>>13))+((1540483477*(h>>>16)&65535)<<16),(h^=h>>>15)>>>0}),jr.exports);return ur.exports=i,ur.exports.murmur3=i,ur.exports.murmur2=e,ur.exports})(),vr=Se(Sr);class qr{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,s,a){this.ids.push(Mn(e)),this.positions.push(r,s,a)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=Mn(e);let s=0,a=this.ids.length-1;for(;s<a;){const h=s+a>>1;this.ids[h]>=r?a=h:s=h+1}const u=[];for(;this.ids[s]===r;)u.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return u}static serialize(e,r){const s=new Float64Array(e.ids),a=new Uint32Array(e.positions);return un(s,a,0,s.length-1),r&&r.push(s.buffer,a.buffer),{ids:s,positions:a}}static deserialize(e){const r=new qr;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function Mn(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:vr(String(i))}function un(i,e,r,s){for(;r<s;){const a=i[r+s>>1];let u=r-1,h=s+1;for(;;){do u++;while(i[u]<a);do h--;while(i[h]>a);if(u>=h)break;en(i,u,h),en(e,3*u,3*h),en(e,3*u+1,3*h+1),en(e,3*u+2,3*h+2)}h-r<s-h?(un(i,e,r,h),r=h+1):(un(i,e,h+1,s),s=h)}}function en(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}Ue("FeaturePositionMap",qr);class hi{constructor(e,r){this.gl=e.gl,this.location=r}}class es extends hi{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Bo extends hi{constructor(e,r){super(e,r),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class ts extends hi{constructor(e,r){super(e,r),this.current=dt.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const Ci=new Float32Array(16);function tn(i){return[st(255*i.r,255*i.g),st(255*i.b,255*i.a)]}class Vi{constructor(e,r,s){this.value=e,this.uniformNames=r.map((a=>`u_${a}`)),this.type=s}setUniform(e,r,s){e.set(s.constantOr(this.value))}getBinding(e,r,s){return this.type==="color"?new ts(e,r):new es(e,r)}}class $i{constructor(e,r){this.uniformNames=r.map((s=>`u_${s}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,r){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,r.y,r.height,r.width]}setUniform(e,r,s,a){let u=null;a==="u_pattern_to"?u=this.patternTo:a==="u_pattern_from"?u=this.patternFrom:a==="u_dasharray_to"?u=this.dashTo:a==="u_dasharray_from"?u=this.dashFrom:a==="u_pixel_ratio_to"?u=this.pixelRatioTo:a==="u_pixel_ratio_from"&&(u=this.pixelRatioFrom),u!==null&&e.set(u)}getBinding(e,r,s){return s.substr(0,9)==="u_pattern"||s.substr(0,12)==="u_dasharray_"?new Bo(e,r):new es(e,r)}}class Ut{constructor(e,r,s,a){this.expression=e,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map((u=>({name:`a_${u}`,type:"Float32",components:s==="color"?2:1,offset:0}))),this.paintVertexArray=new a}populatePaintArray(e,r,s){const a=this.paintVertexArray.length,u=this.expression.evaluate(new Dt(0,s),r,{},s.canonical,[],s.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(a,e,u)}updatePaintArray(e,r,s,a,u){const h=this.expression.evaluate(new Dt(0,u),s,a);this._setPaintValue(e,r,h)}_setPaintValue(e,r,s){if(this.type==="color"){const a=tn(s);for(let u=e;u<r;u++)this.paintVertexArray.emplace(u,a[0],a[1])}else{for(let a=e;a<r;a++)this.paintVertexArray.emplace(a,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class jt{constructor(e,r,s,a,u,h){this.expression=e,this.uniformNames=r.map((m=>`u_${m}_t`)),this.type=s,this.useIntegerZoom=a,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=r.map((m=>({name:`a_${m}`,type:"Float32",components:s==="color"?4:2,offset:0}))),this.paintVertexArray=new h}populatePaintArray(e,r,s){const a=this.expression.evaluate(new Dt(this.zoom,s),r,{},s.canonical,[],s.formattedSection),u=this.expression.evaluate(new Dt(this.zoom+1,s),r,{},s.canonical,[],s.formattedSection),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,a,u)}updatePaintArray(e,r,s,a,u){const h=this.expression.evaluate(new Dt(this.zoom,u),s,a),m=this.expression.evaluate(new Dt(this.zoom+1,u),s,a);this._setPaintValue(e,r,h,m)}_setPaintValue(e,r,s,a){if(this.type==="color"){const u=tn(s),h=tn(a);for(let m=e;m<r;m++)this.paintVertexArray.emplace(m,u[0],u[1],h[0],h[1])}else{for(let u=e;u<r;u++)this.paintVertexArray.emplace(u,s,a);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){const s=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,a=sr(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);e.set(a)}getBinding(e,r,s){return new es(e,r)}}class Rr{constructor(e,r,s,a,u,h){this.expression=e,this.type=r,this.useIntegerZoom=s,this.zoom=a,this.layerId=h,this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(e,r,s){const a=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(a,e,this.getPositionIds(r),s)}updatePaintArray(e,r,s,a,u){this._setPaintValues(e,r,this.getPositionIds(s),u)}_setPaintValues(e,r,s,a){const u=this.getPositions(a);if(!u||!s)return;const h=u[s.min],m=u[s.mid],_=u[s.max];if(h&&m&&_)for(let x=e;x<r;x++)this.emplace(this.zoomInPaintVertexArray,x,m,h),this.emplace(this.zoomOutPaintVertexArray,x,m,_)}upload(e){if(this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer){const r=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,r,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,r,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Fr extends Rr{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns&&e.patterns[this.layerId]}getVertexAttributes(){return Mt.members}emplace(e,r,s,a){e.emplace(r,s.tlbr[0],s.tlbr[1],s.tlbr[2],s.tlbr[3],a.tlbr[0],a.tlbr[1],a.tlbr[2],a.tlbr[3],s.pixelRatio,a.pixelRatio)}}class Nu extends Rr{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes&&e.dashes[this.layerId]}getVertexAttributes(){return qt.members}emplace(e,r,s,a){e.emplace(r,0,s.y,s.height,s.width,0,a.y,a.height,a.width)}}class Vu{constructor(e,r,s){this.binders={},this._buffers=[];const a=[];for(const u in e.paint._values){if(!s(u))continue;const h=e.paint.get(u);if(!(h instanceof Ni&&Ds(h.property.specification)))continue;const m=ed(u,e.type),_=h.value,x=h.property.specification.type,w=h.property.useIntegerZoom,I=h.property.specification["property-type"],C=I==="cross-faded"||I==="cross-faded-data-driven";if(_.kind==="constant")this.binders[u]=C?new $i(_.value,m):new Vi(_.value,m,x),a.push(`/u_${u}`);else if(_.kind==="source"||C){const z=$u(u,x,"source");this.binders[u]=C?u==="line-dasharray"?new Nu(_,x,w,r,z,e.id):new Fr(_,x,w,r,z,e.id):new Ut(_,m,x,z),a.push(`/a_${u}`)}else{const z=$u(u,x,"composite");this.binders[u]=new jt(_,m,x,w,r,z),a.push(`/z_${u}`)}}this.cacheKey=a.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof Ut||r instanceof jt?r.maxValue:0}populatePaintArrays(e,r,s){for(const a in this.binders){const u=this.binders[a];(u instanceof Ut||u instanceof jt||u instanceof Rr)&&u.populatePaintArray(e,r,s)}}setConstantPatternPositions(e,r){for(const s in this.binders){const a=this.binders[s];a instanceof $i&&a.setConstantPatternPositions(e,r)}}setConstantDashPositions(e,r){for(const s in this.binders){const a=this.binders[s];a instanceof $i&&a.setConstantDashPositions(e,r)}}updatePaintArrays(e,r,s,a,u){let h=!1;for(const m in e){const _=r.getPositions(m);for(const x of _){const w=s.feature(x.index);for(const I in this.binders){const C=this.binders[I];if((C instanceof Ut||C instanceof jt||C instanceof Rr)&&C.expression.isStateDependent===!0){const z=a.paint.get(I);C.expression=z.value,C.updatePaintArray(x.start,x.end,w,e[m],u),h=!0}}}}return h}defines(){const e=[];for(const r in this.binders){const s=this.binders[r];(s instanceof Vi||s instanceof $i)&&e.push(...s.uniformNames.map((a=>`#define HAS_UNIFORM_${a}`)))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof Ut||s instanceof jt)for(let a=0;a<s.paintVertexAttributes.length;a++)e.push(s.paintVertexAttributes[a].name);else if(s instanceof Rr){const a=s.getVertexAttributes();for(const u of a)e.push(u.name)}}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof Vi||s instanceof $i||s instanceof jt)for(const a of s.uniformNames)e.push(a)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){const s=[];for(const a in this.binders){const u=this.binders[a];if(u instanceof Vi||u instanceof $i||u instanceof jt){for(const h of u.uniformNames)if(r[h]){const m=u.getBinding(e,r[h],h);s.push({name:h,property:a,binding:m})}}}return s}setUniforms(e,r,s,a){for(const{name:u,property:h,binding:m}of r)this.binders[h].setUniform(m,a,s.get(h),u)}updatePaintBuffers(e){this._buffers=[];for(const r in this.binders){const s=this.binders[r];if(e&&s instanceof Rr){const a=e.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;a&&this._buffers.push(a)}else(s instanceof Ut||s instanceof jt)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(e){for(const r in this.binders){const s=this.binders[r];(s instanceof Ut||s instanceof jt||s instanceof Rr)&&s.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof Ut||r instanceof jt||r instanceof Rr)&&r.destroy()}}}class rs{constructor(e,r,s=()=>!0){this.programConfigurations={};for(const a of e)this.programConfigurations[a.id]=new Vu(a,r,s);this.needsUpload=!1,this._featureMap=new qr,this._bufferOffset=0}populatePaintArrays(e,r,s,a){for(const u in this.programConfigurations)this.programConfigurations[u].populatePaintArrays(e,r,a);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,s,a){for(const u of s)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(e,this._featureMap,r,u,a)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function ed(i,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}function $u(i,e,r){const s={color:{source:Ro,composite:n},number:{source:Oa,composite:Ro}},a=(function(u){return{"line-pattern":{source:te,composite:te},"fill-pattern":{source:te,composite:te},"fill-extrusion-pattern":{source:te,composite:te},"line-dasharray":{source:oe,composite:oe}}[u]})(i);return a&&a[r]||s[e][r]}Ue("ConstantBinder",Vi),Ue("CrossFadedConstantBinder",$i),Ue("SourceExpressionBinder",Ut),Ue("CrossFadedPatternBinder",Fr),Ue("CrossFadedDasharrayBinder",Nu),Ue("CompositeExpressionBinder",jt),Ue("ProgramConfiguration",Vu,{omit:["_buffers"]}),Ue("ProgramConfigurationSet",rs);const nc=Math.pow(2,14)-1,En=-nc-1;function Cn(i){const e=Tt/i.extent,r=i.loadGeometry();for(let s=0;s<r.length;s++){const a=r[s];for(let u=0;u<a.length;u++){const h=a[u],m=Math.round(h.x*e),_=Math.round(h.y*e);h.x=sr(m,En,nc),h.y=sr(_,En,nc),(m<h.x||m>h.x+1||_<h.y||_>h.y+1)&&Or("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function An(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?Cn(i):[]}}const sc=-32768;function oc(i,e,r,s,a){i.emplaceBack(sc+8*e+s,sc+8*r+a)}class ja{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new H,this.indexArray=new ye,this.segments=new je,this.programConfigurations=new rs(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,s){const a=this.layers[0],u=[];let h=null,m=!1,_=a.type==="heatmap";if(a.type==="circle"){const w=a;h=w.layout.get("circle-sort-key"),m=!h.isConstant(),_=_||w.paint.get("circle-pitch-alignment")==="map"}const x=_?r.subdivisionGranularity.circle:1;for(const{feature:w,id:I,index:C,sourceLayerIndex:z}of e){const R=this.layers[0]._featureFilter.needGeometry,F=An(w,R);if(!this.layers[0]._featureFilter.filter(new Dt(this.zoom),F,s))continue;const O=m?h.evaluate(F,{},s):void 0,Z={id:I,properties:w.properties,type:w.type,sourceLayerIndex:z,index:C,geometry:R?F.geometry:Cn(w),patterns:{},sortKey:O};u.push(Z)}m&&u.sort(((w,I)=>w.sortKey-I.sortKey));for(const w of u){const{geometry:I,index:C,sourceLayerIndex:z}=w,R=e[C].feature;this.addFeature(w,I,C,s,x),r.featureIndex.insert(R,I,C,z,this.index)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:s})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ee),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,s,a,u=1){let h;switch(u){case 1:h=[0,7];break;case 3:h=[0,2,5,7];break;case 5:h=[0,1,3,4,6,7];break;case 7:h=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${u}; valid values are 1, 3, 5, 7.`)}const m=h.length;for(const _ of r)for(const x of _){const w=x.x,I=x.y;if(w<0||w>=Tt||I<0||I>=Tt)continue;const C=this.segments.prepareSegment(m*m,this.layoutVertexArray,this.indexArray,e.sortKey),z=C.vertexLength;for(let R=0;R<m;R++)for(let F=0;F<m;F++)oc(this.layoutVertexArray,w,I,h[F],h[R]);for(let R=0;R<m-1;R++)for(let F=0;F<m-1;F++){const O=z+R*m+F,Z=z+(R+1)*m+F;this.indexArray.emplaceBack(O,Z+1,O+1),this.indexArray.emplaceBack(O,Z,Z+1)}C.vertexLength+=m*m,C.primitiveLength+=(m-1)*(m-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:{},canonical:a})}}function Na(i,e){for(let r=0;r<i.length;r++)if(Va(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(Va(i,e[r]))return!0;return!!td(i,e)}function Zu(i,e,r){return!!Va(i,e)||!!rd(e,i,r)}function ff(i,e){if(i.length===1)return gf(e,i[0]);for(let r=0;r<e.length;r++){const s=e[r];for(let a=0;a<s.length;a++)if(Va(i,s[a]))return!0}for(let r=0;r<i.length;r++)if(gf(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(td(i,e[r]))return!0;return!1}function Z0(i,e,r){if(i.length>1){if(td(i,e))return!0;for(let s=0;s<e.length;s++)if(rd(e[s],i,r))return!0}for(let s=0;s<i.length;s++)if(rd(i[s],e,r))return!0;return!1}function td(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){const s=i[r],a=i[r+1];for(let u=0;u<e.length-1;u++)if(U0(s,a,e[u],e[u+1]))return!0}return!1}function U0(i,e,r,s){return Si(i,r,s)!==Si(e,r,s)&&Si(i,e,r)!==Si(i,e,s)}function rd(i,e,r){const s=r*r;if(e.length===1)return i.distSqr(e[0])<s;for(let a=1;a<e.length;a++)if(mf(i,e[a-1],e[a])<s)return!0;return!1}function mf(i,e,r){const s=e.distSqr(r);if(s===0)return i.distSqr(e);const a=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/s;return i.distSqr(a<0?e:a>1?r:r.sub(e)._mult(a)._add(e))}function gf(i,e){let r,s,a,u=!1;for(let h=0;h<i.length;h++){r=i[h];for(let m=0,_=r.length-1;m<r.length;_=m++)s=r[m],a=r[_],s.y>e.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(u=!u)}return u}function Va(i,e){let r=!1;for(let s=0,a=i.length-1;s<i.length;a=s++){const u=i[s],h=i[a];u.y>e.y!=h.y>e.y&&e.x<(h.x-u.x)*(e.y-u.y)/(h.y-u.y)+u.x&&(r=!r)}return r}function G0(i,e,r){const s=r[0],a=r[2];if(i.x<s.x&&e.x<s.x||i.x>a.x&&e.x>a.x||i.y<s.y&&e.y<s.y||i.y>a.y&&e.y>a.y)return!1;const u=Si(i,e,r[0]);return u!==Si(i,e,r[1])||u!==Si(i,e,r[2])||u!==Si(i,e,r[3])}function $a(i,e,r){const s=e.paint.get(i).value;return s.kind==="constant"?s.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Uu(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Gu(i,e,r,s,a){if(!e[0]&&!e[1])return i;const u=ne.convert(e)._mult(a);r==="viewport"&&u._rotate(-s);const h=[];for(let m=0;m<i.length;m++)h.push(i[m].sub(u));return h}function q0(i){const e=[];for(let r=0;r<i.length;r++){const s=i[r],a=e.at(-1);(r===0||a&&!s.equals(a))&&e.push(s)}return e}function W0({queryGeometry:i,size:e},r){return Zu(i,r,e)}function H0({queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:a},u){return Zu(i,u,e*(r.projectTileCoordinates(u.x,u.y,s,a).signedDistanceFromCamera/r.cameraToCenterDistance))}function X0({queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:a},u){const h=r.projectTileCoordinates(u.x,u.y,s,a).signedDistanceFromCamera,m=e*(r.cameraToCenterDistance/h);return Zu(i,id(u,r,s,a),m)}function Y0({queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:a},u){return Zu(i,id(u,r,s,a),e)}function _f({queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:a,pitchAlignment:u="map",pitchScale:h="map"},m){const _=u==="map"?h==="map"?W0:H0:h==="map"?X0:Y0,x={queryGeometry:i,size:e,transform:r,unwrappedTileID:s,getElevation:a};for(const w of m)for(const I of w)if(_(x,I))return!0;return!1}function id(i,e,r,s){const a=e.projectTileCoordinates(i.x,i.y,r,s).point;return new ne((.5*a.x+.5)*e.width,(.5*-a.y+.5)*e.height)}let yf,vf;Ue("CircleBucket",ja,{omit:["layers"]});var K0={get paint(){return vf=vf||new si({"circle-radius":new et(le.paint_circle["circle-radius"]),"circle-color":new et(le.paint_circle["circle-color"]),"circle-blur":new et(le.paint_circle["circle-blur"]),"circle-opacity":new et(le.paint_circle["circle-opacity"]),"circle-translate":new Xe(le.paint_circle["circle-translate"]),"circle-translate-anchor":new Xe(le.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Xe(le.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Xe(le.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new et(le.paint_circle["circle-stroke-width"]),"circle-stroke-color":new et(le.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new et(le.paint_circle["circle-stroke-opacity"])})},get layout(){return yf=yf||new si({"circle-sort-key":new et(le.layout_circle["circle-sort-key"])})}};class J0 extends Ei{constructor(e,r){super(e,K0,r)}createBucket(e){return new ja(e)}queryRadius(e){const r=e;return $a("circle-radius",this,r)+$a("circle-stroke-width",this,r)+Uu(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:s,geometry:a,transform:u,pixelsToTileUnits:h,unwrappedTileID:m,getElevation:_}){const x=Gu(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-u.bearingInRadians,h),w=this.paint.get("circle-radius").evaluate(r,s)+this.paint.get("circle-stroke-width").evaluate(r,s),I=this.paint.get("circle-pitch-scale"),C=this.paint.get("circle-pitch-alignment");let z,R;return C==="map"?(z=x,R=w*h):(z=(function(F,O,Z,X){return F.map((U=>id(U,O,Z,X)))})(x,u,m,_),R=w),_f({queryGeometry:z,size:R,transform:u,unwrappedTileID:m,getElevation:_,pitchAlignment:C,pitchScale:I},a)}}class xf extends ja{}let bf;Ue("HeatmapBucket",xf,{omit:["layers"]});var Q0={get paint(){return bf=bf||new si({"heatmap-radius":new et(le.paint_heatmap["heatmap-radius"]),"heatmap-weight":new et(le.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Xe(le.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Da(le.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Xe(le.paint_heatmap["heatmap-opacity"])})}};function nd(i,{width:e,height:r},s,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==e*r*s)throw new RangeError(`mismatched image size. expected: ${a.length} but got: ${e*r*s}`)}else a=new Uint8Array(e*r*s);return i.width=e,i.height=r,i.data=a,i}function wf(i,{width:e,height:r},s){if(e===i.width&&r===i.height)return;const a=nd({},{width:e,height:r},s);sd(i,a,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},s),i.width=e,i.height=r,i.data=a.data}function sd(i,e,r,s,a,u){if(a.width===0||a.height===0)return e;if(a.width>i.width||a.height>i.height||r.x>i.width-a.width||r.y>i.height-a.height)throw new RangeError("out of range source coordinates for image copy");if(a.width>e.width||a.height>e.height||s.x>e.width-a.width||s.y>e.height-a.height)throw new RangeError("out of range destination coordinates for image copy");const h=i.data,m=e.data;if(h===m)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_<a.height;_++){const x=((r.y+_)*i.width+r.x)*u,w=((s.y+_)*e.width+s.x)*u;for(let I=0;I<a.width*u;I++)m[w+I]=h[x+I]}return e}class ac{constructor(e,r){nd(this,e,1,r)}resize(e){wf(this,e,1)}clone(){return new ac({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,s,a,u){sd(e,r,s,a,u,1)}}class xi{constructor(e,r){nd(this,e,4,r)}resize(e){wf(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new xi({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,s,a,u){sd(e,r,s,a,u,4)}setPixel(e,r,s){const a=4*(e*this.width+r);this.data[a+0]=Math.round(255*s.r/s.a),this.data[a+1]=Math.round(255*s.g/s.a),this.data[a+2]=Math.round(255*s.b/s.a),this.data[a+3]=Math.round(255*s.a)}}function Tf(i){const e={},r=i.resolution||256,s=i.clips?i.clips.length:1,a=i.image||new xi({width:r,height:s});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const u=(h,m,_)=>{e[i.evaluationKey]=_;const x=i.expression.evaluate(e);a.setPixel(h/4/r,m/4,x)};if(i.clips)for(let h=0,m=0;h<s;++h,m+=4*r)for(let _=0,x=0;_<r;_++,x+=4){const w=_/(r-1),{start:I,end:C}=i.clips[h];u(m,x,I*(1-w)+C*w)}else for(let h=0,m=0;h<r;h++,m+=4)u(0,m,h/(r-1));return a}Ue("AlphaImage",ac),Ue("RGBAImage",xi);const od="big-fb";class eb extends Ei{createBucket(e){return new xf(e)}constructor(e,r){super(e,Q0,r),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Tf({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(od)&&this.heatmapFbos.delete(od)}queryRadius(e){return $a("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:s,geometry:a,transform:u,pixelsToTileUnits:h,unwrappedTileID:m,getElevation:_}){return _f({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(r,s)*h,transform:u,unwrappedTileID:m,getElevation:_},a)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}}let Sf;var tb={get paint(){return Sf=Sf||new si({"hillshade-illumination-direction":new Xe(le.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Xe(le.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Xe(le.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Xe(le.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Xe(le.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Xe(le.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Xe(le.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Xe(le.paint_hillshade["hillshade-method"])})}};class rb extends Ei{constructor(e,r){super(e,tb,r),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,r=this.paint.get("hillshade-illumination-altitude").values,s=this.paint.get("hillshade-highlight-color").values,a=this.paint.get("hillshade-shadow-color").values;const u=Math.max(e.length,r.length,s.length,a.length);e=e.concat(Array(u-e.length).fill(e.at(-1))),r=r.concat(Array(u-r.length).fill(r.at(-1))),s=s.concat(Array(u-s.length).fill(s.at(-1))),a=a.concat(Array(u-a.length).fill(a.at(-1)));const h=r.map(hs);return{directionRadians:e.map(hs),altitudeRadians:h,shadowColor:a,highlightColor:s}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}}let Pf;var ib={get paint(){return Pf=Pf||new si({"color-relief-opacity":new Xe(le["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new Da(le["paint_color-relief"]["color-relief-color"])})}};class ad{constructor(e,r,s,a){this.context=e,this.format=s,this.texture=e.gl.createTexture(),this.update(r,a)}update(e,r,s){const{width:a,height:u}=e,h=!(this.size&&this.size[0]===a&&this.size[1]===u||s),{context:m}=this,{gl:_}=m;if(this.useMipmap=!!(r&&r.useMipmap),_.bindTexture(_.TEXTURE_2D,this.texture),m.pixelStoreUnpackFlipY.set(!1),m.pixelStoreUnpack.set(1),m.pixelStoreUnpackPremultiplyAlpha.set(this.format===_.RGBA&&(!r||r.premultiply!==!1)),h)this.size=[a,u],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||sn(e)?_.texImage2D(_.TEXTURE_2D,0,this.format,this.format,_.UNSIGNED_BYTE,e):_.texImage2D(_.TEXTURE_2D,0,this.format,a,u,0,this.format,_.UNSIGNED_BYTE,e.data);else{const{x,y:w}=s||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||sn(e)?_.texSubImage2D(_.TEXTURE_2D,0,x,w,_.RGBA,_.UNSIGNED_BYTE,e):_.texSubImage2D(_.TEXTURE_2D,0,x,w,a,u,_.RGBA,_.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&_.generateMipmap(_.TEXTURE_2D),m.pixelStoreUnpackFlipY.setDefault(),m.pixelStoreUnpack.setDefault(),m.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(e,r,s){const{context:a}=this,{gl:u}=a;u.bindTexture(u.TEXTURE_2D,this.texture),s!==u.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=u.LINEAR),e!==this.filter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,s||e),this.filter=e),r!==this.wrap&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,r),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,r),this.wrap=r)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class If{constructor(e,r,s,a=1,u=1,h=1,m=0){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void Or(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=r.height;const _=this.dim=r.height-2;switch(this.data=new Uint32Array(r.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=a,this.greenFactor=u,this.blueFactor=h,this.baseShift=m;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let x=0;x<_;x++)this.data[this._idx(-1,x)]=this.data[this._idx(0,x)],this.data[this._idx(_,x)]=this.data[this._idx(_-1,x)],this.data[this._idx(x,-1)]=this.data[this._idx(x,0)],this.data[this._idx(x,_)]=this.data[this._idx(x,_-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(_,-1)]=this.data[this._idx(_-1,0)],this.data[this._idx(-1,_)]=this.data[this._idx(0,_-1)],this.data[this._idx(_,_)]=this.data[this._idx(_-1,_-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let x=0;x<_;x++)for(let w=0;w<_;w++){const I=this.get(x,w);I>this.max&&(this.max=I),I<this.min&&(this.min=I)}}get(e,r){const s=new Uint8Array(this.data.buffer),a=4*this._idx(e,r);return this.unpack(s[a],s[a+1],s[a+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,r){if(e<-1||e>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${r}, dim: ${this.dim}`);return(r+1)*this.stride+(e+1)}unpack(e,r,s){return e*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}pack(e){return Mf(e,this.getUnpackVector())}getPixels(){return new xi({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,s){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let a=r*this.dim,u=r*this.dim+this.dim,h=s*this.dim,m=s*this.dim+this.dim;switch(r){case-1:a=u-1;break;case 1:u=a+1}switch(s){case-1:h=m-1;break;case 1:m=h+1}const _=-r*this.dim,x=-s*this.dim;for(let w=h;w<m;w++)for(let I=a;I<u;I++)this.data[this._idx(I,w)]=e.data[this._idx(I+_,w+x)]}}function Mf(i,e){const r=e[0],s=e[1],a=e[2],u=e[3],h=Math.min(r,s,a),m=Math.round((i+u)/h);return{r:Math.floor(m*h/r)%256,g:Math.floor(m*h/s)%256,b:Math.floor(m*h/a)%256}}Ue("DEMData",If);class nb extends Ei{constructor(e,r){super(e,ib,r)}_createColorRamp(e){const r={elevationStops:[],colorStops:[]},s=this._transitionablePaint._values["color-relief-color"].value.expression;if(s instanceof va&&s._styleExpression.expression instanceof ni){this.colorRampExpression=s;const h=s._styleExpression.expression;r.elevationStops=h.labels,r.colorStops=[];for(const m of r.elevationStops)r.colorStops.push(h.evaluate({globals:{elevation:m}}))}if(r.elevationStops.length<1&&(r.elevationStops=[0],r.colorStops=[dt.transparent]),r.elevationStops.length<2&&(r.elevationStops.push(r.elevationStops[0]+1),r.colorStops.push(r.colorStops[0])),r.elevationStops.length<=e)return r;const a={elevationStops:[],colorStops:[]},u=(r.elevationStops.length-1)/(e-1);for(let h=0;h<r.elevationStops.length-.5;h+=u)a.elevationStops.push(r.elevationStops[Math.round(h)]),a.colorStops.push(r.colorStops[Math.round(h)]);return Or(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${r.elevationStops.length}`),a}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,r,s){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const a=this._createColorRamp(r),u=new xi({width:a.colorStops.length,height:1}),h=new xi({width:a.colorStops.length,height:1});for(let m=0;m<a.elevationStops.length;m++){const _=Mf(a.elevationStops[m],s);h.setPixel(0,m,new dt(_.r/255,_.g/255,_.b/255,1)),u.setPixel(0,m,a.colorStops[m])}return this.colorRampTextures={elevationTexture:new ad(e,h,e.gl.RGBA),colorTexture:new ad(e,u,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const sb=yr([{name:"a_pos",components:2,type:"Int16"}],4),{members:ob}=sb;function qu(i,e,r){const s=r.patternDependencies;let a=!1;for(const u of e){const h=u.paint.get(`${i}-pattern`);h.isConstant()||(a=!0);const m=h.constantOr(null);m&&(a=!0,s[m.to]=!0,s[m.from]=!0)}return a}function ld(i,e,r,s,a){const{zoom:u}=s,h=a.patternDependencies;for(const m of e){const _=m.paint.get(`${i}-pattern`).value;if(_.kind!=="constant"){let x=_.evaluate({zoom:u-1},r,{},a.availableImages),w=_.evaluate({zoom:u},r,{},a.availableImages),I=_.evaluate({zoom:u+1},r,{},a.availableImages);x=x&&x.name?x.name:x,w=w&&w.name?w.name:w,I=I&&I.name?I.name:I,h[x]=!0,h[w]=!0,h[I]=!0,r.patterns[m.id]={min:x,mid:w,max:I}}}return r}function Ef(i,e,r,s,a){let u;if(a===(function(h,m,_,x){let w=0;for(let I=m,C=_-x;I<_;I+=x)w+=(h[C]-h[I])*(h[I+1]+h[C+1]),C=I;return w})(i,e,r,s)>0)for(let h=e;h<r;h+=s)u=Df(h/s|0,i[h],i[h+1],u);else for(let h=r-s;h>=e;h-=s)u=Df(h/s|0,i[h],i[h+1],u);return u&&Za(u,u.next)&&(hc(u),u=u.next),u}function jo(i,e){if(!i)return i;e||(e=i);let r,s=i;do if(r=!1,s.steiner||!Za(s,s.next)&&Pr(s.prev,s,s.next)!==0)s=s.next;else{if(hc(s),s=e=s.prev,s===s.next)break;r=!0}while(r||s!==e);return e}function lc(i,e,r,s,a,u,h){if(!i)return;!h&&u&&(function(_,x,w,I){let C=_;do C.z===0&&(C.z=cd(C.x,C.y,x,w,I)),C.prevZ=C.prev,C.nextZ=C.next,C=C.next;while(C!==_);C.prevZ.nextZ=null,C.prevZ=null,(function(z){let R,F=1;do{let O,Z=z;z=null;let X=null;for(R=0;Z;){R++;let U=Z,G=0;for(let ie=0;ie<F&&(G++,U=U.nextZ,U);ie++);let J=F;for(;G>0||J>0&&U;)G!==0&&(J===0||!U||Z.z<=U.z)?(O=Z,Z=Z.nextZ,G--):(O=U,U=U.nextZ,J--),X?X.nextZ=O:z=O,O.prevZ=X,X=O;Z=U}X.nextZ=null,F*=2}while(R>1)})(C)})(i,s,a,u);let m=i;for(;i.prev!==i.next;){const _=i.prev,x=i.next;if(u?lb(i,s,a,u):ab(i))e.push(_.i,i.i,x.i),hc(i),i=x.next,m=x.next;else if((i=x)===m){h?h===1?lc(i=cb(jo(i),e),e,r,s,a,u,2):h===2&&ub(i,e,r,s,a,u):lc(jo(i),e,r,s,a,u,1);break}}}function ab(i){const e=i.prev,r=i,s=i.next;if(Pr(e,r,s)>=0)return!1;const a=e.x,u=r.x,h=s.x,m=e.y,_=r.y,x=s.y,w=Math.min(a,u,h),I=Math.min(m,_,x),C=Math.max(a,u,h),z=Math.max(m,_,x);let R=s.next;for(;R!==e;){if(R.x>=w&&R.x<=C&&R.y>=I&&R.y<=z&&cc(a,m,u,_,h,x,R.x,R.y)&&Pr(R.prev,R,R.next)>=0)return!1;R=R.next}return!0}function lb(i,e,r,s){const a=i.prev,u=i,h=i.next;if(Pr(a,u,h)>=0)return!1;const m=a.x,_=u.x,x=h.x,w=a.y,I=u.y,C=h.y,z=Math.min(m,_,x),R=Math.min(w,I,C),F=Math.max(m,_,x),O=Math.max(w,I,C),Z=cd(z,R,e,r,s),X=cd(F,O,e,r,s);let U=i.prevZ,G=i.nextZ;for(;U&&U.z>=Z&&G&&G.z<=X;){if(U.x>=z&&U.x<=F&&U.y>=R&&U.y<=O&&U!==a&&U!==h&&cc(m,w,_,I,x,C,U.x,U.y)&&Pr(U.prev,U,U.next)>=0||(U=U.prevZ,G.x>=z&&G.x<=F&&G.y>=R&&G.y<=O&&G!==a&&G!==h&&cc(m,w,_,I,x,C,G.x,G.y)&&Pr(G.prev,G,G.next)>=0))return!1;G=G.nextZ}for(;U&&U.z>=Z;){if(U.x>=z&&U.x<=F&&U.y>=R&&U.y<=O&&U!==a&&U!==h&&cc(m,w,_,I,x,C,U.x,U.y)&&Pr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;G&&G.z<=X;){if(G.x>=z&&G.x<=F&&G.y>=R&&G.y<=O&&G!==a&&G!==h&&cc(m,w,_,I,x,C,G.x,G.y)&&Pr(G.prev,G,G.next)>=0)return!1;G=G.nextZ}return!0}function cb(i,e){let r=i;do{const s=r.prev,a=r.next.next;!Za(s,a)&&Af(s,r,r.next,a)&&uc(s,a)&&uc(a,s)&&(e.push(s.i,r.i,a.i),hc(r),hc(r.next),r=i=a),r=r.next}while(r!==i);return jo(r)}function ub(i,e,r,s,a,u){let h=i;do{let m=h.next.next;for(;m!==h.prev;){if(h.i!==m.i&&mb(h,m)){let _=zf(h,m);return h=jo(h,h.next),_=jo(_,_.next),lc(h,e,r,s,a,u,0),void lc(_,e,r,s,a,u,0)}m=m.next}h=h.next}while(h!==i)}function hb(i,e){let r=i.x-e.x;return r===0&&(r=i.y-e.y,r===0)&&(r=(i.next.y-i.y)/(i.next.x-i.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function db(i,e){const r=(function(a,u){let h=u;const m=a.x,_=a.y;let x,w=-1/0;if(Za(a,h))return h;do{if(Za(a,h.next))return h.next;if(_<=h.y&&_>=h.next.y&&h.next.y!==h.y){const F=h.x+(_-h.y)*(h.next.x-h.x)/(h.next.y-h.y);if(F<=m&&F>w&&(w=F,x=h.x<h.next.x?h:h.next,F===m))return x}h=h.next}while(h!==u);if(!x)return null;const I=x,C=x.x,z=x.y;let R=1/0;h=x;do{if(m>=h.x&&h.x>=C&&m!==h.x&&Cf(_<z?m:w,_,C,z,_<z?w:m,_,h.x,h.y)){const F=Math.abs(_-h.y)/(m-h.x);uc(h,a)&&(F<R||F===R&&(h.x>x.x||h.x===x.x&&pb(x,h)))&&(x=h,R=F)}h=h.next}while(h!==I);return x})(i,e);if(!r)return e;const s=zf(r,i);return jo(s,s.next),jo(r,r.next)}function pb(i,e){return Pr(i.prev,i,e.prev)<0&&Pr(e.next,i,i.next)<0}function cd(i,e,r,s,a){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*a|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*a|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function fb(i){let e=i,r=i;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==i);return r}function Cf(i,e,r,s,a,u,h,m){return(a-h)*(e-m)>=(i-h)*(u-m)&&(i-h)*(s-m)>=(r-h)*(e-m)&&(r-h)*(u-m)>=(a-h)*(s-m)}function cc(i,e,r,s,a,u,h,m){return!(i===h&&e===m)&&Cf(i,e,r,s,a,u,h,m)}function mb(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!(function(r,s){let a=r;do{if(a.i!==r.i&&a.next.i!==r.i&&a.i!==s.i&&a.next.i!==s.i&&Af(a,a.next,r,s))return!0;a=a.next}while(a!==r);return!1})(i,e)&&(uc(i,e)&&uc(e,i)&&(function(r,s){let a=r,u=!1;const h=(r.x+s.x)/2,m=(r.y+s.y)/2;do a.y>m!=a.next.y>m&&a.next.y!==a.y&&h<(a.next.x-a.x)*(m-a.y)/(a.next.y-a.y)+a.x&&(u=!u),a=a.next;while(a!==r);return u})(i,e)&&(Pr(i.prev,i,e.prev)||Pr(i,e.prev,e))||Za(i,e)&&Pr(i.prev,i,i.next)>0&&Pr(e.prev,e,e.next)>0)}function Pr(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function Za(i,e){return i.x===e.x&&i.y===e.y}function Af(i,e,r,s){const a=Hu(Pr(i,e,r)),u=Hu(Pr(i,e,s)),h=Hu(Pr(r,s,i)),m=Hu(Pr(r,s,e));return a!==u&&h!==m||!(a!==0||!Wu(i,r,e))||!(u!==0||!Wu(i,s,e))||!(h!==0||!Wu(r,i,s))||!(m!==0||!Wu(r,e,s))}function Wu(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function Hu(i){return i>0?1:i<0?-1:0}function uc(i,e){return Pr(i.prev,i,i.next)<0?Pr(i,e,i.next)>=0&&Pr(i,i.prev,e)>=0:Pr(i,e,i.prev)<0||Pr(i,i.next,e)<0}function zf(i,e){const r=ud(i.i,i.x,i.y),s=ud(e.i,e.x,e.y),a=i.next,u=e.prev;return i.next=e,e.prev=i,r.next=a,a.prev=r,s.next=r,r.prev=s,u.next=s,s.prev=u,s}function Df(i,e,r,s){const a=ud(i,e,r);return s?(a.next=s.next,a.prev=s,s.next.prev=a,s.next=a):(a.prev=a,a.next=a),a}function hc(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ud(i,e,r){return{i,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Ua{constructor(e,r){if(r>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=r}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class Xu{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}Xu.noSubdivision=new Xu({fill:new Ua(0,0),line:new Ua(0,0),tile:new Ua(0,0),stencil:new Ua(0,0),circle:1}),Ue("SubdivisionGranularityExpression",Ua),Ue("SubdivisionGranularitySetting",Xu);const Ga=-32768,dc=32767;class gb{constructor(e,r){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=Tt/e,this._canonical=r}_getKey(e,r){return(e+=32768)<<16|r+32768}_vertexToIndex(e,r){if(e<-32768||r<-32768||e>32767||r>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const s=0|Math.round(e),a=0|Math.round(r),u=this._getKey(s,a);if(this._vertexDictionary.has(u))return this._vertexDictionary.get(u);const h=this._vertexBuffer.length/2;return this._vertexDictionary.set(u,h),this._vertexBuffer.push(s,a),h}_subdivideTrianglesScanline(e){if(this._granularity<2)return(function(a,u){const h=[];for(let m=0;m<u.length;m+=3){const _=u[m],x=u[m+1],w=u[m+2],I=a[2*_],C=a[2*_+1];(a[2*x]-I)*(a[2*w+1]-C)-(a[2*x+1]-C)*(a[2*w]-I)>0?(h.push(_),h.push(w),h.push(x)):(h.push(_),h.push(x),h.push(w))}return h})(this._vertexBuffer,e);const r=[],s=e.length;for(let a=0;a<s;a+=3){const u=[e[a+0],e[a+1],e[a+2]],h=[this._vertexBuffer[2*e[a+0]+0],this._vertexBuffer[2*e[a+0]+1],this._vertexBuffer[2*e[a+1]+0],this._vertexBuffer[2*e[a+1]+1],this._vertexBuffer[2*e[a+2]+0],this._vertexBuffer[2*e[a+2]+1]];let m=1/0,_=1/0,x=-1/0,w=-1/0;for(let F=0;F<3;F++){const O=h[2*F],Z=h[2*F+1];m=Math.min(m,O),x=Math.max(x,O),_=Math.min(_,Z),w=Math.max(w,Z)}if(m===x||_===w)continue;const I=Math.floor(m/this._granularityCellSize),C=Math.ceil(x/this._granularityCellSize),z=Math.floor(_/this._granularityCellSize),R=Math.ceil(w/this._granularityCellSize);if(I!==C||z!==R)for(let F=z;F<R;F++){const O=this._scanlineGenerateVertexRingForCellRow(F,h,u);_b(this._vertexBuffer,O,r)}else r.push(...u)}return r}_scanlineGenerateVertexRingForCellRow(e,r,s){const a=e*this._granularityCellSize,u=a+this._granularityCellSize,h=[];for(let m=0;m<3;m++){const _=r[2*m],x=r[2*m+1],w=r[2*(m+1)%6],I=r[(2*(m+1)+1)%6],C=r[2*(m+2)%6],z=r[(2*(m+2)+1)%6],R=w-_,F=I-x,O=R===0,Z=F===0,X=(a-x)/F,U=(u-x)/F,G=Math.min(X,U),J=Math.max(X,U);if(!Z&&(G>=1||J<=0)||Z&&(x<a||x>u)){I>=a&&I<=u&&h.push(s[(m+1)%3]);continue}!Z&&G>0&&h.push(this._vertexToIndex(_+R*G,x+F*G));const ie=_+R*Math.max(G,0),fe=_+R*Math.min(J,1);O||this._generateIntraEdgeVertices(h,_,x,w,I,ie,fe),!Z&&J<1&&h.push(this._vertexToIndex(_+R*J,x+F*J)),(Z||I>=a&&I<=u)&&h.push(s[(m+1)%3]),!Z&&(I<=a||I>=u)&&this._generateInterEdgeVertices(h,_,x,w,I,C,z,fe,a,u)}return h}_generateIntraEdgeVertices(e,r,s,a,u,h,m){const _=a-r,x=u-s,w=x===0,I=w?Math.min(r,a):Math.min(h,m),C=w?Math.max(r,a):Math.max(h,m),z=Math.floor(I/this._granularityCellSize)+1,R=Math.ceil(C/this._granularityCellSize)-1;if(w?r<a:h<m)for(let F=z;F<=R;F++){const O=F*this._granularityCellSize;e.push(this._vertexToIndex(O,s+x*(O-r)/_))}else for(let F=R;F>=z;F--){const O=F*this._granularityCellSize;e.push(this._vertexToIndex(O,s+x*(O-r)/_))}}_generateInterEdgeVertices(e,r,s,a,u,h,m,_,x,w){const I=u-s,C=h-a,z=m-u,R=(x-u)/z,F=(w-u)/z,O=Math.min(R,F),Z=Math.max(R,F),X=a+C*O;let U=Math.floor(Math.min(X,_)/this._granularityCellSize)+1,G=Math.ceil(Math.max(X,_)/this._granularityCellSize)-1,J=_<X;const ie=z===0;if(ie&&(m===x||m===w))return;if(ie||O>=1||Z<=0){const Pe=s-m,Te=h+(r-h)*Math.min((x-m)/Pe,(w-m)/Pe);U=Math.floor(Math.min(Te,_)/this._granularityCellSize)+1,G=Math.ceil(Math.max(Te,_)/this._granularityCellSize)-1,J=_<Te}const fe=I>0?w:x;if(J)for(let Pe=U;Pe<=G;Pe++)e.push(this._vertexToIndex(Pe*this._granularityCellSize,fe));else for(let Pe=G;Pe>=U;Pe--)e.push(this._vertexToIndex(Pe*this._granularityCellSize,fe))}_generateOutline(e){const r=[];for(const s of e){const a=No(s,this._granularity,!0),u=this._pointArrayToIndices(a),h=[];for(let m=1;m<u.length;m++)h.push(u[m-1]),h.push(u[m]);r.push(h)}return r}_handlePoles(e){let r=!1,s=!1;this._canonical&&(this._canonical.y===0&&(r=!0),this._canonical.y===(1<<this._canonical.z)-1&&(s=!0)),(r||s)&&this._fillPoles(e,r,s)}_ensureNoPoleVertices(){const e=this._vertexBuffer;for(let r=0;r<e.length;r+=2){const s=e[r+1];s===Ga&&(e[r+1]=-32767),s===dc&&(e[r+1]=32766)}}_generatePoleQuad(e,r,s,a,u,h){a>u!=(h===Ga)?(e.push(r),e.push(s),e.push(this._vertexToIndex(a,h)),e.push(s),e.push(this._vertexToIndex(u,h)),e.push(this._vertexToIndex(a,h))):(e.push(s),e.push(r),e.push(this._vertexToIndex(a,h)),e.push(this._vertexToIndex(u,h)),e.push(s),e.push(this._vertexToIndex(a,h)))}_fillPoles(e,r,s){const a=this._vertexBuffer,u=Tt,h=e.length;for(let m=2;m<h;m+=3){const _=e[m-2],x=e[m-1],w=e[m],I=a[2*_],C=a[2*_+1],z=a[2*x],R=a[2*x+1],F=a[2*w],O=a[2*w+1];r&&(C===0&&R===0&&this._generatePoleQuad(e,_,x,I,z,Ga),R===0&&O===0&&this._generatePoleQuad(e,x,w,z,F,Ga),O===0&&C===0&&this._generatePoleQuad(e,w,_,F,I,Ga)),s&&(C===u&&R===u&&this._generatePoleQuad(e,_,x,I,z,dc),R===u&&O===u&&this._generatePoleQuad(e,x,w,z,F,dc),O===u&&C===u&&this._generatePoleQuad(e,w,_,F,I,dc))}}_initializeVertices(e){for(let r=0;r<e.length;r+=2)this._vertexToIndex(e[r],e[r+1])}subdividePolygonInternal(e,r){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:s,holeIndices:a}=(function(m){const _=[],x=[];for(const w of m)if(w.length!==0){w!==m[0]&&_.push(x.length/2);for(let I=0;I<w.length;I++)x.push(w[I].x),x.push(w[I].y)}return{flattened:x,holeIndices:_}})(e);let u;this._initializeVertices(s);try{const m=(function(x,w,I=2){const C=w&&w.length,z=C?w[0]*I:x.length;let R=Ef(x,0,z,I,!0);const F=[];if(!R||R.next===R.prev)return F;let O,Z,X;if(C&&(R=(function(U,G,J,ie){const fe=[];for(let Pe=0,Te=G.length;Pe<Te;Pe++){const Ie=Ef(U,G[Pe]*ie,Pe<Te-1?G[Pe+1]*ie:U.length,ie,!1);Ie===Ie.next&&(Ie.steiner=!0),fe.push(fb(Ie))}fe.sort(hb);for(let Pe=0;Pe<fe.length;Pe++)J=db(fe[Pe],J);return J})(x,w,R,I)),x.length>80*I){O=x[0],Z=x[1];let U=O,G=Z;for(let J=I;J<z;J+=I){const ie=x[J],fe=x[J+1];ie<O&&(O=ie),fe<Z&&(Z=fe),ie>U&&(U=ie),fe>G&&(G=fe)}X=Math.max(U-O,G-Z),X=X!==0?32767/X:0}return lc(R,F,I,O,Z,X,0),F})(s,a),_=this._convertIndices(s,m);u=this._subdivideTrianglesScanline(_)}catch(m){console.error(m)}let h=[];return r&&(h=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(u),{verticesFlattened:this._vertexBuffer,indicesTriangles:u,indicesLineList:h}}_convertIndices(e,r){const s=[];for(let a=0;a<r.length;a++)s.push(this._vertexToIndex(e[2*r[a]],e[2*r[a]+1]));return s}_pointArrayToIndices(e){const r=[];for(let s=0;s<e.length;s++){const a=e[s];r.push(this._vertexToIndex(a.x,a.y))}return r}}function kf(i,e,r,s=!0){return new gb(r,e).subdividePolygonInternal(i,s)}function No(i,e,r=!1){if(!i||i.length<1)return[];if(i.length<2)return[];const s=i[0],a=i[i.length-1],u=r&&(s.x!==a.x||s.y!==a.y);if(e<2)return u?[...i,i[0]]:[...i];const h=Math.floor(Tt/e),m=[];m.push(new ne(i[0].x,i[0].y));const _=i.length,x=u?_:_-1;for(let w=0;w<x;w++){const I=i[w],C=w<_-1?i[w+1]:i[0],z=I.x,R=I.y,F=C.x,O=C.y,Z=z!==F,X=R!==O;if(!Z&&!X)continue;const U=F-z,G=O-R,J=Math.abs(U),ie=Math.abs(G);let fe=z,Pe=R;for(;;){const Ie=U>0?(Math.floor(fe/h)+1)*h:(Math.ceil(fe/h)-1)*h,Oe=G>0?(Math.floor(Pe/h)+1)*h:(Math.ceil(Pe/h)-1)*h,ze=Math.abs(fe-Ie),we=Math.abs(Pe-Oe),xe=Math.abs(fe-F),$e=Math.abs(Pe-O),Ne=Z?ze/J:Number.POSITIVE_INFINITY,Ge=X?we/ie:Number.POSITIVE_INFINITY;if((xe<=ze||!Z)&&($e<=we||!X))break;if(Ne<Ge&&Z||!X){fe=Ie,Pe+=G*Ne;const Ve=new ne(fe,Math.round(Pe));m[m.length-1].x===Ve.x&&m[m.length-1].y===Ve.y||m.push(Ve)}else{fe+=U*Ge,Pe=Oe;const Ve=new ne(Math.round(fe),Pe);m[m.length-1].x===Ve.x&&m[m.length-1].y===Ve.y||m.push(Ve)}}const Te=new ne(F,O);m[m.length-1].x===Te.x&&m[m.length-1].y===Te.y||m.push(Te)}return m}function _b(i,e,r){if(e.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,a=i[2*e[0]];for(let _=1;_<e.length;_++){const x=i[2*e[_]];x<a&&(a=x,s=_)}const u=e.length;let h=s,m=(h+1)%u;for(;;){const _=h-1>=0?h-1:u-1,x=(m+1)%u,w=i[2*e[_]],I=i[2*e[x]],C=i[2*e[h]],z=i[2*e[h]+1],R=i[2*e[m]+1];let F=!1;if(w<I)F=!0;else if(w>I)F=!1;else{const O=R-z,Z=-(i[2*e[m]]-C),X=z<R?1:-1;((w-C)*O+(i[2*e[_]+1]-z)*Z)*X>((I-C)*O+(i[2*e[x]+1]-z)*Z)*X&&(F=!0)}if(F){const O=e[_],Z=e[h],X=e[m];O!==Z&&O!==X&&Z!==X&&r.push(X,Z,O),h--,h<0&&(h=u-1)}else{const O=e[x],Z=e[h],X=e[m];O!==Z&&O!==X&&Z!==X&&r.push(X,Z,O),m++,m>=u&&(m=0)}if(_===x)break}}function Rf(i,e,r,s,a,u,h,m,_){const x=a.length/2,w=h&&m&&_;if(x<je.MAX_VERTEX_ARRAY_LENGTH){const I=e.prepareSegment(x,r,s),C=I.vertexLength;for(let F=0;F<u.length;F+=3)s.emplaceBack(C+u[F],C+u[F+1],C+u[F+2]);let z,R;I.vertexLength+=x,I.primitiveLength+=u.length/3,w&&(R=h.prepareSegment(x,r,m),z=R.vertexLength,R.vertexLength+=x);for(let F=0;F<a.length;F+=2)i(a[F],a[F+1]);if(w)for(let F=0;F<_.length;F++){const O=_[F];for(let Z=1;Z<O.length;Z+=2)m.emplaceBack(z+O[Z-1],z+O[Z]);R.primitiveLength+=O.length/2}}else(function(I,C,z,R,F,O){const Z=[];for(let ie=0;ie<R.length/2;ie++)Z.push(-1);const X={count:0};let U=0,G=I.getOrCreateLatestSegment(C,z),J=G.vertexLength;for(let ie=2;ie<F.length;ie+=3){const fe=F[ie-2],Pe=F[ie-1],Te=F[ie];let Ie=Z[fe]<U,Oe=Z[Pe]<U,ze=Z[Te]<U;G.vertexLength+((Ie?1:0)+(Oe?1:0)+(ze?1:0))>je.MAX_VERTEX_ARRAY_LENGTH&&(G=I.createNewSegment(C,z),U=X.count,Ie=!0,Oe=!0,ze=!0,J=0);const we=pc(Z,R,O,X,fe,Ie,G),xe=pc(Z,R,O,X,Pe,Oe,G),$e=pc(Z,R,O,X,Te,ze,G);z.emplaceBack(J+we-U,J+xe-U,J+$e-U),G.primitiveLength++}})(e,r,s,a,u,i),w&&(function(I,C,z,R,F,O){const Z=[];for(let ie=0;ie<R.length/2;ie++)Z.push(-1);const X={count:0};let U=0,G=I.getOrCreateLatestSegment(C,z),J=G.vertexLength;for(let ie=0;ie<F.length;ie++){const fe=F[ie];for(let Pe=1;Pe<F[ie].length;Pe+=2){const Te=fe[Pe-1],Ie=fe[Pe];let Oe=Z[Te]<U,ze=Z[Ie]<U;G.vertexLength+((Oe?1:0)+(ze?1:0))>je.MAX_VERTEX_ARRAY_LENGTH&&(G=I.createNewSegment(C,z),U=X.count,Oe=!0,ze=!0,J=0);const we=pc(Z,R,O,X,Te,Oe,G),xe=pc(Z,R,O,X,Ie,ze,G);z.emplaceBack(J+we-U,J+xe-U),G.primitiveLength++}}})(h,r,m,a,_,i),e.forceNewSegmentOnNextPrepare(),h?.forceNewSegmentOnNextPrepare()}function pc(i,e,r,s,a,u,h){if(u){const m=s.count;return r(e[2*a],e[2*a+1]),i[a]=s.count,s.count++,h.vertexLength++,m}return i[a]}class hd{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new W,this.indexArray=new ye,this.indexArray2=new Re,this.programConfigurations=new rs(e.layers,e.zoom),this.segments=new je,this.segments2=new je,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,s){this.hasDependencies=qu("fill",this.layers,r);const a=this.layers[0].layout.get("fill-sort-key"),u=!a.isConstant(),h=[];for(const{feature:m,id:_,index:x,sourceLayerIndex:w}of e){const I=this.layers[0]._featureFilter.needGeometry,C=An(m,I);if(!this.layers[0]._featureFilter.filter(new Dt(this.zoom),C,s))continue;const z=u?a.evaluate(C,{},s,r.availableImages):void 0,R={id:_,properties:m.properties,type:m.type,sourceLayerIndex:w,index:x,geometry:I?C.geometry:Cn(m),patterns:{},sortKey:z};h.push(R)}u&&h.sort(((m,_)=>m.sortKey-_.sortKey));for(const m of h){const{geometry:_,index:x,sourceLayerIndex:w}=m;if(this.hasDependencies){const I=ld("fill",this.layers,m,{zoom:this.zoom},r);this.patternFeatures.push(I)}else this.addFeature(m,_,x,s,{},r.subdivisionGranularity);r.featureIndex.insert(e[x].feature,_,x,w,this.index)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:s})}addFeatures(e,r,s){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,r,s,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ob),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,s,a,u,h){for(const m of la(r,500)){const _=kf(m,a,h.fill.getGranularityForZoomLevel(a.z)),x=this.layoutVertexArray;Rf(((w,I)=>{x.emplaceBack(w,I)}),this.segments,this.layoutVertexArray,this.indexArray,_.verticesFlattened,_.indicesTriangles,this.segments2,this.indexArray2,_.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:u,canonical:a})}}let Ff,Lf;Ue("FillBucket",hd,{omit:["layers","patternFeatures"]});var yb={get paint(){return Lf=Lf||new si({"fill-antialias":new Xe(le.paint_fill["fill-antialias"]),"fill-opacity":new et(le.paint_fill["fill-opacity"]),"fill-color":new et(le.paint_fill["fill-color"]),"fill-outline-color":new et(le.paint_fill["fill-outline-color"]),"fill-translate":new Xe(le.paint_fill["fill-translate"]),"fill-translate-anchor":new Xe(le.paint_fill["fill-translate-anchor"]),"fill-pattern":new zo(le.paint_fill["fill-pattern"])})},get layout(){return Ff=Ff||new si({"fill-sort-key":new et(le.layout_fill["fill-sort-key"])})}};class vb extends Ei{constructor(e,r){super(e,yb,r)}recalculate(e,r){super.recalculate(e,r);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new hd(e)}queryRadius(){return Uu(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:r,transform:s,pixelsToTileUnits:a}){return ff(Gu(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,a),r)}isTileClipped(){return!0}}const xb=yr([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),bb=yr([{name:"a_centroid",components:2,type:"Int16"}],4),{members:wb}=xb;class fc{constructor(e,r,s,a,u){this.properties={},this.extent=s,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=a,this._values=u,e.readFields(Tb,this,r)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const r=e.readVarint()+e.pos,s=[];let a,u=1,h=0,m=0,_=0;for(;e.pos<r;){if(h<=0){const x=e.readVarint();u=7&x,h=x>>3}if(h--,u===1||u===2)m+=e.readSVarint(),_+=e.readSVarint(),u===1&&(a&&s.push(a),a=[]),a&&a.push(new ne(m,_));else{if(u!==7)throw new Error(`unknown command ${u}`);a&&a.push(a[0].clone())}}return a&&s.push(a),s}bbox(){const e=this._pbf;e.pos=this._geometry;const r=e.readVarint()+e.pos;let s=1,a=0,u=0,h=0,m=1/0,_=-1/0,x=1/0,w=-1/0;for(;e.pos<r;){if(a<=0){const I=e.readVarint();s=7&I,a=I>>3}if(a--,s===1||s===2)u+=e.readSVarint(),h+=e.readSVarint(),u<m&&(m=u),u>_&&(_=u),h<x&&(x=h),h>w&&(w=h);else if(s!==7)throw new Error(`unknown command ${s}`)}return[m,x,_,w]}toGeoJSON(e,r,s){const a=this.extent*Math.pow(2,s),u=this.extent*e,h=this.extent*r,m=this.loadGeometry();function _(C){return[360*(C.x+u)/a-180,360/Math.PI*Math.atan(Math.exp((1-2*(C.y+h)/a)*Math.PI))-90]}function x(C){return C.map(_)}let w;if(this.type===1){const C=[];for(const R of m)C.push(R[0]);const z=x(C);w=C.length===1?{type:"Point",coordinates:z[0]}:{type:"MultiPoint",coordinates:z}}else if(this.type===2){const C=m.map(x);w=C.length===1?{type:"LineString",coordinates:C[0]}:{type:"MultiLineString",coordinates:C}}else{if(this.type!==3)throw new Error("unknown feature type");{const C=Of(m),z=[];for(const R of C)z.push(R.map(x));w=z.length===1?{type:"Polygon",coordinates:z[0]}:{type:"MultiPolygon",coordinates:z}}}const I={type:"Feature",geometry:w,properties:this.properties};return this.id!=null&&(I.id=this.id),I}}function Tb(i,e,r){i===1?e.id=r.readVarint():i===2?(function(s,a){const u=s.readVarint()+s.pos;for(;s.pos<u;){const h=a._keys[s.readVarint()],m=a._values[s.readVarint()];a.properties[h]=m}})(r,e):i===3?e.type=r.readVarint():i===4&&(e._geometry=r.pos)}function Of(i){const e=i.length;if(e<=1)return[i];const r=[];let s,a;for(let u=0;u<e;u++){const h=Sb(i[u]);h!==0&&(a===void 0&&(a=h<0),a===h<0?(s&&r.push(s),s=[i[u]]):s&&s.push(i[u]))}return s&&r.push(s),r}function Sb(i){let e=0;for(let r,s,a=0,u=i.length,h=u-1;a<u;h=a++)r=i[a],s=i[h],e+=(s.x-r.x)*(r.y+s.y);return e}fc.types=["Unknown","Point","LineString","Polygon"];class Pb{constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Ib,this,r),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const r=this._pbf.readVarint()+this._pbf.pos;return new fc(this._pbf,r,this.extent,this._keys,this._values)}}function Ib(i,e,r){i===15?e.version=r.readVarint():i===1?e.name=r.readString():i===5?e.extent=r.readVarint():i===2?e._features.push(r.pos):i===3?e._keys.push(r.readString()):i===4&&e._values.push((function(s){let a=null;const u=s.readVarint()+s.pos;for(;s.pos<u;){const h=s.readVarint()>>3;a=h===1?s.readString():h===2?s.readFloat():h===3?s.readDouble():h===4?s.readVarint64():h===5?s.readVarint():h===6?s.readSVarint():h===7?s.readBoolean():null}if(a==null)throw new Error("unknown feature value");return a})(r))}class Bf{constructor(e,r){this.layers=e.readFields(Mb,{},r)}}function Mb(i,e,r){if(i===3){const s=new Pb(r,r.readVarint()+r.pos);s.length&&(e[s.name]=s)}}const dd=Math.pow(2,13);function mc(i,e,r,s,a,u,h,m){i.emplaceBack(e,r,2*Math.floor(s*dd)+h,a*dd*2,u*dd*2,Math.round(m))}class pd{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new K,this.centroidVertexArray=new q,this.indexArray=new ye,this.programConfigurations=new rs(e.layers,e.zoom),this.segments=new je,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,s){this.features=[],this.hasDependencies=qu("fill-extrusion",this.layers,r);for(const{feature:a,id:u,index:h,sourceLayerIndex:m}of e){const _=this.layers[0]._featureFilter.needGeometry,x=An(a,_);if(!this.layers[0]._featureFilter.filter(new Dt(this.zoom),x,s))continue;const w={id:u,sourceLayerIndex:m,index:h,geometry:_?x.geometry:Cn(a),properties:a.properties,type:a.type,patterns:{}};this.hasDependencies?this.features.push(ld("fill-extrusion",this.layers,w,{zoom:this.zoom},r)):this.addFeature(w,w.geometry,h,s,{},r.subdivisionGranularity),r.featureIndex.insert(a,w.geometry,h,m,this.index,!0)}}addFeatures(e,r,s){for(const a of this.features){const{geometry:u}=a;this.addFeature(a,u,a.index,r,s,e.subdivisionGranularity)}}update(e,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:s})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wb),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,bb.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,s,a,u,h){for(const m of la(r,500)){const _={x:0,y:0,sampleCount:0},x=this.layoutVertexArray.length;this.processPolygon(_,a,e,m,h);const w=this.layoutVertexArray.length-x,I=Math.floor(_.x/_.sampleCount),C=Math.floor(_.y/_.sampleCount);for(let z=0;z<w;z++)this.centroidVertexArray.emplaceBack(I,C)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:u,canonical:a})}processPolygon(e,r,s,a,u){if(a.length<1||jf(a[0]))return;for(const I of a)I.length!==0&&Eb(e,I);const h={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},m=u.fill.getGranularityForZoomLevel(r.z),_=fc.types[s.type]==="Polygon";for(const I of a){if(I.length===0||jf(I))continue;const C=No(I,m,_);this._generateSideFaces(C,h)}if(!_)return;const x=kf(a,r,m,!1),w=this.layoutVertexArray;Rf(((I,C)=>{mc(w,I,C,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,x.verticesFlattened,x.indicesTriangles)}_generateSideFaces(e,r){let s=0;for(let a=1;a<e.length;a++){const u=e[a],h=e[a-1];if(Cb(u,h))continue;r.segment.vertexLength+4>je.MAX_VERTEX_ARRAY_LENGTH&&(r.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const m=u.sub(h)._perp()._unit(),_=h.dist(u);s+_>32768&&(s=0),mc(this.layoutVertexArray,u.x,u.y,m.x,m.y,0,0,s),mc(this.layoutVertexArray,u.x,u.y,m.x,m.y,0,1,s),s+=_,mc(this.layoutVertexArray,h.x,h.y,m.x,m.y,0,0,s),mc(this.layoutVertexArray,h.x,h.y,m.x,m.y,0,1,s);const x=r.segment.vertexLength;this.indexArray.emplaceBack(x,x+2,x+1),this.indexArray.emplaceBack(x+1,x+2,x+3),r.segment.vertexLength+=4,r.segment.primitiveLength+=2}}}function Eb(i,e){for(let r=0;r<e.length;r++){const s=e[r];r===e.length-1&&e[0].x===s.x&&e[0].y===s.y||(i.x+=s.x,i.y+=s.y,i.sampleCount++)}}function Cb(i,e){return i.x===e.x&&(i.x<0||i.x>Tt)||i.y===e.y&&(i.y<0||i.y>Tt)}function jf(i){return i.every((e=>e.x<0))||i.every((e=>e.x>Tt))||i.every((e=>e.y<0))||i.every((e=>e.y>Tt))}let Nf;Ue("FillExtrusionBucket",pd,{omit:["layers","features"]});var Ab={get paint(){return Nf=Nf||new si({"fill-extrusion-opacity":new Xe(le["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new et(le["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Xe(le["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Xe(le["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new zo(le["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new et(le["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new et(le["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Xe(le["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class zb extends Ei{constructor(e,r){super(e,Ab,r)}createBucket(e){return new pd(e)}queryRadius(){return Uu(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:s,geometry:a,transform:u,pixelsToTileUnits:h,pixelPosMatrix:m}){const _=Gu(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-u.bearingInRadians,h),x=this.paint.get("fill-extrusion-height").evaluate(r,s),w=this.paint.get("fill-extrusion-base").evaluate(r,s),I=(function(z,R){const F=[];for(const O of z){const Z=[O.x,O.y,0,1];kn(Z,Z,R),F.push(new ne(Z[0]/Z[3],Z[1]/Z[3]))}return F})(_,m),C=(function(z,R,F,O){const Z=[],X=[],U=O[8]*R,G=O[9]*R,J=O[10]*R,ie=O[11]*R,fe=O[8]*F,Pe=O[9]*F,Te=O[10]*F,Ie=O[11]*F;for(const Oe of z){const ze=[],we=[];for(const xe of Oe){const $e=xe.x,Ne=xe.y,Ge=O[0]*$e+O[4]*Ne+O[12],Ve=O[1]*$e+O[5]*Ne+O[13],Ye=O[2]*$e+O[6]*Ne+O[14],xt=O[3]*$e+O[7]*Ne+O[15],gt=Ye+J,Kt=xt+ie,Jr=Ge+fe,Er=Ve+Pe,Jt=Ye+Te,Wt=xt+Ie,Pt=new ne((Ge+U)/Kt,(Ve+G)/Kt);Pt.z=gt/Kt,ze.push(Pt);const hr=new ne(Jr/Wt,Er/Wt);hr.z=Jt/Wt,we.push(hr)}Z.push(ze),X.push(we)}return[Z,X]})(a,w,x,m);return(function(z,R,F){let O=1/0;ff(F,R)&&(O=Vf(F,R[0]));for(let Z=0;Z<R.length;Z++){const X=R[Z],U=z[Z];for(let G=0;G<X.length-1;G++){const J=X[G],ie=[J,X[G+1],U[G+1],U[G],J];Na(F,ie)&&(O=Math.min(O,Vf(F,ie)))}}return O!==1/0&&O})(C[0],C[1],I)}}function gc(i,e){return i.x*e.x+i.y*e.y}function Vf(i,e){if(i.length===1){let r=0;const s=e[r++];let a;for(;!a||s.equals(a);)if(a=e[r++],!a)return 1/0;for(;r<e.length;r++){const u=e[r],h=i[0],m=a.sub(s),_=u.sub(s),x=h.sub(s),w=gc(m,m),I=gc(m,_),C=gc(_,_),z=gc(x,m),R=gc(x,_),F=w*C-I*I,O=(C*z-I*R)/F,Z=(w*R-I*z)/F,X=s.z*(1-O-Z)+a.z*O+u.z*Z;if(isFinite(X))return X}return 1/0}{let r=1/0;for(const s of e)r=Math.min(r,s.z);return r}}const Db=yr([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:kb}=Db,Rb=yr([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Fb}=Rb,Lb=Math.cos(Math.PI/180*37.5),$f=Math.pow(2,14)/.5;class fd{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((r=>r.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((r=>{this.gradients[r.id]={}})),this.layoutVertexArray=new re,this.layoutVertexArray2=new Y,this.indexArray=new ye,this.programConfigurations=new rs(e.layers,e.zoom),this.segments=new je,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((r=>r.isStateDependent())).map((r=>r.id))}populate(e,r,s){this.hasDependencies=qu("line",this.layers,r)||this.hasLineDasharray(this.layers);const a=this.layers[0].layout.get("line-sort-key"),u=!a.isConstant(),h=[];for(const{feature:m,id:_,index:x,sourceLayerIndex:w}of e){const I=this.layers[0]._featureFilter.needGeometry,C=An(m,I);if(!this.layers[0]._featureFilter.filter(new Dt(this.zoom),C,s))continue;const z=u?a.evaluate(C,{},s):void 0,R={id:_,properties:m.properties,type:m.type,sourceLayerIndex:w,index:x,geometry:I?C.geometry:Cn(m),patterns:{},dashes:{},sortKey:z};h.push(R)}u&&h.sort(((m,_)=>m.sortKey-_.sortKey));for(const m of h){const{geometry:_,index:x,sourceLayerIndex:w}=m;this.hasDependencies?(qu("line",this.layers,r)?ld("line",this.layers,m,{zoom:this.zoom},r):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,m,this.zoom,r),this.patternFeatures.push(m)):this.addFeature(m,_,x,s,{},{},r.subdivisionGranularity),r.featureIndex.insert(e[x].feature,_,x,w,this.index)}}update(e,r,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,{imagePositions:s,dashPositions:a})}addFeatures(e,r,s,a){for(const u of this.patternFeatures)this.addFeature(u,u.geometry,u.index,r,s,a,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Fb)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,kb),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,s,a,u,h,m){const _=this.layers[0].layout,x=_.get("line-join").evaluate(e,{}),w=_.get("line-cap"),I=_.get("line-miter-limit"),C=_.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const z of r)this.addLine(z,e,x,w,I,C,a,m);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:u,dashPositions:h,canonical:a})}addLine(e,r,s,a,u,h,m,_){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=No(e,m?_.line.getGranularityForZoomLevel(m.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let U=0;U<e.length-1;U++)this.totalDistance+=e[U].dist(e[U+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const x=fc.types[r.type]==="Polygon";let w=e.length;for(;w>=2&&e[w-1].equals(e[w-2]);)w--;let I=0;for(;I<w-1&&e[I].equals(e[I+1]);)I++;if(w<(x?3:2))return;s==="bevel"&&(u=1.05);const C=this.overscaling<=16?122880/(512*this.overscaling):0,z=this.segments.prepareSegment(10*w,this.layoutVertexArray,this.indexArray);let R,F,O,Z,X;this.e1=this.e2=-1,x&&(R=e[w-2],X=e[I].sub(R)._unit()._perp());for(let U=I;U<w;U++){if(O=U===w-1?x?e[I+1]:void 0:e[U+1],O&&e[U].equals(O))continue;X&&(Z=X),R&&(F=R),R=e[U],X=O?O.sub(R)._unit()._perp():Z,Z=Z||X;let G=Z.add(X);G.x===0&&G.y===0||G._unit();const J=Z.x*X.x+Z.y*X.y,ie=G.x*X.x+G.y*X.y,fe=ie!==0?1/ie:1/0,Pe=2*Math.sqrt(2-2*ie),Te=ie<Lb&&F&&O,Ie=Z.x*X.y-Z.y*X.x>0;if(Te&&U>I){const we=R.dist(F);if(we>2*C){const xe=R.sub(R.sub(F)._mult(C/we)._round());this.updateDistance(F,xe),this.addCurrentVertex(xe,Z,0,0,z),F=xe}}const Oe=F&&O;let ze=Oe?s:x?"butt":a;if(Oe&&ze==="round"&&(fe<h?ze="miter":fe<=2&&(ze="fakeround")),ze==="miter"&&fe>u&&(ze="bevel"),ze==="bevel"&&(fe>2&&(ze="flipbevel"),fe<u&&(ze="miter")),F&&this.updateDistance(F,R),ze==="miter")G._mult(fe),this.addCurrentVertex(R,G,0,0,z);else if(ze==="flipbevel"){if(fe>100)G=X.mult(-1);else{const we=fe*Z.add(X).mag()/Z.sub(X).mag();G._perp()._mult(we*(Ie?-1:1))}this.addCurrentVertex(R,G,0,0,z),this.addCurrentVertex(R,G.mult(-1),0,0,z)}else if(ze==="bevel"||ze==="fakeround"){const we=-Math.sqrt(fe*fe-1),xe=Ie?we:0,$e=Ie?0:we;if(F&&this.addCurrentVertex(R,Z,xe,$e,z),ze==="fakeround"){const Ne=Math.round(180*Pe/Math.PI/20);for(let Ge=1;Ge<Ne;Ge++){let Ve=Ge/Ne;if(Ve!==.5){const xt=Ve-.5;Ve+=Ve*xt*(Ve-1)*((1.0904+J*(J*(3.55645-1.43519*J)-3.2452))*xt*xt+(.848013+J*(.215638*J-1.06021)))}const Ye=X.sub(Z)._mult(Ve)._add(Z)._unit()._mult(Ie?-1:1);this.addHalfVertex(R,Ye.x,Ye.y,!1,Ie,0,z)}}O&&this.addCurrentVertex(R,X,-xe,-$e,z)}else if(ze==="butt")this.addCurrentVertex(R,G,0,0,z);else if(ze==="square"){const we=F?1:-1;this.addCurrentVertex(R,G,we,we,z)}else ze==="round"&&(F&&(this.addCurrentVertex(R,Z,0,0,z),this.addCurrentVertex(R,Z,1,1,z,!0)),O&&(this.addCurrentVertex(R,X,-1,-1,z,!0),this.addCurrentVertex(R,X,0,0,z)));if(Te&&U<w-1){const we=R.dist(O);if(we>2*C){const xe=R.add(O.sub(R)._mult(C/we)._round());this.updateDistance(R,xe),this.addCurrentVertex(xe,X,0,0,z),R=xe}}}}addCurrentVertex(e,r,s,a,u,h=!1){const m=r.y*a-r.x,_=-r.y-r.x*a;this.addHalfVertex(e,r.x+r.y*s,r.y-r.x*s,h,!1,s,u),this.addHalfVertex(e,m,_,h,!0,-a,u),this.distance>$f/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,s,a,u,h))}addHalfVertex({x:e,y:r},s,a,u,h,m,_){const x=.5*(this.lineClips?this.scaledDistance*($f-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(u?1:0),(r<<1)+(h?1:0),Math.round(63*s)+128,Math.round(63*a)+128,1+(m===0?0:m<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const w=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,w,this.e2),_.primitiveLength++),h?this.e2=w:this.e1=w}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}hasLineDasharray(e){for(const r of e){const s=r.paint.get("line-dasharray");if(s&&!s.isConstant())return!0}return!1}addLineDashDependencies(e,r,s,a){for(const u of e){const h=u.paint.get("line-dasharray");if(!h||h.value.kind==="constant")continue;const m=u.layout.get("line-cap")==="round",_={dasharray:h.value.evaluate({zoom:s-1},r,{}),round:m},x={dasharray:h.value.evaluate({zoom:s},r,{}),round:m},w={dasharray:h.value.evaluate({zoom:s+1},r,{}),round:m},I=`${_.dasharray.join(",")},${_.round}`,C=`${x.dasharray.join(",")},${x.round}`,z=`${w.dasharray.join(",")},${w.round}`;a.dashDependencies[I]=_,a.dashDependencies[C]=x,a.dashDependencies[z]=w,r.dashes[u.id]={min:I,mid:C,max:z}}}}let Zf,Uf;Ue("LineBucket",fd,{omit:["layers","patternFeatures"]});var Gf={get paint(){return Uf=Uf||new si({"line-opacity":new et(le.paint_line["line-opacity"]),"line-color":new et(le.paint_line["line-color"]),"line-translate":new Xe(le.paint_line["line-translate"]),"line-translate-anchor":new Xe(le.paint_line["line-translate-anchor"]),"line-width":new et(le.paint_line["line-width"]),"line-gap-width":new et(le.paint_line["line-gap-width"]),"line-offset":new et(le.paint_line["line-offset"]),"line-blur":new et(le.paint_line["line-blur"]),"line-dasharray":new zo(le.paint_line["line-dasharray"]),"line-pattern":new zo(le.paint_line["line-pattern"]),"line-gradient":new Da(le.paint_line["line-gradient"])})},get layout(){return Zf=Zf||new si({"line-cap":new Xe(le.layout_line["line-cap"]),"line-join":new et(le.layout_line["line-join"]),"line-miter-limit":new Xe(le.layout_line["line-miter-limit"]),"line-round-limit":new Xe(le.layout_line["line-round-limit"]),"line-sort-key":new et(le.layout_line["line-sort-key"])})}};class Ob extends et{possiblyEvaluate(e,r){return r=new Dt(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,s,a){return r=fr({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,s,a)}}let Yu;class Bb extends Ei{constructor(e,r){super(e,Gf,r),this.gradientVersion=0,Yu||(Yu=new Ob(Gf.paint.properties["line-width"].specification),Yu.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!(function(s){return s._styleExpression!==void 0})(r)&&r._styleExpression.expression instanceof bn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=Yu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new fd(e)}queryRadius(e){const r=e,s=qf($a("line-width",this,r),$a("line-gap-width",this,r)),a=$a("line-offset",this,r);return s/2+Math.abs(a)+Uu(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:s,geometry:a,transform:u,pixelsToTileUnits:h}){const m=Gu(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-u.bearingInRadians,h),_=h/2*qf(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),x=this.paint.get("line-offset").evaluate(r,s);return x&&(a=(function(w,I){const C=[];for(let z=0;z<w.length;z++){const R=q0(w[z]),F=[];for(let O=0;O<R.length;O++){const Z=R[O],X=R[O-1],U=R[O+1],G=O===0?new ne(0,0):Z.sub(X)._unit()._perp(),J=O===R.length-1?new ne(0,0):U.sub(Z)._unit()._perp(),ie=G._add(J)._unit(),fe=ie.x*J.x+ie.y*J.y;fe!==0&&ie._mult(1/fe),F.push(ie._mult(I)._add(Z))}C.push(F)}return C})(a,x*h)),(function(w,I,C){for(let z=0;z<I.length;z++){const R=I[z];if(w.length>=3){for(let F=0;F<R.length;F++)if(Va(w,R[F]))return!0}if(Z0(w,R,C))return!0}return!1})(m,a,_)}isTileClipped(){return!0}}function qf(i,e){return e>0?e+2*i:i}const jb=yr([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Nb=yr([{name:"a_projected_pos",components:3,type:"Float32"}],4);yr([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Vb=yr([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);yr([{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"}]);const Wf=yr([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),$b=yr([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Zb(i,e,r){return i.sections.forEach((s=>{s.text=(function(a,u,h){const m=u.layout.get("text-transform").evaluate(h,{});return m==="uppercase"?a=a.toLocaleUpperCase():m==="lowercase"&&(a=a.toLocaleLowerCase()),In.applyArabicShaping&&(a=In.applyArabicShaping(a)),a})(s.text,e,r)})),i}yr([{name:"triangle",components:3,type:"Uint16"}]),yr([{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"}]),yr([{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",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),yr([{type:"Float32",name:"offsetX"}]),yr([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),yr([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Nr=24;const _c={"!":"οΈ","#":"οΌ",$:"οΌ","%":"οΌ
","&":"οΌ","(":"οΈ΅",")":"οΈΆ","*":"οΌ","+":"οΌ",",":"οΈ","-":"οΈ²",".":"γ»","/":"οΌ",":":"οΈ",";":"οΈ","<":"οΈΏ","=":"οΌ",">":"οΉ","?":"οΈ","@":"οΌ ","[":"οΉ","\\":"οΌΌ","]":"οΉ","^":"οΌΎ",_:"οΈ³","`":"ο½","{":"οΈ·","|":"β","}":"οΈΈ","~":"ο½","Β’":"οΏ ","Β£":"οΏ‘","Β₯":"οΏ₯","Β¦":"οΏ€","Β¬":"οΏ’","Β―":"οΏ£","β":"οΈ²","β":"οΈ±","β":"οΉ","β":"οΉ","β":"οΉ","β":"οΉ","β¦":"οΈ","β―":"οΈ","β§":"γ»","β©":"οΏ¦","γ":"οΈ","γ":"οΈ","γ":"οΈΏ","γ":"οΉ","γ":"οΈ½","γ":"οΈΎ","γ":"οΉ","γ":"οΉ","γ":"οΉ","γ":"οΉ","γ":"οΈ»","γ":"οΈΌ","γ":"οΈΉ","γ":"οΈΊ","γ":"οΈ","γ":"οΈ","οΌ":"οΈ","οΌ":"οΈ΅","οΌ":"οΈΆ","οΌ":"οΈ","οΌ":"οΈ²","οΌ":"γ»","οΌ":"οΈ","οΌ":"οΈ","οΌ":"οΈΏ","οΌ":"οΉ","οΌ":"οΈ","οΌ»":"οΉ","οΌ½":"οΉ","οΌΏ":"οΈ³","ο½":"οΈ·","ο½":"β","ο½":"οΈΈ","ο½":"οΈ΅","ο½ ":"οΈΆ","q":"οΈ","ο½’":"οΉ","ο½£":"οΉ"},Ub={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Gb={40:!0};function Hf(i,e,r,s,a,u){if("fontStack"in e){const h=r[e.fontStack],m=h&&h[i];return m?m.metrics.advance*e.scale+a:0}{const h=s[e.imageName];return h?h.displaySize[0]*e.scale*Nr/u+a:0}}function Xf(i,e,r,s){const a=Math.pow(i-e,2);return s?i<e?a/2:2*a:a+Math.abs(r)*r}function qb(i,e,r){let s=0;return i===10&&(s-=1e4),r&&(s+=150),i!==40&&i!==65288||(s+=50),e!==41&&e!==65289||(s+=50),s}function Yf(i,e,r,s,a,u){let h=null,m=Xf(e,r,a,u);for(const _ of s){const x=Xf(e-_.x,r,a,u)+_.badness;x<=m&&(h=_,m=x)}return{index:i,x:e,priorBreak:h,badness:m}}function Kf(i){return i?Kf(i.priorBreak).concat(i.index):[]}class qa{constructor(e="",r=[],s=[]){this.text=e,this.sections=r,this.sectionIndex=s,this.imageSectionID=null}static fromFeature(e,r){const s=new qa;for(let a=0;a<e.sections.length;a++){const u=e.sections[a];u.image?s.addImageSection(u):s.addTextSection(u,r)}return s}length(){return[...this.text].length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=(function(e){let r="",s={premature:!0,value:void 0};const a=e[Symbol.iterator]();let u=a.next();const h=e[Symbol.iterator]();h.next();let m=h.next();for(;!u.done;)r+=!m.done&&Wl(m.value.codePointAt(0))&&!_c[m.value]||!s.premature&&Wl(s.value.codePointAt(0))&&!_c[s.value]||!_c[u.value]?u.value:_c[u.value],s={value:u.value,premature:!1},u=a.next(),m=h.next();return r})(this.text)}hasZeroWidthSpaces(){return this.text.includes("β")}trim(){const e=this.text.match(/^\s*/),r=e?e[0].length:0,s=this.text.match(/\S\s*$/),a=s?s[0].length-1:0;this.text=this.text.substring(r,this.text.length-a),this.sectionIndex=this.sectionIndex.slice(r,this.sectionIndex.length-a)}substring(e,r){const s=[...this.text].slice(e,r).join(""),a=this.sectionIndex.slice(e,r);return new qa(s,this.sections,a)}toCodeUnitIndex(e){return[...this.text].slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,r)=>Math.max(e,this.sections[r].scale)),0)}getMaxImageSize(e){let r=0,s=0;for(let a=0;a<this.length();a++){const u=this.getSection(a);if("imageName"in u){const h=e[u.imageName];if(!h)continue;const m=h.displaySize;r=Math.max(r,m[0]),s=Math.max(s,m[1])}}return{maxImageWidth:r,maxImageHeight:s}}addTextSection(e,r){this.text+=e.text,this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||r});const s=this.sections.length-1;this.sectionIndex.push(...[...e.text].map((()=>s)))}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void Or("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:r}),this.sectionIndex.push(this.sections.length-1)):Or("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,r,s,a,u){const h=[],m=this.determineAverageLineWidth(e,r,s,a,u),_=this.hasZeroWidthSpaces();let x=0,w=0;const I=this.text[Symbol.iterator]();let C=I.next();const z=this.text[Symbol.iterator]();z.next();let R=z.next();const F=this.text[Symbol.iterator]();F.next(),F.next();let O=F.next();for(;!C.done;){const Z=this.getSection(w),X=C.value.codePointAt(0);if(Du(X)||(x+=Hf(X,Z,s,a,e,u)),!R.done){const U=Eo(X),G=R.value.codePointAt(0);(Ub[X]||U||"imageName"in Z||!O.done&&Gb[G])&&h.push(Yf(w+1,x,m,h,qb(X,G,U&&_),!1))}w++,C=I.next(),R=z.next(),O=F.next()}return Kf(Yf(this.length(),x,m,h,0,!0))}determineAverageLineWidth(e,r,s,a,u){let h=0,m=0;for(const _ of this.text){const x=this.getSection(m);h+=Hf(_.codePointAt(0),x,s,a,e,u),m++}return h/Math.max(1,Math.ceil(h/r))}}const md=4294967296,Jf=1/md,Qf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class Ku{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,r,s=this.length){for(;this.pos<s;){const a=this.readVarint(),u=a>>3,h=this.pos;this.type=7&a,e(u,r,this),this.pos===h&&this.skip(a)}return r}readMessage(e,r){return this.readFields(e,r,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*md;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*md;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const r=this.buf;let s,a;return a=r[this.pos++],s=127&a,a<128?s:(a=r[this.pos++],s|=(127&a)<<7,a<128?s:(a=r[this.pos++],s|=(127&a)<<14,a<128?s:(a=r[this.pos++],s|=(127&a)<<21,a<128?s:(a=r[this.pos],s|=(15&a)<<28,(function(u,h,m){const _=m.buf;let x,w;if(w=_[m.pos++],x=(112&w)>>4,w<128||(w=_[m.pos++],x|=(127&w)<<3,w<128)||(w=_[m.pos++],x|=(127&w)<<10,w<128)||(w=_[m.pos++],x|=(127&w)<<17,w<128)||(w=_[m.pos++],x|=(127&w)<<24,w<128)||(w=_[m.pos++],x|=(1&w)<<31,w<128))return Wa(u,x,h);throw new Error("Expected varint not more than 10 bytes")})(s,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){const e=this.readVarint()+this.pos,r=this.pos;return this.pos=e,e-r>=12&&Qf?Qf.decode(this.buf.subarray(r,e)):(function(s,a,u){let h="",m=a;for(;m<u;){const _=s[m];let x,w,I,C=null,z=_>239?4:_>223?3:_>191?2:1;if(m+z>u)break;z===1?_<128&&(C=_):z===2?(x=s[m+1],(192&x)==128&&(C=(31&_)<<6|63&x,C<=127&&(C=null))):z===3?(x=s[m+1],w=s[m+2],(192&x)==128&&(192&w)==128&&(C=(15&_)<<12|(63&x)<<6|63&w,(C<=2047||C>=55296&&C<=57343)&&(C=null))):z===4&&(x=s[m+1],w=s[m+2],I=s[m+3],(192&x)==128&&(192&w)==128&&(192&I)==128&&(C=(15&_)<<18|(63&x)<<12|(63&w)<<6|63&I,(C<=65535||C>=1114112)&&(C=null))),C===null?(C=65533,z=1):C>65535&&(C-=65536,h+=String.fromCharCode(C>>>10&1023|55296),C=56320|1023&C),h+=String.fromCharCode(C),m+=z}return h})(this.buf,r,e)}readBytes(){const e=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,e);return this.pos=e,r}readPackedVarint(e=[],r){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readVarint(r));return e}readPackedSVarint(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(e){const r=7&e;if(r===0)for(;this.buf[this.pos++]>127;);else if(r===2)this.pos=this.readVarint()+this.pos;else if(r===5)this.pos+=4;else{if(r!==1)throw new Error(`Unimplemented type: ${r}`);this.pos+=8}}writeTag(e,r){this.writeVarint(e<<3|r)}realloc(e){let r=this.length||16;for(;r<this.pos+e;)r*=2;if(r!==this.length){const s=new Uint8Array(r);s.set(this.buf),this.buf=s,this.dataView=new DataView(s.buffer),this.length=r}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Jf),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Jf),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?(function(r,s){let a,u;if(r>=0?(a=r%4294967296|0,u=r/4294967296|0):(a=~(-r%4294967296),u=~(-r/4294967296),4294967295^a?a=a+1|0:(a=0,u=u+1|0)),r>=18446744073709552e3||r<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),(function(h,m,_){_.buf[_.pos++]=127&h|128,h>>>=7,_.buf[_.pos++]=127&h|128,h>>>=7,_.buf[_.pos++]=127&h|128,h>>>=7,_.buf[_.pos++]=127&h|128,_.buf[_.pos]=127&(h>>>=7)})(a,0,s),(function(h,m){const _=(7&h)<<4;m.buf[m.pos++]|=_|((h>>>=3)?128:0),h&&(m.buf[m.pos++]=127&h|((h>>>=7)?128:0),h&&(m.buf[m.pos++]=127&h|((h>>>=7)?128:0),h&&(m.buf[m.pos++]=127&h|((h>>>=7)?128:0),h&&(m.buf[m.pos++]=127&h|((h>>>=7)?128:0),h&&(m.buf[m.pos++]=127&h)))))})(u,s)})(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const r=this.pos;this.pos=(function(a,u,h){for(let m,_,x=0;x<u.length;x++){if(m=u.charCodeAt(x),m>55295&&m<57344){if(!_){m>56319||x+1===u.length?(a[h++]=239,a[h++]=191,a[h++]=189):_=m;continue}if(m<56320){a[h++]=239,a[h++]=191,a[h++]=189,_=m;continue}m=_-55296<<10|m-56320|65536,_=null}else _&&(a[h++]=239,a[h++]=191,a[h++]=189,_=null);m<128?a[h++]=m:(m<2048?a[h++]=m>>6|192:(m<65536?a[h++]=m>>12|224:(a[h++]=m>>18|240,a[h++]=m>>12&63|128),a[h++]=m>>6&63|128),a[h++]=63&m|128)}return h})(this.buf,e,this.pos);const s=this.pos-r;s>=128&&em(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const r=e.length;this.writeVarint(r),this.realloc(r);for(let s=0;s<r;s++)this.buf[this.pos++]=e[s]}writeRawMessage(e,r){this.pos++;const s=this.pos;e(r,this);const a=this.pos-s;a>=128&&em(s,a,this),this.pos=s-1,this.writeVarint(a),this.pos+=a}writeMessage(e,r,s){this.writeTag(e,2),this.writeRawMessage(r,s)}writePackedVarint(e,r){r.length&&this.writeMessage(e,Wb,r)}writePackedSVarint(e,r){r.length&&this.writeMessage(e,Hb,r)}writePackedBoolean(e,r){r.length&&this.writeMessage(e,Kb,r)}writePackedFloat(e,r){r.length&&this.writeMessage(e,Xb,r)}writePackedDouble(e,r){r.length&&this.writeMessage(e,Yb,r)}writePackedFixed32(e,r){r.length&&this.writeMessage(e,Jb,r)}writePackedSFixed32(e,r){r.length&&this.writeMessage(e,Qb,r)}writePackedFixed64(e,r){r.length&&this.writeMessage(e,ew,r)}writePackedSFixed64(e,r){r.length&&this.writeMessage(e,tw,r)}writeBytesField(e,r){this.writeTag(e,2),this.writeBytes(r)}writeFixed32Field(e,r){this.writeTag(e,5),this.writeFixed32(r)}writeSFixed32Field(e,r){this.writeTag(e,5),this.writeSFixed32(r)}writeFixed64Field(e,r){this.writeTag(e,1),this.writeFixed64(r)}writeSFixed64Field(e,r){this.writeTag(e,1),this.writeSFixed64(r)}writeVarintField(e,r){this.writeTag(e,0),this.writeVarint(r)}writeSVarintField(e,r){this.writeTag(e,0),this.writeSVarint(r)}writeStringField(e,r){this.writeTag(e,2),this.writeString(r)}writeFloatField(e,r){this.writeTag(e,5),this.writeFloat(r)}writeDoubleField(e,r){this.writeTag(e,1),this.writeDouble(r)}writeBooleanField(e,r){this.writeVarintField(e,+r)}}function Wa(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function em(i,e,r){const s=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(s);for(let a=r.pos-1;a>=i;a--)r.buf[a+s]=r.buf[a]}function Wb(i,e){for(let r=0;r<i.length;r++)e.writeVarint(i[r])}function Hb(i,e){for(let r=0;r<i.length;r++)e.writeSVarint(i[r])}function Xb(i,e){for(let r=0;r<i.length;r++)e.writeFloat(i[r])}function Yb(i,e){for(let r=0;r<i.length;r++)e.writeDouble(i[r])}function Kb(i,e){for(let r=0;r<i.length;r++)e.writeBoolean(i[r])}function Jb(i,e){for(let r=0;r<i.length;r++)e.writeFixed32(i[r])}function Qb(i,e){for(let r=0;r<i.length;r++)e.writeSFixed32(i[r])}function ew(i,e){for(let r=0;r<i.length;r++)e.writeFixed64(i[r])}function tw(i,e){for(let r=0;r<i.length;r++)e.writeSFixed64(i[r])}function rw(i,e,r){i===1&&r.readMessage(iw,e)}function iw(i,e,r){if(i===3){const{id:s,bitmap:a,width:u,height:h,left:m,top:_,advance:x}=r.readMessage(nw,{});e.push({id:s,bitmap:new ac({width:u+6,height:h+6},a),metrics:{width:u,height:h,left:m,top:_,advance:x}})}}function nw(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}function tm(i){let e=0,r=0;for(const h of i)e+=h.w*h.h,r=Math.max(r,h.w);i.sort(((h,m)=>m.h-h.h));const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let a=0,u=0;for(const h of i)for(let m=s.length-1;m>=0;m--){const _=s[m];if(!(h.w>_.w||h.h>_.h)){if(h.x=_.x,h.y=_.y,u=Math.max(u,h.y+h.h),a=Math.max(a,h.x+h.w),h.w===_.w&&h.h===_.h){const x=s.pop();x&&m<s.length&&(s[m]=x)}else h.h===_.h?(_.x+=h.w,_.w-=h.w):h.w===_.w?(_.y+=h.h,_.h-=h.h):(s.push({x:_.x+h.w,y:_.y,w:_.w-h.w,h:h.h}),_.y+=h.h,_.h-=h.h);break}}return{w:a,h:u,fill:e/(a*u)||0}}class gd{constructor(e,{pixelRatio:r,version:s,stretchX:a,stretchY:u,content:h,textFitWidth:m,textFitHeight:_}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=a,this.stretchY=u,this.content=h,this.version=s,this.textFitWidth=m,this.textFitHeight=_}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class rm{constructor(e,r){const s={},a={};this.haveRenderCallbacks=[];const u=[];this.addImages(e,s,u),this.addImages(r,a,u);const{w:h,h:m}=tm(u),_=new xi({width:h||1,height:m||1});for(const x in e){const w=e[x],I=s[x].paddedRect;xi.copy(w.data,_,{x:0,y:0},{x:I.x+1,y:I.y+1},w.data)}for(const x in r){const w=r[x],I=a[x].paddedRect,C=I.x+1,z=I.y+1,R=w.data.width,F=w.data.height;xi.copy(w.data,_,{x:0,y:0},{x:C,y:z},w.data),xi.copy(w.data,_,{x:0,y:F-1},{x:C,y:z-1},{width:R,height:1}),xi.copy(w.data,_,{x:0,y:0},{x:C,y:z+F},{width:R,height:1}),xi.copy(w.data,_,{x:R-1,y:0},{x:C-1,y:z},{width:1,height:F}),xi.copy(w.data,_,{x:0,y:0},{x:C+R,y:z},{width:1,height:F})}this.image=_,this.iconPositions=s,this.patternPositions=a}addImages(e,r,s){for(const a in e){const u=e[a],h={x:0,y:0,w:u.data.width+2,h:u.data.height+2};s.push(h),r[a]=new gd(h,u),u.hasRenderCallback&&this.haveRenderCallbacks.push(a)}}patchUpdatedImages(e,r){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in e.updatedImages)this.patchUpdatedImage(this.iconPositions[s],e.getImage(s),r),this.patchUpdatedImage(this.patternPositions[s],e.getImage(s),r)}patchUpdatedImage(e,r,s){if(!e||!r||e.version===r.version)return;e.version=r.version;const[a,u]=e.tl;s.update(r.data,void 0,{x:a,y:u})}}var Ns;function Ju(i,e,r,s,a,u,h,m,_,x,w,I,C,z,R){const F=qa.fromFeature(i,a);let O;I===S.az.vertical&&F.verticalizePunctuation();let Z=F.determineLineBreaks(x,u,e,s,z);const{processBidirectionalText:X,processStyledBidirectionalText:U}=In;if(X&&F.sections.length===1){O=[],Z=Z.map((fe=>F.toCodeUnitIndex(fe)));const ie=X(F.toString(),Z);for(const fe of ie){const Pe=[...fe].map((()=>0));O.push(new qa(fe,F.sections,Pe))}}else if(U){O=[],Z=Z.map((Te=>F.toCodeUnitIndex(Te)));let ie=0;const fe=[];for(const Te of F.text)fe.push(...Array(Te.length).fill(F.sectionIndex[ie])),ie++;const Pe=U(F.text,fe,Z);for(const Te of Pe){const Ie=[];let Oe="";for(const ze of Te[0])Ie.push(Te[1][Oe.length]),Oe+=ze;O.push(new qa(Te[0],F.sections,Ie))}}else O=(function(ie,fe){const Pe=[];let Te=0;for(const Ie of fe)Pe.push(ie.substring(Te,Ie)),Te=Ie;return Te<ie.length()&&Pe.push(ie.substring(Te,ie.length())),Pe})(F,Z);const G=[],J={positionedLines:G,text:F.toString(),top:w[1],bottom:w[1],left:w[0],right:w[0],writingMode:I,iconsInText:!1,verticalizable:!1};return(function(ie,fe,Pe,Te,Ie,Oe,ze,we,xe,$e,Ne,Ge){let Ve=0,Ye=0,xt=0,gt=0;const Kt=we==="right"?1:we==="left"?0:.5,Jr=Nr/Ge;let Er=0;for(const Pt of Ie){Pt.trim();const hr=Pt.getMaxScale(),xr={positionedGlyphs:[],lineOffset:0};ie.positionedLines[Er]=xr;const Gt=xr.positionedGlyphs;let bi=0;if(!Pt.length()){Ye+=Oe,++Er;continue}const Qr=sw(Te,Pt,Jr);let wi=0;for(const Zr of Pt.text){const ir=Pt.getSection(wi),Cr=Zr.codePointAt(0),dr=ow(xe,Ne,Cr),Ur={glyph:Cr,imageName:null,x:Ve,y:Ye+-17,vertical:dr,scale:1,fontStack:"",sectionIndex:Pt.getSectionIndex(wi),metrics:null,rect:null};let ss;if("fontStack"in ir){if(ss=aw(ir,Cr,dr,Qr,fe,Pe),!ss)continue;Ur.fontStack=ir.fontStack}else{if(ie.iconsInText=!0,ir.scale*=Jr,ss=lw(ir,dr,hr,Qr,Te),!ss)continue;bi=Math.max(bi,ss.imageOffset),Ur.imageName=ir.imageName}const{rect:pn,metrics:Sc,baselineOffset:Gs}=ss;Ur.y+=Gs,Ur.scale=ir.scale,Ur.metrics=Sc,Ur.rect=pn,Gt.push(Ur),dr?(ie.verticalizable=!0,Ve+=("imageName"in ir?Sc.advance:Nr)*ir.scale+$e):Ve+=Sc.advance*ir.scale+$e,wi++}Gt.length!==0&&(xt=Math.max(Ve-$e,xt),cw(Gt,0,Gt.length-1,Kt)),Ve=0,xr.lineOffset=Math.max(bi,(hr-1)*Nr);const rn=Oe*hr+bi;Ye+=rn,gt=Math.max(rn,gt),++Er}const{horizontalAlign:Jt,verticalAlign:Wt}=_d(ze);(function(Pt,hr,xr,Gt,bi,Qr,wi,rn,Zr){const ir=(hr-xr)*bi;let Cr=0;Cr=Qr!==wi?-rn*Gt- -17:-Gt*Zr*wi+.5*wi;for(const dr of Pt)for(const Ur of dr.positionedGlyphs)Ur.x+=ir,Ur.y+=Cr})(ie.positionedLines,Kt,Jt,Wt,xt,gt,Oe,Ye,Ie.length),ie.top+=-Wt*Ye,ie.bottom=ie.top+Ye,ie.left+=-Jt*xt,ie.right=ie.left+xt})(J,e,r,s,O,h,m,_,I,x,C,R),!(function(ie){for(const fe of ie)if(fe.positionedGlyphs.length!==0)return!1;return!0})(G)&&J}function _d(i){let e=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(i){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function sw(i,e,r){const s=e.getMaxScale()*Nr,{maxImageWidth:a,maxImageHeight:u}=e.getMaxImageSize(i),h=Math.max(s,u*r);return{verticalLineContentWidth:Math.max(s,a*r),horizontalLineContentHeight:h}}function im(i){switch(i){case"top":return 0;case"center":return .5;default:return 1}}function ow(i,e,r){return!(i===S.az.horizontal||!e&&!ql(r)||e&&(Du(r)||(s=r,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(s)))));var s}function aw(i,e,r,s,a,u){const h=u[i.fontStack],m=(function(x,w,I,C){if(x&&x.rect)return x;const z=w[I.fontStack],R=z&&z[C];return R?{rect:null,metrics:R.metrics}:null})(h&&h[e],a,i,e);if(m===null)return null;let _;if(r)_=s.verticalLineContentWidth-i.scale*Nr;else{const x=im(i.verticalAlign);_=(s.horizontalLineContentHeight-i.scale*Nr)*x}return{rect:m.rect,metrics:m.metrics,baselineOffset:_}}function lw(i,e,r,s,a){const u=a[i.imageName];if(!u)return null;const h=u.paddedRect,m=u.displaySize,_={width:m[0],height:m[1],left:1,top:-3,advance:e?m[1]:m[0]};let x;if(e)x=s.verticalLineContentWidth-m[1]*i.scale;else{const w=im(i.verticalAlign);x=(s.horizontalLineContentHeight-m[1]*i.scale)*w}return{rect:h,metrics:_,baselineOffset:x,imageOffset:(e?m[0]:m[1])*i.scale-Nr*r}}function cw(i,e,r,s){if(s===0)return;const a=i[r],u=(i[r].x+a.metrics.advance*a.scale)*s;for(let h=e;h<=r;h++)i[h].x-=u}function uw(i,e,r){const{horizontalAlign:s,verticalAlign:a}=_d(r),u=e[0]-i.displaySize[0]*s,h=e[1]-i.displaySize[1]*a;return{image:i,top:h,bottom:h+i.displaySize[1],left:u,right:u+i.displaySize[0]}}function nm(i){var e,r;let s=i.left,a=i.top,u=i.right-s,h=i.bottom-a;const m=(e=i.image.textFitWidth)!==null&&e!==void 0?e:"stretchOrShrink",_=(r=i.image.textFitHeight)!==null&&r!==void 0?r:"stretchOrShrink",x=(i.image.content[2]-i.image.content[0])/(i.image.content[3]-i.image.content[1]);if(_==="proportional"){if(m==="stretchOnly"&&u/h<x||m==="proportional"){const w=Math.ceil(h*x);s*=w/u,u=w}}else if(m==="proportional"&&_==="stretchOnly"&&x!==0&&u/h>x){const w=Math.ceil(u/x);a*=w/h,h=w}return{x1:s,y1:a,x2:s+u,y2:a+h}}function sm(i,e,r,s,a,u){const h=i.image;let m;if(h.content){const O=h.content,Z=h.pixelRatio||1;m=[O[0]/Z,O[1]/Z,h.displaySize[0]-O[2]/Z,h.displaySize[1]-O[3]/Z]}const _=e.left*u,x=e.right*u;let w,I,C,z;r==="width"||r==="both"?(z=a[0]+_-s[3],I=a[0]+x+s[1]):(z=a[0]+(_+x-h.displaySize[0])/2,I=z+h.displaySize[0]);const R=e.top*u,F=e.bottom*u;return r==="height"||r==="both"?(w=a[1]+R-s[0],C=a[1]+F+s[2]):(w=a[1]+(R+F-h.displaySize[1])/2,C=w+h.displaySize[1]),{image:h,top:w,right:I,bottom:C,left:z,collisionPadding:m}}Ue("ImagePosition",gd),Ue("ImageAtlas",rm),S.az=void 0,(Ns=S.az||(S.az={}))[Ns.none=0]="none",Ns[Ns.horizontal=1]="horizontal",Ns[Ns.vertical=2]="vertical",Ns[Ns.horizontalOnly=3]="horizontalOnly";const is=128,Vs=32640;function om(i,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Dt(i+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:a}=r;let u=0;for(;u<s.length&&s[u]<=i;)u++;u=Math.max(0,u-1);let h=u;for(;h<s.length&&s[h]<i+1;)h++;h=Math.min(s.length-1,h);const m=s[u],_=s[h];return r.kind==="composite"?{kind:"composite",minZoom:m,maxZoom:_,interpolationType:a}:{kind:"camera",minZoom:m,maxZoom:_,minSize:r.evaluate(new Dt(m)),maxSize:r.evaluate(new Dt(_)),interpolationType:a}}}function yd(i,e,r){let s="never";const a=i.get(e);return a?s=a:i.get(r)&&(s="always"),s}const hw=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Qu(i,e,r,s,a,u,h,m,_,x,w,I,C){const z=m?Math.min(Vs,Math.round(m[0])):0,R=m?Math.min(Vs,Math.round(m[1])):0;i.emplaceBack(e,r,Math.round(32*s),Math.round(32*a),u,h,(z<<1)+(_?1:0),R,16*x,16*w,256*I,256*C)}function vd(i,e,r){i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r)}function dw(i){for(const e of i.sections)if(Fu(e.text))return!0;return!1}class xd{constructor(e){this.layoutVertexArray=new Q,this.indexArray=new ye,this.programConfigurations=e,this.segments=new je,this.dynamicLayoutVertexArray=new ae,this.opacityVertexArray=new ve,this.hasVisibleVertices=!1,this.placedSymbolArray=new g}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,s,a){this.isEmpty()||(s&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,jb.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Nb.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,hw,!0),this.opacityVertexBuffer.itemSize=1),(s||a)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Ue("SymbolBuffers",xd);class bd{constructor(e,r,s){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new s,this.segments=new je,this.collisionVertexArray=new _e}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Vb.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Ue("CollisionBuffers",bd);class Ha{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((h=>h.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=om(this.zoom,r["text-size"]),this.iconSizeData=om(this.zoom,r["icon-size"]);const s=this.layers[0].layout,a=s.get("symbol-sort-key"),u=s.get("symbol-z-order");this.canOverlap=yd(s,"text-overlap","text-allow-overlap")!=="never"||yd(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!a.isConstant(),this.sortFeaturesByY=(u==="viewport-y"||u==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map((h=>S.az[h]))),this.stateDependentLayerIds=this.layers.filter((h=>h.isStateDependent())).map((h=>h.id)),this.sourceID=e.sourceID}createArrays(){this.text=new xd(new rs(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new xd(new rs(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new P,this.lineVertexArray=new E,this.symbolInstances=new b,this.textAnchorOffsets=new D}calculateGlyphDependencies(e,r,s,a,u){for(const h of e)if(r[h.codePointAt(0)]=!0,(s||a)&&u){const m=_c[h];m&&(r[m.codePointAt(0)]=!0)}}populate(e,r,s){const a=this.layers[0],u=a.layout,h=u.get("text-font"),m=u.get("text-field"),_=u.get("icon-image"),x=(m.value.kind!=="constant"||m.value.value instanceof ci&&!m.value.value.isEmpty()||m.value.value.toString().length>0)&&(h.value.kind!=="constant"||h.value.value.length>0),w=_.value.kind!=="constant"||!!_.value.value||Object.keys(_.parameters).length>0,I=u.get("symbol-sort-key");if(this.features=[],!x&&!w)return;const C=r.iconDependencies,z=r.glyphDependencies,R=r.availableImages,F=new Dt(this.zoom);for(const{feature:O,id:Z,index:X,sourceLayerIndex:U}of e){const G=a._featureFilter.needGeometry,J=An(O,G);if(!a._featureFilter.filter(F,J,s))continue;let ie,fe;if(G||(J.geometry=Cn(O)),x){const Te=a.getValueAndResolveTokens("text-field",J,s,R),Ie=ci.factory(Te),Oe=this.hasRTLText=this.hasRTLText||dw(Ie);(!Oe||In.getRTLTextPluginStatus()==="unavailable"||Oe&&In.isParsed())&&(ie=Zb(Ie,a,J))}if(w){const Te=a.getValueAndResolveTokens("icon-image",J,s,R);fe=Te instanceof yi?Te:yi.fromString(Te)}if(!ie&&!fe)continue;const Pe=this.sortFeaturesByKey?I.evaluate(J,{},s):void 0;if(this.features.push({id:Z,text:ie,icon:fe,index:X,sourceLayerIndex:U,geometry:J.geometry,properties:O.properties,type:fc.types[O.type],sortKey:Pe}),fe&&(C[fe.name]=!0),ie){const Te=h.evaluate(J,{},s).join(","),Ie=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(S.az.vertical)>=0;for(const Oe of ie.sections)if(Oe.image)C[Oe.image.name]=!0;else{const ze=Bs(ie.toString()),we=Oe.fontStack||Te,xe=z[we]=z[we]||{};this.calculateGlyphDependencies(Oe.text,xe,Ie,this.allowVerticalPlacement,ze)}}}u.get("symbol-placement")==="line"&&(this.features=(function(O){const Z={},X={},U=[];let G=0;function J(Te){U.push(O[Te]),G++}function ie(Te,Ie,Oe){const ze=X[Te];return delete X[Te],X[Ie]=ze,U[ze].geometry[0].pop(),U[ze].geometry[0]=U[ze].geometry[0].concat(Oe[0]),ze}function fe(Te,Ie,Oe){const ze=Z[Ie];return delete Z[Ie],Z[Te]=ze,U[ze].geometry[0].shift(),U[ze].geometry[0]=Oe[0].concat(U[ze].geometry[0]),ze}function Pe(Te,Ie,Oe){const ze=Oe?Ie[0][Ie[0].length-1]:Ie[0][0];return`${Te}:${ze.x}:${ze.y}`}for(let Te=0;Te<O.length;Te++){const Ie=O[Te],Oe=Ie.geometry,ze=Ie.text?Ie.text.toString():null;if(!ze){J(Te);continue}const we=Pe(ze,Oe),xe=Pe(ze,Oe,!0);if(we in X&&xe in Z&&X[we]!==Z[xe]){const $e=fe(we,xe,Oe),Ne=ie(we,xe,U[$e].geometry);delete Z[we],delete X[xe],X[Pe(ze,U[Ne].geometry,!0)]=Ne,U[$e].geometry=null}else we in X?ie(we,xe,Oe):xe in Z?fe(we,xe,Oe):(J(Te),Z[we]=G-1,X[xe]=G-1)}return U.filter((Te=>Te.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((O,Z)=>O.sortKey-Z.sortKey))}update(e,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,{imagePositions:s}),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,{imagePositions:s}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const s=this.lineVertexArray.length;if(e.segment!==void 0){let a=e.dist(r[e.segment+1]),u=e.dist(r[e.segment]);const h={};for(let m=e.segment+1;m<r.length;m++)h[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:a},m<r.length-1&&(a+=r[m+1].dist(r[m]));for(let m=e.segment||0;m>=0;m--)h[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:u},m>0&&(u+=r[m-1].dist(r[m]));for(let m=0;m<r.length;m++){const _=h[m];this.lineVertexArray.emplaceBack(_.x,_.y,_.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(e,r,s,a,u,h,m,_,x,w,I,C){const z=e.indexArray,R=e.layoutVertexArray,F=e.segments.prepareSegment(4*r.length,R,z,this.canOverlap?h.sortKey:void 0),O=this.glyphOffsetArray.length,Z=F.vertexLength,X=this.allowVerticalPlacement&&m===S.az.vertical?Math.PI/2:0,U=h.text&&h.text.sections;for(let G=0;G<r.length;G++){const{tl:J,tr:ie,bl:fe,br:Pe,tex:Te,pixelOffsetTL:Ie,pixelOffsetBR:Oe,minFontScaleX:ze,minFontScaleY:we,glyphOffset:xe,isSDF:$e,sectionIndex:Ne}=r[G],Ge=F.vertexLength,Ve=xe[1];Qu(R,_.x,_.y,J.x,Ve+J.y,Te.x,Te.y,s,$e,Ie.x,Ie.y,ze,we),Qu(R,_.x,_.y,ie.x,Ve+ie.y,Te.x+Te.w,Te.y,s,$e,Oe.x,Ie.y,ze,we),Qu(R,_.x,_.y,fe.x,Ve+fe.y,Te.x,Te.y+Te.h,s,$e,Ie.x,Oe.y,ze,we),Qu(R,_.x,_.y,Pe.x,Ve+Pe.y,Te.x+Te.w,Te.y+Te.h,s,$e,Oe.x,Oe.y,ze,we),vd(e.dynamicLayoutVertexArray,_,X),z.emplaceBack(Ge,Ge+2,Ge+1),z.emplaceBack(Ge+1,Ge+2,Ge+3),F.vertexLength+=4,F.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(xe[0]),G!==r.length-1&&Ne===r[G+1].sectionIndex||e.programConfigurations.populatePaintArrays(R.length,h,h.index,{imagePositions:{},canonical:C,formattedSection:U&&U[Ne]})}e.placedSymbolArray.emplaceBack(_.x,_.y,O,this.glyphOffsetArray.length-O,Z,x,w,_.segment,s?s[0]:0,s?s[1]:0,a[0],a[1],m,0,!1,0,I)}_addCollisionDebugVertex(e,r,s,a,u,h){return r.emplaceBack(0,0),e.emplaceBack(s.x,s.y,a,u,Math.round(h.x),Math.round(h.y))}addCollisionDebugVertices(e,r,s,a,u,h,m){const _=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),x=_.vertexLength,w=u.layoutVertexArray,I=u.collisionVertexArray,C=m.anchorX,z=m.anchorY;this._addCollisionDebugVertex(w,I,h,C,z,new ne(e,r)),this._addCollisionDebugVertex(w,I,h,C,z,new ne(s,r)),this._addCollisionDebugVertex(w,I,h,C,z,new ne(s,a)),this._addCollisionDebugVertex(w,I,h,C,z,new ne(e,a)),_.vertexLength+=4;const R=u.indexArray;R.emplaceBack(x,x+1),R.emplaceBack(x+1,x+2),R.emplaceBack(x+2,x+3),R.emplaceBack(x+3,x),_.primitiveLength+=4}addDebugCollisionBoxes(e,r,s,a){for(let u=e;u<r;u++){const h=this.collisionBoxArray.get(u);this.addCollisionDebugVertices(h.x1,h.y1,h.x2,h.y2,a?this.textCollisionBox:this.iconCollisionBox,h.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new bd(ge,Wf.members,Re),this.iconCollisionBox=new bd(ge,Wf.members,Re);for(let e=0;e<this.symbolInstances.length;e++){const r=this.symbolInstances.get(e);this.addDebugCollisionBoxes(r.textBoxStartIndex,r.textBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r,!0),this.addDebugCollisionBoxes(r.iconBoxStartIndex,r.iconBoxEndIndex,r,!1),this.addDebugCollisionBoxes(r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex,r,!1)}}_deserializeCollisionBoxesForSymbol(e,r,s,a,u,h,m,_,x){const w={};for(let I=r;I<s;I++){const C=e.get(I);w.textBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},w.textFeatureIndex=C.featureIndex;break}for(let I=a;I<u;I++){const C=e.get(I);w.verticalTextBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},w.verticalTextFeatureIndex=C.featureIndex;break}for(let I=h;I<m;I++){const C=e.get(I);w.iconBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},w.iconFeatureIndex=C.featureIndex;break}for(let I=_;I<x;I++){const C=e.get(I);w.verticalIconBox={x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,anchorPointX:C.anchorPointX,anchorPointY:C.anchorPointY},w.verticalIconFeatureIndex=C.featureIndex;break}return w}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const s=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const s=e.placedSymbolArray.get(r),a=s.vertexStartIndex+4*s.numGlyphs;for(let u=s.vertexStartIndex;u<a;u+=4)e.indexArray.emplaceBack(u,u+2,u+1),e.indexArray.emplaceBack(u+1,u+2,u+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),s=Math.cos(e),a=[],u=[],h=[];for(let m=0;m<this.symbolInstances.length;++m){h.push(m);const _=this.symbolInstances.get(m);a.push(0|Math.round(r*_.anchorX+s*_.anchorY)),u.push(_.featureIndex)}return h.sort(((m,_)=>a[m]-a[_]||u[_]-u[m])),h}addToSortKeyRanges(e,r){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const r of this.symbolInstanceIndexes){const s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((a,u,h)=>{a>=0&&h.indexOf(a)===u&&this.addIndicesForPlacedSymbol(this.text,a)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let am,lm;Ue("SymbolBucket",Ha,{omit:["layers","collisionBoxArray","features","compareText"]}),Ha.MAX_GLYPHS=65535,Ha.addDynamicAttributes=vd;var wd={get paint(){return lm=lm||new si({"icon-opacity":new et(le.paint_symbol["icon-opacity"]),"icon-color":new et(le.paint_symbol["icon-color"]),"icon-halo-color":new et(le.paint_symbol["icon-halo-color"]),"icon-halo-width":new et(le.paint_symbol["icon-halo-width"]),"icon-halo-blur":new et(le.paint_symbol["icon-halo-blur"]),"icon-translate":new Xe(le.paint_symbol["icon-translate"]),"icon-translate-anchor":new Xe(le.paint_symbol["icon-translate-anchor"]),"text-opacity":new et(le.paint_symbol["text-opacity"]),"text-color":new et(le.paint_symbol["text-color"],{runtimeType:_i,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new et(le.paint_symbol["text-halo-color"]),"text-halo-width":new et(le.paint_symbol["text-halo-width"]),"text-halo-blur":new et(le.paint_symbol["text-halo-blur"]),"text-translate":new Xe(le.paint_symbol["text-translate"]),"text-translate-anchor":new Xe(le.paint_symbol["text-translate-anchor"])})},get layout(){return am=am||new si({"symbol-placement":new Xe(le.layout_symbol["symbol-placement"]),"symbol-spacing":new Xe(le.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Xe(le.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new et(le.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Xe(le.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Xe(le.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Xe(le.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Xe(le.layout_symbol["icon-ignore-placement"]),"icon-optional":new Xe(le.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Xe(le.layout_symbol["icon-rotation-alignment"]),"icon-size":new et(le.layout_symbol["icon-size"]),"icon-text-fit":new Xe(le.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Xe(le.layout_symbol["icon-text-fit-padding"]),"icon-image":new et(le.layout_symbol["icon-image"]),"icon-rotate":new et(le.layout_symbol["icon-rotate"]),"icon-padding":new et(le.layout_symbol["icon-padding"]),"icon-keep-upright":new Xe(le.layout_symbol["icon-keep-upright"]),"icon-offset":new et(le.layout_symbol["icon-offset"]),"icon-anchor":new et(le.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Xe(le.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Xe(le.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Xe(le.layout_symbol["text-rotation-alignment"]),"text-field":new et(le.layout_symbol["text-field"]),"text-font":new et(le.layout_symbol["text-font"]),"text-size":new et(le.layout_symbol["text-size"]),"text-max-width":new et(le.layout_symbol["text-max-width"]),"text-line-height":new Xe(le.layout_symbol["text-line-height"]),"text-letter-spacing":new et(le.layout_symbol["text-letter-spacing"]),"text-justify":new et(le.layout_symbol["text-justify"]),"text-radial-offset":new et(le.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Xe(le.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new et(le.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new et(le.layout_symbol["text-anchor"]),"text-max-angle":new Xe(le.layout_symbol["text-max-angle"]),"text-writing-mode":new Xe(le.layout_symbol["text-writing-mode"]),"text-rotate":new et(le.layout_symbol["text-rotate"]),"text-padding":new Xe(le.layout_symbol["text-padding"]),"text-keep-upright":new Xe(le.layout_symbol["text-keep-upright"]),"text-transform":new et(le.layout_symbol["text-transform"]),"text-offset":new et(le.layout_symbol["text-offset"]),"text-allow-overlap":new Xe(le.layout_symbol["text-allow-overlap"]),"text-overlap":new Xe(le.layout_symbol["text-overlap"]),"text-ignore-placement":new Xe(le.layout_symbol["text-ignore-placement"]),"text-optional":new Xe(le.layout_symbol["text-optional"])})}};class cm{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:mr,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ue("FormatSectionOverride",cm,{omit:["defaultValue"]});class eh extends Ei{constructor(e,r){super(e,wd,r)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const a=[];for(const u of s)a.indexOf(u)<0&&a.push(u);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,s,a){const u=this.layout.get(e).evaluate(r,{},s,a),h=this._unevaluatedLayout._values[e];return h.isDataDriven()||ks(h.value)||!u?u:(function(m,_){return _.replace(/{([^{}]+)}/g,((x,w)=>m&&w in m?String(m[w]):""))})(r.properties,u)}createBucket(e){return new Ha(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of wd.paint.overridableProperties){if(!eh.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),s=new cm(r),a=new Rl(s,r.property.specification);let u=null;u=r.value.kind==="constant"||r.value.kind==="source"?new va("source",a):new Fl("composite",a,r.value.zoomStops),this.paint._values[e]=new Ni(r.property,u,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&eh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const s=e.get("text-field"),a=wd.paint.properties[r];let u=!1;const h=m=>{for(const _ of m)if(a.overrides&&a.overrides.hasOverride(_))return void(u=!0)};if(s.value.kind==="constant"&&s.value.value instanceof ci)h(s.value.value.sections);else if(s.value.kind==="source"||s.value.kind==="composite"){const m=x=>{u||(x instanceof Ji&&gr(x.value)===Qs?h(x.value.sections):x instanceof co?h(x.sections):x.eachChild(m))},_=s.value;_._styleExpression&&m(_._styleExpression.expression)}return u}}let um;var pw={get paint(){return um=um||new si({"background-color":new Xe(le.paint_background["background-color"]),"background-pattern":new za(le.paint_background["background-pattern"]),"background-opacity":new Xe(le.paint_background["background-opacity"])})}};class fw extends Ei{constructor(e,r){super(e,pw,r)}}class mw extends Ei{constructor(e,r){super(e,{},r),this.onAdd=s=>{this.implementation.onAdd&&this.implementation.onAdd(s,s.painter.context.gl)},this.onRemove=s=>{this.implementation.onRemove&&this.implementation.onRemove(s,s.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class gw{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const _w={once:!0},Td=63710088e-1;class $s{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new $s(kt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,s=this.lat*r,a=e.lat*r,u=Math.sin(s)*Math.sin(a)+Math.cos(s)*Math.cos(a)*Math.cos((e.lng-this.lng)*r);return Td*Math.acos(Math.min(u,1))}static convert(e){if(e instanceof $s)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new $s(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new $s(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const hm=2*Math.PI*Td;function dm(i){return hm*Math.cos(i*Math.PI/180)}function pm(i){return(180+i)/360}function fm(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function mm(i,e){return i/dm(e)}function gm(i){return 360*i-180}function th(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}function _m(i,e){return i*dm(th(e))}class yc{constructor(e,r,s=0){this.x=+e,this.y=+r,this.z=+s}static fromLngLat(e,r=0){const s=$s.convert(e);return new yc(pm(s.lng),fm(s.lat),mm(r,s.lat))}toLngLat(){return new $s(gm(this.x),th(this.y))}toAltitude(){return _m(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/hm*(e=th(this.y),1/Math.cos(e*Math.PI/180));var e}}function ym(i,e,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[i*s-2*Math.PI*6378137/2,e*s-2*Math.PI*6378137/2]}class Sd{constructor(e,r,s){if(!(function(a,u,h){return!(a<0||a>25||h<0||h>=Math.pow(2,a)||u<0||u>=Math.pow(2,a))})(e,r,s))throw new Error(`x=${r}, y=${s}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=s,this.key=Xa(0,e,e,r,s)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,s){const a=(h=this.y,m=this.z,_=ym(256*(u=this.x),256*(h=Math.pow(2,m)-h-1),m),x=ym(256*(u+1),256*(h+1),m),_[0]+","+_[1]+","+x[0]+","+x[1]);var u,h,m,_,x;const w=(function(I,C,z){let R,F="";for(let O=I;O>0;O--)R=1<<O-1,F+=(C&R?1:0)+(z&R?2:0);return F})(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,w).replace(/{bbox-epsg-3857}/g,a)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new ne((e.x*r-this.x)*Tt,(e.y*r-this.y)*Tt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class vm{constructor(e,r){this.wrap=e,this.canonical=r,this.key=Xa(e,r.z,r.z,r.x,r.y)}}class Zi{constructor(e,r,s,a,u){if(this.terrainRttPosMatrix32f=null,e<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${s}`);this.overscaledZ=e,this.wrap=r,this.canonical=new Sd(s,+a,+u),this.key=Xa(r,e,s,a,u)}clone(){return new Zi(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new Zi(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Zi(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-e;return e>this.canonical.z?Xa(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):Xa(this.wrap*+r,e,e,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;const r=this.canonical.z-e.canonical.z;return!(r<0)&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new Zi(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,s=2*this.canonical.x,a=2*this.canonical.y;return[new Zi(r,this.wrap,r,s,a),new Zi(r,this.wrap,r,s+1,a),new Zi(r,this.wrap,r,s,a+1),new Zi(r,this.wrap,r,s+1,a+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Zi(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Zi(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new vm(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new yc(e.x-this.wrap,e.y))}}function Xa(i,e,r,s,a){(i*=2)<0&&(i=-1*i-1);const u=1<<r;return(u*u*i+u*a+s).toString(36)+r.toString(36)+e.toString(36)}function Pd(i,e){return e?i.properties[e]:i.id}function yw(i,e){const r={id:i.id};if(e.removeAllProperties&&(delete i.removeProperties,delete i.addOrUpdateProperties,delete e.removeProperties),e.removeProperties)for(const s of e.removeProperties){const a=i.addOrUpdateProperties.findIndex((u=>u.key===s));a>-1&&i.addOrUpdateProperties.splice(a,1)}return(i.removeAllProperties||e.removeAllProperties)&&(r.removeAllProperties=!0),(i.removeProperties||e.removeProperties)&&(r.removeProperties=[...i.removeProperties||[],...e.removeProperties||[]]),(i.addOrUpdateProperties||e.addOrUpdateProperties)&&(r.addOrUpdateProperties=[...i.addOrUpdateProperties||[],...e.addOrUpdateProperties||[]]),(i.newGeometry||e.newGeometry)&&(r.newGeometry=e.newGeometry||i.newGeometry),r}function xm(i){var e,r;if(!i)return{};const s={};return s.removeAll=i.removeAll,s.remove=new Set(i.remove||[]),s.add=new Map((e=i.add)===null||e===void 0?void 0:e.map((a=>[a.id,a]))),s.update=new Map((r=i.update)===null||r===void 0?void 0:r.map((a=>[a.id,a]))),s}Ue("CanonicalTileID",Sd),Ue("OverscaledTileID",Zi,{omit:["terrainRttPosMatrix32f"]});class Vo{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const r=new Vo;return r.extend(e(new ne(this.minX,this.minY))),r.extend(e(new ne(this.maxX,this.minY))),r.extend(e(new ne(this.minX,this.maxY))),r.extend(e(new ne(this.maxX,this.maxY))),r}static fromPoints(e){const r=new Vo;for(const s of e)r.extend(s);return r}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class bm{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const s=e[r];this._stringToNumber[s]=r,this._numberToString[r]=s}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class wm{constructor(e,r,s,a,u){this.type="Feature",this._vectorTileFeature=e,this._x=s,this._y=a,this._z=r,this.properties=e.properties,this.id=u}projectPoint(e,r,s,a){return[360*(e.x+r)/a-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/a)*Math.PI))-90]}projectLine(e,r,s,a){return e.map((u=>this.projectPoint(u,r,s,a)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,r=e.extent*Math.pow(2,this._z),s=e.extent*this._x,a=e.extent*this._y,u=e.loadGeometry();switch(e.type){case 1:{const h=[];for(const _ of u)h.push(_[0]);const m=this.projectLine(h,s,a,r);this._geometry=h.length===1?{type:"Point",coordinates:m[0]}:{type:"MultiPoint",coordinates:m};break}case 2:{const h=u.map((m=>this.projectLine(m,s,a,r)));this._geometry=h.length===1?{type:"LineString",coordinates:h[0]}:{type:"MultiLineString",coordinates:h};break}case 3:{const h=Of(u),m=[];for(const _ of h)m.push(_.map((x=>this.projectLine(x,s,a,r))));this._geometry=m.length===1?{type:"Polygon",coordinates:m[0]}:{type:"MultiPolygon",coordinates:m};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&r!=="_x"&&r!=="_y"&&r!=="_z"&&(e[r]=this[r]);return e}}class Ya{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,r,s){this._name=e,this.dataBuffer=r,typeof s=="number"?this._size=s:(this.nullabilityBuffer=s,this._size=s.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class rh extends Ya{}class Id extends rh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Md extends rh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Tm extends Ya{delta;constructor(e,r,s,a){super(e,r,a),this.delta=s}}class Ed extends Tm{constructor(e,r,s,a){super(e,Int32Array.of(r),s,a)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class Cd extends Ya{constructor(e,r,s){super(e,Int32Array.of(r),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}class vw{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,r,s,a,u=4096){this._name=e,this._geometryVector=r,this._idVector=s,this._propertyVectors=a,this._extent=u}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((r=>[r.name,r])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let r=0;for(;r<this.numFeatures;){let s;this.idVector&&(s=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(r)):this.idVector.getValue(r));const a=e?.next().value,u={};for(const h of this.propertyVectors){if(!h)continue;const m=h.name,_=h.getValue(r);_!==null&&(u[m]=_)}r++,yield{id:s,geometry:a,properties:u}}}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const e=[],r=this.geometryVector.getGeometries();for(let s=0;s<this.numFeatures;s++){let a;this.idVector&&(a=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(s)):this.idVector.getValue(s));const u={coordinates:r[s],type:this.geometryVector.geometryType(s)},h={};for(const m of this.propertyVectors){if(!m)continue;const _=m.name,x=m.getValue(s);x!==null&&(h[_]=x)}e.push({id:a,geometry:u,properties:h})}return e}containsMaxSaveIntegerValues(e){return e instanceof Id||e instanceof Cd&&e instanceof Ed||e instanceof Md}}class xw{value;constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var _t,ns,Yr,hn,$o,Ai,Vr,$r,Sm,Ui;function Wr(i,e,r){const s=new Int32Array(r);let a=0,u=e.get();for(let h=0;h<s.length;h++){let m=i[u++],_=127&m;m<128||(m=i[u++],_|=(127&m)<<7,m<128||(m=i[u++],_|=(127&m)<<14,m<128||(m=i[u++],_|=(127&m)<<21,m<128||(m=i[u++],_|=(15&m)<<28)))),s[a++]=_}return e.set(u),s}function ih(i,e,r){const s=new BigInt64Array(r);for(let a=0;a<s.length;a++)s[a]=ww(i,e);return s}function bw(i,e){let r,s;return s=i[e.get()],e.increment(),r=127&s,s<128?r:(s=i[e.get()],e.increment(),r|=(127&s)<<7,s<128?r:(s=i[e.get()],e.increment(),r|=(127&s)<<14,s<128?r:(s=i[e.get()],e.increment(),r|=(127&s)<<21,s<128?r:(s=i[e.get()],r|=(15&s)<<28,(function(a,u,h){let m,_;if(_=u[h.get()],h.increment(),m=(112&_)>>4,_<128||(_=u[h.get()],h.increment(),m|=(127&_)<<3,_<128)||(_=u[h.get()],h.increment(),m|=(127&_)<<10,_<128)||(_=u[h.get()],h.increment(),m|=(127&_)<<17,_<128)||(_=u[h.get()],h.increment(),m|=(127&_)<<24,_<128)||(_=u[h.get()],h.increment(),m|=(1&_)<<31,_<128))return 4294967296*m+(a>>>0);throw new Error("Expected varint not more than 10 bytes")})(r,i,e)))))}function Pm(i,e,r,s){throw new Error("FastPFor is not implemented yet.")}function Zo(i){return i>>>1^-(1&i)}function Ka(i){return i>>1n^-(1n&i)}function ww(i,e){let r=0n,s=0,a=e.get();for(;a<i.length;){const u=i[a++];if(r|=BigInt(127&u)<<BigInt(s),!(128&u))break;if(s+=7,s>=64)throw new Error("Varint too long")}return e.set(a),r}function Im(i,e,r){const s=new Int32Array(r);let a=0;for(let u=0;u<e;u++){const h=i[u];s.fill(i[u+e],a,a+h),a+=h}return s}function Mm(i,e,r){const s=new BigInt64Array(r);let a=0;for(let u=0;u<e;u++){const h=Number(i[u]);s.fill(i[u+e],a,a+h),a+=h}return s}function Em(i,e,r){const s=new Float64Array(r);let a=0;for(let u=0;u<e;u++){const h=i[u];s.fill(i[u+e],a,a+h),a+=h}return s}function Ad(i){const e=i.length/4*4;let r=1;if(e>=4)for(let s=i[0];r<e-4;r+=4)s=i[r]+=s,s=i[r+1]+=s,s=i[r+2]+=s,s=i[r+3]+=s;for(;r!=i.length;)i[r]+=i[r-1],++r}function Cm(i){i[0]=i[0]>>>1^-(1&i[0]),i[1]=i[1]>>>1^-(1&i[1]);const e=i.length/4*4;let r=2;if(e>=4)for(;r<e-4;r+=4){const s=i[r],a=i[r+1],u=i[r+2],h=i[r+3];i[r]=(s>>>1^-(1&s))+i[r-2],i[r+1]=(a>>>1^-(1&a))+i[r-1],i[r+2]=(u>>>1^-(1&u))+i[r],i[r+3]=(h>>>1^-(1&h))+i[r+1]}for(;r!=i.length;r+=2)i[r]=(i[r]>>>1^-(1&i[r]))+i[r-2],i[r+1]=(i[r+1]>>>1^-(1&i[r+1]))+i[r-1]}(function(i){i.NONE="NONE",i.DELTA="DELTA",i.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",i.RLE="RLE",i.MORTON="MORTON",i.PDE="PDE"})(_t||(_t={})),(function(i){i.NONE="NONE",i.FAST_PFOR="FAST_PFOR",i.VARINT="VARINT",i.ALP="ALP"})(ns||(ns={})),(function(i){i.PRESENT="PRESENT",i.DATA="DATA",i.OFFSET="OFFSET",i.LENGTH="LENGTH"})(Yr||(Yr={}));class zd{_dictionaryType;_offsetType;_lengthType;constructor(e,r,s){this._dictionaryType=e,this._offsetType=r,this._lengthType=s}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function di(i,e){const r=(function(s,a){const u=s[a.get()],h=Object.values(Yr)[u>>4];let m=null;switch(h){case Yr.DATA:m=new zd(Object.values(hn)[15&u]);break;case Yr.OFFSET:m=new zd(null,Object.values($o)[15&u]);break;case Yr.LENGTH:m=new zd(null,null,Object.values(Ai)[15&u])}a.increment();const _=s[a.get()],x=Object.values(_t)[_>>5],w=Object.values(_t)[_>>2&7],I=Object.values(ns)[3&_];a.increment();const C=Wr(s,a,2),z=C[0];return{physicalStreamType:h,logicalStreamType:m,logicalLevelTechnique1:x,logicalLevelTechnique2:w,physicalLevelTechnique:I,numValues:z,byteLength:C[1],decompressedCount:z}})(i,e);return r.logicalLevelTechnique1===_t.MORTON?(function(s,a,u){const h=Wr(a,u,2);return{physicalStreamType:s.physicalStreamType,logicalStreamType:s.logicalStreamType,logicalLevelTechnique1:s.logicalLevelTechnique1,logicalLevelTechnique2:s.logicalLevelTechnique2,physicalLevelTechnique:s.physicalLevelTechnique,numValues:s.numValues,byteLength:s.byteLength,decompressedCount:s.decompressedCount,numBits:h[0],coordinateShift:h[1]}})(r,i,e):_t.RLE!==r.logicalLevelTechnique1&&_t.RLE!==r.logicalLevelTechnique2||ns.NONE===r.physicalLevelTechnique?r:(function(s,a,u){const h=Wr(a,u,2);return{physicalStreamType:s.physicalStreamType,logicalStreamType:s.logicalStreamType,logicalLevelTechnique1:s.logicalLevelTechnique1,logicalLevelTechnique2:s.logicalLevelTechnique2,physicalLevelTechnique:s.physicalLevelTechnique,numValues:s.numValues,byteLength:s.byteLength,decompressedCount:h[1],runs:h[0],numRleValues:h[1]}})(r,i,e)}(function(i){i.NONE="NONE",i.SINGLE="SINGLE",i.SHARED="SHARED",i.VERTEX="VERTEX",i.MORTON="MORTON",i.FSST="FSST"})(hn||(hn={})),(function(i){i.VERTEX="VERTEX",i.INDEX="INDEX",i.STRING="STRING",i.KEY="KEY"})($o||($o={})),(function(i){i.VAR_BINARY="VAR_BINARY",i.GEOMETRIES="GEOMETRIES",i.PARTS="PARTS",i.RINGS="RINGS",i.TRIANGLES="TRIANGLES",i.SYMBOL="SYMBOL",i.DICTIONARY="DICTIONARY"})(Ai||(Ai={})),(function(i){i[i.FLAT=0]="FLAT",i[i.CONST=1]="CONST",i[i.SEQUENCE=2]="SEQUENCE",i[i.DICTIONARY=3]="DICTIONARY",i[i.FSST_DICTIONARY=4]="FSST_DICTIONARY"})(Vr||(Vr={}));class dn{values;_size;constructor(e,r){this.values=e,this._size=r}get(e){const r=Math.floor(e/8);return(this.values[r]>>e%8&1)==1}set(e,r){const s=Math.floor(e/8);this.values[s]=this.values[s]|(r?1:0)<<e%8}getInt(e){const r=Math.floor(e/8);return this.values[r]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function pi(i,e,r,s,a){return(function(u,h,m){switch(h.logicalLevelTechnique1){case _t.DELTA:return h.logicalLevelTechnique2===_t.RLE?(function(_,x,w){const I=new Int32Array(w);let C=0,z=0;for(let R=0;R<x;R++){const F=_[R],O=Zo(_[R+x]);for(let Z=0;Z<F;Z++)z+=O,I[C++]=z}return I})(u,h.runs,h.numRleValues):((function(_){_[0]=_[0]>>>1^-(1&_[0]);const x=_.length/4*4;let w=1;if(x>=4)for(;w<x-4;w+=4){const I=_[w],C=_[w+1],z=_[w+2],R=_[w+3];_[w]=(I>>>1^-(1&I))+_[w-1],_[w+1]=(C>>>1^-(1&C))+_[w],_[w+2]=(z>>>1^-(1&z))+_[w+1],_[w+3]=(R>>>1^-(1&R))+_[w+2]}for(;w!=_.length;++w)_[w]=(_[w]>>>1^-(1&_[w]))+_[w-1]})(u),u);case _t.RLE:return(function(_,x,w){return w?(function(I,C,z){const R=new Int32Array(z);let F=0;for(let O=0;O<C;O++){const Z=I[O];let X=I[O+C];X=X>>>1^-(1&X),R.fill(X,F,F+Z),F+=Z}return R})(_,x.runs,x.numRleValues):Im(_,x.runs,x.numRleValues)})(u,h,m);case _t.MORTON:return Ad(u),u;case _t.COMPONENTWISE_DELTA:return Cm(u),u;case _t.NONE:return m&&(function(_){for(let x=0;x<_.length;x++){const w=_[x];_[x]=w>>>1^-(1&w)}})(u),u;default:throw new Error(`The specified Logical level technique is not supported: ${h.logicalLevelTechnique1}`)}})(nh(i,e,r),r,s)}function Zs(i,e,r){return(function(s,a){if(a.logicalLevelTechnique1===_t.DELTA&&a.logicalLevelTechnique2===_t.NONE)return(function(h){const m=new Int32Array(h.length+1);m[0]=0,m[1]=Zo(h[0]);let _=m[1],x=2;for(;x!=m.length;++x){const w=h[x-1];_+=w>>>1^-(1&w),m[x]=m[x-1]+_}return m})(s);if(a.logicalLevelTechnique1===_t.RLE&&a.logicalLevelTechnique2===_t.NONE)return(function(h,m,_){const x=new Int32Array(_+1);x[0]=0;let w=1,I=x[0];for(let C=0;C<m;C++){const z=h[C],R=h[C+m];for(let F=w;F<w+z;F++)x[F]=R+I,I=x[F];w+=z}return x})(s,a.runs,a.numRleValues);if(a.logicalLevelTechnique1===_t.NONE&&a.logicalLevelTechnique2===_t.NONE){(function(h){let m=0;for(let _=0;_<h.length;_++)h[_]+=m,m=h[_]})(s);const u=new Int32Array(a.numValues+1);return u[0]=0,u.set(s,1),u}if(a.logicalLevelTechnique1===_t.DELTA&&a.logicalLevelTechnique2===_t.RLE){const u=(function(h,m,_){const x=new Int32Array(_+1);x[0]=0;let w=1,I=x[0];for(let C=0;C<m;C++){const z=h[C];let R=h[C+m];R=R>>>1^-(1&R);for(let F=w;F<w+z;F++)x[F]=R+I,I=x[F];w+=z}return x})(s,a.runs,a.numRleValues);return Ad(u),u}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")})(nh(i,e,r),r)}function nh(i,e,r){const s=r.physicalLevelTechnique;if(s===ns.FAST_PFOR)return Pm();if(s===ns.VARINT)return Wr(i,e,r.numValues);if(s===ns.NONE){const a=e.get();e.add(r.byteLength);const u=i.subarray(a,e.get());return new Int32Array(u)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}function Dd(i,e,r,s){const a=nh(i,e,r);if(a.length===1){const u=a[0];return s?Zo(u):u}return s?(function(u){return Zo(u[1])})(a):(function(u){return u[1]})(a)}function Am(i,e,r){return(function(s){if(s.length==2){const a=Zo(s[1]);return[a,a]}return[Zo(s[2]),Zo(s[3])]})(nh(i,e,r))}function zm(i,e,r){return(function(s){if(s.length==2){const a=Ka(s[1]);return[a,a]}return[Ka(s[2]),Ka(s[3])]})(ih(i,e,r.numValues))}function Dm(i,e,r,s){return(function(a,u,h){switch(u.logicalLevelTechnique1){case _t.DELTA:return u.logicalLevelTechnique2===_t.RLE?(function(m,_,x){const w=new BigInt64Array(x);let I=0,C=0n;for(let z=0;z<_;z++){const R=Number(m[z]),F=Ka(m[z+_]);for(let O=0;O<R;O++)C+=F,w[I++]=C}return w})(a,u.runs,u.numRleValues):((function(m){m[0]=m[0]>>1n^-(1n&m[0]);const _=m.length/4*4;let x=1;if(_>=4)for(;x<_-4;x+=4){const w=m[x],I=m[x+1],C=m[x+2],z=m[x+3];m[x]=(w>>1n^-(1n&w))+m[x-1],m[x+1]=(I>>1n^-(1n&I))+m[x],m[x+2]=(C>>1n^-(1n&C))+m[x+1],m[x+3]=(z>>1n^-(1n&z))+m[x+2]}for(;x!=m.length;++x)m[x]=(m[x]>>1n^-(1n&m[x]))+m[x-1]})(a),a);case _t.RLE:return(function(m,_,x){return x?(function(w,I,C){const z=new BigInt64Array(C);let R=0;for(let F=0;F<I;F++){const O=Number(w[F]);let Z=w[F+I];Z=Z>>1n^-(1n&Z),z.fill(Z,R,R+O),R+=O}return z})(m,_.runs,_.numRleValues):Mm(m,_.runs,_.numRleValues)})(a,u,h);case _t.NONE:return h&&(function(m){for(let _=0;_<m.length;_++){const x=m[_];m[_]=x>>1n^-(1n&x)}})(a),a;default:throw new Error(`The specified Logical level technique is not supported: ${u.logicalLevelTechnique1}`)}})(ih(i,e,r.numValues),r,s)}function km(i,e,r,s){const a=ih(i,e,r.numValues);if(a.length===1){const u=a[0];return s?Ka(u):u}return s?(function(u){return Ka(u[1])})(a):(function(u){return u[1]})(a)}function kd(i,e,r,s,a){return(function(u,h,m,_){switch(h.logicalLevelTechnique1){case _t.DELTA:return h.logicalLevelTechnique2===_t.RLE&&(u=Im(u,h.runs,h.numRleValues)),(function(x,w){const I=new Int32Array(x.size());let C=0;x.get(0)?(I[0]=x.get(0)?w[0]>>>1^-(1&w[0]):0,C=1):I[0]=0;let z=1;for(;z!=I.length;++z)I[z]=x.get(z)?I[z-1]+(w[C]>>>1^-(1&w[C++])):I[z-1];return I})(_,u);case _t.RLE:return(function(x,w,I,C){const z=w;return I?(function(R,F,O){const Z=new Int32Array(R.size());let X=0;for(let U=0;U<O;U++){const G=F[U];let J=F[U+O];J=J>>>1^-(1&J);for(let ie=X;ie<X+G;ie++)R.get(ie)?Z[ie]=J:(Z[ie]=0,X++);X+=G}return Z})(C,x,z.runs):(function(R,F,O){const Z=new Int32Array(R.size());let X=0;for(let U=0;U<O;U++){const G=F[U],J=F[U+O];for(let ie=X;ie<X+G;ie++)R.get(ie)?Z[ie]=J:(Z[ie]=0,X++);X+=G}return Z})(C,x,z.runs)})(u,h,m,_);case _t.MORTON:return Ad(u),u;case _t.COMPONENTWISE_DELTA:return Cm(u),u;case _t.NONE:return u=m?(function(x,w){const I=new Int32Array(x.size());let C=0,z=0;for(;z!=I.length;++z)if(x.get(z)){const R=w[C++];I[z]=R>>>1^-(1&R)}else I[z]=0;return I})(_,u):(function(x,w){const I=new Int32Array(x.size());let C=0,z=0;for(;z!=I.length;++z)I[z]=x.get(z)?w[C++]:0;return I})(_,u),u;default:throw new Error("The specified Logical level technique is not supported")}})(r.physicalLevelTechnique===ns.FAST_PFOR?Pm():Wr(i,e,r.numValues),r,s,a)}function sh(i,e,r,s){const a=i.logicalLevelTechnique1;if(a===_t.RLE)return i.runs===1?Vr.CONST:Vr.FLAT;const u=e instanceof dn?e.size():e;if(a===_t.DELTA&&i.logicalLevelTechnique2===_t.RLE){const h=i.runs,m=2;if(i.numRleValues!==u)return Vr.FLAT;if(h===1)return Vr.SEQUENCE;if(h===2){const _=s.get();let x;if(i.physicalLevelTechnique===ns.VARINT)x=Wr(r,s,4);else{const w=s.get();x=new Int32Array(r.buffer,r.byteOffset+w,4)}if(s.set(_),x[2]===m&&x[3]===m)return Vr.SEQUENCE}}return i.numValues===1?Vr.CONST:Vr.FLAT}class Rm extends rh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Fm extends Tm{constructor(e,r,s,a){super(e,BigInt64Array.of(r),s,a)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Ja{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,r,s){this._geometryOffsets=e,this._partOffsets=r,this._ringOffsets=s}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}function Rd(i,e,r){return{x:Lm(i,e)-r,y:Lm(i>>1,e)-r}}function Lm(i,e){let r=0;for(let s=0;s<e;s++)r|=(i&1<<2*s)>>s;return r}(function(i){i[i.POINT=0]="POINT",i[i.LINESTRING=1]="LINESTRING",i[i.POLYGON=2]="POLYGON",i[i.MULTIPOINT=3]="MULTIPOINT",i[i.MULTILINESTRING=4]="MULTILINESTRING",i[i.MULTIPOLYGON=5]="MULTIPOLYGON"})($r||($r={})),(function(i){i[i.POINT=0]="POINT",i[i.LINESTRING=1]="LINESTRING",i[i.POLYGON=2]="POLYGON"})(Sm||(Sm={})),(function(i){i[i.MORTON=0]="MORTON",i[i.VEC_2=1]="VEC_2",i[i.VEC_3=2]="VEC_3"})(Ui||(Ui={}));class Tw{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((r=>[r]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,r){return[e].concat(r)}createMultiPolygon(e){return e.flat()}}function Om(i){const e=new Array(i.numGeometries);let r=1,s=1,a=1,u=0;const h=new Tw;let m=0,_=0;const x=i.mortonSettings,w=i.topologyVector,I=w.geometryOffsets,C=w.partOffsets,z=w.ringOffsets,R=i.vertexOffsets,F=i.containsPolygonGeometry(),O=i.vertexBuffer;for(let Z=0;Z<i.numGeometries;Z++){const X=i.geometryType(Z);if(X===$r.POINT){if(R&&R.length!==0)if(i.vertexBufferType===Ui.VEC_2){const U=2*R[_++],G=new ne(O[U],O[U+1]);e[u++]=h.createPoint(G)}else{const U=Rd(O[R[_++]],x.numBits,x.coordinateShift),G=new ne(U.x,U.y);e[u++]=h.createPoint(G)}else{const U=new ne(O[m++],O[m++]);e[u++]=h.createPoint(U)}I&&a++,C&&r++,z&&s++}else if(X===$r.MULTIPOINT){const U=I[a]-I[a-1];a++;const G=new Array(U);if(R&&R.length!==0){for(let J=0;J<U;J++){const ie=2*R[_++];G[J]=new ne(O[ie],O[ie+1])}e[u++]=h.createMultiPoint(G)}else{for(let J=0;J<U;J++){const ie=O[m++],fe=O[m++];G[J]=new ne(ie,fe)}e[u++]=h.createMultiPoint(G)}}else if(X===$r.LINESTRING){let U,G=0;F?(G=z[s]-z[s-1],s++):G=C[r]-C[r-1],r++,R&&R.length!==0?(U=i.vertexBufferType===Ui.VEC_2?Ld(O,R,_,G,!1):Od(O,R,_,G,!1,x),_+=G):(U=Fd(O,m,G,!1),m+=2*G),e[u++]=h.createLineString(U),I&&a++}else if(X===$r.POLYGON){const U=C[r]-C[r-1];r++;const G=new Array(U-1);let J=z[s]-z[s-1];if(s++,R&&R.length!==0){const ie=i.vertexBufferType===Ui.VEC_2?ah(O,R,_,J):lh(O,R,_,J,0,x);_+=J;for(let fe=0;fe<G.length;fe++)J=z[s]-z[s-1],s++,G[fe]=i.vertexBufferType===Ui.VEC_2?ah(O,R,_,J):lh(O,R,_,J,0,x),_+=J;e[u++]=h.createPolygon(ie,G)}else{const ie=oh(O,m,J);m+=2*J;for(let fe=0;fe<G.length;fe++)J=z[s]-z[s-1],s++,G[fe]=oh(O,m,J),m+=2*J;e[u++]=h.createPolygon(ie,G)}I&&a++}else if(X===$r.MULTILINESTRING){const U=I[a]-I[a-1];a++;const G=new Array(U);if(R&&R.length!==0){for(let J=0;J<U;J++){let ie=0;F?(ie=z[s]-z[s-1],s++):ie=C[r]-C[r-1],r++;const fe=i.vertexBufferType===Ui.VEC_2?Ld(O,R,_,ie,!1):Od(O,R,_,ie,!1,x);G[J]=fe,_+=ie}e[u++]=h.createMultiLineString(G)}else{for(let J=0;J<U;J++){let ie=0;F?(ie=z[s]-z[s-1],s++):ie=C[r]-C[r-1],r++,G[J]=Fd(O,m,ie,!1),m+=2*ie}e[u++]=h.createMultiLineString(G)}}else{if(X!==$r.MULTIPOLYGON)throw new Error("The specified geometry type is currently not supported.");{const U=I[a]-I[a-1];a++;const G=new Array(U);let J=0;if(R&&R.length!==0){for(let ie=0;ie<U;ie++){const fe=C[r]-C[r-1];r++;const Pe=new Array(fe-1);J=z[s]-z[s-1],s++;const Te=i.vertexBufferType===Ui.VEC_2?ah(O,R,_,J):lh(O,R,_,J,0,x);_+=J;for(let Ie=0;Ie<Pe.length;Ie++)J=z[s]-z[s-1],s++,Pe[Ie]=i.vertexBufferType===Ui.VEC_2?ah(O,R,_,J):lh(O,R,_,J,0,x),_+=J;G[ie]=h.createPolygon(Te,Pe)}e[u++]=h.createMultiPolygon(G)}else{for(let ie=0;ie<U;ie++){const fe=C[r]-C[r-1];r++;const Pe=new Array(fe-1);J=z[s]-z[s-1],s++;const Te=oh(O,m,J);m+=2*J;for(let Ie=0;Ie<Pe.length;Ie++){const Oe=z[s]-z[s-1];s++,Pe[Ie]=oh(O,m,Oe),m+=2*Oe}G[ie]=h.createPolygon(Te,Pe)}e[u++]=h.createMultiPolygon(G)}}}}return e}function oh(i,e,r){return Fd(i,e,r,!0)}function ah(i,e,r,s){return Ld(i,e,r,s,!0)}function lh(i,e,r,s,a,u){return Od(i,e,r,s,!0,u)}function Fd(i,e,r,s){const a=new Array(s?r+1:r);for(let u=0;u<2*r;u+=2)a[u/2]=new ne(i[e+u],i[e+u+1]);return s&&(a[a.length-1]=a[0]),a}function Ld(i,e,r,s,a){const u=new Array(a?s+1:s);for(let h=0;h<2*s;h+=2){const m=2*e[r+h/2];u[h/2]=new ne(i[m],i[m+1])}return a&&(u[u.length-1]=u[0]),u}function Od(i,e,r,s,a,u){const h=new Array(a?s+1:s);for(let m=0;m<s;m++){const _=Rd(i[e[r+m]],u.numBits,u.coordinateShift);h[m]=new ne(_.x,_.y)}return a&&(h[h.length-1]=h[0]),h}class Bm{_vertexBufferType;_topologyVector;_vertexOffsets;_vertexBuffer;_mortonSettings;constructor(e,r,s,a,u){this._vertexBufferType=e,this._topologyVector=r,this._vertexOffsets=s,this._vertexBuffer=a,this._mortonSettings=u}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}*[Symbol.iterator](){const e=Om(this);let r=0;for(;r<this.numGeometries;)yield{coordinates:e[r],type:this.geometryType(r)},r++}getSimpleEncodedVertex(e){const r=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[r],this.vertexBuffer[r+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){const s=Rd(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[s.x,s.y]}const r=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[r],this.vertexBuffer[r+1]]}getGeometries(){return Om(this)}get mortonSettings(){return this._mortonSettings}}class jm extends Bm{_numGeometries;_geometryType;constructor(e,r,s,a,u,h,m){super(s,a,u,h,m),this._numGeometries=e,this._geometryType=r}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===$r.POLYGON||this._geometryType===$r.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class Nm extends Bm{_geometryTypes;constructor(e,r,s,a,u,h){super(e,s,a,u,h),this._geometryTypes=r}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===$r.POLYGON||this.geometryType(e)===$r.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class Vm{_triangleOffsets;_indexBuffer;_vertexBuffer;_topologyVector;constructor(e,r,s,a){this._triangleOffsets=e,this._indexBuffer=r,this._vertexBuffer=s,this._topologyVector=a}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const e=new Array(this.numGeometries),r=this._topologyVector,s=r.partOffsets,a=r.ringOffsets,u=r.geometryOffsets;let h=0,m=1,_=1,x=1;for(let w=0;w<this.numGeometries;w++)switch(this.geometryType(w)){case $r.POLYGON:{const I=s[m]-s[m-1];m++;const C=[];for(let z=0;z<I;z++){const R=a[_]-a[_-1];_++;const F=[];for(let O=0;O<R;O++){const Z=this._vertexBuffer[h++],X=this._vertexBuffer[h++];F.push(new ne(Z,X))}F.length>0&&F.push(F[0]),C.push(F)}e[w]=C,u&&x++}break;case $r.MULTIPOLYGON:{const I=u[x]-u[x-1];x++;const C=[];for(let z=0;z<I;z++){const R=s[m]-s[m-1];m++;for(let F=0;F<R;F++){const O=a[_]-a[_-1];_++;const Z=[];for(let X=0;X<O;X++){const U=this._vertexBuffer[h++],G=this._vertexBuffer[h++];Z.push(new ne(U,G))}Z.length>0&&Z.push(Z[0]),C.push(Z)}}e[w]=C}}return e}[Symbol.iterator](){return null}}function $m(i,e,r,s,a,u){return new Sw(i,e,r,s,a,u)}class Sw extends Vm{_numGeometries;_geometryType;constructor(e,r,s,a,u,h){super(s,a,u,h),this._numGeometries=e,this._geometryType=r}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function Zm(i,e,r,s,a){return new Pw(i,e,r,s,a)}class Pw extends Vm{_geometryTypes;constructor(e,r,s,a,u){super(r,s,a,u),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function Iw(i,e,r,s,a){const u=di(i,r);let h=null,m=null,_=null,x=null,w=null,I=null,C=null,z=null;if(sh(u,s,i,r)===Vr.CONST){const F=Dd(i,r,u,!1);for(let O=0;O<e-1;O++){const Z=di(i,r);switch(Z.physicalStreamType){case Yr.LENGTH:switch(Z.logicalStreamType.lengthType){case Ai.GEOMETRIES:h=Zs(i,r,Z);break;case Ai.PARTS:m=Zs(i,r,Z);break;case Ai.RINGS:_=Zs(i,r,Z);break;case Ai.TRIANGLES:C=Zs(i,r,Z)}break;case Yr.OFFSET:switch(Z.logicalStreamType.offsetType){case $o.VERTEX:x=pi(i,r,Z,!1);break;case $o.INDEX:z=pi(i,r,Z,!1)}break;case Yr.DATA:hn.VERTEX===Z.logicalStreamType.dictionaryType?w=pi(i,r,Z,!0):(I={numBits:Z.numBits,coordinateShift:Z.coordinateShift},w=pi(i,r,Z,!1))}}return z!==null?h!=null||m!=null?$m(s,F,C,z,w,new Ja(h,m,_)):$m(s,F,C,z,w):I===null?(function(O,Z,X,U,G){return new jm(O,Z,Ui.VEC_2,X,U,G)})(s,F,new Ja(h,m,_),x,w):(function(O,Z,X,U,G,J){return new jm(O,Z,Ui.MORTON,X,U,G,J)})(s,F,new Ja(h,m,_),x,w,I)}const R=pi(i,r,u,!1);for(let F=0;F<e-1;F++){const O=di(i,r);switch(O.physicalStreamType){case Yr.LENGTH:switch(O.logicalStreamType.lengthType){case Ai.GEOMETRIES:h=pi(i,r,O,!1);break;case Ai.PARTS:m=pi(i,r,O,!1);break;case Ai.RINGS:_=pi(i,r,O,!1);break;case Ai.TRIANGLES:C=Zs(i,r,O)}break;case Yr.OFFSET:switch(O.logicalStreamType.offsetType){case $o.VERTEX:x=pi(i,r,O,!1);break;case $o.INDEX:z=pi(i,r,O,!1)}break;case Yr.DATA:hn.VERTEX===O.logicalStreamType.dictionaryType?w=pi(i,r,O,!0):(I={numBits:O.numBits,coordinateShift:O.coordinateShift},w=pi(i,r,O,!1))}}return z!==null&&m===null?Zm(R,C,z,w):(h!==null?(h=Bd(R,h,2),m!==null&&_!==null?(m=Um(R,h,m,!1),_=(function(F,O,Z,X){const U=new Int32Array(Z[Z.length-1]+1);let G=0;U[0]=G;let J=1,ie=1,fe=0;for(let Pe=0;Pe<F.length;Pe++){const Te=F[Pe],Ie=O[Pe+1]-O[Pe];if(Te!==0&&Te!==3)for(let Oe=0;Oe<Ie;Oe++){const ze=Z[J]-Z[J-1];J++;for(let we=0;we<ze;we++)G=U[ie++]=G+X[fe++]}else for(let Oe=0;Oe<Ie;Oe++)U[ie++]=++G,J++}return U})(R,h,m,_)):m!==null&&(m=(function(F,O,Z){const X=new Int32Array(O[O.length-1]+1);let U=0;X[0]=U;let G=1,J=0;for(let ie=0;ie<F.length;ie++){const fe=F[ie],Pe=O[ie+1]-O[ie];if(fe===4||fe===1)for(let Te=0;Te<Pe;Te++)U=X[G++]=U+Z[J++];else for(let Te=0;Te<Pe;Te++)X[G++]=++U}return X})(R,h,m))):m!==null&&_!==null?(m=Bd(R,m,1),_=Um(R,m,_,!0)):m!==null&&(m=Bd(R,m,0)),z!==null?Zm(R,C,z,w,new Ja(h,m,_)):I===null?(function(F,O,Z,X){return new Nm(Ui.VEC_2,F,O,Z,X)})(R,new Ja(h,m,_),x,w):(function(F,O,Z,X,U){return new Nm(Ui.MORTON,F,O,Z,X,U)})(R,new Ja(h,m,_),x,w,I))}function Bd(i,e,r){const s=new Int32Array(i.length+1);let a=0;s[0]=a;let u=0;for(let h=0;h<i.length;h++)a=s[h+1]=a+(i[h]>r?e[u++]:1);return s}function Um(i,e,r,s){const a=new Int32Array(e[e.length-1]+1);let u=0;a[0]=u;let h=1,m=0;for(let _=0;_<i.length;_++){const x=i[_],w=e[_+1]-e[_];if(x===5||x===2||s&&(x===4||x===1))for(let I=0;I<w;I++)u=a[h++]=u+r[m++];else for(let I=0;I<w;I++)a[h++]=++u}return a}class Mw extends Ya{dataVector;constructor(e,r,s){super(e,r.getBuffer(),s),this.dataVector=r}getValueFromBuffer(e){return this.dataVector.get(e)}}class Ew extends rh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Gm extends Ya{constructor(e,r,s){super(e,BigInt64Array.of(r),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}function vc(i,e,r){return qm(i,Math.ceil(e/8),r)}function qm(i,e,r){const s=new Uint8Array(e);let a=0;for(;a<e;){const u=i[r.increment()];if(u<=127){const h=u+3,m=i[r.increment()],_=a+h;s.fill(m,a,_),a=_}else{const h=256-u;for(let m=0;m<h;m++)s[a++]=i[r.increment()]}}return s}const Cw=new TextDecoder;function jd(i,e,r){return r-e>=12?Cw.decode(i.subarray(e,r)):(function(s,a,u){let h="",m=a;for(;m<u;){const _=s[m];let x,w,I,C=null,z=_>239?4:_>223?3:_>191?2:1;if(m+z>u)break;z===1?_<128&&(C=_):z===2?(x=s[m+1],(192&x)==128&&(C=(31&_)<<6|63&x,C<=127&&(C=null))):z===3?(x=s[m+1],w=s[m+2],(192&x)==128&&(192&w)==128&&(C=(15&_)<<12|(63&x)<<6|63&w,(C<=2047||C>=55296&&C<=57343)&&(C=null))):z===4&&(x=s[m+1],w=s[m+2],I=s[m+3],(192&x)==128&&(192&w)==128&&(192&I)==128&&(C=(15&_)<<18|(63&x)<<12|(63&w)<<6|63&I,(C<=65535||C>=1114112)&&(C=null))),C===null?(C=65533,z=1):C>65535&&(C-=65536,h+=String.fromCharCode(C>>>10&1023|55296),C=56320|1023&C),h+=String.fromCharCode(C),m+=z}return h})(i,e,r)}class Nd extends Ya{offsetBuffer;constructor(e,r,s,a){super(e,s,a),this.offsetBuffer=r}}class Wm extends Nd{textEncoder;constructor(e,r,s,a){super(e,r,s,a??r.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return jd(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class Qa extends Nd{indexBuffer;textEncoder;constructor(e,r,s,a,u){super(e,s,a,u??r.length),this.indexBuffer=r,this.indexBuffer=r,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const r=this.indexBuffer[e];return jd(this.dataBuffer,this.offsetBuffer[r],this.offsetBuffer[r+1])}}class Hm extends Nd{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,r,s,a,u,h,m){super(e,s,a,m),this.indexBuffer=r,this.symbolOffsetBuffer=u,this.symbolTableBuffer=h,this.textEncoder=new TextEncoder}getValueFromBuffer(e){this.decodedDictionary==null&&(this.symbolLengthBuffer==null&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=(function(s,a,u){const h=[],m=new Array(a.length).fill(0);for(let _=1;_<a.length;_++)m[_]=m[_-1]+a[_-1];for(let _=0;_<u.length;_++)if(u[_]===255)h.push(u[++_]);else{const x=a[u[_]],w=m[u[_]];for(let I=0;I<x;I++)h.push(s[w+I])}return new Uint8Array(h)})(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const r=this.indexBuffer[e];return jd(this.decodedDictionary,this.offsetBuffer[r],this.offsetBuffer[r+1])}offsetToLengthBuffer(e){const r=new Uint32Array(e.length-1);let s=e[0];for(let a=1;a<e.length;a++){const u=e[a];r[a-1]=u-s,s=u}return r}}function Aw(i,e,r,s,a,u){return r.type==="scalarType"?(function(h,m,_,x,w,I){let C=null,z=0;if(h===0)return null;if(I.nullable){const F=di(m,_);z=F.numValues;const O=_.get(),Z=vc(m,z,_);_.set(O+F.byteLength),C=new dn(Z,F.numValues)}const R=C??x;switch(w.physicalType){case 4:case 3:return(function(F,O,Z,X,U){const G=di(F,O),J=sh(G,U,F,O),ie=X.physicalType===3;if(J===Vr.FLAT){const fe=xc(U)?kd(F,O,G,ie,U):pi(F,O,G,ie);return new Id(Z.name,fe,U)}if(J===Vr.SEQUENCE){const fe=Am(F,O,G);return new Ed(Z.name,fe[0],fe[1],G.numRleValues)}{const fe=Dd(F,O,G,ie);return new Cd(Z.name,fe,U)}})(m,_,I,w,R);case 9:return(function(F,O,Z,X,U){let G=null,J=null,ie=null,fe=null,Pe=null,Te=null,Ie=null,Oe=null;for(let ze=0;ze<X;ze++){const we=di(O,Z);if(we.byteLength!==0)switch(we.physicalStreamType){case Yr.PRESENT:{const xe=vc(O,we.numValues,Z);Te=new dn(xe,we.numValues);break}case Yr.OFFSET:J=U!=null||Te!=null?kd(O,Z,we,!1,U??Te):pi(O,Z,we,!1);break;case Yr.LENGTH:{const xe=Zs(O,Z,we);Ai.DICTIONARY===we.logicalStreamType.lengthType?G=xe:Ai.SYMBOL===we.logicalStreamType.lengthType?fe=xe:Ie=xe;break}case Yr.DATA:{const xe=O.subarray(Z.get(),Z.get()+we.byteLength);Z.add(we.byteLength);const $e=we.logicalStreamType.dictionaryType;hn.FSST===$e?Pe=xe:hn.SINGLE===$e||hn.SHARED===$e?ie=xe:hn.NONE===$e&&(Oe=xe);break}}}return(function(ze,we,xe,$e,Ne,Ge,Ve){return we?new Hm(ze,xe,$e,Ne,Ge,we,Ve):null})(F,Pe,J,G,ie,fe,U??Te)??(function(ze,we,xe,$e,Ne){return we?Ne?new Qa(ze,xe,$e,we,Ne):new Qa(ze,xe,$e,we):null})(F,ie,J,G,U??Te)??(function(ze,we,xe,$e,Ne){if(!we||!xe)return null;if($e)return Ne?new Qa(ze,$e,we,xe,Ne):new Qa(ze,$e,we,xe);if(Ne&&Ne.size()!==we.length-1){const Ge=new Int32Array(Ne.size());let Ve=0;for(let Ye=0;Ye<Ne.size();Ye++)Ge[Ye]=Ne.get(Ye)?Ve++:0;return new Qa(ze,Ge,we,xe,Ne)}return Ne?new Wm(ze,we,xe,Ne):new Wm(ze,we,xe)})(F,Ie,Oe,J,U??Te)})(I.name,m,_,I.nullable?h-1:h,C);case 0:return(function(F,O,Z,X,U){const G=di(F,O),J=G.numValues,ie=O.get(),fe=xc(U)?(function(Te,Ie,Oe,ze){const we=qm(Te,Math.ceil(Ie/8),Oe),xe=new dn(we,Ie),$e=ze.size(),Ne=new dn(new Uint8Array($e),$e);let Ge=0;for(let Ve=0;Ve<ze.size();Ve++){const Ye=!!ze.get(Ve)&&xe.get(Ge++);Ne.set(Ve,Ye)}return Ne.getBuffer()})(F,J,O,U):vc(F,J,O);O.set(ie+G.byteLength);const Pe=new dn(fe,J);return new Mw(Z.name,Pe,U)})(m,_,I,0,R);case 6:case 5:return(function(F,O,Z,X,U){const G=di(F,O),J=sh(G,X,F,O),ie=U.physicalType===5;if(J===Vr.FLAT){const fe=xc(X)?(function(Pe,Te,Ie,Oe,ze){return(function(we,xe,$e,Ne){switch(xe.logicalLevelTechnique1){case _t.DELTA:return xe.logicalLevelTechnique2===_t.RLE&&(we=Mm(we,xe.runs,xe.numRleValues)),(function(Ge,Ve){const Ye=new BigInt64Array(Ge.size());let xt=0;Ge.get(0)?(Ye[0]=Ge.get(0)?Ve[0]>>1n^-(1n&Ve[0]):0n,xt=1):Ye[0]=0n;let gt=1;for(;gt!=Ye.length;++gt)Ye[gt]=Ge.get(gt)?Ye[gt-1]+(Ve[xt]>>1n^-(1n&Ve[xt++])):Ye[gt-1];return Ye})(Ne,we);case _t.RLE:return(function(Ge,Ve,Ye,xt){const gt=Ve;return Ye?(function(Kt,Jr,Er){const Jt=new BigInt64Array(Kt.size());let Wt=0;for(let Pt=0;Pt<Er;Pt++){const hr=Number(Jr[Pt]);let xr=Jr[Pt+Er];xr=xr>>1n^-(1n&xr);for(let Gt=Wt;Gt<Wt+hr;Gt++)Kt.get(Gt)?Jt[Gt]=xr:(Jt[Gt]=0n,Wt++);Wt+=hr}return Jt})(xt,Ge,gt.runs):(function(Kt,Jr,Er){const Jt=new BigInt64Array(Kt.size());let Wt=0;for(let Pt=0;Pt<Er;Pt++){const hr=Number(Jr[Pt]),xr=Jr[Pt+Er];for(let Gt=Wt;Gt<Wt+hr;Gt++)Kt.get(Gt)?Jt[Gt]=xr:(Jt[Gt]=0n,Wt++);Wt+=hr}return Jt})(xt,Ge,gt.runs)})(we,xe,$e,Ne);case _t.NONE:return we=$e?(function(Ge,Ve){const Ye=new BigInt64Array(Ge.size());let xt=0,gt=0;for(;gt!=Ye.length;++gt)if(Ge.get(gt)){const Kt=Ve[xt++];Ye[gt]=Kt>>1n^-(1n&Kt)}else Ye[gt]=0n;return Ye})(Ne,we):(function(Ge,Ve){const Ye=new BigInt64Array(Ge.size());let xt=0,gt=0;for(;gt!=Ye.length;++gt)Ye[gt]=Ge.get(gt)?Ve[xt++]:0n;return Ye})(Ne,we),we;default:throw new Error("The specified Logical level technique is not supported")}})(ih(Pe,Te,Ie.numValues),Ie,Oe,ze)})(F,O,G,ie,X):Dm(F,O,G,ie);return new Rm(Z.name,fe,X)}if(J===Vr.SEQUENCE){const fe=zm(F,O,G);return new Fm(Z.name,fe[0],fe[1],G.numRleValues)}{const fe=km(F,O,G,ie);return new Gm(Z.name,fe,X)}})(m,_,I,R,w);case 7:return(function(F,O,Z,X){const U=di(F,O),G=xc(X)?(function(J,ie,fe,Pe){const Te=ie.get(),Ie=Te+Pe*Float32Array.BYTES_PER_ELEMENT,Oe=new Uint8Array(J.subarray(Te,Ie)).buffer,ze=new Float32Array(Oe);ie.set(Ie);const we=fe.size(),xe=new Float32Array(we);let $e=0;for(let Ne=0;Ne<we;Ne++)xe[Ne]=fe.get(Ne)?ze[$e++]:0;return xe})(F,O,X,U.numValues):(function(J,ie,fe){const Pe=ie.get(),Te=Pe+fe*Float32Array.BYTES_PER_ELEMENT,Ie=new Uint8Array(J.subarray(Pe,Te)).buffer,Oe=new Float32Array(Ie);return ie.set(Te),Oe})(F,O,U.numValues);return new Ew(Z.name,G,X)})(m,_,I,R);case 8:return(function(F,O,Z,X){const U=di(F,O),G=xc(X)?(function(J,ie,fe,Pe){const Te=ie.get(),Ie=Te+Pe*Float64Array.BYTES_PER_ELEMENT,Oe=new Uint8Array(J.subarray(Te,Ie)).buffer,ze=new Float64Array(Oe);ie.set(Ie);const we=fe.size(),xe=new Float64Array(we);let $e=0;for(let Ne=0;Ne<we;Ne++)xe[Ne]=fe.get(Ne)?ze[$e++]:0;return xe})(F,O,X,U.numValues):(function(J,ie,fe){const Pe=ie.get(),Te=Pe+fe*Float64Array.BYTES_PER_ELEMENT,Ie=new Uint8Array(J.subarray(Pe,Te)).buffer,Oe=new Float64Array(Ie);return ie.set(Te),Oe})(F,O,U.numValues);return new Md(Z.name,G,X)})(m,_,I,R);default:throw new Error(`The specified data type for the field is currently not supported: ${w}`)}})(s,i,e,a,r.scalarType,r):s!=1?null:(function(h,m,_,x){let w=null,I=null,C=null,z=null,R=!1;for(;!R;){const X=di(h,m);switch(X.physicalStreamType){case Yr.LENGTH:Ai.DICTIONARY===X.logicalStreamType.lengthType?w=Zs(h,m,X):C=Zs(h,m,X);break;case Yr.DATA:hn.SINGLE===X.logicalStreamType.dictionaryType||hn.SHARED===X.logicalStreamType.dictionaryType?(I=h.subarray(m.get(),m.get()+X.byteLength),R=!0):z=h.subarray(m.get(),m.get()+X.byteLength),m.add(X.byteLength)}}const F=_.complexType.children,O=[];let Z=0;for(const X of F){const U=Wr(h,m,1)[0];if(U==0)continue;const G=`${_.name}${X.name==="default"?"":":"+X.name}`;if(U!==2||X.type!=="scalarField"||X.scalarField.physicalType!==9)throw new Error("Currently only optional string fields are implemented for a struct.");const J=di(h,m),ie=vc(h,J.numValues,m),fe=di(h,m),Pe=fe.decompressedCount!==x?kd(h,m,fe,!1,new dn(ie,J.numValues)):pi(h,m,fe,!1);O[Z++]=z?new Hm(G,Pe,w,I,C,z,new dn(ie,J.numValues)):new Qa(G,Pe,w,I,new dn(ie,J.numValues))}return O})(i,e,r,a)}function xc(i){return i instanceof dn}function zw(i){if(i.name==="id")return!1;if(i.type==="scalarType"){const e=i.scalarType;if(e.type==="physicalType")switch(e.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if(e.type==="logicalType")return!1}else if(i.type==="complexType"){const e=i.complexType;if(e.type==="physicalType")switch(e.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",i),!1}const Dw=new TextDecoder;function Xm(i,e){const r=Wr(i,e,1)[0];if(r===0)return"";const s=e.get(),a=i.subarray(s,s+r);return e.add(r),Dw.decode(a)}function Ym(i,e){const r=Wr(i,e,1)[0]>>>0,s=!!(4&r),a=!!(2&r),u=Wr(i,e,1)[0]>>>0,h={};if(1&r&&(h.nullable=!0),a){const m={};if(s?(m.type="logicalType",m.logicalType=u):(m.type="physicalType",m.physicalType=u),8&r){const _=Wr(i,e,1)[0]>>>0;m.children=new Array(_);for(let x=0;x<_;x++)m.children[x]=Ym(i,e)}h.type="complexField",h.complexField=m}else{const m={};s?(m.type="logicalType",m.logicalType=u):(m.type="physicalType",m.physicalType=u),h.type="scalarField",h.scalarField=m}return h}function kw(i,e){const r=Wr(i,e,1)[0]>>>0,s=(function(a){switch(a){case 0:case 1:case 2:case 3:{const u={};u.nullable=!!(1&a),u.columnScope=0;const h={};return h.physicalType=a>1?6:4,h.type="physicalType",u.scalarType=h,u.type="scalarType",u}case 4:{const u={nullable:!1,columnScope:0},h={type:"physicalType",physicalType:0};return u.type="complexType",u.complexType=h,u}case 30:{const u={nullable:!1,columnScope:0},h={type:"physicalType",physicalType:1};return u.type="complexType",u.complexType=h,u}default:return(function(u){let h=null;switch(u){case 10:case 11:h=0;break;case 12:case 13:h=1;break;case 14:case 15:h=2;break;case 16:case 17:h=3;break;case 18:case 19:h=4;break;case 20:case 21:h=5;break;case 22:case 23:h=6;break;case 24:case 25:h=7;break;case 26:case 27:h=8;break;case 28:case 29:h=9;break;default:return null}const m={};m.nullable=!!(1&u),m.columnScope=0;const _={type:"physicalType"};return _.physicalType=h,m.type="scalarType",m.scalarType=_,m})(a)}})(r);if(!s)throw new Error(`Unsupported column type code: ${r}`);if((function(a){return a>=10})(r)?s.name=Xm(i,e):r>=0&&r<=3?s.name="id":r===4&&(s.name="geometry"),(function(a){return a===30})(r)){const a=Wr(i,e,1)[0]>>>0,u=s.complexType;u.children=new Array(a);for(let h=0;h<a;h++)u.children[h]=Ym(i,e)}return s}function Rw(i,e){const r={featureTables:[]},s={};s.name=Xm(i,e);const a=Wr(i,e,1)[0]>>>0,u=Wr(i,e,1)[0]>>>0;s.columns=new Array(u);for(let h=0;h<u;h++)s.columns[h]=kw(i,e);return r.featureTables.push(s),[r,a]}function Fw(i,e,r,s,a,u,h=!1){const m=e.scalarType.physicalType,_=sh(a,u,i,r);if(m===4)switch(_){case Vr.FLAT:{const x=pi(i,r,a,!1);return new Id(s,x,u)}case Vr.SEQUENCE:{const x=Am(i,r,a);return new Ed(s,x[0],x[1],a.numRleValues)}case Vr.CONST:{const x=Dd(i,r,a,!1);return new Cd(s,x,u)}}else switch(_){case Vr.FLAT:{if(h){const w=(function(I,C,z,R){const F=(function(O,Z,X){const U=new Float64Array(Z);for(let G=0;G<Z;G++)U[G]=bw(O,X);return U})(I,z.numValues,C);return(function(O,Z,X){switch(Z.logicalLevelTechnique1){case _t.DELTA:return Z.logicalLevelTechnique2===_t.RLE&&(O=Em(O,Z.runs,Z.numRleValues)),(function(U){U[0]=U[0]%2==1?(U[0]+1)/-2:U[0]/2;const G=U.length/4*4;let J=1;if(G>=4)for(;J<G-4;J+=4){const ie=U[J],fe=U[J+1],Pe=U[J+2],Te=U[J+3];U[J]=(ie%2==1?(ie+1)/-2:ie/2)+U[J-1],U[J+1]=(fe%2==1?(fe+1)/-2:fe/2)+U[J],U[J+2]=(Pe%2==1?(Pe+1)/-2:Pe/2)+U[J+1],U[J+3]=(Te%2==1?(Te+1)/-2:Te/2)+U[J+2]}for(;J!=U.length;++J)U[J]=(U[J]%2==1?(U[J]+1)/-2:U[J]/2)+U[J-1]})(O),O;case _t.RLE:return(function(U,G,J){return Em(U,G.runs,G.numRleValues)})(O,Z);case _t.NONE:return O;default:throw new Error(`The specified Logical level technique is not supported: ${Z.logicalLevelTechnique1}`)}})(F,z)})(i,r,a);return new Md(s,w,u)}const x=Dm(i,r,a,!1);return new Rm(s,x,u)}case Vr.SEQUENCE:{const x=zm(i,r,a);return new Fm(s,x[0],x[1],a.numRleValues)}case Vr.CONST:{const x=km(i,r,a,!1);return new Gm(s,x,u)}}throw new Error("Vector type not supported for id column.")}class Lw{constructor(e,r){var s;switch(this._featureData=e,this.properties=this._featureData.properties||{},(s=this._featureData.geometry)===null||s===void 0?void 0:s.type){case $r.POINT:case $r.MULTIPOINT:this.type=1;break;case $r.LINESTRING:case $r.MULTILINESTRING:this.type=2;break;case $r.POLYGON:case $r.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=r,this.id=Number(this._featureData.id)}loadGeometry(){const e=[];for(const r of this._featureData.geometry.coordinates){const s=[];for(const a of r)s.push(new ne(a.x,a.y));e.push(s)}return e}}class Ow{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new Lw(this.features[e],this.extent)}}class Km{constructor(e){this.layers={};const r=(function(s,a,u=!0){const h=new xw(0),m=[];for(;h.get()<s.length;){const _=Wr(s,h,1)[0]>>>0,x=h.get()+_;if(x>s.length)throw new Error(`Block overruns tile: ${x} > ${s.length}`);if(Wr(s,h,1)[0]>>>0!=1){h.set(x);continue}const w=Rw(s,h),I=w[1],C=w[0].featureTables[0];let z=null,R=null;const F=[];let O=0;for(const X of C.columns){const U=X.name;if(U==="id"){let G=null;if(X.nullable){const ie=di(s,h),fe=h.get(),Pe=vc(s,ie.numValues,h);h.set(fe+ie.byteLength),G=new dn(Pe,ie.numValues)}const J=di(s,h);O=J.decompressedCount,z=Fw(s,X,h,U,J,G??O,u)}else if(U==="geometry"){const G=Wr(s,h,1)[0];if(O===0){const J=h.get();O=di(s,h).decompressedCount,h.set(J)}R=Iw(s,G,h,O)}else{const G=zw(X)?Wr(s,h,1)[0]:1;if(G===0&&X.type==="scalarType")continue;const J=Aw(s,h,X,G,O);if(J)if(Array.isArray(J))for(const ie of J)F.push(ie);else F.push(J)}}const Z=new vw(C.name,R,z,F,I);m.push(Z),h.set(x)}return m})(new Uint8Array(e));this.layers=r.reduce(((s,a)=>Object.assign(Object.assign({},s),{[a.name]:new Ow(a)})),{})}}class Bw{constructor(e,r){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=r,"id"in e&&(typeof e.id=="string"?this.id=parseInt(e.id,10):typeof e.id!="number"||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],r=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(const s of r){const a=[];for(const u of s)a.push(new ne(u[0],u[1]));e.push(a)}return e}}const bc="_geojsonTileLayer";function jw(i,e){e.writeVarintField(15,i.version||1),e.writeStringField(1,i.name||""),e.writeVarintField(5,i.extent||4096);const r={keys:[],values:[],keycache:{},valuecache:{}};for(let u=0;u<i.length;u++)r.feature=i.feature(u),e.writeMessage(2,Nw,r);const s=r.keys;for(const u of s)e.writeStringField(3,u);const a=r.values;for(const u of a)e.writeMessage(4,Zw,u)}function Nw(i,e){if(!i.feature)return;const r=i.feature;r.id!==void 0&&e.writeVarintField(1,r.id),e.writeMessage(2,Vw,i),e.writeVarintField(3,r.type),e.writeMessage(4,$w,r)}function Vw(i,e){for(const r in i.feature?.properties){let s=i.feature.properties[r],a=i.keycache[r];if(s==null)continue;a===void 0&&(i.keys.push(r),a=i.keys.length-1,i.keycache[r]=a),e.writeVarint(a),typeof s!="string"&&typeof s!="boolean"&&typeof s!="number"&&(s=JSON.stringify(s));const u=typeof s+":"+s;let h=i.valuecache[u];h===void 0&&(i.values.push(s),h=i.values.length-1,i.valuecache[u]=h),e.writeVarint(h)}}function Vd(i,e){return(e<<3)+(7&i)}function Jm(i){return i<<1^i>>31}function $w(i,e){const r=i.loadGeometry(),s=i.type;let a=0,u=0;for(const h of r){let m=1;s===1&&(m=h.length),e.writeVarint(Vd(1,m));const _=s===3?h.length-1:h.length;for(let x=0;x<_;x++){x===1&&s!==1&&e.writeVarint(Vd(2,_-1));const w=h[x].x-a,I=h[x].y-u;e.writeVarint(Jm(w)),e.writeVarint(Jm(I)),a+=w,u+=I}i.type===3&&e.writeVarint(Vd(7,1))}}function Zw(i,e){const r=typeof i;r==="string"?e.writeStringField(1,i):r==="boolean"?e.writeBooleanField(7,i):r==="number"&&(i%1!=0?e.writeDoubleField(3,i):i<0?e.writeSVarintField(6,i):e.writeVarintField(5,i))}class Qm{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Ls(Tt,16,0),this.grid3D=new Ls(Tt,16,0),this.featureIndexArray=new N,this.promoteId=r}insert(e,r,s,a,u,h){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,a,u);const _=h?this.grid3D:this.grid;for(let x=0;x<r.length;x++){const w=r[x],I=[1/0,1/0,-1/0,-1/0];for(let C=0;C<w.length;C++){const z=w[C];I[0]=Math.min(I[0],z.x),I[1]=Math.min(I[1],z.y),I[2]=Math.max(I[2],z.x),I[3]=Math.max(I[3],z.y)}I[0]<Tt&&I[1]<Tt&&I[2]>=0&&I[3]>=0&&_.insert(m,I[0],I[1],I[2],I[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding!=="mlt"?new Bf(new Ku(this.rawTileData)).layers:new Km(this.rawTileData).layers,this.sourceLayerCoder=new bm(this.vtLayers?Object.keys(this.vtLayers).sort():[bc])),this.vtLayers}query(e,r,s,a){this.loadVTLayers();const u=e.params,h=Tt/e.tileSize/e.scale,m=_o(u.filter,u.globalState),_=e.queryGeometry,x=e.queryPadding*h,w=Vo.fromPoints(_),I=this.grid.query(w.minX-x,w.minY-x,w.maxX+x,w.maxY+x),C=Vo.fromPoints(e.cameraQueryGeometry).expandBy(x),z=this.grid3D.query(C.minX,C.minY,C.maxX,C.maxY,((O,Z,X,U)=>(function(G,J,ie,fe,Pe){for(const Ie of G)if(J<=Ie.x&&ie<=Ie.y&&fe>=Ie.x&&Pe>=Ie.y)return!0;const Te=[new ne(J,ie),new ne(J,Pe),new ne(fe,Pe),new ne(fe,ie)];if(G.length>2){for(const Ie of Te)if(Va(G,Ie))return!0}for(let Ie=0;Ie<G.length-1;Ie++)if(G0(G[Ie],G[Ie+1],Te))return!0;return!1})(e.cameraQueryGeometry,O-x,Z-x,X+x,U+x)));for(const O of z)I.push(O);I.sort(Uw);const R={};let F;for(let O=0;O<I.length;O++){const Z=I[O];if(Z===F)continue;F=Z;const X=this.featureIndexArray.get(Z);let U=null;this.loadMatchingFeature(R,X.bucketIndex,X.sourceLayerIndex,X.featureIndex,m,u.layers,u.availableImages,r,s,a,((G,J,ie)=>(U||(U=Cn(G)),J.queryIntersectsFeature({queryGeometry:_,feature:G,featureState:ie,geometry:U,zoom:this.z,transform:e.transform,pixelsToTileUnits:h,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return R}loadMatchingFeature(e,r,s,a,u,h,m,_,x,w,I){const C=this.bucketLayerIDs[r];if(h&&!C.some((O=>h.has(O))))return;const z=this.sourceLayerCoder.decode(s),R=this.vtLayers[z].feature(a);if(u.needGeometry){const O=An(R,!0);if(!u.filter(new Dt(this.tileID.overscaledZ),O,this.tileID.canonical))return}else if(!u.filter(new Dt(this.tileID.overscaledZ),R))return;const F=this.getId(R,z);for(let O=0;O<C.length;O++){const Z=C[O];if(h&&!h.has(Z))continue;const X=_[Z];if(!X)continue;let U={};F&&w&&(U=w.getState(X.sourceLayer||bc,F));const G=fr({},x[Z]);G.paint=eg(G.paint,X.paint,R,U,m),G.layout=eg(G.layout,X.layout,R,U,m);const J=!I||I(R,X,U);if(!J)continue;const ie=new wm(R,this.z,this.x,this.y,F);ie.layer=G;let fe=e[Z];fe===void 0&&(fe=e[Z]=[]),fe.push({featureIndex:a,feature:ie,intersectionZ:J})}}lookupSymbolFeatures(e,r,s,a,u,h,m,_){const x={};this.loadVTLayers();const w=_o(u.filterSpec,u.globalState);for(const I of e)this.loadMatchingFeature(x,s,a,I,w,h,m,_,r);return x}hasLayer(e){for(const r of this.bucketLayerIDs)for(const s of r)if(e===s)return!0;return!1}getId(e,r){var s;let a=e.id;return this.promoteId&&(a=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof a=="boolean"&&(a=Number(a)),a===void 0&&(!((s=e.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(a=Number(e.properties.cluster_id))),a}}function eg(i,e,r,s,a){return Xi(i,((u,h)=>{const m=e instanceof Ao?e.get(h):null;return m&&m.evaluate?m.evaluate(r,s,a):m}))}function Uw(i,e){return e-i}function tg(i,e,r,s,a){const u=[];for(let h=0;h<i.length;h++){const m=i[h];let _;for(let x=0;x<m.length-1;x++){let w=m[x],I=m[x+1];w.x<e&&I.x<e||(w.x<e?w=new ne(e,w.y+(e-w.x)/(I.x-w.x)*(I.y-w.y))._round():I.x<e&&(I=new ne(e,w.y+(e-w.x)/(I.x-w.x)*(I.y-w.y))._round()),w.y<r&&I.y<r||(w.y<r?w=new ne(w.x+(r-w.y)/(I.y-w.y)*(I.x-w.x),r)._round():I.y<r&&(I=new ne(w.x+(r-w.y)/(I.y-w.y)*(I.x-w.x),r)._round()),w.x>=s&&I.x>=s||(w.x>=s?w=new ne(s,w.y+(s-w.x)/(I.x-w.x)*(I.y-w.y))._round():I.x>=s&&(I=new ne(s,w.y+(s-w.x)/(I.x-w.x)*(I.y-w.y))._round()),w.y>=a&&I.y>=a||(w.y>=a?w=new ne(w.x+(a-w.y)/(I.y-w.y)*(I.x-w.x),a)._round():I.y>=a&&(I=new ne(w.x+(a-w.y)/(I.y-w.y)*(I.x-w.x),a)._round()),_&&w.equals(_[_.length-1])||(_=[w],u.push(_)),_.push(I)))))}}return u}function rg(i,e,r,s,a){switch(e){case 1:return(function(u,h,m,_){const x=[];for(const w of u)for(const I of w){const C=_===0?I.x:I.y;C>=h&&C<=m&&x.push([I])}return x})(i,r,s,a);case 2:return ig(i,r,s,a,!1);case 3:return ig(i,r,s,a,!0)}return[]}function Gw(i,e,r,s,a){const u=s===0?qw:Ww;let h=[];const m=[];for(let w=0;w<i.length-1;w++){const I=i[w],C=i[w+1],z=s===0?I.x:I.y,R=s===0?C.x:C.y;let F=!1;z<e?R>e&&h.push(u(I,C,e)):z>r?R<r&&h.push(u(I,C,r)):h.push(I),R<e&&z>=e&&(h.push(u(I,C,e)),F=!0),R>r&&z<=r&&(h.push(u(I,C,r)),F=!0),!a&&F&&(m.push(h),h=[])}const _=i.length-1,x=s===0?i[_].x:i[_].y;return x>=e&&x<=r&&h.push(i[_]),a&&h.length>0&&!h[0].equals(h[h.length-1])&&h.push(new ne(h[0].x,h[0].y)),h.length>0&&m.push(h),m}function ig(i,e,r,s,a){const u=[];for(const h of i){const m=Gw(h,e,r,s,a);m.length>0&&u.push(...m)}return u}function qw(i,e,r){return new ne(r,i.y+(r-i.x)/(e.x-i.x)*(e.y-i.y))}function Ww(i,e,r){return new ne(i.x+(r-i.y)/(e.y-i.y)*(e.x-i.x),r)}Ue("FeatureIndex",Qm,{omit:["rawTileData","sourceLayerCoder"]});class Us extends ne{constructor(e,r,s,a){super(e,r),this.angle=s,a!==void 0&&(this.segment=a)}clone(){return new Us(this.x,this.y,this.angle,this.segment)}}function ng(i,e,r,s,a){if(e.segment===void 0||r===0)return!0;let u=e,h=e.segment+1,m=0;for(;m>-r/2;){if(h--,h<0)return!1;m-=i[h].dist(u),u=i[h]}m+=i[h].dist(i[h+1]),h++;const _=[];let x=0;for(;m<r/2;){const w=i[h],I=i[h+1];if(!I)return!1;let C=i[h-1].angleTo(w)-w.angleTo(I);for(C=Math.abs((C+3*Math.PI)%(2*Math.PI)-Math.PI),_.push({distance:m,angleDelta:C}),x+=C;m-_[0].distance>s;)x-=_.shift().angleDelta;if(x>a)return!1;h++,m+=w.dist(I)}return!0}function sg(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function og(i,e,r){return i?.6*e*r:0}function ag(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function Hw(i,e,r,s,a,u){const h=og(r,a,u),m=ag(r,s)*u;let _=0;const x=sg(i)/2;for(let w=0;w<i.length-1;w++){const I=i[w],C=i[w+1],z=I.dist(C);if(_+z>x){const R=(x-_)/z,F=Ht.number(I.x,C.x,R),O=Ht.number(I.y,C.y,R),Z=new Us(F,O,C.angleTo(I),w);return Z._round(),!h||ng(i,Z,m,h,e)?Z:void 0}_+=z}}function Xw(i,e,r,s,a,u,h,m,_){const x=og(s,u,h),w=ag(s,a),I=w*h,C=i[0].x===0||i[0].x===_||i[0].y===0||i[0].y===_;return e-I<e/4&&(e=I+e/4),lg(i,C?e/2*m%e:(w/2+2*u)*h*m%e,e,x,r,I,C,!1,_)}function lg(i,e,r,s,a,u,h,m,_){const x=u/2,w=sg(i);let I=0,C=e-r,z=[];for(let R=0;R<i.length-1;R++){const F=i[R],O=i[R+1],Z=F.dist(O),X=O.angleTo(F);for(;C+r<I+Z;){C+=r;const U=(C-I)/Z,G=Ht.number(F.x,O.x,U),J=Ht.number(F.y,O.y,U);if(G>=0&&G<_&&J>=0&&J<_&&C-x>=0&&C+x<=w){const ie=new Us(G,J,X,R);ie._round(),s&&!ng(i,ie,u,s,a)||z.push(ie)}}I+=Z}return m||z.length||h||(z=lg(i,I/2,r,s,a,u,h,!0,_)),z}function cg(i,e,r,s){const a=[],u=i.image,h=u.pixelRatio,m=u.paddedRect.w-2,_=u.paddedRect.h-2;let x={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom};const w=u.stretchX||[[0,m]],I=u.stretchY||[[0,_]],C=(xe,$e)=>xe+$e[1]-$e[0],z=w.reduce(C,0),R=I.reduce(C,0),F=m-z,O=_-R;let Z=0,X=z,U=0,G=R,J=0,ie=F,fe=0,Pe=O;if(u.content&&s){const xe=u.content,$e=xe[2]-xe[0],Ne=xe[3]-xe[1];(u.textFitWidth||u.textFitHeight)&&(x=nm(i)),Z=ch(w,0,xe[0]),U=ch(I,0,xe[1]),X=ch(w,xe[0],xe[2]),G=ch(I,xe[1],xe[3]),J=xe[0]-Z,fe=xe[1]-U,ie=$e-X,Pe=Ne-G}const Te=x.x1,Ie=x.y1,Oe=x.x2-Te,ze=x.y2-Ie,we=(xe,$e,Ne,Ge)=>{const Ve=uh(xe.stretch-Z,X,Oe,Te),Ye=hh(xe.fixed-J,ie,xe.stretch,z),xt=uh($e.stretch-U,G,ze,Ie),gt=hh($e.fixed-fe,Pe,$e.stretch,R),Kt=uh(Ne.stretch-Z,X,Oe,Te),Jr=hh(Ne.fixed-J,ie,Ne.stretch,z),Er=uh(Ge.stretch-U,G,ze,Ie),Jt=hh(Ge.fixed-fe,Pe,Ge.stretch,R),Wt=new ne(Ve,xt),Pt=new ne(Kt,xt),hr=new ne(Kt,Er),xr=new ne(Ve,Er),Gt=new ne(Ye/h,gt/h),bi=new ne(Jr/h,Jt/h),Qr=e*Math.PI/180;if(Qr){const Zr=Math.sin(Qr),ir=Math.cos(Qr),Cr=[ir,-Zr,Zr,ir];Wt._matMult(Cr),Pt._matMult(Cr),xr._matMult(Cr),hr._matMult(Cr)}const wi=xe.stretch+xe.fixed,rn=$e.stretch+$e.fixed;return{tl:Wt,tr:Pt,bl:xr,br:hr,tex:{x:u.paddedRect.x+1+wi,y:u.paddedRect.y+1+rn,w:Ne.stretch+Ne.fixed-wi,h:Ge.stretch+Ge.fixed-rn},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Gt,pixelOffsetBR:bi,minFontScaleX:ie/h/Oe,minFontScaleY:Pe/h/ze,isSDF:r}};if(s&&(u.stretchX||u.stretchY)){const xe=ug(w,F,z),$e=ug(I,O,R);for(let Ne=0;Ne<xe.length-1;Ne++){const Ge=xe[Ne],Ve=xe[Ne+1];for(let Ye=0;Ye<$e.length-1;Ye++)a.push(we(Ge,$e[Ye],Ve,$e[Ye+1]))}}else a.push(we({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:m+1},{fixed:0,stretch:_+1}));return a}function ch(i,e,r){let s=0;for(const a of i)s+=Math.max(e,Math.min(r,a[1]))-Math.max(e,Math.min(r,a[0]));return s}function ug(i,e,r){const s=[{fixed:-1,stretch:0}];for(const[a,u]of i){const h=s[s.length-1];s.push({fixed:a-h.stretch,stretch:h.stretch}),s.push({fixed:a-h.stretch,stretch:h.stretch+(u-a)})}return s.push({fixed:e+1,stretch:r}),s}function uh(i,e,r,s){return i/e*r+s}function hh(i,e,r,s){return i-e*r/s}Ue("Anchor",Us);class dh{constructor(e,r,s,a,u,h,m,_,x,w){var I;if(this.boxStartIndex=e.length,x){let C=h.top,z=h.bottom;const R=h.collisionPadding;R&&(C-=R[1],z+=R[3]);let F=z-C;F>0&&(F=Math.max(10,F),this.circleDiameter=F)}else{const C=!((I=h.image)===null||I===void 0)&&I.content&&(h.image.textFitWidth||h.image.textFitHeight)?nm(h):{x1:h.left,y1:h.top,x2:h.right,y2:h.bottom};C.y1=C.y1*m-_[0],C.y2=C.y2*m+_[2],C.x1=C.x1*m-_[3],C.x2=C.x2*m+_[1];const z=h.collisionPadding;if(z&&(C.x1-=z[0]*m,C.y1-=z[1]*m,C.x2+=z[2]*m,C.y2+=z[3]*m),w){const R=new ne(C.x1,C.y1),F=new ne(C.x2,C.y1),O=new ne(C.x1,C.y2),Z=new ne(C.x2,C.y2),X=w*Math.PI/180;R._rotate(X),F._rotate(X),O._rotate(X),Z._rotate(X),C.x1=Math.min(R.x,F.x,O.x,Z.x),C.x2=Math.max(R.x,F.x,O.x,Z.x),C.y1=Math.min(R.y,F.y,O.y,Z.y),C.y2=Math.max(R.y,F.y,O.y,Z.y)}e.emplaceBack(r.x,r.y,C.x1,C.y1,C.x2,C.y2,s,a,u)}this.boxEndIndex=e.length}}class Yw{constructor(e=[],r=(s,a)=>s<a?-1:s>a?1:0){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:s}=this,a=r[e];for(;e>0;){const u=e-1>>1,h=r[u];if(s(a,h)>=0)break;r[e]=h,e=u}r[e]=a}_down(e){const{data:r,compare:s}=this,a=this.length>>1,u=r[e];for(;e<a;){let h=1+(e<<1);const m=h+1;if(m<this.length&&s(r[m],r[h])<0&&(h=m),s(r[h],u)>=0)break;r[e]=r[h],e=h}r[e]=u}}function Kw(i,e=1,r=!1){const s=Vo.fromPoints(i[0]),a=Math.min(s.width(),s.height());let u=a/2;const h=new Yw([],Jw),{minX:m,minY:_,maxX:x,maxY:w}=s;if(a===0)return new ne(m,_);for(let z=m;z<x;z+=a)for(let R=_;R<w;R+=a)h.push(new el(z+u,R+u,u,i));let I=(function(z){let R=0,F=0,O=0;const Z=z[0];for(let X=0,U=Z.length,G=U-1;X<U;G=X++){const J=Z[X],ie=Z[G],fe=J.x*ie.y-ie.x*J.y;F+=(J.x+ie.x)*fe,O+=(J.y+ie.y)*fe,R+=3*fe}return new el(F/R,O/R,0,z)})(i),C=h.length;for(;h.length;){const z=h.pop();(z.d>I.d||!I.d)&&(I=z,r&&console.log("found best %d after %d probes",Math.round(1e4*z.d)/1e4,C)),z.max-I.d<=e||(u=z.h/2,h.push(new el(z.p.x-u,z.p.y-u,u,i)),h.push(new el(z.p.x+u,z.p.y-u,u,i)),h.push(new el(z.p.x-u,z.p.y+u,u,i)),h.push(new el(z.p.x+u,z.p.y+u,u,i)),C+=4)}return r&&(console.log(`num probes: ${C}`),console.log(`best distance: ${I.d}`)),I.p}function Jw(i,e){return e.max-i.max}function el(i,e,r,s){this.p=new ne(i,e),this.h=r,this.d=(function(a,u){let h=!1,m=1/0;for(let _=0;_<u.length;_++){const x=u[_];for(let w=0,I=x.length,C=I-1;w<I;C=w++){const z=x[w],R=x[C];z.y>a.y!=R.y>a.y&&a.x<(R.x-z.x)*(a.y-z.y)/(R.y-z.y)+z.x&&(h=!h),m=Math.min(m,mf(a,z,R))}}return(h?1:-1)*Math.sqrt(m)})(this.p,s),this.max=this.d+this.h*Math.SQRT2}var Kr;S.aP=void 0,(Kr=S.aP||(S.aP={}))[Kr.center=1]="center",Kr[Kr.left=2]="left",Kr[Kr.right=3]="right",Kr[Kr.top=4]="top",Kr[Kr.bottom=5]="bottom",Kr[Kr["top-left"]=6]="top-left",Kr[Kr["top-right"]=7]="top-right",Kr[Kr["bottom-left"]=8]="bottom-left",Kr[Kr["bottom-right"]=9]="bottom-right";const $d=Number.POSITIVE_INFINITY;function hg(i,e){return e[1]!==$d?(function(r,s,a){let u=0,h=0;switch(s=Math.abs(s),a=Math.abs(a),r){case"top-right":case"top-left":case"top":h=a-7;break;case"bottom-right":case"bottom-left":case"bottom":h=7-a}switch(r){case"top-right":case"bottom-right":case"right":u=-s;break;case"top-left":case"bottom-left":case"left":u=s}return[u,h]})(i,e[0],e[1]):(function(r,s){let a=0,u=0;s<0&&(s=0);const h=s/Math.SQRT2;switch(r){case"top-right":case"top-left":u=h-7;break;case"bottom-right":case"bottom-left":u=7-h;break;case"bottom":u=7-s;break;case"top":u=s-7}switch(r){case"top-right":case"bottom-right":a=-h;break;case"top-left":case"bottom-left":a=h;break;case"left":a=s;break;case"right":a=-s}return[a,u]})(i,e[0])}function dg(i,e,r){var s;const a=i.layout,u=(s=a.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(e,{},r);if(u){const m=u.values,_=[];for(let x=0;x<m.length;x+=2){const w=_[x]=m[x],I=m[x+1].map((C=>C*Nr));w.startsWith("top")?I[1]-=7:w.startsWith("bottom")&&(I[1]+=7),_[x+1]=I}return new ri(_)}const h=a.get("text-variable-anchor");if(h){let m;m=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[a.get("text-radial-offset").evaluate(e,{},r)*Nr,$d]:a.get("text-offset").evaluate(e,{},r).map((x=>x*Nr));const _=[];for(const x of h)_.push(x,hg(x,m));return new ri(_)}return null}function Zd(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Qw(i,e,r,s,a,u,h,m,_,x,w,I){let C=u.textMaxSize.evaluate(e,{});C===void 0&&(C=h);const z=i.layers[0].layout,R=z.get("icon-offset").evaluate(e,{},w),F=fg(r.horizontal),O=h/24,Z=i.tilePixelRatio*O,X=i.tilePixelRatio*C/24,U=i.tilePixelRatio*m,G=i.tilePixelRatio*z.get("symbol-spacing"),J=z.get("text-padding")*i.tilePixelRatio,ie=(function(Ne,Ge,Ve,Ye=1){const xt=Ne.get("icon-padding").evaluate(Ge,{},Ve),gt=xt&&xt.values;return[gt[0]*Ye,gt[1]*Ye,gt[2]*Ye,gt[3]*Ye]})(z,e,w,i.tilePixelRatio),fe=z.get("text-max-angle")/180*Math.PI,Pe=z.get("text-rotation-alignment")!=="viewport"&&z.get("symbol-placement")!=="point",Te=z.get("icon-rotation-alignment")==="map"&&z.get("symbol-placement")!=="point",Ie=z.get("symbol-placement"),Oe=G/2,ze=z.get("icon-text-fit");let we;s&&ze!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(we=sm(s,r.vertical,ze,z.get("icon-text-fit-padding"),R,O)),F&&(s=sm(s,F,ze,z.get("icon-text-fit-padding"),R,O)));const xe=w?I.line.getGranularityForZoomLevel(w.z):1,$e=(Ne,Ge)=>{Ge.x<0||Ge.x>=Tt||Ge.y<0||Ge.y>=Tt||(function(Ve,Ye,xt,gt,Kt,Jr,Er,Jt,Wt,Pt,hr,xr,Gt,bi,Qr,wi,rn,Zr,ir,Cr,dr,Ur,ss,pn,Sc){const Gs=Ve.addToLineVertexArray(Ye,xt);let Uo,tl,rl,il,yg=0,vg=0,xg=0,bg=0,Kd=-1,Jd=-1;const os={};let wg=vr("");if(Ve.allowVerticalPlacement&>.vertical){const oi=Jt.layout.get("text-rotate").evaluate(dr,{},pn)+90;rl=new dh(Wt,Ye,Pt,hr,xr,gt.vertical,Gt,bi,Qr,oi),Er&&(il=new dh(Wt,Ye,Pt,hr,xr,Er,rn,Zr,Qr,oi))}if(Kt){const oi=Jt.layout.get("icon-rotate").evaluate(dr,{}),Gi=Jt.layout.get("icon-text-fit")!=="none",Go=cg(Kt,oi,ss,Gi),mn=Er?cg(Er,oi,ss,Gi):void 0;tl=new dh(Wt,Ye,Pt,hr,xr,Kt,rn,Zr,!1,oi),yg=4*Go.length;const qo=Ve.iconSizeData;let zn=null;qo.kind==="source"?(zn=[is*Jt.layout.get("icon-size").evaluate(dr,{})],zn[0]>Vs&&Or(`${Ve.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):qo.kind==="composite"&&(zn=[is*Ur.compositeIconSizes[0].evaluate(dr,{},pn),is*Ur.compositeIconSizes[1].evaluate(dr,{},pn)],(zn[0]>Vs||zn[1]>Vs)&&Or(`${Ve.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ve.addSymbols(Ve.icon,Go,zn,Cr,ir,dr,S.az.none,Ye,Gs.lineStartIndex,Gs.lineLength,-1,pn),Kd=Ve.icon.placedSymbolArray.length-1,mn&&(vg=4*mn.length,Ve.addSymbols(Ve.icon,mn,zn,Cr,ir,dr,S.az.vertical,Ye,Gs.lineStartIndex,Gs.lineLength,-1,pn),Jd=Ve.icon.placedSymbolArray.length-1)}const Tg=Object.keys(gt.horizontal);for(const oi of Tg){const Gi=gt.horizontal[oi];if(!Uo){wg=vr(Gi.text);const mn=Jt.layout.get("text-rotate").evaluate(dr,{},pn);Uo=new dh(Wt,Ye,Pt,hr,xr,Gi,Gt,bi,Qr,mn)}const Go=Gi.positionedLines.length===1;if(xg+=pg(Ve,Ye,Gi,Jr,Jt,Qr,dr,wi,Gs,gt.vertical?S.az.horizontal:S.az.horizontalOnly,Go?Tg:[oi],os,Kd,Ur,pn),Go)break}gt.vertical&&(bg+=pg(Ve,Ye,gt.vertical,Jr,Jt,Qr,dr,wi,Gs,S.az.vertical,["vertical"],os,Jd,Ur,pn));const r1=Uo?Uo.boxStartIndex:Ve.collisionBoxArray.length,i1=Uo?Uo.boxEndIndex:Ve.collisionBoxArray.length,n1=rl?rl.boxStartIndex:Ve.collisionBoxArray.length,s1=rl?rl.boxEndIndex:Ve.collisionBoxArray.length,o1=tl?tl.boxStartIndex:Ve.collisionBoxArray.length,a1=tl?tl.boxEndIndex:Ve.collisionBoxArray.length,l1=il?il.boxStartIndex:Ve.collisionBoxArray.length,c1=il?il.boxEndIndex:Ve.collisionBoxArray.length;let fn=-1;const fh=(oi,Gi)=>oi&&oi.circleDiameter?Math.max(oi.circleDiameter,Gi):Gi;fn=fh(Uo,fn),fn=fh(rl,fn),fn=fh(tl,fn),fn=fh(il,fn);const Sg=fn>-1?1:0;Sg&&(fn*=Sc/Nr),Ve.glyphOffsetArray.length>=Ha.MAX_GLYPHS&&Or("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),dr.sortKey!==void 0&&Ve.addToSortKeyRanges(Ve.symbolInstances.length,dr.sortKey);const u1=dg(Jt,dr,pn),[h1,d1]=(function(oi,Gi){const Go=oi.length,mn=Gi?.values;if(mn?.length>0)for(let qo=0;qo<mn.length;qo+=2){const zn=mn[qo+1];oi.emplaceBack(S.aP[mn[qo]],zn[0],zn[1])}return[Go,oi.length]})(Ve.textAnchorOffsets,u1);Ve.symbolInstances.emplaceBack(Ye.x,Ye.y,os.right>=0?os.right:-1,os.center>=0?os.center:-1,os.left>=0?os.left:-1,os.vertical||-1,Kd,Jd,wg,r1,i1,n1,s1,o1,a1,l1,c1,Pt,xg,bg,yg,vg,Sg,0,Gt,fn,h1,d1)})(i,Ge,Ne,r,s,a,we,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,Z,[J,J,J,J],Pe,_,U,ie,Te,R,e,u,x,w,h)};if(Ie==="line")for(const Ne of tg(e.geometry,0,0,Tt,Tt)){const Ge=No(Ne,xe),Ve=Xw(Ge,G,fe,r.vertical||F,s,24,X,i.overscaling,Tt);for(const Ye of Ve)F&&e1(i,F.text,Oe,Ye)||$e(Ge,Ye)}else if(Ie==="line-center"){for(const Ne of e.geometry)if(Ne.length>1){const Ge=No(Ne,xe),Ve=Hw(Ge,fe,r.vertical||F,s,24,X);Ve&&$e(Ge,Ve)}}else if(e.type==="Polygon")for(const Ne of la(e.geometry,0)){const Ge=Kw(Ne,16);$e(No(Ne[0],xe,!0),new Us(Ge.x,Ge.y,0))}else if(e.type==="LineString")for(const Ne of e.geometry){const Ge=No(Ne,xe);$e(Ge,new Us(Ge[0].x,Ge[0].y,0))}else if(e.type==="Point")for(const Ne of e.geometry)for(const Ge of Ne)$e([Ge],new Us(Ge.x,Ge.y,0))}function pg(i,e,r,s,a,u,h,m,_,x,w,I,C,z,R){const F=(function(X,U,G,J,ie,fe,Pe,Te){const Ie=J.layout.get("text-rotate").evaluate(fe,{})*Math.PI/180,Oe=[];for(const ze of U.positionedLines)for(const we of ze.positionedGlyphs){if(!we.rect)continue;const xe=we.rect||{};let $e=4,Ne=!0,Ge=1,Ve=0;const Ye=(ie||Te)&&we.vertical,xt=we.metrics.advance*we.scale/2;if(Te&&U.verticalizable&&(Ve=ze.lineOffset/2-(we.imageName?-(Nr-we.metrics.width*we.scale)/2:(we.scale-1)*Nr)),we.imageName){const Zr=Pe[we.imageName];Ne=Zr.sdf,Ge=Zr.pixelRatio,$e=1/Ge}const gt=ie?[we.x+xt,we.y]:[0,0];let Kt=ie?[0,0]:[we.x+xt+G[0],we.y+G[1]-Ve],Jr=[0,0];Ye&&(Jr=Kt,Kt=[0,0]);const Er=we.metrics.isDoubleResolution?2:1,Jt=(we.metrics.left-$e)*we.scale-xt+Kt[0],Wt=(-we.metrics.top-$e)*we.scale+Kt[1],Pt=Jt+xe.w/Er*we.scale/Ge,hr=Wt+xe.h/Er*we.scale/Ge,xr=new ne(Jt,Wt),Gt=new ne(Pt,Wt),bi=new ne(Jt,hr),Qr=new ne(Pt,hr);if(Ye){const Zr=new ne(-xt,xt- -17),ir=-Math.PI/2,Cr=12-xt,dr=new ne(22-Cr,-(we.imageName?Cr:0)),Ur=new ne(...Jr);xr._rotateAround(ir,Zr)._add(dr)._add(Ur),Gt._rotateAround(ir,Zr)._add(dr)._add(Ur),bi._rotateAround(ir,Zr)._add(dr)._add(Ur),Qr._rotateAround(ir,Zr)._add(dr)._add(Ur)}if(Ie){const Zr=Math.sin(Ie),ir=Math.cos(Ie),Cr=[ir,-Zr,Zr,ir];xr._matMult(Cr),Gt._matMult(Cr),bi._matMult(Cr),Qr._matMult(Cr)}const wi=new ne(0,0),rn=new ne(0,0);Oe.push({tl:xr,tr:Gt,bl:bi,br:Qr,tex:xe,writingMode:U.writingMode,glyphOffset:gt,sectionIndex:we.sectionIndex,isSDF:Ne,pixelOffsetTL:wi,pixelOffsetBR:rn,minFontScaleX:0,minFontScaleY:0})}return Oe})(0,r,m,a,u,h,s,i.allowVerticalPlacement),O=i.textSizeData;let Z=null;O.kind==="source"?(Z=[is*a.layout.get("text-size").evaluate(h,{})],Z[0]>Vs&&Or(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):O.kind==="composite"&&(Z=[is*z.compositeTextSizes[0].evaluate(h,{},R),is*z.compositeTextSizes[1].evaluate(h,{},R)],(Z[0]>Vs||Z[1]>Vs)&&Or(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),i.addSymbols(i.text,F,Z,m,u,h,x,e,_.lineStartIndex,_.lineLength,C,R);for(const X of w)I[X]=i.text.placedSymbolArray.length-1;return 4*F.length}function fg(i){for(const e in i)return i[e];return null}function e1(i,e,r,s){const a=i.compareText;if(e in a){const u=a[e];for(let h=u.length-1;h>=0;h--)if(s.dist(u[h])<r)return!0}else a[e]=[];return a[e].push(s),!1}const mg=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Ud{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,s]=new Uint8Array(e,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const a=s>>4;if(a!==1)throw new Error(`Got v${a} data when expected v1.`);const u=mg[15&s];if(!u)throw new Error("Unrecognized array type.");const[h]=new Uint16Array(e,2,1),[m]=new Uint32Array(e,4,1);return new Ud(m,h,u,e)}constructor(e,r=64,s=Float64Array,a){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const u=mg.indexOf(this.ArrayType),h=2*e*this.ArrayType.BYTES_PER_ELEMENT,m=e*this.IndexArrayType.BYTES_PER_ELEMENT,_=(8-m%8)%8;if(u<0)throw new Error(`Unexpected typed array class: ${s}.`);a&&a instanceof ArrayBuffer?(this.data=a,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+_,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+h+m+_),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+_,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+u]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=e,this.coords[this._pos++]=r,s}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Gd(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,s,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:u,coords:h,nodeSize:m}=this,_=[0,u.length-1,0],x=[];for(;_.length;){const w=_.pop()||0,I=_.pop()||0,C=_.pop()||0;if(I-C<=m){for(let O=C;O<=I;O++){const Z=h[2*O],X=h[2*O+1];Z>=e&&Z<=s&&X>=r&&X<=a&&x.push(u[O])}continue}const z=C+I>>1,R=h[2*z],F=h[2*z+1];R>=e&&R<=s&&F>=r&&F<=a&&x.push(u[z]),(w===0?e<=R:r<=F)&&(_.push(C),_.push(z-1),_.push(1-w)),(w===0?s>=R:a>=F)&&(_.push(z+1),_.push(I),_.push(1-w))}return x}within(e,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:a,coords:u,nodeSize:h}=this,m=[0,a.length-1,0],_=[],x=s*s;for(;m.length;){const w=m.pop()||0,I=m.pop()||0,C=m.pop()||0;if(I-C<=h){for(let O=C;O<=I;O++)_g(u[2*O],u[2*O+1],e,r)<=x&&_.push(a[O]);continue}const z=C+I>>1,R=u[2*z],F=u[2*z+1];_g(R,F,e,r)<=x&&_.push(a[z]),(w===0?e-s<=R:r-s<=F)&&(m.push(C),m.push(z-1),m.push(1-w)),(w===0?e+s>=R:r+s>=F)&&(m.push(z+1),m.push(I),m.push(1-w))}return _}}function Gd(i,e,r,s,a,u){if(a-s<=r)return;const h=s+a>>1;gg(i,e,h,s,a,u),Gd(i,e,r,s,h-1,1-u),Gd(i,e,r,h+1,a,1-u)}function gg(i,e,r,s,a,u){for(;a>s;){if(a-s>600){const x=a-s+1,w=r-s+1,I=Math.log(x),C=.5*Math.exp(2*I/3),z=.5*Math.sqrt(I*C*(x-C)/x)*(w-x/2<0?-1:1);gg(i,e,r,Math.max(s,Math.floor(r-w*C/x+z)),Math.min(a,Math.floor(r+(x-w)*C/x+z)),u)}const h=e[2*r+u];let m=s,_=a;for(wc(i,e,s,r),e[2*a+u]>h&&wc(i,e,s,a);m<_;){for(wc(i,e,m,_),m++,_--;e[2*m+u]<h;)m++;for(;e[2*_+u]>h;)_--}e[2*s+u]===h?wc(i,e,s,_):(_++,wc(i,e,_,a)),_<=r&&(s=_+1),r<=_&&(a=_-1)}}function wc(i,e,r,s){qd(i,r,s),qd(e,2*r,2*s),qd(e,2*r+1,2*s+1)}function qd(i,e,r){const s=i[e];i[e]=i[r],i[r]=s}function _g(i,e,r,s){const a=i-r,u=e-s;return a*a+u*u}var Wd;S.cI=void 0,(Wd=S.cI||(S.cI={})).create="create",Wd.load="load",Wd.fullLoad="fullLoad";let ph=null,Tc=[];const Hd=1e3/60,Xd="loadTime",Yd="fullLoadTime",t1={mark(i){performance.mark(i)},frame(i){const e=i;ph!=null&&Tc.push(e-ph),ph=e},clearMetrics(){ph=null,Tc=[],performance.clearMeasures(Xd),performance.clearMeasures(Yd);for(const i in S.cI)performance.clearMarks(S.cI[i])},getPerformanceMetrics(){performance.measure(Xd,S.cI.create,S.cI.load),performance.measure(Yd,S.cI.create,S.cI.fullLoad);const i=performance.getEntriesByName(Xd)[0].duration,e=performance.getEntriesByName(Yd)[0].duration,r=Tc.length,s=1/(Tc.reduce(((u,h)=>u+h),0)/r/1e3),a=Tc.filter((u=>u>Hd)).reduce(((u,h)=>u+(h-Hd)/Hd),0);return{loadTime:i,fullLoadTime:e,fps:s,percentDroppedFrames:a/(r+a)*100,totalFrames:r}}};S.$=me,S.A=tt,S.B=Fs,S.C=Br,S.D=Xe,S.E=ke,S.F=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}},S.G=Ht,S.H=Dt,S.I=gd,S.J=zu,S.K=function(i){if(er==null){const e=i.navigator?i.navigator.userAgent:null;er=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return er},S.L=class{constructor(i,e){this.target=i,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new gw((()=>this.process())),this.subscription=Fn(this.target,"message",(r=>this.receive(r)),!1),this.globalScope=Ri(self)?i:window}registerMessageHandler(i,e){this.messageHandlers[i]=e}unregisterMessageHandler(i){delete this.messageHandlers[i]}sendAsync(i,e){return new Promise(((r,s)=>{const a=Math.round(1e18*Math.random()).toString(36).substring(0,10),u=e?Fn(e.signal,"abort",(()=>{u?.unsubscribe(),delete this.resolveRejects[a];const _={id:a,type:"<cancel>",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(_)}),_w):null;this.resolveRejects[a]={resolve:_=>{u?.unsubscribe(),r(_)},reject:_=>{u?.unsubscribe(),s(_)}};const h=[],m=Object.assign(Object.assign({},i),{id:a,sourceMapId:this.mapId,origin:location.origin,data:Io(i.data,h)});this.target.postMessage(m,{transfer:h})}))}receive(i){const e=i.data,r=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!=="resource://android"&&location.origin!=="resource://android"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type==="<cancel>"){delete this.tasks[r];const s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(Ri(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e)}}process(){if(this.taskQueue.length===0)return;const i=this.taskQueue.shift(),e=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(i,e)}processTask(i,e){return l(this,void 0,void 0,(function*(){if(e.type==="<response>"){const a=this.resolveRejects[i];return delete this.resolveRejects[i],a?void(e.error?a.reject(Mo(e.error)):a.resolve(Mo(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const r=Mo(e.data),s=new AbortController;this.abortControllers[i]=s;try{const a=yield this.messageHandlers[e.type](e.sourceMapId,r,s);this.completeTask(i,null,a)}catch(a){this.completeTask(i,a)}}))}completeTask(i,e,r){const s=[];delete this.abortControllers[i];const a={id:i,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?Io(e):null,data:Io(r,s)};this.target.postMessage(a,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},S.M=$,S.N=function(){var i=new tt(16);return tt!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},S.O=function(i,e,r){var s,a,u,h,m,_,x,w,I,C,z,R,F=r[0],O=r[1],Z=r[2];return e===i?(i[12]=e[0]*F+e[4]*O+e[8]*Z+e[12],i[13]=e[1]*F+e[5]*O+e[9]*Z+e[13],i[14]=e[2]*F+e[6]*O+e[10]*Z+e[14],i[15]=e[3]*F+e[7]*O+e[11]*Z+e[15]):(a=e[1],u=e[2],h=e[3],m=e[4],_=e[5],x=e[6],w=e[7],I=e[8],C=e[9],z=e[10],R=e[11],i[0]=s=e[0],i[1]=a,i[2]=u,i[3]=h,i[4]=m,i[5]=_,i[6]=x,i[7]=w,i[8]=I,i[9]=C,i[10]=z,i[11]=R,i[12]=s*F+m*O+I*Z+e[12],i[13]=a*F+_*O+C*Z+e[13],i[14]=u*F+x*O+z*Z+e[14],i[15]=h*F+w*O+R*Z+e[15]),i},S.P=ne,S.Q=function(i,e,r){var s=r[0],a=r[1],u=r[2];return i[0]=e[0]*s,i[1]=e[1]*s,i[2]=e[2]*s,i[3]=e[3]*s,i[4]=e[4]*a,i[5]=e[5]*a,i[6]=e[6]*a,i[7]=e[7]*a,i[8]=e[8]*u,i[9]=e[9]*u,i[10]=e[10]*u,i[11]=e[11]*u,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},S.R=xi,S.S=function(i,e,r){var s=e[0],a=e[1],u=e[2],h=e[3],m=e[4],_=e[5],x=e[6],w=e[7],I=e[8],C=e[9],z=e[10],R=e[11],F=e[12],O=e[13],Z=e[14],X=e[15],U=r[0],G=r[1],J=r[2],ie=r[3];return i[0]=U*s+G*m+J*I+ie*F,i[1]=U*a+G*_+J*C+ie*O,i[2]=U*u+G*x+J*z+ie*Z,i[3]=U*h+G*w+J*R+ie*X,i[4]=(U=r[4])*s+(G=r[5])*m+(J=r[6])*I+(ie=r[7])*F,i[5]=U*a+G*_+J*C+ie*O,i[6]=U*u+G*x+J*z+ie*Z,i[7]=U*h+G*w+J*R+ie*X,i[8]=(U=r[8])*s+(G=r[9])*m+(J=r[10])*I+(ie=r[11])*F,i[9]=U*a+G*_+J*C+ie*O,i[10]=U*u+G*x+J*z+ie*Z,i[11]=U*h+G*w+J*R+ie*X,i[12]=(U=r[12])*s+(G=r[13])*m+(J=r[14])*I+(ie=r[15])*F,i[13]=U*a+G*_+J*C+ie*O,i[14]=U*u+G*x+J*z+ie*Z,i[15]=U*h+G*w+J*R+ie*X,i},S.T=ad,S.U=function(i,e){const r={};for(let s=0;s<e.length;s++){const a=e[s];a in i&&(r[a]=i[a])}return r},S.V=$s,S.W=kt,S.X=fm,S.Y=pm,S.Z=ce,S._=l,S.a=ps,S.a$=ei,S.a0=Vt,S.a1=us,S.a2=Zi,S.a3=gm,S.a4=th,S.a5=Tt,S.a6=function(i,e,r){if(!i)return e||{};if(!e)return i||{};const s=xm(i),a=xm(e);(function(h,m){m.removeAll&&(h.add.clear(),h.update.clear(),h.remove.clear(),m.remove.clear());for(const _ of m.remove)h.add.delete(_),h.update.delete(_);for(const[_,x]of m.update){const w=h.update.get(_);w&&(m.update.set(_,yw(w,x)),h.update.delete(_))}})(s,a);const u={};if((s.removeAll||a.removeAll)&&(u.removeAll=!0),u.remove=new Set([...s.remove,...a.remove]),u.add=new Map([...s.add,...a.add]),u.update=new Map([...s.update,...a.update]),u.remove.size&&u.add.size)for(const h of u.add.keys())u.remove.delete(h);return(function(h){const m={};return h.removeAll&&(m.removeAll=h.removeAll),h.remove&&(m.remove=Array.from(h.remove)),h.add&&(m.add=Array.from(h.add.values())),h.update&&(m.update=Array.from(h.update.values())),m})(u)},S.a7=function(i,e){const r=new Map;if(i==null||i.type==null)return r;if(i.type==="Feature"){const s=Pd(i,e);return s==null?void 0:(r.set(s,i),r)}if(i.type==="FeatureCollection"){const s=new Set;for(const a of i.features){const u=Pd(a,e);if(u==null||s.has(u))return;s.add(u),r.set(u,a)}return r}},S.a8=function(i,e,r){var s,a;const u=[];if(e.removeAll)i.clear();else if(e.remove)for(const h of e.remove){const m=i.get(h);m&&(u.push(m.geometry),i.delete(h))}if(e.add)for(const h of e.add){const m=Pd(h,r);if(m==null)continue;const _=i.get(m);_&&u.push(_.geometry),u.push(h.geometry),i.set(m,h)}if(e.update)for(const h of e.update){const m=i.get(h.id);if(!m)continue;const _=!!h.newGeometry,x=h.removeAllProperties||((s=h.removeProperties)===null||s===void 0?void 0:s.length)>0||((a=h.addOrUpdateProperties)===null||a===void 0?void 0:a.length)>0;if(!_&&!x)continue;u.push(m.geometry);const w=Object.assign({},m);if(i.set(h.id,w),_&&(u.push(h.newGeometry),w.geometry=h.newGeometry),x){if(w.properties=h.removeAllProperties?{}:Object.assign({},w.properties||{}),h.removeProperties)for(const I of h.removeProperties)delete w.properties[I];if(h.addOrUpdateProperties)for(const{key:I,value:C}of h.addOrUpdateProperties)w.properties[I]=C}}return u},S.a9=yc,S.aA=function(i,{uSize:e,uSizeT:r},{lowerSize:s,upperSize:a}){return i.kind==="source"?s/is:i.kind==="composite"?Ht.number(s/is,a/is,r):e},S.aB=function(i,e){var r=e[0],s=e[1],a=e[2],u=e[3],h=e[4],m=e[5],_=e[6],x=e[7],w=e[8],I=e[9],C=e[10],z=e[11],R=e[12],F=e[13],O=e[14],Z=e[15],X=r*m-s*h,U=r*_-a*h,G=r*x-u*h,J=s*_-a*m,ie=s*x-u*m,fe=a*x-u*_,Pe=w*F-I*R,Te=w*O-C*R,Ie=w*Z-z*R,Oe=I*O-C*F,ze=I*Z-z*F,we=C*Z-z*O,xe=X*we-U*ze+G*Oe+J*Ie-ie*Te+fe*Pe;return xe?(i[0]=(m*we-_*ze+x*Oe)*(xe=1/xe),i[1]=(a*ze-s*we-u*Oe)*xe,i[2]=(F*fe-O*ie+Z*J)*xe,i[3]=(C*ie-I*fe-z*J)*xe,i[4]=(_*Ie-h*we-x*Te)*xe,i[5]=(r*we-a*Ie+u*Te)*xe,i[6]=(O*G-R*fe-Z*U)*xe,i[7]=(w*fe-C*G+z*U)*xe,i[8]=(h*ze-m*Ie+x*Pe)*xe,i[9]=(s*Ie-r*ze-u*Pe)*xe,i[10]=(R*ie-F*G+Z*X)*xe,i[11]=(I*G-w*ie-z*X)*xe,i[12]=(m*Te-h*Oe-_*Pe)*xe,i[13]=(r*Oe-s*Te+a*Pe)*xe,i[14]=(F*U-R*J-O*X)*xe,i[15]=(w*J-I*U+C*X)*xe,i):null},S.aC=At,S.aD=function(i){var e=i[0],r=i[1];return Math.sqrt(e*e+r*r)},S.aE=function(i){return i[0]=0,i[1]=0,i},S.aF=function(i,e,r){return i[0]=e[0]*r,i[1]=e[1]*r,i},S.aG=vd,S.aH=kn,S.aI=function(i,e,r,s){const a=e.y-i.y,u=e.x-i.x,h=s.y-r.y,m=s.x-r.x,_=h*u-m*a;if(_===0)return null;const x=(m*(i.y-r.y)-h*(i.x-r.x))/_;return new ne(i.x+x*u,i.y+x*a)},S.aJ=tg,S.aK=Na,S.aL=function(i){let e=1/0,r=1/0,s=-1/0,a=-1/0;for(const u of i)e=Math.min(e,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y);return[e,r,s,a]},S.aM=Nr,S.aN=Di,S.aO=function(i,e,r,s,a=!1){if(!r[0]&&!r[1])return[0,0];const u=a?s==="map"?-i.bearingInRadians:0:s==="viewport"?i.bearingInRadians:0;if(u){const h=Math.sin(u),m=Math.cos(u);r=[r[0]*m-r[1]*h,r[0]*h+r[1]*m]}return[a?r[0]:Di(e,r[0],i.zoom),a?r[1]:Di(e,r[1],i.zoom)]},S.aQ=yd,S.aR=Zd,S.aS=_d,S.aT=Ud,S.aU=yr,S.aV=Xu,S.aW=q,S.aX=je,S.aY=ye,S.aZ=gi,S.a_=_m,S.aa=Vo,S.ab=25,S.ac=Sd,S.ad=i=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e)};for(const s of i){const a=window.document.createElement("source");de(s)||(e.crossOrigin="Anonymous"),a.src=s,e.appendChild(a)}}))},S.ae=Me,S.af=function(){return Hi++},S.ag=c,S.ah=Ha,S.ai=bc,S.aj=_o,S.ak=An,S.al=wm,S.am=function(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((r,s,a,u)=>{const h=a||u;return e[s]=!h||h.toLowerCase(),""})),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},S.an=sr,S.ao=85.051129,S.ap=hs,S.aq=function(i){return Math.pow(2,i)},S.ar=It,S.as=mm,S.at=function(i){return Math.log(i)/Math.LN2},S.au=function(i){var e=i[0],r=i[1];return e*e+r*r},S.av=function(i){if(!i.length)return new Set;const e=Math.max(...i.map((_=>_.canonical.z)));let r=1/0,s=-1/0,a=1/0,u=-1/0;const h=[];for(const _ of i){const{x,y:w,z:I}=_.canonical,C=Math.pow(2,e-I),z=x*C,R=w*C;h.push({id:_,x:z,y:R}),z<r&&(r=z),z>s&&(s=z),R<a&&(a=R),R>u&&(u=R)}const m=new Set;for(const _ of h)_.x!==r&&_.x!==s&&_.y!==a&&_.y!==u||m.add(_.id);return m},S.aw=function(i,e){const r=Math.abs(2*i.wrap)-+(i.wrap<0),s=Math.abs(2*e.wrap)-+(e.wrap<0);return i.overscaledZ-e.overscaledZ||s-r||e.canonical.y-i.canonical.y||e.canonical.x-i.canonical.x},S.ax=class{constructor(i,e){this.max=i,this.onRemove=e,this.reset()}reset(){for(const i in this.data)for(const e of this.data[i])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(i,e,r){const s=i.wrapped().key;this.data[s]===void 0&&(this.data[s]=[]);const a={value:e,timeout:void 0};if(r!==void 0&&(a.timeout=setTimeout((()=>{this.remove(i,a)}),r)),this.data[s].push(a),this.order.push(s),this.order.length>this.max){const u=this._getAndRemoveByKey(this.order[0]);u&&this.onRemove(u)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const e=this.data[i].shift();return e.timeout&&clearTimeout(e.timeout),this.data[i].length===0&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),e.value}getByKey(i){const e=this.data[i];return e?e[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,e){if(!this.has(i))return this;const r=i.wrapped().key,s=e===void 0?0:this.data[r].indexOf(e),a=this.data[r][s];return this.data[r].splice(s,1),a.timeout&&clearTimeout(a.timeout),this.data[r].length===0&&delete this.data[r],this.onRemove(a.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(i){const e=[];for(const r in this.data)for(const s of this.data[r])i(s.value)||e.push(s);for(const r of e)this.remove(r.value.tileID,r)}},S.ay=function(i,e){let r=0,s=0;if(i.kind==="constant")s=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:a,minZoom:u,maxZoom:h}=i,m=a?sr(ni.interpolationFactor(a,e,u,h),0,1):0;i.kind==="camera"?s=Ht.number(i.minSize,i.maxSize,m):r=m}return{uSizeT:r,uSize:s}},S.b=sn,S.b$=ts,S.b0=wr,S.b1=function(i){var e=new tt(3);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e},S.b2=function(i,e,r){return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],i},S.b3=function(i,e){var r=e[0],s=e[1],a=e[2],u=r*r+s*s+a*a;return u>0&&(u=1/Math.sqrt(u)),i[0]=e[0]*u,i[1]=e[1]*u,i[2]=e[2]*u,i},S.b4=Hr,S.b5=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]},S.b6=function(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i[3]=e[3]*r[3],i},S.b7=mt,S.b8=function(i,e,r){const s=e[0]*r[0]+e[1]*r[1]+e[2]*r[2];return s===0?null:(-(i[0]*r[0]+i[1]*r[1]+i[2]*r[2])-r[3])/s},S.b9=mi,S.bA=function(){return new Float64Array(3)},S.bB=Rn,S.bC=function(i,e,r){var s=r[0],a=r[1],u=r[2],h=r[3],m=e[0],_=e[1],x=e[2],w=a*x-u*_,I=u*m-s*x,C=s*_-a*m;return i[0]=m+h*(w+=w)+a*(C+=C)-u*(I+=I),i[1]=_+h*I+u*w-s*C,i[2]=x+h*C+s*I-a*w,i},S.bD=function(i,e,r){const s=(a=[i[0],i[1],i[2],e[0],e[1],e[2],r[0],r[1],r[2]])[0]*((w=a[8])*(h=a[4])-(m=a[5])*(x=a[7]))+a[1]*(-w*(u=a[3])+m*(_=a[6]))+a[2]*(x*u-h*_);var a,u,h,m,_,x,w;if(s===0)return null;const I=Hr([],[e[0],e[1],e[2]],[r[0],r[1],r[2]]),C=Hr([],[r[0],r[1],r[2]],[i[0],i[1],i[2]]),z=Hr([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),R=ei([],I,-i[3]);return wr(R,R,ei([],C,-e[3])),wr(R,R,ei([],z,-r[3])),ei(R,R,1/s),R},S.bE=Td,S.bF=function(){return new Float64Array(4)},S.bG=function(i,e,r,s){var a=[],u=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],u[0]=a[0]*Math.cos(s)-a[1]*Math.sin(s),u[1]=a[0]*Math.sin(s)+a[1]*Math.cos(s),u[2]=a[2],i[0]=u[0]+r[0],i[1]=u[1]+r[1],i[2]=u[2]+r[2],i},S.bH=function(i,e,r,s){var a=[],u=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],u[0]=a[0],u[1]=a[1]*Math.cos(s)-a[2]*Math.sin(s),u[2]=a[1]*Math.sin(s)+a[2]*Math.cos(s),i[0]=u[0]+r[0],i[1]=u[1]+r[1],i[2]=u[2]+r[2],i},S.bI=function(i,e,r,s){var a=[],u=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],u[0]=a[2]*Math.sin(s)+a[0]*Math.cos(s),u[1]=a[1],u[2]=a[2]*Math.cos(s)-a[0]*Math.sin(s),i[0]=u[0]+r[0],i[1]=u[1]+r[1],i[2]=u[2]+r[2],i},S.bJ=function(i,e,r){var s=Math.sin(r),a=Math.cos(r),u=e[0],h=e[1],m=e[2],_=e[3],x=e[8],w=e[9],I=e[10],C=e[11];return e!==i&&(i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=u*a-x*s,i[1]=h*a-w*s,i[2]=m*a-I*s,i[3]=_*a-C*s,i[8]=u*s+x*a,i[9]=h*s+w*a,i[10]=m*s+I*a,i[11]=_*s+C*a,i},S.bK=function(i,e){const r=De(i,360),s=De(e,360),a=s-r,u=s>r?a-360:a+360;return Math.abs(a)<Math.abs(u)?a:u},S.bL=function(i){return i[0]=0,i[1]=0,i[2]=0,i},S.bM=function(i,e,r,s){const a=Math.sqrt(i*i+e*e),u=Math.sqrt(r*r+s*s);i/=a,e/=a,r/=u,s/=u;const h=Math.acos(i*r+e*s);return-e*r+i*s>0?h:-h},S.bN=function(i,e){const r=De(i,2*Math.PI),s=De(e,2*Math.PI);return Math.min(Math.abs(r-s),Math.abs(r-s+2*Math.PI),Math.abs(r-s-2*Math.PI))},S.bO=function(){const i={},e=le.$version;for(const r in le.$root){const s=le.$root[r];if(s.required){let a=null;a=r==="version"?e:s.type==="array"?[]:{},a!=null&&(i[r]=a)}}return i},S.bP=se,S.bQ=Gl,S.bR=function i(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!i(e[s],r[s]))return!1;return!0}if(typeof e=="object"&&e!==null&&r!==null){if(typeof r!="object"||Object.keys(e).length!==Object.keys(r).length)return!1;for(const s in e)if(!i(e[s],r[s]))return!1;return!0}return e===r},S.bS=function(i){i=i.slice();const e=Object.create(null);for(let r=0;r<i.length;r++)e[i[r].id]=i[r];for(let r=0;r<i.length;r++)"ref"in i[r]&&(i[r]=Rt(i[r],e[i[r].ref]));return i},S.bT=function(i,e){if(i.type==="custom")return new mw(i,e);switch(i.type){case"background":return new fw(i,e);case"circle":return new J0(i,e);case"color-relief":return new nb(i,e);case"fill":return new vb(i,e);case"fill-extrusion":return new zb(i,e);case"heatmap":return new eb(i,e);case"hillshade":return new rb(i,e);case"line":return new Bb(i,e);case"raster":return new Jh(i,e);case"symbol":return new eh(i,e)}},S.bU=i=>i.type==="raster",S.bV=ki,S.bW=function(i,e){if(!i)return[{command:"setStyle",args:[e]}];let r=[];try{if(!We(i.version,e.version))return[{command:"setStyle",args:[e]}];We(i.center,e.center)||r.push({command:"setCenter",args:[e.center]}),We(i.state,e.state)||r.push({command:"setGlobalState",args:[e.state]}),We(i.centerAltitude,e.centerAltitude)||r.push({command:"setCenterAltitude",args:[e.centerAltitude]}),We(i.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),We(i.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),We(i.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),We(i.roll,e.roll)||r.push({command:"setRoll",args:[e.roll]}),We(i.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),We(i.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),We(i.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),We(i.light,e.light)||r.push({command:"setLight",args:[e.light]}),We(i.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),We(i.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),We(i.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const s={},a=[];(function(h,m,_,x){let w;for(w in m=m||{},h=h||{})Object.prototype.hasOwnProperty.call(h,w)&&(Object.prototype.hasOwnProperty.call(m,w)||or(w,_,x));for(w in m)Object.prototype.hasOwnProperty.call(m,w)&&(Object.prototype.hasOwnProperty.call(h,w)?We(h[w],m[w])||(h[w].type==="geojson"&&m[w].type==="geojson"&&zr(h,m,w)?Ke(_,{command:"setGeoJSONSourceData",args:[w,m[w].data]}):Zt(w,m,_,x)):lt(w,m,_))})(i.sources,e.sources,a,s);const u=[];i.layers&&i.layers.forEach((h=>{"source"in h&&s[h.source]?r.push({command:"removeLayer",args:[h.id]}):u.push(h)})),r=r.concat(a),(function(h,m,_){m=m||[];const x=(h=h||[]).map(ar),w=m.map(ar),I=h.reduce(kr,{}),C=m.reduce(kr,{}),z=x.slice(),R=Object.create(null);let F,O,Z,X,U;for(let G=0,J=0;G<x.length;G++)F=x[G],Object.prototype.hasOwnProperty.call(C,F)?J++:(Ke(_,{command:"removeLayer",args:[F]}),z.splice(z.indexOf(F,J),1));for(let G=0,J=0;G<w.length;G++)F=w[w.length-1-G],z[z.length-1-G]!==F&&(Object.prototype.hasOwnProperty.call(I,F)?(Ke(_,{command:"removeLayer",args:[F]}),z.splice(z.lastIndexOf(F,z.length-J),1)):J++,X=z[z.length-G],Ke(_,{command:"addLayer",args:[C[F],X]}),z.splice(z.length-G,0,F),R[F]=!0);for(let G=0;G<w.length;G++)if(F=w[G],O=I[F],Z=C[F],!R[F]&&!We(O,Z))if(We(O.source,Z.source)&&We(O["source-layer"],Z["source-layer"])&&We(O.type,Z.type)){for(U in Dr(O.layout,Z.layout,_,F,null,"setLayoutProperty"),Dr(O.paint,Z.paint,_,F,null,"setPaintProperty"),We(O.filter,Z.filter)||Ke(_,{command:"setFilter",args:[F,Z.filter]}),We(O.minzoom,Z.minzoom)&&We(O.maxzoom,Z.maxzoom)||Ke(_,{command:"setLayerZoomRange",args:[F,Z.minzoom,Z.maxzoom]}),O)Object.prototype.hasOwnProperty.call(O,U)&&U!=="layout"&&U!=="paint"&&U!=="filter"&&U!=="metadata"&&U!=="minzoom"&&U!=="maxzoom"&&(U.indexOf("paint.")===0?Dr(O[U],Z[U],_,F,U.slice(6),"setPaintProperty"):We(O[U],Z[U])||Ke(_,{command:"setLayerProperty",args:[F,U,Z[U]]}));for(U in Z)Object.prototype.hasOwnProperty.call(Z,U)&&!Object.prototype.hasOwnProperty.call(O,U)&&U!=="layout"&&U!=="paint"&&U!=="filter"&&U!=="metadata"&&U!=="minzoom"&&U!=="maxzoom"&&(U.indexOf("paint.")===0?Dr(O[U],Z[U],_,F,U.slice(6),"setPaintProperty"):We(O[U],Z[U])||Ke(_,{command:"setLayerProperty",args:[F,U,Z[U]]}))}else Ke(_,{command:"removeLayer",args:[F]}),X=z[z.lastIndexOf(F)+1],Ke(_,{command:"addLayer",args:[Z,X]})})(u,e.layers,r)}catch(s){console.warn("Unable to compute style diff:",s),r=[{command:"setStyle",args:[e]}]}return r},S.bX=function(i){const e=[],r=i.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},S.bY=Xi,S.bZ=Yi,S.b_=class extends hi{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},S.ba=function(i,e,r){return i[0]=e[0]*r,i[1]=e[1]*r,i[2]=e[2]*r,i[3]=e[3]*r,i},S.bb=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]},S.bc=vm,S.bd=Xa,S.be=function(i,e,r,s,a){var u=1/Math.tan(e/2);if(i[0]=u/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=u,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,a!=null&&a!==1/0){var h=1/(s-a);i[10]=(a+s)*h,i[14]=2*a*s*h}else i[10]=-1,i[14]=-2*s;return i},S.bf=function(i){var e=new tt(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},S.bg=function(i,e,r){var s=Math.sin(r),a=Math.cos(r),u=e[0],h=e[1],m=e[2],_=e[3],x=e[4],w=e[5],I=e[6],C=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=u*a+x*s,i[1]=h*a+w*s,i[2]=m*a+I*s,i[3]=_*a+C*s,i[4]=x*a-u*s,i[5]=w*a-h*s,i[6]=I*a-m*s,i[7]=C*a-_*s,i},S.bh=function(i,e,r){var s=Math.sin(r),a=Math.cos(r),u=e[4],h=e[5],m=e[6],_=e[7],x=e[8],w=e[9],I=e[10],C=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=u*a+x*s,i[5]=h*a+w*s,i[6]=m*a+I*s,i[7]=_*a+C*s,i[8]=x*a-u*s,i[9]=w*a-h*s,i[10]=I*a-m*s,i[11]=C*a-_*s,i},S.bi=function(){const i=new Float32Array(16);return It(i),i},S.bj=function(){const i=new Float64Array(16);return It(i),i},S.bk=function(){return new Float64Array(16)},S.bl=function(i,e,r){const s=new Float64Array(4);return Rn(s,i,e-90,r),s},S.bm=function(i,e,r,s){var a,u,h,m,_,x=e[0],w=e[1],I=e[2],C=e[3],z=r[0],R=r[1],F=r[2],O=r[3];return(u=x*z+w*R+I*F+C*O)<0&&(u=-u,z=-z,R=-R,F=-F,O=-O),1-u>bt?(a=Math.acos(u),h=Math.sin(a),m=Math.sin((1-s)*a)/h,_=Math.sin(s*a)/h):(m=1-s,_=s),i[0]=m*x+_*z,i[1]=m*w+_*R,i[2]=m*I+_*F,i[3]=m*C+_*O,i},S.bn=function(i){const e=new Float64Array(9);var r,s,a,u,h,m,_,x,w,I,C,z,R,F,O,Z,X,U;I=(a=(s=i)[0])*(_=a+a),C=(u=s[1])*_,R=(h=s[2])*_,F=h*(x=u+u),Z=(m=s[3])*_,X=m*x,U=m*(w=h+h),(r=e)[0]=1-(z=u*x)-(O=h*w),r[3]=C-U,r[6]=R+X,r[1]=C+U,r[4]=1-I-O,r[7]=F-Z,r[2]=R-X,r[5]=F+Z,r[8]=1-I-z;const G=gi(-Math.asin(sr(e[2],-1,1)));let J,ie;return Math.hypot(e[5],e[8])<.001?(J=0,ie=-gi(Math.atan2(e[3],e[4]))):(J=gi(e[5]===0&&e[8]===0?0:Math.atan2(e[5],e[8])),ie=gi(e[1]===0&&e[0]===0?0:Math.atan2(e[1],e[0]))),{roll:J,pitch:G+90,bearing:ie}},S.bo=function(i,e){return i.roll==e.roll&&i.pitch==e.pitch&&i.bearing==e.bearing},S.bp=dt,S.bq=es,S.br=Ga,S.bs=dc,S.bt=Ua,S.bu=at,S.bv=zt,S.bw=ii,S.bx=function(i,e,r,s,a){return at(s,a,sr((i-e)/(r-e),0,1))},S.by=function(i,e,r,s){return i[0]=e[0]+r[0]*s,i[1]=e[1]+r[1]*s,i[2]=e[2]+r[2]*s,i},S.bz=De,S.c=B,S.c$=class{constructor(i){this._marks={start:[i.url,"start"].join("#"),end:[i.url,"end"].join("#"),measure:i.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let i=performance.getEntriesByName(this._marks.measure);return i.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),i=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),i}},S.c0=class extends hi{constructor(i,e){super(i,e),this.current=Ci}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},S.c1=Bo,S.c2=class extends hi{constructor(i,e){super(i,e),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},S.c3=class extends hi{constructor(i,e){super(i,e),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},S.c4=pt,S.c5=function(i,e){var r=Math.sin(e),s=Math.cos(e);return i[0]=s,i[1]=r,i[2]=0,i[3]=-r,i[4]=s,i[5]=0,i[6]=0,i[7]=0,i[8]=1,i},S.c6=function(i,e,r){var s=e[0],a=e[1],u=e[2];return i[0]=s*r[0]+a*r[3]+u*r[6],i[1]=s*r[1]+a*r[4]+u*r[7],i[2]=s*r[2]+a*r[5]+u*r[8],i},S.c7=function(i,e,r,s,a,u,h){var m=1/(e-r),_=1/(s-a),x=1/(u-h);return i[0]=-2*m,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*_,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*x,i[11]=0,i[12]=(e+r)*m,i[13]=(a+s)*_,i[14]=(h+u)*x,i[15]=1,i},S.c8=class extends hi{constructor(i,e){super(i,e),this.current=new Array}set(i){if(i!=this.current){this.current=i;const e=new Float32Array(4*i.length);for(let r=0;r<i.length;r++)e[4*r]=i[r].r,e[4*r+1]=i[r].g,e[4*r+2]=i[r].b,e[4*r+3]=i[r].a;this.gl.uniform4fv(this.location,e)}}},S.c9=class extends hi{constructor(i,e){super(i,e),this.current=new Array}set(i){if(i!=this.current){this.current=i;const e=new Float32Array(i);this.gl.uniform1fv(this.location,e)}}},S.cA=function(i,e){var r;if(!Ks[e])return!1;const s=i?.target,a=((r=s?.ownerDocument)===null||r===void 0?void 0:r.defaultView)||window;return i instanceof a.MouseEvent||i instanceof a.WheelEvent},S.cB=function(i,e){return _n[e]&&"touches"in i},S.cC=function(i){return _n[i]||Ks[i]},S.cD=function(i,e,r){var s=e[0],a=e[1];return i[0]=r[0]*s+r[4]*a+r[12],i[1]=r[1]*s+r[5]*a+r[13],i},S.cE=function(i,e){const{x:r,y:s}=yc.fromLngLat(e);return!(i<0||i>25||s<0||s>=1||r<0||r>=1)},S.cF=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},S.cG=class extends ka{},S.cH=t1,S.cJ=ee,S.cK=function(i,e){B.REGISTERED_PROTOCOLS[i]=e},S.cL=function(i){delete B.REGISTERED_PROTOCOLS[i]},S.cM=function(i,e){const r={};for(let a=0;a<i.length;a++){const u=e&&e[i[a].id]||xu(i[a]);e&&(e[i[a].id]=u);let h=r[u];h||(h=r[u]=[]),h.push(i[a])}const s=[];for(const a in r)s.push(r[a]);return s},S.cN=Ue,S.cO=bm,S.cP=Qm,S.cQ=rm,S.cR=function(i){var e;i.bucket.createArrays(),i.bucket.tilePixelRatio=Tt/(512*i.bucket.overscaling),i.bucket.compareText={},i.bucket.iconsNeedLinear=!1;const r=i.bucket.layers[0],s=r.layout,a=r._unevaluatedLayout._values,u={layoutIconSize:a["icon-size"].possiblyEvaluate(new Dt(i.bucket.zoom+1),i.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new Dt(i.bucket.zoom+1),i.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new Dt(18))};if(i.bucket.textSizeData.kind==="composite"){const{minZoom:w,maxZoom:I}=i.bucket.textSizeData;u.compositeTextSizes=[a["text-size"].possiblyEvaluate(new Dt(w),i.canonical),a["text-size"].possiblyEvaluate(new Dt(I),i.canonical)]}if(i.bucket.iconSizeData.kind==="composite"){const{minZoom:w,maxZoom:I}=i.bucket.iconSizeData;u.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new Dt(w),i.canonical),a["icon-size"].possiblyEvaluate(new Dt(I),i.canonical)]}const h=s.get("text-line-height")*Nr,m=s.get("text-rotation-alignment")!=="viewport"&&s.get("symbol-placement")!=="point",_=s.get("text-keep-upright"),x=s.get("text-size");for(const w of i.bucket.features){const I=s.get("text-font").evaluate(w,{},i.canonical).join(","),C=x.evaluate(w,{},i.canonical),z=u.layoutTextSize.evaluate(w,{},i.canonical),R=u.layoutIconSize.evaluate(w,{},i.canonical),F={horizontal:{},vertical:void 0},O=w.text;let Z,X=[0,0];if(O){const J=O.toString(),ie=s.get("text-letter-spacing").evaluate(w,{},i.canonical)*Nr,fe=Yh(J)?ie:0,Pe=s.get("text-anchor").evaluate(w,{},i.canonical),Te=dg(r,w,i.canonical);if(!Te){const we=s.get("text-radial-offset").evaluate(w,{},i.canonical);X=we?hg(Pe,[we*Nr,$d]):s.get("text-offset").evaluate(w,{},i.canonical).map((xe=>xe*Nr))}let Ie=m?"center":s.get("text-justify").evaluate(w,{},i.canonical);const Oe=s.get("symbol-placement")==="point"?s.get("text-max-width").evaluate(w,{},i.canonical)*Nr:1/0,ze=()=>{i.bucket.allowVerticalPlacement&&Bs(J)&&(F.vertical=Ju(O,i.glyphMap,i.glyphPositions,i.imagePositions,I,Oe,h,Pe,"left",fe,X,S.az.vertical,!0,z,C))};if(!m&&Te){const we=new Set;if(Ie==="auto")for(let $e=0;$e<Te.values.length;$e+=2)we.add(Zd(Te.values[$e]));else we.add(Ie);let xe=!1;for(const $e of we)if(!F.horizontal[$e])if(xe)F.horizontal[$e]=F.horizontal[0];else{const Ne=Ju(O,i.glyphMap,i.glyphPositions,i.imagePositions,I,Oe,h,"center",$e,fe,X,S.az.horizontal,!1,z,C);Ne&&(F.horizontal[$e]=Ne,xe=Ne.positionedLines.length===1)}ze()}else{Ie==="auto"&&(Ie=Zd(Pe));const we=Ju(O,i.glyphMap,i.glyphPositions,i.imagePositions,I,Oe,h,Pe,Ie,fe,X,S.az.horizontal,!1,z,C);we&&(F.horizontal[Ie]=we),ze(),Bs(J)&&m&&_&&(F.vertical=Ju(O,i.glyphMap,i.glyphPositions,i.imagePositions,I,Oe,h,Pe,Ie,fe,X,S.az.vertical,!1,z,C))}}let U=!1;if(w.icon&&w.icon.name){const J=i.imageMap[w.icon.name];J&&(Z=uw(i.imagePositions[w.icon.name],s.get("icon-offset").evaluate(w,{},i.canonical),s.get("icon-anchor").evaluate(w,{},i.canonical)),U=!!J.sdf,i.bucket.sdfIcons===void 0?i.bucket.sdfIcons=U:i.bucket.sdfIcons!==U&&Or("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(J.pixelRatio!==i.bucket.pixelRatio||s.get("icon-rotate").constantOr(1)!==0)&&(i.bucket.iconsNeedLinear=!0))}const G=fg(F.horizontal)||F.vertical;(e=i.bucket).iconsInText||(e.iconsInText=!!G&&G.iconsInText),(G||Z)&&Qw(i.bucket,w,F,Z,i.imageMap,u,z,R,X,U,i.canonical,i.subdivisionGranularity)}i.showCollisionBoxes&&i.bucket.generateCollisionDebugBuffers()},S.cS=hd,S.cT=pd,S.cU=fd,S.cV=function(i){const e=new Ku;return(function(r,s){for(const a in r.layers)s.writeMessage(3,jw,r.layers[a])})(i,e),e.finish()},S.cW=function(i,e,r,s,a,u){let h=rg(i,e,r,a,0);return h=rg(h,e,s,u,1),h},S.cX=class{constructor(i){this.maxEntries=i,this.map=new Map}get(i){const e=this.map.get(i);return e!==void 0&&(this.map.delete(i),this.map.set(i,e)),e}set(i,e){if(this.map.has(i))this.map.delete(i);else if(this.map.size>=this.maxEntries){const r=this.map.keys().next().value;this.map.delete(r)}this.map.set(i,e)}clear(){this.map.clear()}},S.cY=Bf,S.cZ=Ku,S.c_=Km,S.ca=class extends Jn{},S.cb=$b,S.cc=class extends Oo{},S.cd=od,S.ce=function(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))},S.cf=Tf,S.cg=function(i,e,r){var s=e[0],a=e[1],u=e[2],h=r[3]*s+r[7]*a+r[11]*u+r[15];return i[0]=(r[0]*s+r[4]*a+r[8]*u+r[12])/(h=h||1),i[1]=(r[1]*s+r[5]*a+r[9]*u+r[13])/h,i[2]=(r[2]*s+r[6]*a+r[10]*u+r[14])/h,i},S.ch=class extends Jl{},S.ci=class extends t{},S.cj=function(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]&&i[7]===e[7]&&i[8]===e[8]&&i[9]===e[9]&&i[10]===e[10]&&i[11]===e[11]&&i[12]===e[12]&&i[13]===e[13]&&i[14]===e[14]&&i[15]===e[15]},S.ck=function(i,e){var r=i[0],s=i[1],a=i[2],u=i[3],h=i[4],m=i[5],_=i[6],x=i[7],w=i[8],I=i[9],C=i[10],z=i[11],R=i[12],F=i[13],O=i[14],Z=i[15],X=e[0],U=e[1],G=e[2],J=e[3],ie=e[4],fe=e[5],Pe=e[6],Te=e[7],Ie=e[8],Oe=e[9],ze=e[10],we=e[11],xe=e[12],$e=e[13],Ne=e[14],Ge=e[15];return Math.abs(r-X)<=bt*Math.max(1,Math.abs(r),Math.abs(X))&&Math.abs(s-U)<=bt*Math.max(1,Math.abs(s),Math.abs(U))&&Math.abs(a-G)<=bt*Math.max(1,Math.abs(a),Math.abs(G))&&Math.abs(u-J)<=bt*Math.max(1,Math.abs(u),Math.abs(J))&&Math.abs(h-ie)<=bt*Math.max(1,Math.abs(h),Math.abs(ie))&&Math.abs(m-fe)<=bt*Math.max(1,Math.abs(m),Math.abs(fe))&&Math.abs(_-Pe)<=bt*Math.max(1,Math.abs(_),Math.abs(Pe))&&Math.abs(x-Te)<=bt*Math.max(1,Math.abs(x),Math.abs(Te))&&Math.abs(w-Ie)<=bt*Math.max(1,Math.abs(w),Math.abs(Ie))&&Math.abs(I-Oe)<=bt*Math.max(1,Math.abs(I),Math.abs(Oe))&&Math.abs(C-ze)<=bt*Math.max(1,Math.abs(C),Math.abs(ze))&&Math.abs(z-we)<=bt*Math.max(1,Math.abs(z),Math.abs(we))&&Math.abs(R-xe)<=bt*Math.max(1,Math.abs(R),Math.abs(xe))&&Math.abs(F-$e)<=bt*Math.max(1,Math.abs(F),Math.abs($e))&&Math.abs(O-Ne)<=bt*Math.max(1,Math.abs(O),Math.abs(Ne))&&Math.abs(Z-Ge)<=bt*Math.max(1,Math.abs(Z),Math.abs(Ge))},S.cl=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},S.cm=i=>i.type==="symbol",S.cn=i=>i.type==="circle",S.co=i=>i.type==="heatmap",S.cp=i=>i.type==="line",S.cq=i=>i.type==="fill",S.cr=i=>i.type==="fill-extrusion",S.cs=i=>i.type==="hillshade",S.ct=i=>i.type==="color-relief",S.cu=i=>i.type==="background",S.cv=i=>i.type==="custom",S.cw=$t,S.cx=function(i,e,r){if(e<=0)return i;const s=1/e;return r===void 0||Math.abs(r)<1e-10?Math.round(i*s)/s:(r>0?Math.ceil(i*s-1e-9):Math.floor(i*s+1e-10))/s},S.cy=function(i,e,r){const s=Wi(e.x-r.x,e.y-r.y),a=Wi(i.x-r.x,i.y-r.y);var u,h;return gi(Math.atan2(s[0]*a[1]-s[1]*a[0],(u=s)[0]*(h=a)[0]+u[1]*h[1]))},S.cz=ai,S.d=de,S.d0=function(i,e,r,s,a){return l(this,void 0,void 0,(function*(){if(Vt())try{return yield us(i,e,r,s,a)}catch{}return(function(u,h,m,_,x){const w=u.width,I=u.height;Ki&&on||(Ki=new OffscreenCanvas(w,I),on=Ki.getContext("2d",{willReadFrequently:!0})),Ki.width=w,Ki.height=I,on.drawImage(u,0,0,w,I);const C=on.getImageData(h,m,_,x);return on.clearRect(0,0,w,I),C.data})(i,e,r,s,a)}))},S.d1=If,S.d2=Se,S.d3=class{constructor(i,e){this.layers={[bc]:this},this.name=bc,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=i.length,this.features=i}feature(i){return new Bw(this.features[i],this.extent)}},S.d4=go,S.d5=In,S.e=fr,S.f=i=>l(void 0,void 0,void 0,(function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(e)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),S.g=j,S.h=i=>new Promise(((e,r)=>{const s=new Image;s.onload=()=>{e(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame((()=>{s.src=cs}))},s.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const a=new Blob([new Uint8Array(i)],{type:"image/png"});s.src=i.byteLength?URL.createObjectURL(a):cs})),S.i=Ri,S.j=(i,e)=>pe(fr(i,{type:"json"}),e),S.k=be,S.l=Ce,S.m=pe,S.n=(i,e)=>pe(fr(i,{type:"arrayBuffer"}),e),S.o=function(i){return new Ku(i).readFields(rw,[])},S.p=tm,S.q=function(i){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(i))},S.r=ac,S.s=Fn,S.t=si,S.u=le,S.v=So,S.w=Or,S.x=Yl,S.y=Po,S.z=Co})),A("worker",["./shared"],(function(S){class l{constructor(B,j){this.keyCache={},B&&this.replace(B,j)}replace(B,j){this._layerConfigs={},this._layers={},this.update(B,[],j)}update(B,j,$){for(const se of B){this._layerConfigs[se.id]=se;const pe=this._layers[se.id]=S.bT(se,$);pe._featureFilter=S.aj(pe.filter,$),this.keyCache[se.id]&&delete this.keyCache[se.id]}for(const se of j)delete this.keyCache[se],delete this._layerConfigs[se],delete this._layers[se];this.familiesBySource={};const ee=S.cM(Object.values(this._layerConfigs),this.keyCache);for(const se of ee){const pe=se.map((ke=>this._layers[ke.id])),de=pe[0];if(de.isHidden())continue;const ue=de.source||"";let he=this.familiesBySource[ue];he||(he=this.familiesBySource[ue]={});const Ce=de.sourceLayer||S.ai;let be=he[Ce];be||(be=he[Ce]=[]),be.push(pe)}}}class ne{constructor(B){const j={},$=[];for(const de in B){const ue=B[de],he=j[de]={};for(const Ce in ue){const be=ue[+Ce];if(!be||be.bitmap.width===0||be.bitmap.height===0)continue;const ke={x:0,y:0,w:be.bitmap.width+2,h:be.bitmap.height+2};$.push(ke),he[Ce]={rect:ke,metrics:be.metrics}}}const{w:ee,h:se}=S.p($),pe=new S.r({width:ee||1,height:se||1});for(const de in B){const ue=B[de];for(const he in ue){const Ce=ue[+he];if(!Ce||Ce.bitmap.width===0||Ce.bitmap.height===0)continue;const be=j[de][he].rect;S.r.copy(Ce.bitmap,pe,{x:0,y:0},{x:be.x+1,y:be.y+1},Ce.bitmap)}}this.image=pe,this.positions=j}}S.cN("GlyphAtlas",ne);class Se{constructor(B){this.tileID=new S.a2(B.tileID.overscaledZ,B.tileID.wrap,B.tileID.canonical.z,B.tileID.canonical.x,B.tileID.canonical.y),this.uid=B.uid,this.zoom=B.zoom,this.pixelRatio=B.pixelRatio,this.tileSize=B.tileSize,this.source=B.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=B.showCollisionBoxes,this.collectResourceTiming=!!B.collectResourceTiming,this.returnDependencies=!!B.returnDependencies,this.promoteId=B.promoteId,this.inFlightDependencies=[]}parse(B,j,$,ee,se){return S._(this,void 0,void 0,(function*(){this.status="parsing",this.data=B,this.collisionBoxArray=new S.ag;const pe=new S.cO(Object.keys(B.layers).sort()),de=new S.cP(this.tileID,this.promoteId);de.bucketLayerIDs=[];const ue={},he={featureIndex:de,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:$,subdivisionGranularity:se},Ce=j.familiesBySource[this.source];for(const Me in Ce){const Tr=B.layers[Me];if(!Tr)continue;Tr.version===1&&S.w(`Vector tile source "${this.source}" layer "${Me}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const li=pe.encode(Me),Ln=[];for(let mr=0;mr<Tr.length;mr++){const Be=Tr.feature(mr),ot=de.getId(Be,Me);Ln.push({feature:Be,id:ot,index:mr,sourceLayerIndex:li})}for(const mr of Ce[Me]){const Be=mr[0];Be.source!==this.source&&S.w(`layer.source = ${Be.source} does not equal this.source = ${this.source}`),Be.isHidden(this.zoom,!0)||(Le(mr,this.zoom,$),(ue[Be.id]=Be.createBucket({index:de.bucketLayerIDs.length,layers:mr,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:li,sourceID:this.source})).populate(Ln,he,this.tileID.canonical),de.bucketLayerIDs.push(mr.map((ot=>ot.id))))}}const be=S.bY(he.glyphDependencies,(Me=>Object.keys(Me).map(Number)));this.inFlightDependencies.forEach((Me=>Me?.abort())),this.inFlightDependencies=[];let ke=Promise.resolve({});if(Object.keys(be).length){const Me=new AbortController;this.inFlightDependencies.push(Me),ke=ee.sendAsync({type:"GG",data:{stacks:be,source:this.source,tileID:this.tileID,type:"glyphs"}},Me)}const le=Object.keys(he.iconDependencies);let nt=Promise.resolve({});if(le.length){const Me=new AbortController;this.inFlightDependencies.push(Me),nt=ee.sendAsync({type:"GI",data:{icons:le,source:this.source,tileID:this.tileID,type:"icons"}},Me)}const Rt=Object.keys(he.patternDependencies);let We=Promise.resolve({});if(Rt.length){const Me=new AbortController;this.inFlightDependencies.push(Me),We=ee.sendAsync({type:"GI",data:{icons:Rt,source:this.source,tileID:this.tileID,type:"patterns"}},Me)}const Ke=he.dashDependencies;let lt=Promise.resolve({});if(Object.keys(Ke).length){const Me=new AbortController;this.inFlightDependencies.push(Me),lt=ee.sendAsync({type:"GDA",data:{dashes:Ke}},Me)}const[or,Zt,zr,Dr]=yield Promise.all([ke,nt,We,lt]),ar=new ne(or),kr=new S.cQ(Zt,zr);for(const Me in ue){const Tr=ue[Me];Tr instanceof S.ah?(Le(Tr.layers,this.zoom,$),S.cR({bucket:Tr,glyphMap:or,glyphPositions:ar.positions,imageMap:Zt,imagePositions:kr.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:he.subdivisionGranularity})):Tr.hasDependencies&&(Tr instanceof S.cS||Tr instanceof S.cT||Tr instanceof S.cU)&&(Le(Tr.layers,this.zoom,$),Tr.addFeatures(he,this.tileID.canonical,kr.patternPositions,Dr))}return this.status="done",{buckets:Object.values(ue).filter((Me=>!Me.isEmpty())),featureIndex:de,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ar.image,imageAtlas:kr,dashPositions:Dr,glyphMap:this.returnDependencies?or:null,iconMap:this.returnDependencies?Zt:null,glyphPositions:this.returnDependencies?ar.positions:null}}))}}function Le(ce,B,j){const $=new S.H(B);for(const ee of ce)ee.recalculate($,j)}class He{constructor(B,j,$,ee,se){this.type=B,this.properties=$||{},this.extent=se,this.pointsArray=j,this.id=ee}loadGeometry(){return this.pointsArray.map((B=>B.map((j=>new S.P(j.x,j.y)))))}}class qe{constructor(B,j,$){this.version=2,this._myFeatures=B,this.name=j,this.length=B.length,this.extent=$}feature(B){return this._myFeatures[B]}}class Ze{constructor(){this.layers={}}addLayer(B){this.layers[B.name]=B}}function wt(ce){let B=S.cV(ce);return B.byteOffset===0&&B.byteLength===B.buffer.byteLength||(B=new Uint8Array(B)),{vectorTile:ce,rawData:B.buffer}}function Qe(ce,B,j){const{extent:$}=ce,ee=Math.pow(2,j.z-B.z),se=(j.x-B.x*ee)*$,pe=(j.y-B.y*ee)*$,de=[];for(let ue=0;ue<ce.length;ue++){const he=ce.feature(ue);let Ce=he.loadGeometry();for(const ke of Ce)for(const le of ke)le.x=le.x*ee-se,le.y=le.y*ee-pe;const be=128;Ce=S.cW(Ce,he.type,-be,-be,$+be,$+be),Ce.length!==0&&de.push(new He(he.type,Ce,he.properties,he.id,$))}return new qe(de,ce.name,$)}class me{constructor(B,j,$){this.actor=B,this.layerIndex=j,this.availableImages=$,this.fetching={},this.loading={},this.loaded={},this.overzoomedTileResultCache=new S.cX(1e3)}loadVectorTile(B,j){return S._(this,void 0,void 0,(function*(){const $=yield S.n(B.request,j);try{return{vectorTile:B.encoding!=="mlt"?new S.cY(new S.cZ($.data)):new S.c_($.data),rawData:$.data,cacheControl:$.cacheControl,expires:$.expires}}catch(ee){const se=new Uint8Array($.data);let pe=`Unable to parse the tile at ${B.request.url}, `;throw pe+=se[0]===31&&se[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${ee.message}`,new Error(pe)}}))}loadTile(B){return S._(this,void 0,void 0,(function*(){const{uid:j,overzoomParameters:$}=B;$&&(B.request=$.overzoomRequest);const ee=!!(B&&B.request&&B.request.collectResourceTiming)&&new S.c$(B.request),se=new Se(B);this.loading[j]=se;const pe=new AbortController;se.abort=pe;try{const de=yield this.loadVectorTile(B,pe);if(delete this.loading[j],!de)return null;if($){const ke=this._getOverzoomTile(B,de.vectorTile);de.rawData=ke.rawData,de.vectorTile=ke.vectorTile}const ue=de.rawData,he={};de.expires&&(he.expires=de.expires),de.cacheControl&&(he.cacheControl=de.cacheControl);const Ce={};if(ee){const ke=ee.finish();ke&&(Ce.resourceTiming=JSON.parse(JSON.stringify(ke)))}se.vectorTile=de.vectorTile;const be=se.parse(de.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity);this.loaded[j]=se,this.fetching[j]={rawTileData:ue,cacheControl:he,resourceTiming:Ce};try{const ke=yield be;return S.e({rawTileData:ue.slice(0),encoding:B.encoding},ke,he,Ce)}finally{delete this.fetching[j]}}catch(de){throw delete this.loading[j],se.status="done",this.loaded[j]=se,de}}))}_getOverzoomTile(B,j){const{tileID:$,source:ee,overzoomParameters:se}=B,{maxZoomTileID:pe}=se,de=`${pe.key}_${$.key}`,ue=this.overzoomedTileResultCache.get(de);if(ue)return ue;const he=new Ze,Ce=this.layerIndex.familiesBySource[ee];for(const ke in Ce){const le=j.layers[ke];if(!le)continue;const nt=Qe(le,pe,$.canonical);nt.length>0&&he.addLayer(nt)}const be=wt(he);return this.overzoomedTileResultCache.set(de,be),be}reloadTile(B){return S._(this,void 0,void 0,(function*(){const j=B.uid;if(!this.loaded||!this.loaded[j])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const $=this.loaded[j];if($.showCollisionBoxes=B.showCollisionBoxes,$.status==="parsing"){const ee=yield $.parse($.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity);let se;if(this.fetching[j]){const{rawTileData:pe,cacheControl:de,resourceTiming:ue}=this.fetching[j];delete this.fetching[j],se=S.e({rawTileData:pe.slice(0),encoding:B.encoding},ee,de,ue)}else se=ee;return se}if($.status==="done"&&$.vectorTile)return $.parse($.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity)}))}abortTile(B){return S._(this,void 0,void 0,(function*(){const j=this.loading,$=B.uid;j&&j[$]&&j[$].abort&&(j[$].abort.abort(),delete j[$])}))}removeTile(B){return S._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[B.uid]&&delete this.loaded[B.uid]}))}}class Vt{constructor(){this.loaded={}}loadTile(B){return S._(this,void 0,void 0,(function*(){const{uid:j,encoding:$,rawImageData:ee,redFactor:se,greenFactor:pe,blueFactor:de,baseShift:ue}=B,he=ee.width+2,Ce=ee.height+2,be=S.b(ee)?new S.R({width:he,height:Ce},yield S.d0(ee,-1,-1,he,Ce)):ee,ke=new S.d1(j,be,$,se,pe,de,ue);return this.loaded=this.loaded||{},this.loaded[j]=ke,ke}))}removeTile(B){const j=this.loaded,$=B.uid;j&&j[$]&&delete j[$]}}var bt,tt,pt=(function(){if(tt)return bt;function ce(j,$){if(j.length!==0){B(j[0],$);for(var ee=1;ee<j.length;ee++)B(j[ee],!$)}}function B(j,$){for(var ee=0,se=0,pe=0,de=j.length,ue=de-1;pe<de;ue=pe++){var he=(j[pe][0]-j[ue][0])*(j[ue][1]+j[pe][1]),Ce=ee+he;se+=Math.abs(ee)>=Math.abs(he)?ee-Ce+he:he-Ce+ee,ee=Ce}ee+se>=0!=!!$&&j.reverse()}return tt=1,bt=function j($,ee){var se,pe=$&&$.type;if(pe==="FeatureCollection")for(se=0;se<$.features.length;se++)j($.features[se],ee);else if(pe==="GeometryCollection")for(se=0;se<$.geometries.length;se++)j($.geometries[se],ee);else if(pe==="Feature")j($.geometry,ee);else if(pe==="Polygon")ce($.coordinates,ee);else if(pe==="MultiPolygon")for(se=0;se<$.coordinates.length;se++)ce($.coordinates[se],ee);return $}})(),It=S.d2(pt);const Et={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ce=>ce},mt=Math.fround||(Qt=new Float32Array(1),ce=>(Qt[0]=+ce,Qt[0]));var Qt;class wr{constructor(B){this.options=Object.assign(Object.create(Et),B),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(B){const{log:j,minZoom:$,maxZoom:ee}=this.options;j&&console.time("total time");const se=`prepare ${B.length} points`;j&&console.time(se),this.points=B;const pe=[];for(let ue=0;ue<B.length;ue++){const he=B[ue];if(!he.geometry)continue;const[Ce,be]=he.geometry.coordinates,ke=mt(nr(Ce)),le=mt(mi(be));pe.push(ke,le,1/0,ue,-1,1),this.options.reduce&&pe.push(0)}let de=this.trees[ee+1]=this._createTree(pe);j&&console.timeEnd(se);for(let ue=ee;ue>=$;ue--){const he=+Date.now();de=this.trees[ue]=this._createTree(this._cluster(de,ue)),j&&console.log("z%d: %d clusters in %dms",ue,de.numItems,+Date.now()-he)}return j&&console.timeEnd("total time"),this}getClusters(B,j){let $=((B[0]+180)%360+360)%360-180;const ee=Math.max(-90,Math.min(90,B[1]));let se=B[2]===180?180:((B[2]+180)%360+360)%360-180;const pe=Math.max(-90,Math.min(90,B[3]));if(B[2]-B[0]>=360)$=-180,se=180;else if($>se){const be=this.getClusters([$,ee,180,pe],j),ke=this.getClusters([-180,ee,se,pe],j);return be.concat(ke)}const de=this.trees[this._limitZoom(j)],ue=de.range(nr($),mi(pe),nr(se),mi(ee)),he=de.data,Ce=[];for(const be of ue){const ke=this.stride*be;Ce.push(he[ke+5]>1?ei(he,ke,this.clusterProps):this.points[he[ke+3]])}return Ce}getChildren(B){const j=this._getOriginId(B),$=this._getOriginZoom(B),ee="No cluster with the specified id.",se=this.trees[$];if(!se)throw new Error(ee);const pe=se.data;if(j*this.stride>=pe.length)throw new Error(ee);const de=this.options.radius/(this.options.extent*Math.pow(2,$-1)),ue=se.within(pe[j*this.stride],pe[j*this.stride+1],de),he=[];for(const Ce of ue){const be=Ce*this.stride;pe[be+4]===B&&he.push(pe[be+5]>1?ei(pe,be,this.clusterProps):this.points[pe[be+3]])}if(he.length===0)throw new Error(ee);return he}getLeaves(B,j,$){const ee=[];return this._appendLeaves(ee,B,j=j||10,$=$||0,0),ee}getTile(B,j,$){const ee=this.trees[this._limitZoom(B)],se=Math.pow(2,B),{extent:pe,radius:de}=this.options,ue=de/pe,he=($-ue)/se,Ce=($+1+ue)/se,be={features:[]};return this._addTileFeatures(ee.range((j-ue)/se,he,(j+1+ue)/se,Ce),ee.data,j,$,se,be),j===0&&this._addTileFeatures(ee.range(1-ue/se,he,1,Ce),ee.data,se,$,se,be),j===se-1&&this._addTileFeatures(ee.range(0,he,ue/se,Ce),ee.data,-1,$,se,be),be.features.length?be:null}getClusterExpansionZoom(B){let j=this._getOriginZoom(B)-1;for(;j<=this.options.maxZoom;){const $=this.getChildren(B);if(j++,$.length!==1)break;B=$[0].properties.cluster_id}return j}_appendLeaves(B,j,$,ee,se){const pe=this.getChildren(j);for(const de of pe){const ue=de.properties;if(ue&&ue.cluster?se+ue.point_count<=ee?se+=ue.point_count:se=this._appendLeaves(B,ue.cluster_id,$,ee,se):se<ee?se++:B.push(de),B.length===$)break}return se}_createTree(B){const j=new S.aT(B.length/this.stride|0,this.options.nodeSize,Float32Array);for(let $=0;$<B.length;$+=this.stride)j.add(B[$],B[$+1]);return j.finish(),j.data=B,j}_addTileFeatures(B,j,$,ee,se,pe){for(const de of B){const ue=de*this.stride,he=j[ue+5]>1;let Ce,be,ke;if(he)Ce=Hr(j,ue,this.clusterProps),be=j[ue],ke=j[ue+1];else{const Rt=this.points[j[ue+3]];Ce=Rt.properties;const[We,Ke]=Rt.geometry.coordinates;be=nr(We),ke=mi(Ke)}const le={type:1,geometry:[[Math.round(this.options.extent*(be*se-$)),Math.round(this.options.extent*(ke*se-ee))]],tags:Ce};let nt;nt=he||this.options.generateId?j[ue+3]:this.points[j[ue+3]].id,nt!==void 0&&(le.id=nt),pe.features.push(le)}}_limitZoom(B){return Math.max(this.options.minZoom,Math.min(Math.floor(+B),this.options.maxZoom+1))}_cluster(B,j){const{radius:$,extent:ee,reduce:se,minPoints:pe}=this.options,de=$/(ee*Math.pow(2,j)),ue=B.data,he=[],Ce=this.stride;for(let be=0;be<ue.length;be+=Ce){if(ue[be+2]<=j)continue;ue[be+2]=j;const ke=ue[be],le=ue[be+1],nt=B.within(ue[be],ue[be+1],de),Rt=ue[be+5];let We=Rt;for(const Ke of nt){const lt=Ke*Ce;ue[lt+2]>j&&(We+=ue[lt+5])}if(We>Rt&&We>=pe){let Ke,lt=ke*Rt,or=le*Rt,Zt=-1;const zr=(be/Ce<<5)+(j+1)+this.points.length;for(const Dr of nt){const ar=Dr*Ce;if(ue[ar+2]<=j)continue;ue[ar+2]=j;const kr=ue[ar+5];lt+=ue[ar]*kr,or+=ue[ar+1]*kr,ue[ar+4]=zr,se&&(Ke||(Ke=this._map(ue,be,!0),Zt=this.clusterProps.length,this.clusterProps.push(Ke)),se(Ke,this._map(ue,ar)))}ue[be+4]=zr,he.push(lt/We,or/We,1/0,zr,-1,We),se&&he.push(Zt)}else{for(let Ke=0;Ke<Ce;Ke++)he.push(ue[be+Ke]);if(We>1)for(const Ke of nt){const lt=Ke*Ce;if(!(ue[lt+2]<=j)){ue[lt+2]=j;for(let or=0;or<Ce;or++)he.push(ue[lt+or])}}}}return he}_getOriginId(B){return B-this.points.length>>5}_getOriginZoom(B){return(B-this.points.length)%32}_map(B,j,$){if(B[j+5]>1){const pe=this.clusterProps[B[j+6]];return $?Object.assign({},pe):pe}const ee=this.points[B[j+3]].properties,se=this.options.map(ee);return $&&se===ee?Object.assign({},se):se}}function ei(ce,B,j){return{type:"Feature",id:ce[B+3],properties:Hr(ce,B,j),geometry:{type:"Point",coordinates:[($=ce[B],360*($-.5)),kn(ce[B+1])]}};var $}function Hr(ce,B,j){const $=ce[B+5],ee=$>=1e4?`${Math.round($/1e3)}k`:$>=1e3?Math.round($/100)/10+"k":$,se=ce[B+6],pe=se===-1?{}:Object.assign({},j[se]);return Object.assign(pe,{cluster:!0,cluster_id:ce[B+3],point_count:$,point_count_abbreviated:ee})}function nr(ce){return ce/360+.5}function mi(ce){const B=Math.sin(ce*Math.PI/180),j=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return j<0?0:j>1?1:j}function kn(ce){const B=(180-360*ce)*Math.PI/180;return 360*Math.atan(Math.exp(B))/Math.PI-90}function zi(ce,B,j,$){let ee=$;const se=B+(j-B>>1);let pe,de=j-B;const ue=ce[B],he=ce[B+1],Ce=ce[j],be=ce[j+1];for(let ke=B+3;ke<j;ke+=3){const le=Rn(ce[ke],ce[ke+1],ue,he,Ce,be);if(le>ee)pe=ke,ee=le;else if(le===ee){const nt=Math.abs(ke-se);nt<de&&(pe=ke,de=nt)}}ee>$&&(pe-B>3&&zi(ce,B,pe,$),ce[pe+2]=ee,j-pe>3&&zi(ce,pe,j,$))}function Rn(ce,B,j,$,ee,se){let pe=ee-j,de=se-$;if(pe!==0||de!==0){const ue=((ce-j)*pe+(B-$)*de)/(pe*pe+de*de);ue>1?(j=ee,$=se):ue>0&&(j+=pe*ue,$+=de*ue)}return pe=ce-j,de=B-$,pe*pe+de*de}function At(ce,B,j,$){const ee={type:B,geom:j},se={id:ce??null,type:ee.type,geometry:ee.geom,tags:$,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(ee.type){case"Point":case"MultiPoint":case"LineString":Wi(se,ee.geom);break;case"Polygon":Wi(se,ee.geom[0]);break;case"MultiLineString":for(const pe of ee.geom)Wi(se,pe);break;case"MultiPolygon":for(const pe of ee.geom)Wi(se,pe[0])}return se}function Wi(ce,B){for(let j=0;j<B.length;j+=3)ce.minX=Math.min(ce.minX,B[j]),ce.minY=Math.min(ce.minY,B[j+1]),ce.maxX=Math.max(ce.maxX,B[j]),ce.maxY=Math.max(ce.maxY,B[j+1])}function Tt(ce,B){const j=[];switch(ce.type){case"FeatureCollection":for(let $=0;$<ce.features.length;$++)Di(j,ce.features[$],B,$);break;case"Feature":Di(j,ce,B);break;default:Di(j,{geometry:ce,properties:void 0},B)}return j}function Di(ce,B,j,$){if(!B.geometry)return;if(B.geometry.type==="GeometryCollection"){for(const de of B.geometry.geometries)Di(ce,{id:B.id,geometry:de,properties:B.properties},j,$);return}if(!B.geometry.coordinates?.length)return;const se=Math.pow(j.tolerance/((1<<j.maxZoom)*j.extent),2);let pe=B.id;switch(j.promoteId?pe=B.properties?.[j.promoteId]:j.generateId&&(pe=$||0),B.geometry.type){case"Point":{const de=[];return De(B.geometry.coordinates,de),void ce.push(At(pe,B.geometry.type,de,B.properties))}case"MultiPoint":{const de=[];for(const ue of B.geometry.coordinates)De(ue,de);return void ce.push(At(pe,B.geometry.type,de,B.properties))}case"LineString":{const de=[];return at(B.geometry.coordinates,de,se,!1),void ce.push(At(pe,B.geometry.type,de,B.properties))}case"MultiLineString":{if(j.lineMetrics){for(const ue of B.geometry.coordinates){const he=[];at(ue,he,se,!1),ce.push(At(pe,"LineString",he,B.properties))}return}const de=[];return zt(B.geometry.coordinates,de,se,!1),void ce.push(At(pe,B.geometry.type,de,B.properties))}case"Polygon":{const de=[];return zt(B.geometry.coordinates,de,se,!0),void ce.push(At(pe,B.geometry.type,de,B.properties))}case"MultiPolygon":{const de=[];for(const ue of B.geometry.coordinates){const he=[];zt(ue,he,se,!0),de.push(he)}return void ce.push(At(pe,B.geometry.type,de,B.properties))}default:throw new Error("Input data is not a valid GeoJSON object.")}}function De(ce,B){B.push($t(ce[0]),ai(ce[1]),0)}function at(ce,B,j,$){let ee,se,pe=0;for(let ue=0;ue<ce.length;ue++){const he=$t(ce[ue][0]),Ce=ai(ce[ue][1]);B.push(he,Ce,0),ue>0&&(pe+=$?(ee*Ce-he*se)/2:Math.sqrt(Math.pow(he-ee,2)+Math.pow(Ce-se,2))),ee=he,se=Ce}const de=B.length-3;B[2]=1,j>0&&zi(B,0,de,j),B[de+2]=1,B.size=Math.abs(pe),B.start=0,B.end=B.size}function zt(ce,B,j,$){for(let ee=0;ee<ce.length;ee++){const se=[];at(ce[ee],se,j,$),B.push(se)}}function $t(ce){return ce/360+.5}function ai(ce){const B=Math.sin(ce*Math.PI/180),j=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return j<0?0:j>1?1:j}function sr(ce,B,j,$,ee,se,pe,de){if($/=B,se>=(j/=B)&&pe<$)return ce;if(pe<j||se>=$)return null;const ue=[];for(const he of ce){const Ce=ee===0?he.minX:he.minY,be=ee===0?he.maxX:he.maxY;if(Ce>=j&&be<$)ue.push(he);else if(!(be<j||Ce>=$))switch(he.type){case"Point":case"MultiPoint":{const ke=[];if(kt(he.geometry,ke,j,$,ee),!ke.length)continue;ue.push(At(he.id,ke.length===3?"Point":"MultiPoint",ke,he.tags));continue}case"LineString":{const ke=[];if(fr(he.geometry,ke,j,$,ee,!1,de.lineMetrics),!ke.length)continue;if(de.lineMetrics){for(const le of ke)ue.push(At(he.id,he.type,le,he.tags));continue}if(ke.length>1){ue.push(At(he.id,"MultiLineString",ke,he.tags));continue}ue.push(At(he.id,he.type,ke[0],he.tags));continue}case"MultiLineString":{const ke=[];if(Xi(he.geometry,ke,j,$,ee,!1),!ke.length)continue;if(ke.length===1){ue.push(At(he.id,"LineString",ke[0],he.tags));continue}ue.push(At(he.id,he.type,ke,he.tags));continue}case"Polygon":{const ke=[];if(Xi(he.geometry,ke,j,$,ee,!0),!ke.length)continue;ue.push(At(he.id,he.type,ke,he.tags));continue}case"MultiPolygon":{const ke=[];for(const le of he.geometry){const nt=[];Xi(le,nt,j,$,ee,!0),nt.length&&ke.push(nt)}if(!ke.length)continue;ue.push(At(he.id,he.type,ke,he.tags));continue}}}return ue.length?ue:null}function kt(ce,B,j,$,ee){for(let se=0;se<ce.length;se+=3){const pe=ce[se+ee];pe>=j&&pe<=$&&Yi(B,ce[se],ce[se+1],ce[se+2])}}function fr(ce,B,j,$,ee,se,pe){let de=Hi(ce);const ue=ee===0?ki:Ko;let he,Ce,be=ce.start;for(let We=0;We<ce.length-3;We+=3){const Ke=ce[We],lt=ce[We+1],or=ce[We+2],Zt=ce[We+3],zr=ce[We+4],Dr=ee===0?Ke:lt,ar=ee===0?Zt:zr;let kr=!1;pe&&(he=Math.sqrt(Math.pow(Ke-Zt,2)+Math.pow(lt-zr,2))),Dr<j?ar>j&&(Ce=ue(de,Ke,lt,Zt,zr,j),pe&&(de.start=be+he*Ce)):Dr>$?ar<$&&(Ce=ue(de,Ke,lt,Zt,zr,$),pe&&(de.start=be+he*Ce)):Yi(de,Ke,lt,or),ar<j&&Dr>=j&&(Ce=ue(de,Ke,lt,Zt,zr,j),kr=!0),ar>$&&Dr<=$&&(Ce=ue(de,Ke,lt,Zt,zr,$),kr=!0),!se&&kr&&(pe&&(de.end=be+he*Ce),B.push(de),de=Hi(ce)),pe&&(be+=he)}let ke=ce.length-3;const le=ce[ke],nt=ce[ke+1],Rt=ee===0?le:nt;Rt>=j&&Rt<=$&&Yi(de,le,nt,ce[ke+2]),ke=de.length-3,se&&ke>=3&&(de[ke]!==de[0]||de[ke+1]!==de[1])&&Yi(de,de[0],de[1],de[2]),de.length&&B.push(de)}function Hi(ce){const B=[];return B.size=ce.size,B.start=ce.start,B.end=ce.end,B}function Xi(ce,B,j,$,ee,se){for(const pe of ce)fr(pe,B,j,$,ee,se,!1)}function Yi(ce,B,j,$){ce.push(B,j,$)}function ki(ce,B,j,$,ee,se){const pe=(se-B)/($-B);return Yi(ce,se,j+(ee-j)*pe,1),pe}function Ko(ce,B,j,$,ee,se){const pe=(se-j)/(ee-j);return Yi(ce,B+($-B)*pe,se,1),pe}function Or(ce,B){const j=B.buffer/B.extent;let $=ce;const ee=sr(ce,1,-1-j,j,0,-1,2,B),se=sr(ce,1,1-j,2+j,0,-1,2,B);return(ee||se)&&($=sr(ce,1,-j,1+j,0,-1,2,B)||[],ee&&($=Si(ee,1).concat($)),se&&($=$.concat(Si(se,-1)))),$}function Si(ce,B){const j=[];for(const $ of ce)switch($.type){case"Point":case"MultiPoint":case"LineString":{const ee=Ri($.geometry,B);j.push(At($.id,$.type,ee,$.tags));continue}case"MultiLineString":case"Polygon":{const ee=[];for(const se of $.geometry)ee.push(Ri(se,B));j.push(At($.id,$.type,ee,$.tags));continue}case"MultiPolygon":{const ee=[];for(const se of $.geometry){const pe=[];for(const de of se)pe.push(Ri(de,B));ee.push(pe)}j.push(At($.id,$.type,ee,$.tags));continue}}return j}function Ri(ce,B){const j=[];j.size=ce.size,ce.start!==void 0&&(j.start=ce.start,j.end=ce.end);for(let $=0;$<ce.length;$+=3)j.push(ce[$]+B,ce[$+1],ce[$+2]);return j}function er(ce,B){if(ce.transformed)return ce;const j=1<<ce.z,$=ce.x,ee=ce.y;for(const se of ce.features){if(se.type===1){const de=[];for(let ue=0;ue<se.geometry.length;ue+=2)de.push(sn(se.geometry[ue],se.geometry[ue+1],B,j,$,ee));se.geometry=de;continue}const pe=[];for(const de of se.geometry){const ue=[];for(let he=0;he<de.length;he+=2)ue.push(sn(de[he],de[he+1],B,j,$,ee));pe.push(ue)}se.geometry=pe}return ce.transformed=!0,ce}function sn(ce,B,j,$,ee,se){return[Math.round(j*(ce*$-ee)),Math.round(j*(B*$-se))]}function cs(ce,B,j,$,ee){const se=B===ee.maxZoom?0:ee.tolerance/((1<<B)*ee.extent),pe={features:[],numPoints:0,numSimplified:0,numFeatures:ce.length,source:null,x:j,y:$,z:B,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const de of ce)us(pe,de,se,ee);return pe}function us(ce,B,j,$){ce.minX=Math.min(ce.minX,B.minX),ce.minY=Math.min(ce.minY,B.minY),ce.maxX=Math.max(ce.maxX,B.maxX),ce.maxY=Math.max(ce.maxY,B.maxY);let ee,se=B.tags||null;switch(B.type){case"Point":case"MultiPoint":{const pe=[];for(let de=0;de<B.geometry.length;de+=3)pe.push(B.geometry[de],B.geometry[de+1]),ce.numPoints++,ce.numSimplified++;if(!pe.length)return;ee={type:1,tags:se,geometry:pe};break}case"LineString":{const pe=[];if(Ki(pe,B.geometry,ce,j,!1,!1),!pe.length)return;if($.lineMetrics){se={};for(const de in B.tags)se[de]=B.tags[de];se.mapbox_clip_start=B.geometry.start/B.geometry.size,se.mapbox_clip_end=B.geometry.end/B.geometry.size}ee={type:2,tags:se,geometry:pe};break}case"MultiLineString":case"Polygon":{const pe=[];for(let de=0;de<B.geometry.length;de++)Ki(pe,B.geometry[de],ce,j,B.type==="Polygon",de===0);if(!pe.length)return;ee={type:B.type==="Polygon"?3:2,tags:se,geometry:pe};break}case"MultiPolygon":{const pe=[];for(let de=0;de<B.geometry.length;de++){const ue=B.geometry[de];for(let he=0;he<ue.length;he++)Ki(pe,ue[he],ce,j,!0,he===0)}if(!pe.length)return;ee={type:3,tags:se,geometry:pe};break}}B.id!==null&&(ee.id=B.id),ce.features.push(ee)}function Ki(ce,B,j,$,ee,se){const pe=$*$;if($>0&&B.size<(ee?pe:$))return void(j.numPoints+=B.length/3);const de=[];for(let ue=0;ue<B.length;ue+=3)($===0||B[ue+2]>pe)&&(j.numSimplified++,de.push(B[ue],B[ue+1])),j.numPoints++;ee&&(function(ue,he){let Ce=0;for(let be=0,ke=ue.length,le=ke-2;be<ke;le=be,be+=2)Ce+=(ue[be]-ue[le])*(ue[be+1]+ue[le+1]);if(Ce>0===he)for(let be=0,ke=ue.length;be<ke/2;be+=2){const le=ue[be],nt=ue[be+1];ue[be]=ue[ke-2-be],ue[be+1]=ue[ke-1-be],ue[ke-2-be]=le,ue[ke-1-be]=nt}})(de,se),ce.push(de)}function on(ce,B,j){const $=!!B.newGeometry,ee=B.removeAllProperties||B.removeProperties?.length>0||B.addOrUpdateProperties?.length>0;if($){let se=Tt({type:"FeatureCollection",features:[{type:"Feature",id:ce.id,geometry:B.newGeometry,properties:ee?Fn(ce.tags,B):ce.tags}]},j);return se=Or(se,j),se[0]}if(ee){const se={...ce};return se.tags=Fn(se.tags,B),se}return null}function Fn(ce,B){if(B.removeAllProperties)return{};const j={...ce||{}};if(B.removeProperties)for(const $ of B.removeProperties)delete j[$];if(B.addOrUpdateProperties)for(const{key:$,value:ee}of B.addOrUpdateProperties)j[$]=ee;return j}const hs={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,debug:0};class gi{options;tiles;tileCoords;stats={};total=0;source;constructor(B,j){const $=(j=this.options=Object.assign({},hs,j)).debug;if($&&console.time("preprocess data"),j.maxZoom<0||j.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(j.promoteId&&j.generateId)throw new Error("promoteId and generateId cannot be used together.");let ee=Tt(B,j);this.tiles={},this.tileCoords=[],$&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",j.indexMaxZoom,j.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),ee=Or(ee,j),ee.length&&this.splitTile(ee,0,0,0),j.updateable&&(this.source=ee),$&&(ee.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(B,j,$,ee,se,pe,de){const ue=[B,j,$,ee],he=this.options,Ce=he.debug;for(;ue.length;){ee=ue.pop(),$=ue.pop(),j=ue.pop(),B=ue.pop();const be=1<<j,ke=_n(j,$,ee);let le=this.tiles[ke];if(!le&&(Ce>1&&console.time("creation"),le=this.tiles[ke]=cs(B,j,$,ee,he),this.tileCoords.push({z:j,x:$,y:ee,id:ke}),Ce)){Ce>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",j,$,ee,le.numFeatures,le.numPoints,le.numSimplified),console.timeEnd("creation"));const kr=`z${j}`;this.stats[kr]=(this.stats[kr]||0)+1,this.total++}if(le.source=B,se==null){if(j===he.indexMaxZoom||le.numPoints<=he.indexMaxPoints)continue}else{if(j===he.maxZoom||j===se)continue;if(se!=null){const kr=se-j;if($!==pe>>kr||ee!==de>>kr)continue}}if(le.source=null,!B.length)continue;Ce>1&&console.time("clipping");const nt=.5*he.buffer/he.extent,Rt=.5-nt,We=.5+nt,Ke=1+nt;let lt=null,or=null,Zt=null,zr=null;const Dr=sr(B,be,$-nt,$+We,0,le.minX,le.maxX,he),ar=sr(B,be,$+Rt,$+Ke,0,le.minX,le.maxX,he);Dr&&(lt=sr(Dr,be,ee-nt,ee+We,1,le.minY,le.maxY,he),or=sr(Dr,be,ee+Rt,ee+Ke,1,le.minY,le.maxY,he)),ar&&(Zt=sr(ar,be,ee-nt,ee+We,1,le.minY,le.maxY,he),zr=sr(ar,be,ee+Rt,ee+Ke,1,le.minY,le.maxY,he)),Ce>1&&console.timeEnd("clipping"),ue.push(lt||[],j+1,2*$,2*ee),ue.push(or||[],j+1,2*$,2*ee+1),ue.push(Zt||[],j+1,2*$+1,2*ee),ue.push(zr||[],j+1,2*$+1,2*ee+1)}}getTile(B,j,$){B=+B,j=+j,$=+$;const ee=this.options,{extent:se,debug:pe}=ee;if(B<0||B>24)return null;const de=1<<B,ue=_n(B,j=j+de&de-1,$);if(this.tiles[ue])return er(this.tiles[ue],se);pe>1&&console.log("drilling down to z%d-%d-%d",B,j,$);let he,Ce=B,be=j,ke=$;for(;!he&&Ce>0;)Ce--,be>>=1,ke>>=1,he=this.tiles[_n(Ce,be,ke)];return he?.source?(pe>1&&(console.log("found parent tile z%d-%d-%d",Ce,be,ke),console.time("drilling down")),this.splitTile(he.source,Ce,be,ke,B,j,$),pe>1&&console.timeEnd("drilling down"),this.tiles[ue]?er(this.tiles[ue],se):null):null}invalidateTiles(B){const j=this.options,{debug:$}=j;let ee=1/0,se=-1/0,pe=1/0,de=-1/0;for(const Ce of B)ee=Math.min(ee,Ce.minX),se=Math.max(se,Ce.maxX),pe=Math.min(pe,Ce.minY),de=Math.max(de,Ce.maxY);const ue=j.buffer/j.extent,he=new Set;for(const Ce in this.tiles){const be=this.tiles[Ce],ke=1<<be.z,le=(be.x-ue)/ke,nt=(be.x+1+ue)/ke,Rt=(be.y-ue)/ke,We=(be.y+1+ue)/ke;if(se<le||ee>=nt||de<Rt||pe>=We)continue;let Ke=!1;for(const lt of B)if(lt.maxX>=le&<.minX<nt&<.maxY>=Rt&<.minY<We){Ke=!0;break}if(Ke){if($){$>1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",be.z,be.x,be.y,be.numFeatures,be.numPoints,be.numSimplified);const lt=`z${be.z}`;this.stats[lt]=(this.stats[lt]||0)-1,this.total--}delete this.tiles[Ce],he.add(Ce)}}he.size&&(this.tileCoords=this.tileCoords.filter((Ce=>!he.has(Ce.id))))}updateData(B){const j=this.options,$=j.debug;if(!j.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");const{affected:ee,source:se}=(function(be,ke,le){const nt=(function(We){return We?{removeAll:We.removeAll,remove:new Set(We.remove||[]),add:new Map(We.add?.map((Ke=>[Ke.id,Ke]))),update:new Map(We.update?.map((Ke=>[Ke.id,Ke])))}:{remove:new Set,add:new Map,update:new Map}})(ke);let Rt=[];if(nt.removeAll&&(Rt=be,be=[]),nt.remove.size||nt.add.size){const We=[];for(const Ke of be){const{id:lt}=Ke;(nt.remove.has(lt)||nt.add.has(lt))&&We.push(Ke)}if(We.length){Rt.push(...We);const Ke=new Set(We.map((lt=>lt.id)));be=be.filter((lt=>!Ke.has(lt.id)))}if(nt.add.size){let Ke=Tt({type:"FeatureCollection",features:Array.from(nt.add.values())},le);Ke=Or(Ke,le),Rt.push(...Ke),be.push(...Ke)}}if(nt.update.size)for(const[We,Ke]of nt.update){const lt=be.findIndex((zr=>zr.id===We));if(lt===-1)continue;const or=be[lt],Zt=on(or,Ke,le);Zt&&(Rt.push(or,Zt),be[lt]=Zt)}return{affected:Rt,source:be}})(this.source,B,j);if(!ee.length)return;this.source=se,$>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(ee),$>1&&console.timeEnd("invalidating");const[pe,de,ue]=[0,0,0],he=cs(this.source,pe,de,ue,this.options);he.source=this.source;const Ce=_n(pe,de,ue);if(this.tiles[Ce]=he,this.tileCoords.push({z:pe,x:de,y:ue,id:Ce}),$){const be=`z${pe}`;this.stats[be]=(this.stats[be]||0)+1,this.total++}}}function _n(ce,B,j){return 32*((1<<ce)*j+B)+ce}class Ks extends me{constructor(B,j,$,ee=ds){super(B,j,$),this._dataUpdateable=new Map,this._createGeoJSONIndex=ee}loadVectorTile(B,j){return S._(this,void 0,void 0,(function*(){const $=B.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const ee=this._geoJSONIndex.getTile($.z,$.x,$.y);return ee?wt(new S.d3(ee.features,{version:2,extent:S.a5})):null}))}loadData(B){return S._(this,void 0,void 0,(function*(){var j;(j=this._pendingRequest)===null||j===void 0||j.abort();const $=this._startPerformance(B);this._pendingRequest=new AbortController;try{(!this._pendingData||B.request||B.data||B.dataDiff)&&(this._pendingData=this.loadAndProcessGeoJSON(B,this._pendingRequest));const ee=yield this._pendingData;this._geoJSONIndex=this._createGeoJSONIndex(ee,B),this.loaded={};const se={};return B.request&&(se.data=ee),this._finishPerformance($,B,se),se}catch(ee){if(delete this._pendingRequest,S.Z(ee))return{abandoned:!0};throw ee}}))}_startPerformance(B){var j;if(!((j=B?.request)===null||j===void 0)&&j.collectResourceTiming)return new S.c$(B.request)}_finishPerformance(B,j,$){if(!B)return;const ee=B.finish();ee&&($.resourceTiming={},$.resourceTiming[j.source]=JSON.parse(JSON.stringify(ee)))}getData(){return S._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(B){const j=this.loaded;return j&&j[B.uid]?super.reloadTile(B):this.loadTile(B)}loadAndProcessGeoJSON(B,j){return S._(this,void 0,void 0,(function*(){let $;if(B.request?$=yield this.loadGeoJSONFromUrl(B.request,B.promoteId,j):B.data?$=this._loadGeoJSONFromObject(B.data,B.promoteId):B.dataDiff&&($=this._loadGeoJSONFromDiff(B.dataDiff,B.promoteId,B.source)),delete this._pendingRequest,typeof $!="object")throw new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`);return It($,!0),B.filter&&($=this._filterGeoJSON($,B.filter)),$}))}loadGeoJSONFromUrl(B,j,$){return S._(this,void 0,void 0,(function*(){const ee=yield S.j(B,$);return this._dataUpdateable=S.a7(ee.data,j),ee.data}))}_loadGeoJSONFromObject(B,j){return this._dataUpdateable=S.a7(B,j),B}_loadGeoJSONFromDiff(B,j,$){if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${$}`);S.a8(this._dataUpdateable,B,j);const ee=Array.from(this._dataUpdateable.values());return this._toFeatureCollection(ee)}_filterGeoJSON(B,j){const $=S.d4(j,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if($.result==="error")throw new Error($.value.map((se=>`${se.key}: ${se.message}`)).join(", "));const ee=B.features.filter((se=>$.value.evaluate({zoom:0},se)));return this._toFeatureCollection(ee)}_toFeatureCollection(B){return{type:"FeatureCollection",features:B}}removeSource(B){return S._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(B){return this._geoJSONIndex.getClusterExpansionZoom(B.clusterId)}getClusterChildren(B){return this._geoJSONIndex.getChildren(B.clusterId)}getClusterLeaves(B){return this._geoJSONIndex.getLeaves(B.clusterId,B.limit,B.offset)}}function ds(ce,B){return B.cluster?new wr((function({superclusterOptions:j,clusterProperties:$}){if(!$||!j)return j;const ee={},se={},pe={accumulated:null,zoom:0},de={properties:null},ue=Object.keys($);for(const he of ue){const[Ce,be]=$[he],ke=S.d4(be),le=S.d4(typeof Ce=="string"?[Ce,["accumulated"],["get",he]]:Ce);ee[he]=ke.value,se[he]=le.value}return j.map=he=>{de.properties=he;const Ce={};for(const be of ue)Ce[be]=ee[be].evaluate(pe,de);return Ce},j.reduce=(he,Ce)=>{de.properties=Ce;for(const be of ue)pe.accumulated=he[be],he[be]=se[be].evaluate(pe,de)},j})(B)).load(ce.features):(function(j,$){return new gi(j,$)})(ce,B.geojsonVtOptions)}class ps{constructor(B){this.self=B,this.actor=new S.L(B),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(j,$)=>{if(this.externalWorkerSourceTypes[j])throw new Error(`Worker source with name "${j}" already registered.`);this.externalWorkerSourceTypes[j]=$},this.self.addProtocol=S.cK,this.self.removeProtocol=S.cL,this.self.registerRTLTextPlugin=j=>{S.d5.setMethods(j)},this.actor.registerMessageHandler("LDT",((j,$)=>this._getDEMWorkerSource(j,$.source).loadTile($))),this.actor.registerMessageHandler("RDT",((j,$)=>S._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(j,$.source).removeTile($)})))),this.actor.registerMessageHandler("GCEZ",((j,$)=>S._(this,void 0,void 0,(function*(){return this._getWorkerSource(j,$.type,$.source).getClusterExpansionZoom($)})))),this.actor.registerMessageHandler("GCC",((j,$)=>S._(this,void 0,void 0,(function*(){return this._getWorkerSource(j,$.type,$.source).getClusterChildren($)})))),this.actor.registerMessageHandler("GCL",((j,$)=>S._(this,void 0,void 0,(function*(){return this._getWorkerSource(j,$.type,$.source).getClusterLeaves($)})))),this.actor.registerMessageHandler("LD",((j,$)=>this._getWorkerSource(j,$.type,$.source).loadData($))),this.actor.registerMessageHandler("GD",((j,$)=>this._getWorkerSource(j,$.type,$.source).getData())),this.actor.registerMessageHandler("LT",((j,$)=>this._getWorkerSource(j,$.type,$.source).loadTile($))),this.actor.registerMessageHandler("RT",((j,$)=>this._getWorkerSource(j,$.type,$.source).reloadTile($))),this.actor.registerMessageHandler("AT",((j,$)=>this._getWorkerSource(j,$.type,$.source).abortTile($))),this.actor.registerMessageHandler("RMT",((j,$)=>this._getWorkerSource(j,$.type,$.source).removeTile($))),this.actor.registerMessageHandler("RS",((j,$)=>S._(this,void 0,void 0,(function*(){if(!this.workerSources[j]||!this.workerSources[j][$.type]||!this.workerSources[j][$.type][$.source])return;const ee=this.workerSources[j][$.type][$.source];delete this.workerSources[j][$.type][$.source],ee.removeSource!==void 0&&ee.removeSource($)})))),this.actor.registerMessageHandler("RM",(j=>S._(this,void 0,void 0,(function*(){delete this.layerIndexes[j],delete this.availableImages[j],delete this.workerSources[j],delete this.demWorkerSources[j],this.globalStates.delete(j)})))),this.actor.registerMessageHandler("SR",((j,$)=>S._(this,void 0,void 0,(function*(){this.referrer=$})))),this.actor.registerMessageHandler("SRPS",((j,$)=>this._syncRTLPluginState(j,$))),this.actor.registerMessageHandler("IS",((j,$)=>S._(this,void 0,void 0,(function*(){this.self.importScripts($)})))),this.actor.registerMessageHandler("SI",((j,$)=>this._setImages(j,$))),this.actor.registerMessageHandler("UL",((j,$)=>S._(this,void 0,void 0,(function*(){this._getLayerIndex(j).update($.layers,$.removedIds,this._getGlobalState(j))})))),this.actor.registerMessageHandler("UGS",((j,$)=>S._(this,void 0,void 0,(function*(){const ee=this._getGlobalState(j);for(const se in $)ee[se]=$[se]})))),this.actor.registerMessageHandler("SL",((j,$)=>S._(this,void 0,void 0,(function*(){this._getLayerIndex(j).replace($,this._getGlobalState(j))}))))}_getGlobalState(B){let j=this.globalStates.get(B);return j||(j={},this.globalStates.set(B,j)),j}_setImages(B,j){return S._(this,void 0,void 0,(function*(){this.availableImages[B]=j;for(const $ in this.workerSources[B]){const ee=this.workerSources[B][$];for(const se in ee)ee[se].availableImages=j}}))}_syncRTLPluginState(B,j){return S._(this,void 0,void 0,(function*(){return yield S.d5.syncState(j,this.self.importScripts)}))}_getAvailableImages(B){let j=this.availableImages[B];return j||(j=[]),j}_getLayerIndex(B){let j=this.layerIndexes[B];return j||(j=this.layerIndexes[B]=new l),j}_getWorkerSource(B,j,$){if(this.workerSources[B]||(this.workerSources[B]={}),this.workerSources[B][j]||(this.workerSources[B][j]={}),!this.workerSources[B][j][$]){const ee={sendAsync:(se,pe)=>(se.targetMapId=B,this.actor.sendAsync(se,pe))};switch(j){case"vector":this.workerSources[B][j][$]=new me(ee,this._getLayerIndex(B),this._getAvailableImages(B));break;case"geojson":this.workerSources[B][j][$]=new Ks(ee,this._getLayerIndex(B),this._getAvailableImages(B));break;default:this.workerSources[B][j][$]=new this.externalWorkerSourceTypes[j](ee,this._getLayerIndex(B),this._getAvailableImages(B))}}return this.workerSources[B][j][$]}_getDEMWorkerSource(B,j){return this.demWorkerSources[B]||(this.demWorkerSources[B]={}),this.demWorkerSources[B][j]||(this.demWorkerSources[B][j]=new Vt),this.demWorkerSources[B][j]}}return S.i(self)&&(self.worker=new ps(self)),ps})),A("index",["exports","./shared"],(function(S,l){var ne="5.17.0";function Se(){var d=new l.A(4);return l.A!=Float32Array&&(d[1]=0,d[2]=0),d[0]=1,d[3]=1,d}let Le,He,qe;const Ze={frame(d,t,n,o){const c=o||window,f=c.requestAnimationFrame((v=>{g(),t(v)})),{unsubscribe:g}=l.s(d.signal,"abort",(()=>{g(),c.cancelAnimationFrame(f),n(new l.a(d.signal.reason))}),!1)},frameAsync(d,t){return new Promise(((n,o)=>{this.frame(d,n,o,t)}))},getImageData(d,t=0){return this.getImageCanvasContext(d).getImageData(-t,-t,d.width+2*t,d.height+2*t)},getImageCanvasContext(d){const t=window.document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return t.width=d.width,t.height=d.height,n.drawImage(d,0,0,d.width,d.height),n},resolveURL:d=>(Le||(Le=document.createElement("a")),Le.href=d,Le.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return qe!==void 0?qe:!!matchMedia&&(He==null&&(He=matchMedia("(prefers-reduced-motion: reduce)")),He.matches)},set prefersReducedMotion(d){qe=d}},wt=new class{constructor(){this._realTime=typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return this._frozenAt!==null?this._frozenAt:this._realTime()}setNow(d){this._frozenAt=d}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function Qe(){return wt.getCurrentTime()}class me{static testProp(t){if(!me.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in me.docStyle)return t[n];return t[0]}static create(t,n,o){const c=window.document.createElement(t);return n!==void 0&&(c.className=n),o&&o.appendChild(c),c}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){me.docStyle&&me.selectProp&&(me.userSelect=me.docStyle[me.selectProp],me.docStyle[me.selectProp]="none")}static enableDrag(){me.docStyle&&me.selectProp&&(me.docStyle[me.selectProp]=me.userSelect)}static setTransform(t,n){t.style[me.transformProp]=n}static addEventListener(t,n,o,c={}){t.addEventListener(n,o,"passive"in c?c:c.capture)}static removeEventListener(t,n,o,c={}){t.removeEventListener(n,o,"passive"in c?c:c.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",me.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",me.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",me.suppressClickInternal,!0)}),0)}static getScale(t){const n=t.getBoundingClientRect();return{x:n.width/t.offsetWidth||1,y:n.height/t.offsetHeight||1,boundingClientRect:n}}static getPoint(t,n,o){const c=n.boundingClientRect;return new l.P((o.clientX-c.left)/n.x-t.clientLeft,(o.clientY-c.top)/n.y-t.clientTop)}static mousePos(t,n){const o=me.getScale(t);return me.getPoint(t,o,n)}static touchPos(t,n){const o=[],c=me.getScale(t);for(let f=0;f<n.length;f++)o.push(me.getPoint(t,c,n[f]));return o}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}static sanitize(t){const n=new DOMParser().parseFromString(t,"text/html").body||document.createElement("body"),o=n.querySelectorAll("script");for(const c of o)c.remove();return me.clean(n),n.innerHTML}static isPossiblyDangerous(t,n){const o=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!o.includes("javascript:")&&!o.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const n=t.children;for(const o of n)me.removeAttributes(o),me.clean(o)}static removeAttributes(t){for(const{name:n,value:o}of t.attributes)me.isPossiblyDangerous(n,o)&&t.removeAttribute(n)}}me.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,me.selectProp=me.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),me.transformProp=me.testProp(["transform","WebkitTransform"]);const Vt={supported:!1,testSupport:function(d){!pt&&tt&&(It?Et(d):bt=d)}};let bt,tt,pt=!1,It=!1;function Et(d){const t=d.createTexture();d.bindTexture(d.TEXTURE_2D,t);try{if(d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,tt),d.isContextLost())return;Vt.supported=!0}catch{}d.deleteTexture(t),pt=!0}var mt;typeof document<"u"&&(tt=document.createElement("img"),tt.onload=()=>{bt&&Et(bt),bt=null,It=!0},tt.onerror=()=>{pt=!0,bt=null},tt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(d){let t,n,o,c;d.resetRequestQueue=()=>{t=[],n=0,o=0,c={}},d.addThrottleControl=b=>{const P=o++;return c[P]=b,P},d.removeThrottleControl=b=>{delete c[b],g()},d.getImage=(b,P,E=!0)=>new Promise(((k,D)=>{Vt.supported&&(b.headers||(b.headers={}),b.headers.accept="image/webp,*/*"),l.e(b,{type:"image"}),t.push({abortController:P,requestParameters:b,supportImageRefresh:E,state:"queued",onError:L=>{D(L)},onSuccess:L=>{k(L)}}),g()}));const f=b=>l._(this,void 0,void 0,(function*(){b.state="running";const{requestParameters:P,supportImageRefresh:E,onError:k,onSuccess:D,abortController:L}=b,N=E===!1&&!l.i(self)&&!l.g(P.url)&&(!P.headers||Object.keys(P.headers).reduce(((W,K)=>W&&K==="accept"),!0));n++;const q=N?v(P,L):l.m(P,L);try{const W=yield q;delete b.abortController,b.state="completed",W.data instanceof HTMLImageElement||l.b(W.data)?D(W):W.data&&D({data:yield(H=W.data,typeof createImageBitmap=="function"?l.f(H):l.h(H)),cacheControl:W.cacheControl,expires:W.expires})}catch(W){delete b.abortController,k(W)}finally{n--,g()}var H})),g=()=>{const b=(()=>{for(const P of Object.keys(c))if(c[P]())return!0;return!1})()?l.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:l.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let P=n;P<b&&t.length>0;P++){const E=t.shift();E.abortController.signal.aborted?P--:f(E)}},v=(b,P)=>new Promise(((E,k)=>{const D=new Image,L=b.url,N=b.credentials;N&&N==="include"?D.crossOrigin="use-credentials":(N&&N==="same-origin"||!l.d(L))&&(D.crossOrigin="anonymous"),P.signal.addEventListener("abort",(()=>{D.src="",k(new l.a(P.signal.reason))})),D.fetchPriority="high",D.onload=()=>{D.onerror=D.onload=null,E({data:D})},D.onerror=()=>{D.onerror=D.onload=null,P.signal.aborted||k(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},D.src=L}))})(mt||(mt={})),mt.resetRequestQueue();class Qt{constructor(t){this._transformRequestFn=t??null}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function wr(d){const t=[];if(typeof d=="string")t.push({id:"default",url:d});else if(d&&d.length>0){const n=[];for(const{id:o,url:c}of d){const f=`${o}${c}`;n.indexOf(f)===-1&&(n.push(f),t.push({id:o,url:c}))}}return t}function ei(d,t,n){try{const o=new URL(d);return o.pathname+=`${t}${n}`,o.toString()}catch{throw new Error(`Invalid sprite URL "${d}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function Hr(d){const{userImage:t}=d;return!!(t&&t.render&&t.render())&&(d.data.replace(new Uint8Array(t.data.buffer)),!0)}class nr extends l.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new l.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new l.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,promiseResolve:o}of this.requestors)o(this._getImagesForIds(n));this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const o=n.spriteData;n.data=new l.R({width:o.width,height:o.height},o.context.getImageData(o.x,o.y,o.width,o.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let o=!0;const c=n.data||n.spriteData;return this._validateStretch(n.stretchX,c&&c.width)||(this.fire(new l.k(new Error(`Image "${t}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,c&&c.height)||(this.fire(new l.k(new Error(`Image "${t}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new l.k(new Error(`Image "${t}" has invalid "content" value`))),o=!1),o}_validateStretch(t,n){if(!t)return!0;let o=0;for(const c of t){if(c[0]<o||c[1]<c[0]||n<c[1])return!1;o=c[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const o=n.spriteData,c=o&&o.width||n.data.width,f=o&&o.height||n.data.height;return!(t[0]<0||c<t[0]||t[1]<0||f<t[1]||t[2]<0||c<t[2]||t[3]<0||f<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,o=!0){const c=this.getImage(t);if(o&&(c.data.width!==n.data.width||c.data.height!==n.data.height))throw new Error(`size mismatch between old image (${c.data.width}x${c.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=c.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){const n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise(((n,o)=>{let c=!0;if(!this.isLoaded())for(const f of t)this.images[f]||(c=!1);this.isLoaded()||c?n(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:n})}))}_getImagesForIds(t){const n={};for(const o of t){let c=this.getImage(o);c||(this.fire(new l.l("styleimagemissing",{id:o})),c=this.getImage(o)),c?n[o]={data:c.data.clone(),pixelRatio:c.pixelRatio,sdf:c.sdf,version:c.version,stretchX:c.stretchX,stretchY:c.stretchY,content:c.content,textFitWidth:c.textFitWidth,textFitHeight:c.textFitHeight,hasRenderCallback:!!(c.userImage&&c.userImage.render)}:l.w(`Image "${o}" 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.`)}return n}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],o=this.getImage(t);if(!o)return null;if(n&&n.position.version===o.version)return n.position;if(n)n.position.version=o.version;else{const c={w:o.data.width+2,h:o.data.height+2,x:0,y:0},f=new l.I(c,o);this.patterns[t]={bin:c,position:f}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const n=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new l.T(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const f in this.patterns)t.push(this.patterns[f].bin);const{w:n,h:o}=l.p(t),c=this.atlasImage;c.resize({width:n||1,height:o||1});for(const f in this.patterns){const{bin:g}=this.patterns[f],v=g.x+1,b=g.y+1,P=this.getImage(f).data,E=P.width,k=P.height;l.R.copy(P,c,{x:0,y:0},{x:v,y:b},{width:E,height:k}),l.R.copy(P,c,{x:0,y:k-1},{x:v,y:b-1},{width:E,height:1}),l.R.copy(P,c,{x:0,y:0},{x:v,y:b+k},{width:E,height:1}),l.R.copy(P,c,{x:E-1,y:0},{x:v-1,y:b},{width:1,height:k}),l.R.copy(P,c,{x:0,y:0},{x:v+E,y:b},{width:1,height:k})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const o=this.getImage(n);o||l.w(`Image with ID: "${n}" was not found`),Hr(o)&&this.updateImage(n,o)}}cloneImages(){const t={};for(const n in this.images){const o=this.images[n];t[n]=Object.assign(Object.assign({},o),{data:o.data?o.data.clone():null})}return t}}const mi=1e20;function kn(d,t,n,o,c,f,g,v,b){for(let P=t;P<t+o;P++)zi(d,n*f+P,f,c,g,v,b);for(let P=n;P<n+c;P++)zi(d,P*f+t,1,o,g,v,b)}function zi(d,t,n,o,c,f,g){f[0]=0,g[0]=-mi,g[1]=mi,c[0]=d[t];for(let v=1,b=0,P=0;v<o;v++){c[v]=d[t+v*n];const E=v*v;do{const k=f[b];P=(c[v]-c[k]+E-k*k)/(v-k)/2}while(P<=g[b]&&--b>-1);b++,f[b]=v,g[b]=P,g[b+1]=mi}for(let v=0,b=0;v<o;v++){for(;g[b+1]<v;)b++;const P=f[b],E=v-P;d[t+v*n]=c[P]+E*E}}const Rn=l.v.layout_symbol["text-font"].default.join(",");class At{constructor(t,n,o){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={},this.lang=o}setURL(t){this.url=t}getGlyphs(t){return l._(this,void 0,void 0,(function*(){const n=[];for(const f in t)for(const g of t[f])n.push(this._getAndCacheGlyphsPromise(f,g));const o=yield Promise.all(n),c={};for(const{stack:f,id:g,glyph:v}of o)c[f]||(c[f]={}),c[f][g]=v&&{id:v.id,bitmap:v.bitmap.clone(),metrics:v.metrics};return c}))}_getAndCacheGlyphsPromise(t,n){return l._(this,void 0,void 0,(function*(){let o=this.entries[t];o||(o=this.entries[t]={glyphs:{},requests:{},ranges:{}});let c=o.glyphs[n];return c!==void 0?{stack:t,id:n,glyph:c}:!this.url||this._charUsesLocalIdeographFontFamily(n)?(c=o.glyphs[n]=this._drawGlyph(o,t,n),{stack:t,id:n,glyph:c}):yield this._downloadAndCacheRangePromise(t,n)}))}_downloadAndCacheRangePromise(t,n){return l._(this,void 0,void 0,(function*(){const o=this.entries[t],c=Math.floor(n/256);if(o.ranges[c])return{stack:t,id:n,glyph:null};if(!o.requests[c]){const f=At.loadGlyphRange(t,c,this.url,this.requestManager);o.requests[c]=f}try{const f=yield o.requests[c];for(const g in f)o.glyphs[+g]=f[+g];return o.ranges[c]=!0,{stack:t,id:n,glyph:f[n]||null}}catch(f){const g=o.glyphs[n]=this._drawGlyph(o,t,n);return this._warnOnMissingGlyphRange(g,c,n,f),{stack:t,id:n,glyph:g}}}))}_warnOnMissingGlyphRange(t,n,o,c){const f=256*n,g=f+255,v=o.toString(16).padStart(4,"0").toUpperCase();l.w(`Unable to load glyph range ${n}, ${f}-${g}. Rendering codepoint U+${v} locally instead. ${c}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&l.q(t)}_drawGlyph(t,n,o){const c=n===Rn&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(o),f=c?"ideographTinySDF":"tinySDF";t[f]||(t[f]=this._createTinySDF(c?this.localIdeographFontFamily:n));const g=t[f].draw(String.fromCodePoint(o)),v=new RegExp("^\\p{gc=Cf}+$","u").test(String.fromCodePoint(o));return{id:o,bitmap:new l.r({width:g.width||60,height:g.height||60},g.data),metrics:{width:v?0:g.glyphWidth/2||24,height:g.glyphHeight/2||24,left:g.glyphLeft/2+.5||0,top:g.glyphTop/2-27.5||-8,advance:v?0:g.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(t){const n=t?t.split(","):[];n.push("sans-serif");const o=n.map((c=>/[-\w]+/.test(c)?c:`'${CSS.escape(c)}'`)).join(",");return new At.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:this._fontWeight(n[0]),fontStyle:this._fontStyle(n[0]),lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){const n={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let o;for(const[c,f]of Object.entries(n))new RegExp(`\\b${c}\\b`,"i").test(t)&&(o=`${f}`);return o}destroy(){for(const t in this.entries){const n=this.entries[t];n.tinySDF&&(n.tinySDF=null),n.ideographTinySDF&&(n.ideographTinySDF=null),n.glyphs={},n.requests={},n.ranges={}}this.entries={}}}At.loadGlyphRange=function(d,t,n,o){return l._(this,void 0,void 0,(function*(){const c=256*t,f=c+255,g=o.transformRequest(n.replace("{fontstack}",d).replace("{range}",`${c}-${f}`),"Glyphs"),v=yield l.n(g,new AbortController);if(!v||!v.data)throw new Error(`Could not load glyph range. range: ${t}, ${c}-${f}`);const b={};for(const P of l.o(v.data))b[P.id]=P;return b}))},At.TinySDF=class{constructor({fontSize:d=24,buffer:t=3,radius:n=8,cutoff:o=.25,fontFamily:c="sans-serif",fontWeight:f="normal",fontStyle:g="normal",lang:v=null}={}){this.buffer=t,this.cutoff=o,this.radius=n,this.lang=v;const b=this.size=d+4*t,P=this._createCanvas(b),E=this.ctx=P.getContext("2d",{willReadFrequently:!0});E.font=`${g} ${f} ${d}px ${c}`,E.textBaseline="alphabetic",E.textAlign="left",E.fillStyle="black",this.gridOuter=new Float64Array(b*b),this.gridInner=new Float64Array(b*b),this.f=new Float64Array(b),this.z=new Float64Array(b+1),this.v=new Uint16Array(b)}_createCanvas(d){const t=document.createElement("canvas");return t.width=t.height=d,t}draw(d){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:c,actualBoundingBoxRight:f}=this.ctx.measureText(d),g=Math.ceil(n),v=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(f-c))),b=Math.min(this.size-this.buffer,g+Math.ceil(o)),P=v+2*this.buffer,E=b+2*this.buffer,k=Math.max(P*E,0),D=new Uint8ClampedArray(k),L={data:D,width:P,height:E,glyphWidth:v,glyphHeight:b,glyphTop:g,glyphLeft:0,glyphAdvance:t};if(v===0||b===0)return L;const{ctx:N,buffer:q,gridInner:H,gridOuter:W}=this;this.lang&&(N.lang=this.lang),N.clearRect(q,q,v,b),N.fillText(d,q,q+g);const K=N.getImageData(q,q,v,b);W.fill(mi,0,k),H.fill(0,0,k);for(let re=0;re<b;re++)for(let Y=0;Y<v;Y++){const te=K.data[4*(re*v+Y)+3]/255;if(te===0)continue;const oe=(re+q)*P+Y+q;if(te===1)W[oe]=0,H[oe]=mi;else{const Q=.5-te;W[oe]=Q>0?Q*Q:0,H[oe]=Q<0?Q*Q:0}}kn(W,0,0,P,E,P,this.f,this.v,this.z),kn(H,q,q,v,b,P,this.f,this.v,this.z);for(let re=0;re<k;re++){const Y=Math.sqrt(W[re])-Math.sqrt(H[re]);D[re]=Math.round(255-255*(Y/this.radius+this.cutoff))}return L}};class Wi{constructor(){this.specification=l.u.light.position}possiblyEvaluate(t,n){return l.F(t.expression.evaluate(n))}interpolate(t,n,o){return{x:l.G.number(t.x,n.x,o),y:l.G.number(t.y,n.y,o),z:l.G.number(t.z,n.z,o)}}}let Tt;class Di extends l.E{constructor(t){super(),Tt=Tt||new l.t({anchor:new l.D(l.u.light.anchor),position:new Wi,color:new l.D(l.u.light.color),intensity:new l.D(l.u.light.intensity)}),this._transitionable=new l.x(Tt,void 0),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(l.y,t,n))for(const o in t){const c=t[o];o.endsWith(l.z)?this._transitionable.setTransition(o.slice(0,-l.z.length),c):this._transitionable.setValue(o,c)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,o){return(!o||o.validate!==!1)&&l.B(this,t.call(l.C,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:l.u}))}}const De=new l.t({"sky-color":new l.D(l.u.sky["sky-color"]),"horizon-color":new l.D(l.u.sky["horizon-color"]),"fog-color":new l.D(l.u.sky["fog-color"]),"fog-ground-blend":new l.D(l.u.sky["fog-ground-blend"]),"horizon-fog-blend":new l.D(l.u.sky["horizon-fog-blend"]),"sky-horizon-blend":new l.D(l.u.sky["sky-horizon-blend"]),"atmosphere-blend":new l.D(l.u.sky["atmosphere-blend"])});class at extends l.E{constructor(t){super(),this._transitionable=new l.x(De,void 0),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new l.H(0))}setSky(t,n={}){if(!this._validate(l.J,t,n)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const o in t){const c=t[o];o.endsWith(l.z)?this._transitionable.setTransition(o.slice(0,-l.z.length),c):this._transitionable.setValue(o,c)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,o={}){return o?.validate!==!1&&l.B(this,t.call(l.C,l.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:l.u})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class zt{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){const o=t.join(",")+String(n);return this.dashEntry[o]||(this.dashEntry[o]=this.addDash(t,n)),this.dashEntry[o]}getDashRanges(t,n,o){const c=[];let f=t.length%2==1?-t[t.length-1]*o:0,g=t[0]*o,v=!0;c.push({left:f,right:g,isDash:v,zeroLength:t[0]===0});let b=t[0];for(let P=1;P<t.length;P++){v=!v;const E=t[P];f=b*o,b+=E,g=b*o,c.push({left:f,right:g,isDash:v,zeroLength:E===0})}return c}addRoundDash(t,n,o){const c=n/2;for(let f=-o;f<=o;f++){const g=this.width*(this.nextRow+o+f);let v=0,b=t[v];for(let P=0;P<this.width;P++){P/b.right>1&&(b=t[++v]);const E=Math.abs(P-b.left),k=Math.abs(P-b.right),D=Math.min(E,k);let L;const N=f/o*(c+1);if(b.isDash){const q=c-Math.abs(N);L=Math.sqrt(D*D+q*q)}else L=c-Math.sqrt(D*D+N*N);this.data[g+P]=Math.max(0,Math.min(255,L+128))}}}addRegularDash(t){for(let v=t.length-1;v>=0;--v){const b=t[v],P=t[v+1];b.zeroLength?t.splice(v,1):P&&P.isDash===b.isDash&&(P.left=b.left,t.splice(v,1))}const n=t[0],o=t[t.length-1];n.isDash===o.isDash&&(n.left=o.left-this.width,o.right=n.right+this.width);const c=this.width*this.nextRow;let f=0,g=t[f];for(let v=0;v<this.width;v++){v/g.right>1&&(g=t[++f]);const b=Math.abs(v-g.left),P=Math.abs(v-g.right),E=Math.min(b,P);this.data[c+v]=Math.max(0,Math.min(255,(g.isDash?E:-E)+128))}}addDash(t,n){const o=n?7:0,c=2*o+1;if(this.nextRow+c>this.height)return l.w("LineAtlas out of space"),null;let f=0;for(let v=0;v<t.length;v++)f+=t[v];if(f!==0){const v=this.width/f,b=this.getDashRanges(t,this.width,v);n?this.addRoundDash(b,v,o):this.addRegularDash(b)}const g={y:this.nextRow+o,height:2*o,width:f};return this.nextRow+=c,this.dirty=!0,g}bind(t){const n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}const $t="maplibre_preloaded_worker_pool";class ai{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<ai.workerCount;)this.workers.push(new Worker(l.c.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach((n=>{n.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[$t]}numActive(){return Object.keys(this.active).length}}const sr=Math.floor(Ze.hardwareConcurrency/2);let kt,fr;function Hi(){return kt||(kt=new ai),kt}ai.workerCount=l.K(globalThis)?Math.max(Math.min(sr,3),1):1;class Xi{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n;const o=this.workerPool.acquire(n);for(let c=0;c<o.length;c++){const f=new l.L(o[c],n);f.name=`Worker ${c}`,this.actors.push(f)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n){const o=[];for(const c of this.actors)o.push(c.sendAsync({type:t,data:n}));return Promise.all(o)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((n=>{n.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,n){for(const o of this.actors)o.registerMessageHandler(t,n)}unregisterMessageHandler(t){for(const n of this.actors)n.unregisterMessageHandler(t)}}function Yi(){return fr||(fr=new Xi(Hi(),l.M),fr.registerMessageHandler("GR",((d,t,n)=>l.m(t,n)))),fr}function ki(d,t){const n=l.N();return l.O(n,n,[1,1,0]),l.Q(n,n,[.5*d.width,.5*d.height,1]),d.calculatePosMatrix?l.S(n,n,d.calculatePosMatrix(t.toUnwrapped())):n}function Ko(d,t,n,o,c,f,g){var v;const b=(function(D,L,N){if(D)for(const q of D){const H=L[q];if(H&&H.source===N&&H.type==="fill-extrusion")return!0}else for(const q in L){const H=L[q];if(H.source===N&&H.type==="fill-extrusion")return!0}return!1})((v=c?.layers)!==null&&v!==void 0?v:null,t,d.id),P=f.maxPitchScaleFactor(),E=d.tilesIn(o,P,b);E.sort(Or);const k=[];for(const D of E)k.push({wrappedTileID:D.tileID.wrapped().key,queryResults:D.tile.queryRenderedFeatures(t,n,d.getState(),D.queryGeometry,D.cameraQueryGeometry,D.scale,c,f,P,ki(f,D.tileID),g?(L,N)=>g(D.tileID,L,N):void 0)});return(function(D,L){for(const N in D)for(const q of D[N])Si(q,L);return D})((function(D){const L={},N={};for(const q of D){const H=q.queryResults,W=q.wrappedTileID,K=N[W]=N[W]||{};for(const re in H){const Y=H[re],te=K[re]=K[re]||{},oe=L[re]=L[re]||[];for(const Q of Y)te[Q.featureIndex]||(te[Q.featureIndex]=!0,oe.push(Q))}}return L})(k),d)}function Or(d,t){const n=d.tileID,o=t.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function Si(d,t){const n=d.feature,o=t.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}function Ri(d,t,n,o){return l._(this,void 0,void 0,(function*(){let c=d;if(d.url?c=(yield l.j(t.transformRequest(d.url,"Source"),n)).data:yield Ze.frameAsync(n,o),!c)return null;const f=l.U(l.e(c,d),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in c&&c.vector_layers&&(f.vectorLayerIds=c.vector_layers.map((g=>g.id))),f}))}class er{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof l.V?new l.V(t.lng,t.lat):l.V.convert(t),this}setSouthWest(t){return this._sw=t instanceof l.V?new l.V(t.lng,t.lat):l.V.convert(t),this}extend(t){const n=this._sw,o=this._ne;let c,f;if(t instanceof l.V)c=t,f=t;else{if(!(t instanceof er))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(er.convert(t)):this.extend(l.V.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(l.V.convert(t)):this;if(c=t._sw,f=t._ne,!c||!f)return this}return n||o?(n.lng=Math.min(c.lng,n.lng),n.lat=Math.min(c.lat,n.lat),o.lng=Math.max(f.lng,o.lng),o.lat=Math.max(f.lat,o.lat)):(this._sw=new l.V(c.lng,c.lat),this._ne=new l.V(f.lng,f.lat)),this}getCenter(){return new l.V((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new l.V(this.getWest(),this.getNorth())}getSouthEast(){return new l.V(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:n,lat:o}=l.V.convert(t);let c=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&c}intersects(t){if(!((t=er.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;const n=Math.abs(this.getEast()-this.getWest()),o=Math.abs(t.getEast()-t.getWest());if(n>=360||o>=360)return!0;const c=l.W(this.getWest(),-180,180),f=l.W(this.getEast(),-180,180),g=l.W(t.getWest(),-180,180),v=l.W(t.getEast(),-180,180),b=c>=f,P=g>=v;return!(!b||!P)||(b?v>=c||g<=f:P?f>=g||c<=v:g<=f&&v>=c)}static convert(t){return t instanceof er?t:t&&new er(t)}static fromLngLat(t,n=0){const o=360*n/40075017,c=o/Math.cos(Math.PI/180*t.lat);return new er(new l.V(t.lng-c,t.lat-o),new l.V(t.lng+c,t.lat+o))}adjustAntiMeridian(){const t=new l.V(this._sw.lng,this._sw.lat),n=new l.V(this._ne.lng,this._ne.lat);return new er(t,t.lng>n.lng?new l.V(n.lng+360,n.lat):n)}}class sn{constructor(t,n,o){this.bounds=er.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),o=Math.floor(l.Y(this.bounds.getWest())*n),c=Math.floor(l.X(this.bounds.getNorth())*n),f=Math.ceil(l.Y(this.bounds.getEast())*n),g=Math.ceil(l.X(this.bounds.getSouth())*n);return t.x>=o&&t.x<f&&t.y>=c&&t.y<g}}class cs extends l.E{constructor(t,n,o,c){if(super(),this.id=t,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,l.e(this,l.U(n,["url","scheme","tileSize","promoteId","encoding"])),this._options=l.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(c)}load(){return l._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new l.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield Ri(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,this.map.style.tileManagers[this.id].clearTiles(),t&&(l.e(this,t),t.bounds&&(this.tileBounds=new sn(t.bounds,this.minzoom,this.maxzoom)),this.fire(new l.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new l.l("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,l.Z(t)||this.fire(new l.k(t))}}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return l.e({},this._options)}loadTile(t){return l._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o={request:this.map._requestManager.transformRequest(n,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(t)};o.request.collectResourceTiming=this._collectResourceTiming;let c="RT";if(t.actor&&t.state!=="expired"){if(t.state==="loading")return new Promise(((f,g)=>{t.reloadPromise={resolve:f,reject:g}}))}else t.actor=this.dispatcher.getActor(),c="LT";t.abortController=new AbortController;try{const f=yield t.actor.sendAsync({type:c,data:o},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,f)}catch(f){if(delete t.abortController,t.aborted)return;if(f&&f.status!==404)throw f;this._afterTileLoadWorkerResponse(t,null)}}))}_getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;const n=t.tileID.scaledTo(this.maxzoom).canonical,o=n.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:n,overzoomRequest:this.map._requestManager.transformRequest(o,"Tile")}}_afterTileLoadWorkerResponse(t,n){if(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),t.reloadPromise){const o=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(o.resolve).catch(o.reject)}}abortTile(t){return l._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return l._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class us extends l.E{constructor(t,n,o,c){super(),this.id=t,this.dispatcher=o,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=l.e({type:"raster"},n),l.e(this,l.U(n,["url","scheme","tileSize"]))}load(){return l._(this,arguments,void 0,(function*(t=!1){this._loaded=!1,this.fire(new l.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const n=yield Ri(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,n&&(l.e(this,n),n.bounds&&(this.tileBounds=new sn(n.bounds,this.minzoom,this.maxzoom)),this.fire(new l.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new l.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(n){this._tileJSONRequest=null,this._loaded=!0,l.Z(n)||this.fire(new l.k(n))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return l.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return l._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const o=yield mt.getImage(this.map._requestManager.transformRequest(n,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(o&&o.data){this.map._refreshExpiredTiles&&(o.cacheControl||o.expires)&&t.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const c=this.map.painter.context,f=c.gl,g=o.data;t.texture=this.map.painter.getTileTexture(g.width),t.texture?t.texture.update(g,{useMipmap:!0}):(t.texture=new l.T(c,g,f.RGBA,{useMipmap:!0}),t.texture.bind(f.LINEAR,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(o){if(delete t.abortController,t.aborted)t.state="unloaded";else if(o)throw t.state="errored",o}}))}abortTile(t){return l._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return l._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class Ki extends us{constructor(t,n,o,c){super(t,n,o,c),this.type="raster-dem",this.maxzoom=22,this._options=l.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t){return l._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o=this.map._requestManager.transformRequest(n,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const c=yield mt.getImage(o,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(c&&c.data){const f=c.data;this.map._refreshExpiredTiles&&(c.cacheControl||c.expires)&&t.setExpiryData({cacheControl:c.cacheControl,expires:c.expires});const g=l.b(f)&&l.$()?f:yield this.readImageNow(f),v={type:this.type,uid:t.uid,source:this.id,rawImageData:g,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||t.state==="expired"){t.actor=this.dispatcher.getActor();const b=yield t.actor.sendAsync({type:"LDT",data:v});t.dem=b,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(c){if(delete t.abortController,t.aborted)t.state="unloaded";else if(c)throw t.state="errored",c}}))}readImageNow(t){return l._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&l.a0()){const n=t.width+2,o=t.height+2;try{return new l.R({width:n,height:o},yield l.a1(t,-1,-1,n,o))}catch{}}return Ze.getImageData(t,1)}))}_getNeighboringTiles(t){const n=t.canonical,o=Math.pow(2,n.z),c=(n.x-1+o)%o,f=n.x===0?t.wrap-1:t.wrap,g=(n.x+1+o)%o,v=n.x+1===o?t.wrap+1:t.wrap,b={};return b[new l.a2(t.overscaledZ,f,n.z,c,n.y).key]={backfilled:!1},b[new l.a2(t.overscaledZ,v,n.z,g,n.y).key]={backfilled:!1},n.y>0&&(b[new l.a2(t.overscaledZ,f,n.z,c,n.y-1).key]={backfilled:!1},b[new l.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},b[new l.a2(t.overscaledZ,v,n.z,g,n.y-1).key]={backfilled:!1}),n.y+1<o&&(b[new l.a2(t.overscaledZ,f,n.z,c,n.y+1).key]={backfilled:!1},b[new l.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},b[new l.a2(t.overscaledZ,v,n.z,g,n.y+1).key]={backfilled:!1}),b}unloadTile(t){return l._(this,void 0,void 0,(function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))}))}}function on(d){return d.type==="GeometryCollection"?d.geometries.map((t=>t.coordinates)).flat(1/0):d.coordinates.flat(1/0)}function Fn(d){const t=new er;let n;switch(d.type){case"FeatureCollection":n=d.features.map((o=>on(o.geometry))).flat(1/0);break;case"Feature":n=on(d.geometry);break;default:n=on(d)}if(n.length==0)return t;for(let o=0;o<n.length-1;o+=2)t.extend([n[o],n[o+1]]);return t}class hs extends l.E{constructor(t,n,o,c){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actor=o.getActor(),this.setEventedParent(c),this._data=typeof n.data=="string"?{url:n.data}:{geojson:n.data},this._options=l.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&l.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=l.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer!==void 0?n.buffer:128),tolerance:this._pixelsToTileUnits(n.tolerance!==void 0?n.tolerance:.375),extent:l.a5,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:l.a5,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.optionsChanged}_pixelsToTileUnits(t){return t*(l.a5/this.tileSize)}_getClusterMaxZoom(t){const n=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||t===void 0||l.w(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${n}"`),n}load(){return l._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(t){this.map=t,this.load()}setData(t,n){this._data=typeof t=="string"?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t};const o=this._updateWorkerData();return n?o:this}updateData(t,n){this._pendingWorkerUpdate.diff=l.a6(this._pendingWorkerUpdate.diff,t);const o=this._updateWorkerData();return n?o:this}getData(){return l._(this,void 0,void 0,(function*(){const t=l.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})}))}getBounds(){return l._(this,void 0,void 0,(function*(){return Fn(yield this.getData())}))}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.optionsChanged=!0,this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,n,o){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:n,offset:o}})}_updateWorkerData(){return l._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void l.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:t,diff:n}=this._pendingWorkerUpdate,o=this._getLoadGeoJSONParameters(t,n);t!==void 0?this._pendingWorkerUpdate.data=void 0:n&&(this._pendingWorkerUpdate.diff=void 0),this._pendingWorkerUpdate.optionsChanged=void 0,yield this._dispatchWorkerUpdate(o)}))}_getLoadGeoJSONParameters(t,n){const o=l.e({type:this.type},this.workerOptions);return typeof t=="string"?(o.request=this.map._requestManager.transformRequest(Ze.resolveURL(t),"Source"),o.request.collectResourceTiming=this._collectResourceTiming,o):t!==void 0?(o.data=t,o):(n&&(o.dataDiff=n),o)}_dispatchWorkerUpdate(t){return l._(this,void 0,void 0,(function*(){this._isUpdatingWorker=!0,this.fire(new l.l("dataloading",{dataType:"source"}));try{const n=yield this.actor.sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||n.abandoned)return void this.fire(new l.l("dataabort",{dataType:"source"}));n.data&&(this._data={geojson:n.data});const o=this._applyDiffToSource(t.dataDiff),c=this._getShouldReloadTileOptions(o),f={dataType:"source"};this._applyResourceTiming(f,n),this.fire(new l.l("data",Object.assign(Object.assign({},f),{sourceDataType:"metadata"}))),this.fire(new l.l("data",Object.assign(Object.assign({},f),{sourceDataType:"content",shouldReloadTileOptions:c})))}catch(n){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new l.l("dataabort",{dataType:"source"}));this.fire(new l.k(n))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyResourceTiming(t,n){var o;if(!this._collectResourceTiming)return;const c=(o=n.resourceTiming)===null||o===void 0?void 0:o[this.id];if(!c)return;const f=c.slice(0);f?.length&&l.e(t,{resourceTiming:f})}_applyDiffToSource(t){if(!t)return;const n=typeof this.promoteId=="string"?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const c=l.a7(this._data.geojson,n);if(!c)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:c}}if(!this._data.updateable)return;const o=l.a8(this._data.updateable,t,n);return t.removeAll||this._options.cluster?void 0:o}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((n=>Fn(n)))}}shouldReloadTile(t,{affectedBounds:n}){if(t.state==="loading")return!0;if(t.state==="unloaded")return!1;const{buffer:o,extent:c}=this.workerOptions.geojsonVtOptions,f=(function({x:g,y:v,z:b},P=0){const E=l.a3((g-P)/Math.pow(2,b)),k=l.a4((v+1+P)/Math.pow(2,b)),D=l.a3((g+1+P)/Math.pow(2,b)),L=l.a4((v-P)/Math.pow(2,b));return new er([E,k],[D,L])})(t.tileID.canonical,o/c);for(const g of n)if(f.intersects(g))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(t){return l._(this,void 0,void 0,(function*(){const n=t.actor?"RT":"LT";t.actor=this.actor;const o={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;const c=yield this.actor.sendAsync({type:n,data:o},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(c,this.map.painter,n==="RT")}))}abortTile(t){return l._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return l._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return l.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class gi extends l.E{constructor(t,n,o,c){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=o,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(c),this.options=n}load(t){return l._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new l.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield mt.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,t&&(this.coordinates=t),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,l.Z(n)||this.fire(new l.k(n))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new l.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(l.a9.fromLngLat);var o;return this.tileID=(function(c){const f=l.aa.fromPoints(c),g=f.width(),v=f.height(),b=Math.max(g,v),P=Math.max(0,Math.floor(-Math.log(b)/Math.LN2)),E=Math.pow(2,P);return new l.ac(P,Math.floor((f.minX+f.maxX)/2*E),Math.floor((f.minY+f.maxY)/2*E))})(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map((c=>this.tileID.getTilePoint(c)._round())),this.flippedWindingOrder=((o=this.tileCoords)[1].x-o[0].x)*(o[2].y-o[0].y)-(o[1].y-o[0].y)*(o[2].x-o[0].x)<0,this.fire(new l.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const t=this.map.painter.context,n=t.gl;this.texture||(this.texture=new l.T(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(const c in this.tiles){const f=this.tiles[c];f.state!=="loaded"&&(f.state="loaded",f.texture=this.texture,o=!0)}o&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return l._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){const{minX:n,minY:o,maxX:c,maxY:f}=l.aa.fromPoints(t),g={};for(let v=0;v<=l.ab;v++){const b=Math.pow(2,v),P=Math.floor(n*b),E=Math.floor(o*b),k=Math.floor(c*b),D=Math.floor(f*b),L=(P%b+b)%b,N=k%b,q=Math.floor(P/b),H=Math.floor(k/b);g[v]={minWrap:q,maxWrap:H,minTileXWrapped:L,maxTileXWrapped:N,minTileY:E,maxTileY:D}}return g}}class _n extends gi{constructor(t,n,o,c){super(t,n,o,c),this.roundZoom=!0,this.type="video",this.options=n}load(){return l._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield l.ad(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new l.k(n))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;t<n.start(0)||t>n.end(0)?this.fire(new l.k(new l.ae(`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=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new l.T(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(const c in this.tiles){const f=this.tiles[c];f.state!=="loaded"&&(f.state="loaded",f.texture=this.texture,o=!0)}o&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Ks extends gi{constructor(t,n,o,c){super(t,n,o,c),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((f=>!Array.isArray(f)||f.length!==2||f.some((g=>typeof g!="number"))))||this.fire(new l.k(new l.ae(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new l.k(new l.ae(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new l.k(new l.ae(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new l.k(new l.ae(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new l.k(new l.ae(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return l._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new l.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,o=n.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new l.T(n,this.canvas,o.RGBA,{premultiply:!0}),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE));let c=!1;for(const f in this.tiles){const g=this.tiles[f];g.state!=="loaded"&&(g.state="loaded",g.texture=this.texture,c=!0)}c&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const ds={},ps=d=>{switch(d){case"geojson":return hs;case"image":return gi;case"raster":return us;case"raster-dem":return Ki;case"vector":return cs;case"video":return _n;case"canvas":return Ks}return ds[d]},ce="RTLPluginLoaded";class B extends l.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Yi()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((n=>{throw this.status="error",n}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return l._(this,arguments,void 0,(function*(n,o=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Ze.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!o)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()}))}_requestImport(){return l._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new l.l(ce))}))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let j=null;function $(){return j||(j=new B),j}var ee,se;(function(d){d[d.Base=0]="Base",d[d.Parent=1]="Parent"})(ee||(ee={})),(function(d){d[d.Departing=0]="Departing",d[d.Incoming=1]="Incoming"})(se||(se={}));class pe{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=l.af(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:n,fadingParentID:o,fadeEndTime:c}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=n,this.fadingParentID=o,this.fadeEndTime=c}setSelfFadeLogic(t){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=t}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=Qe(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,n,o){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData,this.latestFeatureIndex.encoding=t.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=(function(c,f){const g={};if(!f)return g;for(const v of c){const b=v.layerIds.map((P=>f.getLayer(P))).filter(Boolean);if(b.length!==0){v.layers=b,v.stateDependentLayerIds&&(v.stateDependentLayers=v.stateDependentLayerIds.map((P=>b.filter((E=>E.id===P))[0])));for(const P of b)g[P.id]=v}}return g})(t.buckets,n?.style),this.hasSymbolBuckets=!1;for(const c in this.buckets){const f=this.buckets[c];if(f instanceof l.ah){if(this.hasSymbolBuckets=!0,!o)break;f.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const c in this.buckets){const f=this.buckets[c];if(f instanceof l.ah&&f.hasRTLText){this.hasRTLText=!0,$().lazyLoad();break}}this.queryPadding=0;for(const c in this.buckets){const f=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(c).queryRadius(f))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new l.ag}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const o in this.buckets){const c=this.buckets[o];c.uploadPending()&&c.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l.T(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l.T(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,o,c,f,g,v,b,P,E,k){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:c,cameraQueryGeometry:f,scale:g,tileSize:this.tileSize,pixelPosMatrix:E,transform:b,params:v,queryPadding:this.queryPadding*P,getElevation:k},t,n,o):{}}querySourceFeatures(t,n){const o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;const c=o.loadVTLayers(),f=n&&n.sourceLayer?n.sourceLayer:"",g=c[l.ai]||c[f];if(!g)return;const v=l.aj(n?.filter,n?.globalState),{z:b,x:P,y:E}=this.tileID.canonical,k={z:b,x:P,y:E};for(let D=0;D<g.length;D++){const L=g.feature(D);if(v.needGeometry){const H=l.ak(L,!0);if(!v.filter(new l.H(this.tileID.overscaledZ),H,this.tileID.canonical))continue}else if(!v.filter(new l.H(this.tileID.overscaledZ),L))continue;const N=o.getId(L,f),q=new l.al(L,b,P,E,N);q.tile=k,t.push(q)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const o=l.am(t.cacheControl);o["max-age"]&&(this.expirationTime=Date.now()+1e3*o["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const o=Date.now();let c=!1;if(this.expirationTime>o)c=!1;else if(n)if(this.expirationTime<n)c=!0;else{const f=this.expirationTime-n;f?this.expirationTime=o+Math.max(f,3e4):c=!0}else c=!0;c?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const o=this.latestFeatureIndex.loadVTLayers();for(const c in this.buckets){if(!n.style.hasLayer(c))continue;const f=this.buckets[c],g=f.layers[0].sourceLayer||l.ai,v=o[g],b=t[g];if(!v||!b||Object.keys(b).length===0)continue;f.update(b,v,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const P=n&&n.style&&n.style.getLayer(c);P&&(this.queryPadding=Math.max(this.queryPadding,P.queryRadius(f)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Qe()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=Qe()+t}setDependencies(t,n){const o={};for(const c of n)o[c]=!0;this.dependencies[t]=o}hasDependency(t,n){for(const o of t){const c=this.dependencies[o];if(c){for(const f of n)if(c[f])return!0}}return!1}}class de{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,o){const c=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][c]=this.stateChanges[t][c]||{},l.e(this.stateChanges[t][c],o),this.deletedStates[t]===null){this.deletedStates[t]={};for(const f in this.state[t])f!==c&&(this.deletedStates[t][f]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][c]===null){this.deletedStates[t][c]={};for(const f in this.state[t][c])o[f]||(this.deletedStates[t][c][f]=null)}else for(const f in o)this.deletedStates[t]&&this.deletedStates[t][c]&&this.deletedStates[t][c][f]===null&&delete this.deletedStates[t][c][f]}removeFeatureState(t,n,o){if(this.deletedStates[t]===null)return;const c=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},o&&n!==void 0)this.deletedStates[t][c]!==null&&(this.deletedStates[t][c]=this.deletedStates[t][c]||{},this.deletedStates[t][c][o]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][c])for(o in this.deletedStates[t][c]={},this.stateChanges[t][c])this.deletedStates[t][c][o]=null;else this.deletedStates[t][c]=null;else this.deletedStates[t]=null}getState(t,n){const o=String(n),c=l.e({},(this.state[t]||{})[o],(this.stateChanges[t]||{})[o]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const f=this.deletedStates[t][n];if(f===null)return{};for(const g in f)delete c[g]}return c}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const o={};for(const c in this.stateChanges){this.state[c]=this.state[c]||{};const f={};for(const g in this.stateChanges[c])this.state[c][g]||(this.state[c][g]={}),l.e(this.state[c][g],this.stateChanges[c][g]),f[g]=this.state[c][g];o[c]=f}for(const c in this.deletedStates){this.state[c]=this.state[c]||{};const f={};if(this.deletedStates[c]===null)for(const g in this.state[c])f[g]={},this.state[c][g]={};else for(const g in this.deletedStates[c]){if(this.deletedStates[c][g]===null)this.state[c][g]={};else for(const v of Object.keys(this.deletedStates[c][g]))delete this.state[c][g][v];f[g]=this.state[c][g]}o[c]=o[c]||{},l.e(o[c],f)}this.stateChanges={},this.deletedStates={},Object.keys(o).length!==0&&t.setFeatureState(o,n)}}const ue=89.25;function he(d,t){const n=l.an(t.lat,-l.ao,l.ao);return new l.P(l.Y(t.lng)*d,l.X(n)*d)}function Ce(d,t){return new l.a9(t.x/d,t.y/d).toLngLat()}function be(d){return d.cameraToCenterDistance*Math.min(.85*Math.tan(l.ap(90-d.pitch)),Math.tan(l.ap(ue-d.pitch)))}function ke(d,t){const n=d.canonical,o=t/l.aq(n.z),c=n.x+Math.pow(2,n.z)*d.wrap,f=l.ar(new Float64Array(16));return l.O(f,f,[c*o,n.y*o,0]),l.Q(f,f,[o/l.a5,o/l.a5,1]),f}function le(d,t,n,o,c){const f=l.a9.fromLngLat(d,t),g=c*l.as(1,d.lat),{x:v,y:b,z:P}=nt(n,o);return new l.a9(f.x+g*-v,f.y+g*-b,f.z+g*-P)}function nt(d,t){const n=l.ap(d),o=l.ap(t),c=Math.cos(-n),f=Math.sin(n);return{x:f*Math.sin(o),y:-f*Math.cos(o),z:c}}function Rt(d,t,n){const o=t.intersectsFrustum(d);if(!n||o===0)return o;const c=t.intersectsPlane(n);return c===0?0:o===2&&c===2?2:1}function We(d,t,n){let o=0;const c=(n-t)/10;for(let f=0;f<10;f++)o+=c*Math.pow(Math.cos(t+(f+.5)/10*(n-t)),d);return o}function Ke(d,t){return function(n,o,c,f,g){const v=2*((d-1)/l.at(Math.cos(l.ap(ue-g))/Math.cos(l.ap(ue)))-1),b=Math.acos(c/f),P=2*We(v-1,0,l.ap(g/2)),E=Math.min(l.ap(ue),b+l.ap(g/2)),k=We(v-1,Math.min(E,b-l.ap(g/2)),E),D=Math.atan(o/c),L=Math.hypot(o,c);let N=n;return N+=l.at(f/L/Math.max(.5,Math.cos(l.ap(g/2)))),N+=v*l.at(Math.cos(D))/2,N-=l.at(Math.max(1,k/P/t))/2,N}}const lt=Ke(9.314,3);function or(d,t){const n=(t.roundZoom?Math.round:Math.floor)(d.zoom+l.at(d.tileSize/t.tileSize));return Math.max(0,n)}function Zt(d,t){const n=d.getCameraFrustum(),o=d.getClippingPlane(),c=d.screenPointToMercatorCoordinate(d.getCameraPoint()),f=l.a9.fromLngLat(d.center,d.elevation);c.z=f.z+Math.cos(d.pitchInRadians)*d.cameraToCenterDistance/d.worldSize;const g=d.getCoveringTilesDetailsProvider(),v=g.allowVariableZoom(d,t),b=or(d,t),P=t.minzoom||0,E=t.maxzoom!==void 0?t.maxzoom:d.maxZoom,k=Math.min(Math.max(0,b),E),D=Math.pow(2,k),L=[D*c.x,D*c.y,0],N=[D*f.x,D*f.y,0],q=Math.hypot(f.x-c.x,f.y-c.y),H=Math.abs(f.z-c.z),W=Math.hypot(q,H),K=te=>({zoom:0,x:0,y:0,wrap:te,fullyVisible:!1}),re=[],Y=[];if(d.renderWorldCopies&&g.allowWorldCopies())for(let te=1;te<=3;te++)re.push(K(-te)),re.push(K(te));for(re.push(K(0));re.length>0;){const te=re.pop(),oe=te.x,Q=te.y;let ae=te.fullyVisible;const ve={x:oe,y:Q,z:te.zoom},ge=g.getTileBoundingVolume(ve,te.wrap,d.elevation,t);if(!ae){const Fe=Rt(n,ge,o);if(Fe===0)continue;ae=Fe===2}const _e=g.distanceToTile2d(c.x,c.y,ve,ge);let ye=b;v&&(ye=(t.calculateTileZoom||lt)(d.zoom+l.at(d.tileSize/t.tileSize),_e,H,W,d.fov)),ye=(t.roundZoom?Math.round:Math.floor)(ye),ye=Math.max(0,ye);const Re=Math.min(ye,E);if(te.wrap=g.getWrap(f,ve,te.wrap),te.zoom>=Re){if(te.zoom<P)continue;const Fe=k-te.zoom,Ee=L[0]-.5-(oe<<Fe),je=L[1]-.5-(Q<<Fe),st=t.reparseOverscaled?Math.max(te.zoom,ye):te.zoom;Y.push({tileID:new l.a2(te.zoom===E?st:te.zoom,te.wrap,te.zoom,oe,Q),distanceSq:l.au([N[0]-.5-oe,N[1]-.5-Q]),tileDistanceToCamera:Math.sqrt(Ee*Ee+je*je)})}else for(let Fe=0;Fe<4;Fe++)re.push({zoom:te.zoom+1,x:(oe<<1)+Fe%2,y:(Q<<1)+(Fe>>1),wrap:te.wrap,fullyVisible:ae})}return Y.sort(((te,oe)=>te.distanceSq-oe.distanceSq)).map((te=>te.tileID))}const zr=l.aa.fromPoints([new l.P(0,0),new l.P(l.a5,l.a5)]);function Dr(d){return d==="raster"||d==="image"||d==="video"}function ar(d,t,n,o,c,f,g){if(!t.hasData())return!1;const{tileID:v,fadingRole:b,fadingDirection:P,fadingParentID:E}=t;if(b===ee.Base&&P===se.Incoming&&E)return n[E.key]=E,!0;const k=Math.max(v.overscaledZ-c,f);for(let D=v.overscaledZ-1;D>=k;D--){const L=v.scaledTo(D),N=d.getLoadedTile(L);if(N)return t.setCrossFadeLogic({fadingRole:ee.Base,fadingDirection:se.Incoming,fadingParentID:N.tileID,fadeEndTime:o+g}),N.setCrossFadeLogic({fadingRole:ee.Parent,fadingDirection:se.Departing,fadeEndTime:o+g}),n[L.key]=L,!0}return!1}function kr(d,t,n,o,c,f){if(!t.hasData())return!1;const g=t.tileID.children(c);let v=Me(d,t,g,n,o,c,f);if(v)return!0;for(const b of g)Me(d,t,b.children(c),n,o,c,f)&&(v=!0);return v}function Me(d,t,n,o,c,f,g){if(n[0].overscaledZ>=f)return!1;let v=!1;for(const b of n){const P=d.getLoadedTile(b);if(!P)continue;const{fadingRole:E,fadingDirection:k,fadingParentID:D}=P;E===ee.Base&&k===se.Departing&&D||(P.setCrossFadeLogic({fadingRole:ee.Base,fadingDirection:se.Departing,fadingParentID:t.tileID,fadeEndTime:c+g}),t.setCrossFadeLogic({fadingRole:ee.Parent,fadingDirection:se.Incoming,fadeEndTime:c+g})),o[b.key]=b,v=!0}return v}function Tr(d,t,n,o){const c=d.tileID;return!!d.selfFading||!d.hasData()&&!!t.has(c)&&(d.setSelfFadeLogic(n+o),!0)}function li(d,t){var n;d.needsHillshadePrepare=!0,d.needsTerrainPrepare=!0;let o=t.tileID.canonical.x-d.tileID.canonical.x;const c=t.tileID.canonical.y-d.tileID.canonical.y,f=Math.pow(2,d.tileID.canonical.z),g=t.tileID.key;o===0&&c===0||Math.abs(c)>1||(Math.abs(o)>1&&(Math.abs(o+f)===1?o+=f:Math.abs(o-f)===1&&(o-=f)),t.dem&&d.dem&&(d.dem.backfillBorder(t.dem,o,c),!((n=d.neighboringTiles)===null||n===void 0)&&n[g]&&(d.neighboringTiles[g].backfilled=!0)))}class Ln{constructor(){this._tiles={}}handleWrapJump(t){const n={};for(const o in this._tiles){const c=this._tiles[o];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+t),n[c.tileID.key]=c}this._tiles=n}setFeatureState(t,n){for(const o in this._tiles)this._tiles[o].setFeatureState(t,n)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map((n=>n.tileID)).sort(l.aw).map((n=>n.key)):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,n){this._tiles[t]=n}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){const n=this.getTileById(t.key);return n?.hasData()?n:null}isIdRenderable(t,n=!1){var o;return(o=this.getTileById(t))===null||o===void 0?void 0:o.isRenderable(n)}getRenderableIds(t=0,n){const o=[];for(const c of this.getAllIds())this.isIdRenderable(c,n)&&o.push(this.getTileById(c));return n?o.sort(((c,f)=>{const g=c.tileID,v=f.tileID,b=new l.P(g.canonical.x,g.canonical.y)._rotate(-t),P=new l.P(v.canonical.x,v.canonical.y)._rotate(-t);return g.overscaledZ-v.overscaledZ||P.y-b.y||P.x-b.x})).map((c=>c.tileID.key)):o.map((c=>c.tileID)).sort(l.aw).map((c=>c.key))}}class mr extends l.E{constructor(t,n,o){super(),this.id=t,this.dispatcher=o,this.on("data",(c=>this._dataHandler(c))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((c,f,g,v)=>{const b=new(ps(f.type))(c,f,g,v);if(b.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${b.id}`);return b})(t,n,o,this),this._inViewTiles=new Ln,this._outOfViewCache=new l.ax(0,(c=>this._unloadTile(c))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new de,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){for(const n of this._inViewTiles.getAllTiles())n.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t),this._inViewTiles=new Ln}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n,o){return l._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,n,o)}catch(c){t.state="errored",c.status!==404?this._source.fire(new l.k(c,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new l.l("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const n of this._inViewTiles.getAllTiles())n.upload(t),n.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var n;return this._inViewTiles.getRenderableIds((n=this.transform)===null||n===void 0?void 0:n.bearingInRadians,t)}hasRenderableParent(t){const n=t.overscaledZ-1;if(n>=this._source.minzoom){const o=this.getLoadedTile(t.scaledTo(n));if(o)return this._inViewTiles.isIdRenderable(o.tileID.key)}return!1}reload(t,n=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const o of this._inViewTiles.getAllIds()){const c=this._inViewTiles.getTileById(o);n&&!this._source.shouldReloadTile(c,n)||(t?this._reloadTile(o,"expired"):c.state!=="errored"&&this._reloadTile(o,"reloading"))}}}_reloadTile(t,n){return l._(this,void 0,void 0,(function*(){const o=this._inViewTiles.getTileById(t);o&&(o.state!=="loading"&&(o.state=n),yield this._loadTile(o,t,n))}))}_tileLoaded(t,n,o){t.timeAdded=Qe(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),o==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&(function(c,f){var g,v;const b=f.getRenderableIds();for(const P of b){if(!c.neighboringTiles||!c.neighboringTiles[P])continue;const E=f.getTileById(P);c.neighboringTiles[P].backfilled||li(c,E),!((v=(g=E.neighboringTiles)===null||g===void 0?void 0:g[c.tileID.key])===null||v===void 0)&&v.backfilled||li(E,c)}})(t,this._inViewTiles),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new l.l("data",{dataType:"source",tile:t,coord:t.tileID}))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,n){const o=this._getLoadedDescendents(n),c=new Set;for(const f of n){const g=o[f.key];if(!g?.length){c.add(f);continue}const v=f.overscaledZ+mr.maxOverzooming,b=g.filter((k=>k.tileID.overscaledZ<=v));if(!b.length){c.add(f);continue}const P=Math.min(...b.map((k=>k.tileID.overscaledZ))),E=b.filter((k=>k.tileID.overscaledZ===P)).map((k=>k.tileID));for(const k of E)t[k.key]=k;this._areDescendentsComplete(E,P,f.overscaledZ)||c.add(f)}return c}_getLoadedDescendents(t){var n;const o={};for(const c of this._inViewTiles.getAllTiles().filter((f=>f.hasData())))for(const f of t)c.tileID.isChildOf(f)&&(o[n=f.key]||(o[n]=[])).push(c);return o}_areDescendentsComplete(t,n,o){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===n:Math.pow(4,n-o)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,o=Math.ceil(t.height/this._source.tileSize)+1,c=Math.floor(n*o*(this._maxTileCacheZoomLevels===null?l.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),f=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,c):c;this._outOfViewCache.setMaxSize(f)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);this._prevLng=t,n&&(this._inViewTiles.handleWrapJump(n),this._resetTileReloadTimers())}update(t,n){if(!this._sourceLoaded||this._paused)return;let o;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?o=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((b=>new l.a2(b.canonical.z,b.wrap,b.canonical.z,b.canonical.x,b.canonical.y))):(o=Zt(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type==="vector"&&this.map._zoomLevelsToOverscale!==void 0?t.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(o=o.filter((b=>this._source.hasTile(b))))):o=[],this.usedForTerrain&&(o=this._addTerrainIdealTiles(o));const c=o.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,c&&this.fire(new l.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const f=or(t,this._source),g=this._updateRetainedTiles(o,f),v=Dr(this._source.type);v&&this._rasterFadeDuration>0&&!n&&(function(b,P,E,k,D,L,N){const q=Qe(),H=l.av(P);for(const W of P){const K=b.getTileById(W.key);K.fadingDirection!==se.Departing&&K.fadeOpacity!==0||K.resetFadeLogic(),ar(b,K,E,q,k,D,N)||kr(b,K,E,q,L,N)||Tr(K,H,q,N)||K.resetFadeLogic()}})(this._inViewTiles,o,g,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),v?this._cleanUpRasterTiles(g):this._cleanUpVectorTiles(g)}_cleanUpRasterTiles(t){for(const n of this._inViewTiles.getAllIds())t[n]||this._removeTile(n)}_cleanUpVectorTiles(t){for(const n of this._inViewTiles.getAllIds()){const o=this._inViewTiles.getTileById(n);t[n]?o.clearSymbolFadeHold():o.hasSymbolBuckets?o.holdingForSymbolFade()?o.symbolFadeFinished()&&this._removeTile(n):o.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(n)}}_addTerrainIdealTiles(t){const n=[];for(const o of t)if(o.canonical.z>this._source.minzoom){const c=o.scaledTo(o.canonical.z-1);n.push(c);const f=o.scaledTo(Math.max(this._source.minzoom,Math.min(o.canonical.z,5)));n.push(f)}return t.concat(n)}releaseSymbolFadeTiles(){for(const t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){var o;const c=new Set;for(const P of t)this._addTile(P).hasData()||c.add(P);const f=t.reduce(((P,E)=>(P[E.key]=E,P)),{}),g=this._retainLoadedChildren(f,c),v={},b=Math.max(n-mr.maxUnderzooming,this._source.minzoom);for(const P of g){let E=this._inViewTiles.getTileById(P.key),k=E?.wasRequested();for(let D=P.overscaledZ-1;D>=b;--D){const L=P.scaledTo(D);if(v[L.key])break;if(v[L.key]=!0,E=this.getTile(L),!E&&k&&(E=this._addTile(L)),E){const N=E.hasData();if((N||!(!((o=this.map)===null||o===void 0)&&o.cancelPendingTileRequestsWhileZooming)||k)&&(f[L.key]=L),k=E.wasRequested(),N)break}}}return f}_addTile(t){let n=this._inViewTiles.getTileById(t.key);if(n)return n;n=this._outOfViewCache.getAndRemove(t),n&&(n.resetFadeLogic(),this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null));const o=n;return n||(n=new pe(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._inViewTiles.setTile(t.key,n),o||this._source.fire(new l.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){this._clearTileReloadTimer(t);const o=n.getExpiryTimeout();o&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),o))}_clearTileReloadTimer(t){const n=this._timers[t];n&&(clearTimeout(n),delete this._timers[t])}_resetTileReloadTimers(){for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t of this._inViewTiles.getAllIds()){const n=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,n)}}refreshTiles(t){for(const n of this._inViewTiles.getAllIds()){const o=this._inViewTiles.getTileById(n);(this._inViewTiles.isIdRenderable(n)||o.state=="errored")&&t.some((c=>c.equals(o.tileID.canonical)))&&this._reloadTile(n,"expired")}}_removeTile(t){const n=this._inViewTiles.getTileById(t);n&&(n.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._outOfViewCache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(t){t.dataType==="source"&&(t.sourceDataType!=="metadata"?t.sourceDataType==="content"&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,n,o){const c=[],f=this.transform;if(!f)return c;const g=f.getCoveringTilesDetailsProvider().allowWorldCopies(),v=o?f.getCameraQueryGeometry(t):t,b=L=>f.screenPointToMercatorCoordinate(L,this.terrain),P=this.transformBbox(t,b,!g),E=this.transformBbox(v,b,!g),k=this.getIds(),D=l.aa.fromPoints(E);for(let L=0;L<k.length;L++){const N=this._inViewTiles.getTileById(k[L]);if(N.holdingForSymbolFade())continue;const q=g?[N.tileID]:[N.tileID.unwrapTo(-1),N.tileID.unwrapTo(0)],H=Math.pow(2,f.zoom-N.tileID.overscaledZ),W=n*N.queryPadding*l.a5/N.tileSize/H;for(const K of q){const re=D.map((Y=>K.getTilePoint(new l.a9(Y.x,Y.y))));if(re.expandBy(W),re.intersects(zr)){const Y=P.map((oe=>K.getTilePoint(oe))),te=E.map((oe=>K.getTilePoint(oe)));c.push({tile:N,tileID:g?K:K.unwrapTo(0),queryGeometry:Y,cameraQueryGeometry:te,scale:H})}}}return c}transformBbox(t,n,o){let c=t.map(n);if(o){const f=l.aa.fromPoints(t);f.shrinkBy(.001*Math.min(f.width(),f.height()));const g=f.map(n);l.aa.fromPoints(c).covers(g)||(c=c.map((v=>v.x>.5?new l.a9(v.x-1,v.y,v.z):v)))}return c}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map((o=>this._inViewTiles.getTileById(o).tileID));return this.transform&&this.transform.populateCache(n),n}hasTransition(){return!!this._source.hasTransition()||!(!Dr(this._source.type)||!(function(t,n){if(n<=0)return!1;const o=Qe();for(const c of t.getAllTiles())if(c.fadeEndTime>=o)return!0;return!1})(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,n,o){this._state.updateState(t=t||l.ai,n,o)}removeFeatureState(t,n,o){this._state.removeFeatureState(t=t||l.ai,n,o)}getFeatureState(t,n){return this._state.getState(t=t||l.ai,n)}setDependencies(t,n,o){const c=this._inViewTiles.getTileById(t);c&&c.setDependencies(n,o)}reloadTilesForDependencies(t,n){for(const o of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(o).hasDependency(t,n)&&this._reloadTile(o,"reloading");this._outOfViewCache.filter((o=>!o.hasDependency(t,n)))}areTilesLoaded(){for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}}mr.maxUnderzooming=10,mr.maxOverzooming=3;class Be{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let o=1;o<this.points.length;o++)this._distances[o]=this._distances[o-1]+this.points[o].dist(this.points[o-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=l.an(t,0,1);let n=1,o=this._distances[n];const c=t*this.paddedLength+this.padding;for(;o<c&&n<this._distances.length;)o=this._distances[++n];const f=n-1,g=this._distances[f],v=o-g,b=v>0?(c-g)/v:0;return this.points[f].mult(1-b).add(this.points[n].mult(b))}}function ot(d,t){let n=!0;return d==="always"||d!=="never"&&t!=="never"||(n=!1),n}class ht{constructor(t,n,o){const c=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(t/o),this.yCellCount=Math.ceil(n/o);for(let g=0;g<this.xCellCount*this.yCellCount;g++)c.push([]),f.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=n,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,n,o,c,f){this._forEachCell(n,o,c,f,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(o),this.bboxes.push(c),this.bboxes.push(f)}insertCircle(t,n,o,c){this._forEachCell(n-c,o-c,n+c,o+c,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(o),this.circles.push(c)}_insertBoxCell(t,n,o,c,f,g){this.boxCells[f].push(g)}_insertCircleCell(t,n,o,c,f,g){this.circleCells[f].push(g)}_query(t,n,o,c,f,g,v){if(o<0||t>this.width||c<0||n>this.height)return[];const b=[];if(t<=0&&n<=0&&this.width<=o&&this.height<=c){if(f)return[{key:null,x1:t,y1:n,x2:o,y2:c}];for(let P=0;P<this.boxKeys.length;P++)b.push({key:this.boxKeys[P],x1:this.bboxes[4*P],y1:this.bboxes[4*P+1],x2:this.bboxes[4*P+2],y2:this.bboxes[4*P+3]});for(let P=0;P<this.circleKeys.length;P++){const E=this.circles[3*P],k=this.circles[3*P+1],D=this.circles[3*P+2];b.push({key:this.circleKeys[P],x1:E-D,y1:k-D,x2:E+D,y2:k+D})}}else this._forEachCell(t,n,o,c,this._queryCell,b,{hitTest:f,overlapMode:g,seenUids:{box:{},circle:{}}},v);return b}query(t,n,o,c){return this._query(t,n,o,c,!1,null)}hitTest(t,n,o,c,f,g){return this._query(t,n,o,c,!0,f,g).length>0}hitTestCircle(t,n,o,c,f){const g=t-o,v=t+o,b=n-o,P=n+o;if(v<0||g>this.width||P<0||b>this.height)return!1;const E=[];return this._forEachCell(g,b,v,P,this._queryCellCircle,E,{hitTest:!0,overlapMode:c,circle:{x:t,y:n,radius:o},seenUids:{box:{},circle:{}}},f),E.length>0}_queryCell(t,n,o,c,f,g,v,b){const{seenUids:P,hitTest:E,overlapMode:k}=v,D=this.boxCells[f];if(D!==null){const N=this.bboxes;for(const q of D)if(!P.box[q]){P.box[q]=!0;const H=4*q,W=this.boxKeys[q];if(t<=N[H+2]&&n<=N[H+3]&&o>=N[H+0]&&c>=N[H+1]&&(!b||b(W))&&(!E||!ot(k,W.overlapMode))&&(g.push({key:W,x1:N[H],y1:N[H+1],x2:N[H+2],y2:N[H+3]}),E))return!0}}const L=this.circleCells[f];if(L!==null){const N=this.circles;for(const q of L)if(!P.circle[q]){P.circle[q]=!0;const H=3*q,W=this.circleKeys[q];if(this._circleAndRectCollide(N[H],N[H+1],N[H+2],t,n,o,c)&&(!b||b(W))&&(!E||!ot(k,W.overlapMode))){const K=N[H],re=N[H+1],Y=N[H+2];if(g.push({key:W,x1:K-Y,y1:re-Y,x2:K+Y,y2:re+Y}),E)return!0}}}return!1}_queryCellCircle(t,n,o,c,f,g,v,b){const{circle:P,seenUids:E,overlapMode:k}=v,D=this.boxCells[f];if(D!==null){const N=this.bboxes;for(const q of D)if(!E.box[q]){E.box[q]=!0;const H=4*q,W=this.boxKeys[q];if(this._circleAndRectCollide(P.x,P.y,P.radius,N[H+0],N[H+1],N[H+2],N[H+3])&&(!b||b(W))&&!ot(k,W.overlapMode))return g.push(!0),!0}}const L=this.circleCells[f];if(L!==null){const N=this.circles;for(const q of L)if(!E.circle[q]){E.circle[q]=!0;const H=3*q,W=this.circleKeys[q];if(this._circlesCollide(N[H],N[H+1],N[H+2],P.x,P.y,P.radius)&&(!b||b(W))&&!ot(k,W.overlapMode))return g.push(!0),!0}}}_forEachCell(t,n,o,c,f,g,v,b){const P=this._convertToXCellCoord(t),E=this._convertToYCellCoord(n),k=this._convertToXCellCoord(o),D=this._convertToYCellCoord(c);for(let L=P;L<=k;L++)for(let N=E;N<=D;N++)if(f.call(this,t,n,o,c,this.xCellCount*N+L,g,v,b))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,o,c,f,g){const v=c-t,b=f-n,P=o+g;return P*P>v*v+b*b}_circleAndRectCollide(t,n,o,c,f,g,v){const b=(g-c)/2,P=Math.abs(t-(c+b));if(P>b+o)return!1;const E=(v-f)/2,k=Math.abs(n-(f+E));if(k>E+o)return!1;if(P<=b||k<=E)return!0;const D=P-b,L=k-E;return D*D+L*L<=o*o}}function _i(d,t,n){const o=l.N();if(!d){const{vecSouth:k,vecEast:D}=an(t),L=Se();L[0]=D[0],L[1]=D[1],L[2]=k[0],L[3]=k[1],c=L,(E=(g=(f=L)[0])*(P=f[3])-(b=f[2])*(v=f[1]))&&(c[0]=P*(E=1/E),c[1]=-v*E,c[2]=-b*E,c[3]=g*E),o[0]=L[0],o[1]=L[1],o[4]=L[2],o[5]=L[3]}var c,f,g,v,b,P,E;return l.Q(o,o,[1/n,1/n,1]),o}function Jo(d,t,n,o){if(d){const c=l.N();if(!t){const{vecSouth:f,vecEast:g}=an(n);c[0]=g[0],c[1]=g[1],c[4]=f[0],c[5]=f[1]}return l.Q(c,c,[o,o,1]),c}return n.pixelsToClipSpaceMatrix}function an(d){const t=Math.cos(d.rollInRadians),n=Math.sin(d.rollInRadians),o=Math.cos(d.pitchInRadians),c=Math.cos(d.bearingInRadians),f=Math.sin(d.bearingInRadians),g=l.aC();g[0]=-c*o*n-f*t,g[1]=-f*o*n+c*t;const v=l.aD(g);v<1e-9?l.aE(g):l.aF(g,g,1/v);const b=l.aC();b[0]=c*o*t-f*n,b[1]=f*o*t+c*n;const P=l.aD(b);return P<1e-9?l.aE(b):l.aF(b,b,1/P),{vecEast:b,vecSouth:g}}function ct(d,t,n,o){let c;o?(c=[d,t,o(d,t),1],l.aH(c,c,n)):(c=[d,t,0,1],ta(c,c,n));const f=c[3];return{point:new l.P(c[0]/f,c[1]/f),signedDistanceFromCamera:f,isOccluded:!1}}function Js(d,t){return .5+d/t*.5}function Qs(d,t){return d.x>=-t[0]&&d.x<=t[0]&&d.y>=-t[1]&&d.y<=t[1]}function Qo(d,t,n,o,c,f,g,v,b,P,E,k,D){const L=n?d.textSizeData:d.iconSizeData,N=l.ay(L,t.transform.zoom),q=[256/t.width*2+1,256/t.height*2+1],H=n?d.text.dynamicLayoutVertexArray:d.icon.dynamicLayoutVertexArray;H.clear();const W=d.lineVertexArray,K=n?d.text.placedSymbolArray:d.icon.placedSymbolArray,re=t.transform.width/t.transform.height;let Y=!1;for(let te=0;te<K.length;te++){const oe=K.get(te);if(oe.hidden||oe.writingMode===l.az.vertical&&!Y){Bn(oe.numGlyphs,H);continue}Y=!1;const Q=new l.P(oe.anchorX,oe.anchorY),ae={getElevation:D,pitchedLabelPlaneMatrix:o,lineVertexArray:W,pitchWithMap:f,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:Q,unwrappedTileID:b,width:P,height:E,translation:k},ve=gs(oe.anchorX,oe.anchorY,ae);if(!Qs(ve.point,q)){Bn(oe.numGlyphs,H);continue}const ge=Js(t.transform.cameraToCenterDistance,ve.signedDistanceFromCamera),_e=l.aA(L,N,oe),ye=f?_e*t.transform.getPitchedTextCorrection(oe.anchorX,oe.anchorY,b)/ge:_e*ge,Re=ms({projectionContext:ae,pitchedLabelPlaneMatrixInverse:c,symbol:oe,fontSize:ye,flip:!1,keepUpright:g,glyphOffsetArray:d.glyphOffsetArray,dynamicLayoutVertexArray:H,aspectRatio:re,rotateToLine:v});Y=Re.useVertical,(Re.notEnoughRoom||Y||Re.needsFlipping&&ms({projectionContext:ae,pitchedLabelPlaneMatrixInverse:c,symbol:oe,fontSize:ye,flip:!0,keepUpright:g,glyphOffsetArray:d.glyphOffsetArray,dynamicLayoutVertexArray:H,aspectRatio:re,rotateToLine:v}).notEnoughRoom)&&Bn(oe.numGlyphs,H)}n?d.text.dynamicLayoutVertexBuffer.updateData(H):d.icon.dynamicLayoutVertexBuffer.updateData(H)}function fs(d,t,n,o,c,f,g,v){const b=f.glyphStartIndex+f.numGlyphs,P=f.lineStartIndex,E=f.lineStartIndex+f.lineLength,k=t.getoffsetX(f.glyphStartIndex),D=t.getoffsetX(b-1),L=Fi(d*k,n,o,c,f.segment,P,E,v,g);if(!L)return null;const N=Fi(d*D,n,o,c,f.segment,P,E,v,g);return N?v.projectionCache.anyProjectionOccluded?null:{first:L,last:N}:null}function eo(d,t,n,o){return d===l.az.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*o?{useVertical:!0}:(d===l.az.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function ms(d){const{projectionContext:t,pitchedLabelPlaneMatrixInverse:n,symbol:o,fontSize:c,flip:f,keepUpright:g,glyphOffsetArray:v,dynamicLayoutVertexArray:b,aspectRatio:P,rotateToLine:E}=d,k=c/24,D=o.lineOffsetX*k,L=o.lineOffsetY*k;let N;if(o.numGlyphs>1){const q=o.glyphStartIndex+o.numGlyphs,H=o.lineStartIndex,W=o.lineStartIndex+o.lineLength,K=fs(k,v,D,L,f,o,E,t);if(!K)return{notEnoughRoom:!0};const re=ea(K.first.point.x,K.first.point.y,t,n),Y=ea(K.last.point.x,K.last.point.y,t,n);if(g&&!f){const te=eo(o.writingMode,re,Y,P);if(te)return te}N=[K.first];for(let te=o.glyphStartIndex+1;te<q-1;te++){const oe=Fi(k*v.getoffsetX(te),D,L,f,o.segment,H,W,t,E);if(!oe)return{notEnoughRoom:!0};N.push(oe)}N.push(K.last)}else{if(g&&!f){const H=Ct(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,W=o.lineStartIndex+o.segment+1,K=new l.P(t.lineVertexArray.getx(W),t.lineVertexArray.gety(W)),re=Ct(K.x,K.y,t),Y=re.signedDistanceFromCamera>0?re.point:to(t.tileAnchorPoint,K,H,1,t),te=ea(H.x,H.y,t,n),oe=ea(Y.x,Y.y,t,n),Q=eo(o.writingMode,te,oe,P);if(Q)return Q}const q=Fi(k*v.getoffsetX(o.glyphStartIndex),D,L,f,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,t,E);if(!q||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};N=[q]}for(const q of N)l.aG(b,q.point,q.angle);return{}}function to(d,t,n,o,c){const f=d.add(d.sub(t)._unit()),g=Ct(f.x,f.y,c).point,v=n.sub(g);return n.add(v._mult(o/v.mag()))}function ti(d,t,n){const o=t.projectionCache;if(o.projections[d])return o.projections[d];const c=new l.P(t.lineVertexArray.getx(d),t.lineVertexArray.gety(d)),f=Ct(c.x,c.y,t);if(f.signedDistanceFromCamera>0)return o.projections[d]=f.point,o.anyProjectionOccluded=o.anyProjectionOccluded||f.isOccluded,f.point;const g=d-n.direction;return to(n.distanceFromAnchor===0?t.tileAnchorPoint:new l.P(t.lineVertexArray.getx(g),t.lineVertexArray.gety(g)),c,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,t)}function Ct(d,t,n){const o=d+n.translation[0],c=t+n.translation[1];let f;return n.pitchWithMap?(f=ct(o,c,n.pitchedLabelPlaneMatrix,n.getElevation),f.isOccluded=!1):(f=n.transform.projectTileCoordinates(o,c,n.unwrappedTileID,n.getElevation),f.point.x=(.5*f.point.x+.5)*n.width,f.point.y=(.5*-f.point.y+.5)*n.height),f}function ea(d,t,n,o){if(n.pitchWithMap){const c=[d,t,0,1];return l.aH(c,c,o),n.transform.projectTileCoordinates(c[0]/c[3],c[1]/c[3],n.unwrappedTileID,n.getElevation).point}return{x:d/n.width*2-1,y:1-t/n.height*2}}function gs(d,t,n){return n.transform.projectTileCoordinates(d,t,n.unwrappedTileID,n.getElevation)}function ro(d,t,n){return d._unit()._perp()._mult(t*n)}function On(d,t,n,o,c,f,g,v,b){if(v.projectionCache.offsets[d])return v.projectionCache.offsets[d];const P=n.add(t);if(d+b.direction<o||d+b.direction>=c)return v.projectionCache.offsets[d]=P,P;const E=ti(d+b.direction,v,b),k=ro(E.sub(n),g,b.direction),D=n.add(k),L=E.add(k);return v.projectionCache.offsets[d]=l.aI(f,P,D,L)||P,v.projectionCache.offsets[d]}function Fi(d,t,n,o,c,f,g,v,b){const P=o?d-t:d+t;let E=P>0?1:-1,k=0;o&&(E*=-1,k=Math.PI),E<0&&(k+=Math.PI);let D,L=E>0?f+c:f+c+1;v.projectionCache.cachedAnchorPoint?D=v.projectionCache.cachedAnchorPoint:(D=Ct(v.tileAnchorPoint.x,v.tileAnchorPoint.y,v).point,v.projectionCache.cachedAnchorPoint=D);let N,q,H=D,W=D,K=0,re=0;const Y=Math.abs(P),te=[];let oe;for(;K+re<=Y;){if(L+=E,L<f||L>=g)return null;K+=re,W=H,q=N;const ve={absOffsetX:Y,direction:E,distanceFromAnchor:K,previousVertex:W};if(H=ti(L,v,ve),n===0)te.push(W),oe=H.sub(W);else{let ge;const _e=H.sub(W);ge=_e.mag()===0?ro(ti(L+E,v,ve).sub(H),n,E):ro(_e,n,E),q||(q=W.add(ge)),N=On(L,ge,H,f,g,q,n,v,ve),te.push(q),oe=N.sub(q)}re=oe.mag()}const Q=oe._mult((Y-K)/re)._add(q||W),ae=k+Math.atan2(H.y-W.y,H.x-W.x);return te.push(Q),{point:Q,angle:b?ae:0,path:te}}const Nc=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Bn(d,t){for(let n=0;n<d;n++){const o=t.length;t.resize(o+4),t.float32.set(Nc,3*o)}}function ta(d,t,n){const o=t[0],c=t[1];return d[0]=n[0]*o+n[4]*c+n[12],d[1]=n[1]*o+n[5]*c+n[13],d[3]=n[3]*o+n[7]*c+n[15],d}const lr=100;class Vc{constructor(t,n=new ht(t.width+200,t.height+200,25),o=new ht(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=o,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+lr,this.screenBottomBoundary=t.height+lr,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,o,c,f,g,v,b,P,E,k,D){const L=this.projectAndGetPerspectiveRatio(t.anchorPointX+b[0],t.anchorPointY+b[1],f,E,D),N=o*L.perspectiveRatio;let q;if(g||v)q=this._projectCollisionBox(t,N,c,f,g,v,b,L,E,k,D);else{const oe=L.x+(k?k.x*N:0),Q=L.y+(k?k.y*N:0);q={allPointsOccluded:!1,box:[oe+t.x1*N,Q+t.y1*N,oe+t.x2*N,Q+t.y2*N]}}const[H,W,K,re]=q.box,Y=g?q.allPointsOccluded:L.isOccluded;let te=Y;return te||(te=L.perspectiveRatio<this.perspectiveRatioCutoff),te||(te=!this.isInsideGrid(H,W,K,re)),te||n!=="always"&&this.grid.hitTest(H,W,K,re,n,P)?{box:[H,W,K,re],placeable:!1,offscreen:!1,occluded:Y}:{box:[H,W,K,re],placeable:!0,offscreen:this.isOffscreen(H,W,K,re),occluded:Y}}placeCollisionCircles(t,n,o,c,f,g,v,b,P,E,k,D,L,N){const q=[],H=new l.P(n.anchorX,n.anchorY),W=this.getPerspectiveRatio(H.x,H.y,g,N),K=(P?f*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,g)/W:f*W)/l.aM,re={getElevation:N,pitchedLabelPlaneMatrix:v,lineVertexArray:o,pitchWithMap:P,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:H,unwrappedTileID:g,width:this.transform.width,height:this.transform.height,translation:L},Y=fs(K,c,n.lineOffsetX*K,n.lineOffsetY*K,!1,n,!1,re);let te=!1,oe=!1,Q=!0;if(Y){const ae=.5*k*W+D,ve=new l.P(-100,-100),ge=new l.P(this.screenRightBoundary,this.screenBottomBoundary),_e=new Be,ye=Y.first,Re=Y.last;let Fe=[];for(let st=ye.path.length-1;st>=1;st--)Fe.push(ye.path[st]);for(let st=1;st<Re.path.length;st++)Fe.push(Re.path[st]);const Ee=2.5*ae;if(P){const st=this.projectPathToScreenSpace(Fe,re);Fe=st.some((Mt=>Mt.signedDistanceFromCamera<=0))?[]:st.map((Mt=>Mt.point))}let je=[];if(Fe.length>0){const st=Fe[0].clone(),Mt=Fe[0].clone();for(let qt=1;qt<Fe.length;qt++)st.x=Math.min(st.x,Fe[qt].x),st.y=Math.min(st.y,Fe[qt].y),Mt.x=Math.max(Mt.x,Fe[qt].x),Mt.y=Math.max(Mt.y,Fe[qt].y);je=st.x>=ve.x&&Mt.x<=ge.x&&st.y>=ve.y&&Mt.y<=ge.y?[Fe]:Mt.x<ve.x||st.x>ge.x||Mt.y<ve.y||st.y>ge.y?[]:l.aJ([Fe],ve.x,ve.y,ge.x,ge.y)}for(const st of je){_e.reset(st,.25*ae);let Mt=0;Mt=_e.length<=.5*ae?1:Math.ceil(_e.paddedLength/Ee)+1;for(let qt=0;qt<Mt;qt++){const Ot=qt/Math.max(Mt-1,1),Xt=_e.lerp(Ot),Bt=Xt.x+lr,ur=Xt.y+lr;q.push(Bt,ur,ae,0);const Yt=Bt-ae,jr=ur-ae,Sr=Bt+ae,vr=ur+ae;if(Q=Q&&this.isOffscreen(Yt,jr,Sr,vr),oe=oe||this.isInsideGrid(Yt,jr,Sr,vr),t!=="always"&&this.grid.hitTestCircle(Bt,ur,ae,t,E)&&(te=!0,!b))return{circles:[],offscreen:!1,collisionDetected:te}}}}return{circles:!b&&te||!oe||W<this.perspectiveRatioCutoff?[]:q,offscreen:Q,collisionDetected:te}}projectPathToScreenSpace(t,n){const o=(function(c,f){const g=l.N();return l.aB(g,f.pitchedLabelPlaneMatrix),c.map((v=>{const b=ct(v.x,v.y,g,f.getElevation),P=f.transform.projectTileCoordinates(b.point.x,b.point.y,f.unwrappedTileID,f.getElevation);return P.point.x=(.5*P.point.x+.5)*f.width,P.point.y=(.5*-P.point.y+.5)*f.height,P}))})(t,n);return(function(c){let f=0,g=0,v=0,b=0;for(let P=0;P<c.length;P++)c[P].isOccluded?(v=P+1,b=0):(b++,b>g&&(g=b,f=v));return c.slice(f,f+g)})(o)}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],o=new l.aa;for(const k of t){const D=new l.P(k.x+lr,k.y+lr);o.extend(D),n.push(D)}const{minX:c,minY:f,maxX:g,maxY:v}=o,b=this.grid.query(c,f,g,v).concat(this.ignoredGrid.query(c,f,g,v)),P={},E={};for(const k of b){const D=k.key;if(P[D.bucketInstanceId]===void 0&&(P[D.bucketInstanceId]={}),P[D.bucketInstanceId][D.featureIndex])continue;const L=[new l.P(k.x1,k.y1),new l.P(k.x2,k.y1),new l.P(k.x2,k.y2),new l.P(k.x1,k.y2)];l.aK(n,L)&&(P[D.bucketInstanceId][D.featureIndex]=!0,E[D.bucketInstanceId]===void 0&&(E[D.bucketInstanceId]=[]),E[D.bucketInstanceId].push(D.featureIndex))}return E}insertCollisionBox(t,n,o,c,f,g){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:f,collisionGroupID:g,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,o,c,f,g){const v=o?this.ignoredGrid:this.grid,b={bucketInstanceId:c,featureIndex:f,collisionGroupID:g,overlapMode:n};for(let P=0;P<t.length;P+=4)v.insertCircle(b,t[P],t[P+1],t[P+2])}projectAndGetPerspectiveRatio(t,n,o,c,f){if(f){let g;c?(g=[t,n,c(t,n),1],l.aH(g,g,f)):(g=[t,n,0,1],ta(g,g,f));const v=g[3];return{x:(g[0]/v+1)/2*this.transform.width+lr,y:(-g[1]/v+1)/2*this.transform.height+lr,perspectiveRatio:.5+this.transform.cameraToCenterDistance/v*.5,isOccluded:!1,signedDistanceFromCamera:v}}{const g=this.transform.projectTileCoordinates(t,n,o,c);return{x:(g.point.x+1)/2*this.transform.width+lr,y:(1-g.point.y)/2*this.transform.height+lr,perspectiveRatio:.5+this.transform.cameraToCenterDistance/g.signedDistanceFromCamera*.5,isOccluded:g.isOccluded,signedDistanceFromCamera:g.signedDistanceFromCamera}}}getPerspectiveRatio(t,n,o,c){const f=this.transform.projectTileCoordinates(t,n,o,c);return .5+this.transform.cameraToCenterDistance/f.signedDistanceFromCamera*.5}isOffscreen(t,n,o,c){return o<lr||t>=this.screenRightBoundary||c<lr||n>this.screenBottomBoundary}isInsideGrid(t,n,o,c){return o>=0&&t<this.gridRightBoundary&&c>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=l.ar([]);return l.O(t,t,[-100,-100,0]),t}_projectCollisionBox(t,n,o,c,f,g,v,b,P,E,k){let D=1,L=0,N=0,q=1;const H=t.anchorPointX+v[0],W=t.anchorPointY+v[1];if(g&&!f){const Fe=this.projectAndGetPerspectiveRatio(H+1,W,c,P,k),Ee=Fe.x-b.x,je=Math.atan((Fe.y-b.y)/Ee)+(Ee<0?Math.PI:0),st=Math.sin(je),Mt=Math.cos(je);D=Mt,L=st,N=-st,q=Mt}else if(!g&&f){const Fe=an(this.transform);D=Fe.vecEast[0],L=Fe.vecEast[1],N=Fe.vecSouth[0],q=Fe.vecSouth[1]}let K=b.x,re=b.y,Y=n;f&&(K=H,re=W,Y=Math.pow(2,-(this.transform.zoom-o.overscaledZ)),Y*=this.transform.getPitchedTextCorrection(H,W,c),E||(Y*=l.an(.5+b.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),E&&(K+=D*E.x*Y+N*E.y*Y,re+=L*E.x*Y+q*E.y*Y);const te=t.x1*Y,oe=t.x2*Y,Q=(te+oe)/2,ae=t.y1*Y,ve=t.y2*Y,ge=(ae+ve)/2,_e=[{offsetX:te,offsetY:ae},{offsetX:Q,offsetY:ae},{offsetX:oe,offsetY:ae},{offsetX:oe,offsetY:ge},{offsetX:oe,offsetY:ve},{offsetX:Q,offsetY:ve},{offsetX:te,offsetY:ve},{offsetX:te,offsetY:ge}];let ye=[];for(const{offsetX:Fe,offsetY:Ee}of _e)ye.push(new l.P(K+D*Fe+N*Ee,re+L*Fe+q*Ee));let Re=!1;if(f){const Fe=ye.map((Ee=>this.projectAndGetPerspectiveRatio(Ee.x,Ee.y,c,P,k)));Re=Fe.some((Ee=>!Ee.isOccluded)),ye=Fe.map((Ee=>new l.P(Ee.x,Ee.y)))}else Re=!0;return{box:l.aL(ye),allPointsOccluded:!Re}}}class $c{constructor(t,n,o,c){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):c&&o?1:0,this.placed=o}isHidden(){return this.opacity===0&&!this.placed}}class io{constructor(t,n,o,c,f){this.text=new $c(t?t.text:null,n,o,f),this.icon=new $c(t?t.icon:null,n,c,f)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Zc{constructor(t,n,o){this.text=t,this.icon=n,this.skipFade=o}}class Uc{constructor(t,n,o,c,f){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=o,this.bucketIndex=c,this.tileID=f}}class Gc{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:o=>o.collisionGroupID===n}}return this.collisionGroups[t]}}function ra(d,t,n,o,c){const{horizontalAlign:f,verticalAlign:g}=l.aS(d);return new l.P(-(f-.5)*t+o[0]*c,-(g-.5)*n+o[1]*c)}class ul{constructor(t,n,o,c,f){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new Vc(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Gc(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=f,f&&(f.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const n=this.terrain;return n?(o,c)=>n.getElevation(t,o,c):null}getBucketParts(t,n,o,c){const f=o.getBucket(n),g=o.latestFeatureIndex;if(!f||!g||n.id!==f.layerIds[0])return;const v=o.collisionBoxArray,b=f.layers[0].layout,P=f.layers[0].paint,E=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),k=o.tileSize/l.a5,D=o.tileID.toUnwrapped(),L=b.get("text-rotation-alignment")==="map",N=l.aN(o,1,this.transform.zoom),q=l.aO(this.collisionIndex.transform,o,P.get("text-translate"),P.get("text-translate-anchor")),H=l.aO(this.collisionIndex.transform,o,P.get("icon-translate"),P.get("icon-translate-anchor")),W=_i(L,this.transform,N);this.retainedQueryData[f.bucketInstanceId]=new Uc(f.bucketInstanceId,g,f.sourceLayerIndex,f.index,o.tileID);const K={bucket:f,layout:b,translationText:q,translationIcon:H,unwrappedTileID:D,pitchedLabelPlaneMatrix:W,scale:E,textPixelRatio:k,holdingForFade:o.holdingForSymbolFade(),collisionBoxArray:v,partiallyEvaluatedTextSize:l.ay(f.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(f.sourceID)};if(c)for(const re of f.sortKeyRanges){const{sortKey:Y,symbolInstanceStart:te,symbolInstanceEnd:oe}=re;t.push({sortKey:Y,symbolInstanceStart:te,symbolInstanceEnd:oe,parameters:K})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:f.symbolInstances.length,parameters:K})}attemptAnchorPlacement(t,n,o,c,f,g,v,b,P,E,k,D,L,N,q,H,W,K,re,Y){const te=l.aP[t.textAnchor],oe=[t.textOffset0,t.textOffset1],Q=ra(te,o,c,oe,f),ae=this.collisionIndex.placeCollisionBox(n,D,b,P,E,v,g,H,k.predicate,re,Q,Y);if((!K||this.collisionIndex.placeCollisionBox(K,D,b,P,E,v,g,W,k.predicate,re,Q,Y).placeable)&&ae.placeable){let ve;if(this.prevPlacement&&this.prevPlacement.variableOffsets[L.crossTileID]&&this.prevPlacement.placements[L.crossTileID]&&this.prevPlacement.placements[L.crossTileID].text&&(ve=this.prevPlacement.variableOffsets[L.crossTileID].anchor),L.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[L.crossTileID]={textOffset:oe,width:o,height:c,anchor:te,textBoxScale:f,prevAnchor:ve},this.markUsedJustification(N,te,L,q),N.allowVerticalPlacement&&(this.markUsedOrientation(N,q,L),this.placedOrientations[L.crossTileID]=q),{shift:Q,placedGlyphBoxes:ae}}}placeLayerBucketPart(t,n,o){const{bucket:c,layout:f,translationText:g,translationIcon:v,unwrappedTileID:b,pitchedLabelPlaneMatrix:P,textPixelRatio:E,holdingForFade:k,collisionBoxArray:D,partiallyEvaluatedTextSize:L,collisionGroup:N}=t.parameters,q=f.get("text-optional"),H=f.get("icon-optional"),W=l.aQ(f,"text-overlap","text-allow-overlap"),K=W==="always",re=l.aQ(f,"icon-overlap","icon-allow-overlap"),Y=re==="always",te=f.get("text-rotation-alignment")==="map",oe=f.get("text-pitch-alignment")==="map",Q=f.get("icon-text-fit")!=="none",ae=f.get("symbol-z-order")==="viewport-y",ve=K&&(Y||!c.hasIconData()||H),ge=Y&&(K||!c.hasTextData()||q);!c.collisionArrays&&D&&c.deserializeCollisionBoxes(D);const _e=this.retainedQueryData[c.bucketInstanceId].tileID,ye=this._getTerrainElevationFunc(_e),Re=this.transform.getFastPathSimpleProjectionMatrix(_e),Fe=(Ee,je,st)=>{var Mt,qt;if(n[Ee.crossTileID])return;if(k)return void(this.placements[Ee.crossTileID]=new Zc(!1,!1,!1));let Ot=!1,Xt=!1,Bt=!0,ur=null,Yt={box:null,placeable:!1,offscreen:null,occluded:!1},jr={placeable:!1},Sr=null,vr=null,qr=null,Mn=0,un=0,en=0;je.textFeatureIndex?Mn=je.textFeatureIndex:Ee.useRuntimeCollisionCircles&&(Mn=Ee.featureIndex),je.verticalTextFeatureIndex&&(un=je.verticalTextFeatureIndex);const hi=je.textBox;if(hi){const Ci=Ut=>{let jt=l.az.horizontal;if(c.allowVerticalPlacement&&!Ut&&this.prevPlacement){const Rr=this.prevPlacement.placedOrientations[Ee.crossTileID];Rr&&(this.placedOrientations[Ee.crossTileID]=Rr,jt=Rr,this.markUsedOrientation(c,jt,Ee))}return jt},tn=(Ut,jt)=>{if(c.allowVerticalPlacement&&Ee.numVerticalGlyphVertices>0&&je.verticalTextBox){for(const Rr of c.writingModes)if(Rr===l.az.vertical?(Yt=jt(),jr=Yt):Yt=Ut(),Yt&&Yt.placeable)break}else Yt=Ut()},Vi=Ee.textAnchorOffsetStartIndex,$i=Ee.textAnchorOffsetEndIndex;if($i===Vi){const Ut=(jt,Rr)=>{const Fr=this.collisionIndex.placeCollisionBox(jt,W,E,_e,b,oe,te,g,N.predicate,ye,void 0,Re);return Fr&&Fr.placeable&&(this.markUsedOrientation(c,Rr,Ee),this.placedOrientations[Ee.crossTileID]=Rr),Fr};tn((()=>Ut(hi,l.az.horizontal)),(()=>{const jt=je.verticalTextBox;return c.allowVerticalPlacement&&Ee.numVerticalGlyphVertices>0&&jt?Ut(jt,l.az.vertical):{box:null,offscreen:null}})),Ci(Yt&&Yt.placeable)}else{let Ut=l.aP[(qt=(Mt=this.prevPlacement)===null||Mt===void 0?void 0:Mt.variableOffsets[Ee.crossTileID])===null||qt===void 0?void 0:qt.anchor];const jt=(Fr,Nu,Vu)=>{const rs=Fr.x2-Fr.x1,ed=Fr.y2-Fr.y1,$u=Ee.textBoxScale,nc=Q&&re==="never"?Nu:null;let En=null,Cn=W==="never"?1:2,An="never";Ut&&Cn++;for(let sc=0;sc<Cn;sc++){for(let oc=Vi;oc<$i;oc++){const ja=c.textAnchorOffsets.get(oc);if(Ut&&ja.textAnchor!==Ut)continue;const Na=this.attemptAnchorPlacement(ja,Fr,rs,ed,$u,te,oe,E,_e,b,N,An,Ee,c,Vu,g,v,nc,ye);if(Na&&(En=Na.placedGlyphBoxes,En&&En.placeable))return Ot=!0,ur=Na.shift,En}Ut?Ut=null:An=W}return o&&!En&&(En={box:this.collisionIndex.placeCollisionBox(hi,"always",E,_e,b,oe,te,g,N.predicate,ye,void 0,Re).box,offscreen:!1,placeable:!1,occluded:!1}),En};tn((()=>jt(hi,je.iconBox,l.az.horizontal)),(()=>{const Fr=je.verticalTextBox;return c.allowVerticalPlacement&&(!Yt||!Yt.placeable)&&Ee.numVerticalGlyphVertices>0&&Fr?jt(Fr,je.verticalIconBox,l.az.vertical):{box:null,occluded:!0,offscreen:null}})),Yt&&(Ot=Yt.placeable,Bt=Yt.offscreen);const Rr=Ci(Yt&&Yt.placeable);if(!Ot&&this.prevPlacement){const Fr=this.prevPlacement.variableOffsets[Ee.crossTileID];Fr&&(this.variableOffsets[Ee.crossTileID]=Fr,this.markUsedJustification(c,Fr.anchor,Ee,Rr))}}}if(Sr=Yt,Ot=Sr&&Sr.placeable,Bt=Sr&&Sr.offscreen,Ee.useRuntimeCollisionCircles&&Ee.centerJustifiedTextSymbolIndex>=0){const Ci=c.text.placedSymbolArray.get(Ee.centerJustifiedTextSymbolIndex),tn=l.aA(c.textSizeData,L,Ci),Vi=f.get("text-padding");vr=this.collisionIndex.placeCollisionCircles(W,Ci,c.lineVertexArray,c.glyphOffsetArray,tn,b,P,o,oe,N.predicate,Ee.collisionCircleDiameter,Vi,g,ye),vr.circles.length&&vr.collisionDetected&&!o&&l.w("Collisions detected, but collision boxes are not shown"),Ot=K||vr.circles.length>0&&!vr.collisionDetected,Bt=Bt&&vr.offscreen}if(je.iconFeatureIndex&&(en=je.iconFeatureIndex),je.iconBox){const Ci=tn=>this.collisionIndex.placeCollisionBox(tn,re,E,_e,b,oe,te,v,N.predicate,ye,Q&&ur?ur:void 0,Re);jr&&jr.placeable&&je.verticalIconBox?(qr=Ci(je.verticalIconBox),Xt=qr.placeable):(qr=Ci(je.iconBox),Xt=qr.placeable),Bt=Bt&&qr.offscreen}const es=q||Ee.numHorizontalGlyphVertices===0&&Ee.numVerticalGlyphVertices===0,Bo=H||Ee.numIconVertices===0;es||Bo?Bo?es||(Xt=Xt&&Ot):Ot=Xt&&Ot:Xt=Ot=Xt&&Ot;const ts=Xt&&qr.placeable;if(Ot&&Sr.placeable&&this.collisionIndex.insertCollisionBox(Sr.box,W,f.get("text-ignore-placement"),c.bucketInstanceId,jr&&jr.placeable&&un?un:Mn,N.ID),ts&&this.collisionIndex.insertCollisionBox(qr.box,re,f.get("icon-ignore-placement"),c.bucketInstanceId,en,N.ID),vr&&Ot&&this.collisionIndex.insertCollisionCircles(vr.circles,W,f.get("text-ignore-placement"),c.bucketInstanceId,Mn,N.ID),o&&this.storeCollisionData(c.bucketInstanceId,st,je,Sr,qr,vr),Ee.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(c.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[Ee.crossTileID]=new Zc((Ot||ve)&&!Sr?.occluded,(Xt||ge)&&!qr?.occluded,Bt||c.justReloaded),n[Ee.crossTileID]=!0};if(ae){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const Ee=c.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let je=Ee.length-1;je>=0;--je){const st=Ee[je];Fe(c.symbolInstances.get(st),c.collisionArrays[st],st)}}else for(let Ee=t.symbolInstanceStart;Ee<t.symbolInstanceEnd;Ee++)Fe(c.symbolInstances.get(Ee),c.collisionArrays[Ee],Ee);c.justReloaded=!1}storeCollisionData(t,n,o,c,f,g){if(o.textBox||o.iconBox){let v,b;this.collisionBoxArrays.has(t)?v=this.collisionBoxArrays.get(t):(v=new Map,this.collisionBoxArrays.set(t,v)),v.has(n)?b=v.get(n):(b={text:null,icon:null},v.set(n,b)),o.textBox&&(b.text=c.box),o.iconBox&&(b.icon=f.box)}if(g){let v=this.collisionCircleArrays[t];v===void 0&&(v=this.collisionCircleArrays[t]=[]);for(let b=0;b<g.circles.length;b+=4)v.push(g.circles[b+0]-lr),v.push(g.circles[b+1]-lr),v.push(g.circles[b+2]),v.push(g.collisionDetected?1:0)}}markUsedJustification(t,n,o,c){let f;f=c===l.az.vertical?o.verticalPlacedTextSymbolIndex:{left:o.leftJustifiedTextSymbolIndex,center:o.centerJustifiedTextSymbolIndex,right:o.rightJustifiedTextSymbolIndex}[l.aR(n)];const g=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,o.verticalPlacedTextSymbolIndex];for(const v of g)v>=0&&(t.text.placedSymbolArray.get(v).crossTileID=f>=0&&v!==f?0:o.crossTileID)}markUsedOrientation(t,n,o){const c=n===l.az.horizontal||n===l.az.horizontalOnly?n:0,f=n===l.az.vertical?n:0,g=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const v of g)t.text.placedSymbolArray.get(v).placedOrientation=c;o.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=f)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let o=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const c=n?n.symbolFadeChange(t):1,f=n?n.opacities:{},g=n?n.variableOffsets:{},v=n?n.placedOrientations:{};for(const b in this.placements){const P=this.placements[b],E=f[b];E?(this.opacities[b]=new io(E,c,P.text,P.icon),o=o||P.text!==E.text.placed||P.icon!==E.icon.placed):(this.opacities[b]=new io(null,c,P.text,P.icon,P.skipFade),o=o||P.text||P.icon)}for(const b in f){const P=f[b];if(!this.opacities[b]){const E=new io(P,c,!1,!1);E.isHidden()||(this.opacities[b]=E,o=o||P.text.placed||P.icon.placed)}}for(const b in g)this.variableOffsets[b]||!this.opacities[b]||this.opacities[b].isHidden()||(this.variableOffsets[b]=g[b]);for(const b in v)this.placedOrientations[b]||!this.opacities[b]||this.opacities[b].isHidden()||(this.placedOrientations[b]=v[b]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");o?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const o={};for(const c of n){const f=c.getBucket(t);f&&c.latestFeatureIndex&&t.id===f.layerIds[0]&&this.updateBucketOpacities(f,c.tileID,o,c.collisionBoxArray)}}updateBucketOpacities(t,n,o,c){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const f=t.layers[0],g=f.layout,v=new io(null,0,!1,!1,!0),b=g.get("text-allow-overlap"),P=g.get("icon-allow-overlap"),E=f._unevaluatedLayout.hasValue("text-variable-anchor")||f._unevaluatedLayout.hasValue("text-variable-anchor-offset"),k=g.get("text-rotation-alignment")==="map",D=g.get("text-pitch-alignment")==="map",L=g.get("icon-text-fit")!=="none",N=new io(null,0,b&&(P||!t.hasIconData()||g.get("icon-optional")),P&&(b||!t.hasTextData()||g.get("text-optional")),!0);!t.collisionArrays&&c&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(c);const q=(W,K,re)=>{for(let Y=0;Y<K/4;Y++)W.opacityVertexArray.emplaceBack(re);W.hasVisibleVertices=W.hasVisibleVertices||re!==so},H=this.collisionBoxArrays.get(t.bucketInstanceId);for(let W=0;W<t.symbolInstances.length;W++){const K=t.symbolInstances.get(W),{numHorizontalGlyphVertices:re,numVerticalGlyphVertices:Y,crossTileID:te}=K;let oe=this.opacities[te];o[te]?oe=v:oe||(oe=N,this.opacities[te]=oe),o[te]=!0;const Q=K.numIconVertices>0,ae=this.placedOrientations[K.crossTileID],ve=ae===l.az.vertical,ge=ae===l.az.horizontal||ae===l.az.horizontalOnly;if(re>0||Y>0){const ye=fl(oe.text);q(t.text,re,ve?so:ye),q(t.text,Y,ge?so:ye);const Re=oe.text.isHidden();[K.rightJustifiedTextSymbolIndex,K.centerJustifiedTextSymbolIndex,K.leftJustifiedTextSymbolIndex].forEach((je=>{je>=0&&(t.text.placedSymbolArray.get(je).hidden=Re||ve?1:0)})),K.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(K.verticalPlacedTextSymbolIndex).hidden=Re||ge?1:0);const Fe=this.variableOffsets[K.crossTileID];Fe&&this.markUsedJustification(t,Fe.anchor,K,ae);const Ee=this.placedOrientations[K.crossTileID];Ee&&(this.markUsedJustification(t,"left",K,Ee),this.markUsedOrientation(t,Ee,K))}if(Q){const ye=fl(oe.icon),Re=!(L&&K.verticalPlacedIconSymbolIndex&&ve);K.placedIconSymbolIndex>=0&&(q(t.icon,K.numIconVertices,Re?ye:so),t.icon.placedSymbolArray.get(K.placedIconSymbolIndex).hidden=oe.icon.isHidden()),K.verticalPlacedIconSymbolIndex>=0&&(q(t.icon,K.numVerticalIconVertices,Re?so:ye),t.icon.placedSymbolArray.get(K.verticalPlacedIconSymbolIndex).hidden=oe.icon.isHidden())}const _e=H&&H.has(W)?H.get(W):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const ye=t.collisionArrays[W];if(ye){let Re=new l.P(0,0);if(ye.textBox||ye.verticalTextBox){let Fe=!0;if(E){const Ee=this.variableOffsets[te];Ee?(Re=ra(Ee.anchor,Ee.width,Ee.height,Ee.textOffset,Ee.textBoxScale),k&&Re._rotate(D?-this.transform.bearingInRadians:this.transform.bearingInRadians)):Fe=!1}if(ye.textBox||ye.verticalTextBox){let Ee;ye.textBox&&(Ee=ve),ye.verticalTextBox&&(Ee=ge),hl(t.textCollisionBox.collisionVertexArray,oe.text.placed,!Fe||Ee,_e.text,Re.x,Re.y)}}if(ye.iconBox||ye.verticalIconBox){const Fe=!!(!ge&&ye.verticalIconBox);let Ee;ye.iconBox&&(Ee=Fe),ye.verticalIconBox&&(Ee=!Fe),hl(t.iconCollisionBox.collisionVertexArray,oe.icon.placed,Ee,_e.icon,L?Re.x:0,L?Re.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,n){const o=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*o>t}setStale(){this.stale=!0}}function hl(d,t,n,o,c,f){o&&o.length!==0||(o=[0,0,0,0]);const g=o[0]-lr,v=o[1]-lr,b=o[2]-lr,P=o[3]-lr;d.emplaceBack(t?1:0,n?1:0,c||0,f||0,g,v),d.emplaceBack(t?1:0,n?1:0,c||0,f||0,b,v),d.emplaceBack(t?1:0,n?1:0,c||0,f||0,b,P),d.emplaceBack(t?1:0,n?1:0,c||0,f||0,g,P)}const dl=Math.pow(2,25),pl=Math.pow(2,24),Ch=Math.pow(2,17),no=Math.pow(2,16),ia=Math.pow(2,9),qc=Math.pow(2,8),_s=Math.pow(2,1);function fl(d){if(d.opacity===0&&!d.placed)return 0;if(d.opacity===1&&d.placed)return 4294967295;const t=d.placed?1:0,n=Math.floor(127*d.opacity);return n*dl+t*pl+n*Ch+t*no+n*ia+t*qc+n*_s+t}const so=0;class yn{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,o,c,f){const g=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(g,c,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,f())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort(((v,b)=>v.sortKey-b.sortKey)));this._currentPartIndex<g.length;)if(n.placeLayerBucketPart(g[this._currentPartIndex],this._seenCrossTileIDs,o),this._currentPartIndex++,f())return!0;return!1}}class ys{constructor(t,n,o,c,f,g,v,b){this.placement=new ul(t,n,g,v,b),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=c,this._showCollisionBoxes=f,this._done=!1}isDone(){return this._done}continuePlacement(t,n,o){const c=Qe(),f=()=>!this._forceFullPlacement&&Qe()-c>2;for(;this._currentPlacementIndex>=0;){const g=n[t[this._currentPlacementIndex]],v=this.placement.collisionIndex.transform.zoom;if(g.type==="symbol"&&(!g.minzoom||g.minzoom<=v)&&(!g.maxzoom||g.maxzoom>v)){if(this._inProgressLayer||(this._inProgressLayer=new yn(g)),this._inProgressLayer.continuePlacement(o[g.source],this.placement,this._showCollisionBoxes,g,f))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const dt=512/l.a5/2;class ml{constructor(t,n,o){this.tileID=t,this.bucketInstanceId=o,this._symbolsByKey={};const c=new Map;for(let f=0;f<n.length;f++){const g=n.get(f),v=g.key,b=c.get(v);b?b.push(g):c.set(v,[g])}for(const[f,g]of c){const v={positions:g.map((b=>({x:Math.floor(b.anchorX*dt),y:Math.floor(b.anchorY*dt)}))),crossTileIDs:g.map((b=>b.crossTileID))};if(v.positions.length>128){const b=new l.aT(v.positions.length,16,Uint16Array);for(const{x:P,y:E}of v.positions)b.add(P,E);b.finish(),delete v.positions,v.index=b}this._symbolsByKey[f]=v}}getScaledCoordinates(t,n){const{x:o,y:c,z:f}=this.tileID.canonical,{x:g,y:v,z:b}=n.canonical,P=dt/Math.pow(2,b-f),E=(v*l.a5+t.anchorY)*P,k=c*l.a5*dt;return{x:Math.floor((g*l.a5+t.anchorX)*P-o*l.a5*dt),y:Math.floor(E-k)}}findMatches(t,n,o){const c=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let f=0;f<t.length;f++){const g=t.get(f);if(g.crossTileID)continue;const v=this._symbolsByKey[g.key];if(!v)continue;const b=this.getScaledCoordinates(g,n);if(v.index){const P=v.index.range(b.x-c,b.y-c,b.x+c,b.y+c).sort();for(const E of P){const k=v.crossTileIDs[E];if(!o[k]){o[k]=!0,g.crossTileID=k;break}}}else if(v.positions)for(let P=0;P<v.positions.length;P++){const E=v.positions[P],k=v.crossTileIDs[P];if(Math.abs(E.x-b.x)<=c&&Math.abs(E.y-b.y)<=c&&!o[k]){o[k]=!0,g.crossTileID=k;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class Ah{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class gl{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const o in this.indexes){const c=this.indexes[o],f={};for(const g in c){const v=c[g];v.tileID=v.tileID.unwrapTo(v.tileID.wrap+n),f[v.tileID.key]=v}this.indexes[o]=f}this.lng=t}addBucket(t,n,o){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let f=0;f<n.symbolInstances.length;f++)n.symbolInstances.get(f).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const c=this.usedCrossTileIDs[t.overscaledZ];for(const f in this.indexes){const g=this.indexes[f];if(Number(f)>t.overscaledZ)for(const v in g){const b=g[v];b.tileID.isChildOf(t)&&b.findMatches(n.symbolInstances,t,c)}else{const v=g[t.scaledTo(Number(f)).key];v&&v.findMatches(n.symbolInstances,t,c)}}for(let f=0;f<n.symbolInstances.length;f++){const g=n.symbolInstances.get(f);g.crossTileID||(g.crossTileID=o.generate(),c[g.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new ml(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const o of n.getCrossTileIDsLists())for(const c of o)delete this.usedCrossTileIDs[t][c]}removeStaleBuckets(t){let n=!1;for(const o in this.indexes){const c=this.indexes[o];for(const f in c)t[c[f].bucketInstanceId]||(this.removeBucketCrossTileIDs(o,c[f]),delete c[f],n=!0)}return n}}class ci{constructor(){this.layerIndexes={},this.crossTileIDs=new Ah,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,o){let c=this.layerIndexes[t.id];c===void 0&&(c=this.layerIndexes[t.id]=new gl);let f=!1;const g={};c.handleWrapJump(o);for(const v of n){const b=v.getBucket(t);b&&t.id===b.layerIds[0]&&(b.bucketInstanceId||(b.bucketInstanceId=++this.maxBucketInstanceId),c.addBucket(v.tileID,b,this.crossTileIDs)&&(f=!0),g[b.bucketInstanceId]=!0)}return c.removeStaleBuckets(g)&&(f=!0),f}pruneUnusedLayers(t){const n={};t.forEach((o=>{n[o]=!0}));for(const o in this.layerIndexes)n[o]||delete this.layerIndexes[o]}}var Xr="void main() {fragColor=vec4(1.0);}";const tr={prelude:rt(`#ifdef GL_ES
|
|
46
|
+
precision mediump float;
|
|
47
|
+
#else
|
|
48
|
+
#if !defined(lowp)
|
|
49
|
+
#define lowp
|
|
50
|
+
#endif
|
|
51
|
+
#if !defined(mediump)
|
|
52
|
+
#define mediump
|
|
53
|
+
#endif
|
|
54
|
+
#if !defined(highp)
|
|
55
|
+
#define highp
|
|
56
|
+
#endif
|
|
57
|
+
#endif
|
|
58
|
+
out highp vec4 fragColor;`,`#ifdef GL_ES
|
|
59
|
+
precision highp float;
|
|
60
|
+
#else
|
|
61
|
+
#if !defined(lowp)
|
|
62
|
+
#define lowp
|
|
63
|
+
#endif
|
|
64
|
+
#if !defined(mediump)
|
|
65
|
+
#define mediump
|
|
66
|
+
#endif
|
|
67
|
+
#if !defined(highp)
|
|
68
|
+
#define highp
|
|
69
|
+
#endif
|
|
70
|
+
#endif
|
|
71
|
+
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
|
|
72
|
+
);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c
|
|
73
|
+
);}
|
|
74
|
+
#ifdef TERRAIN3D
|
|
75
|
+
uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;
|
|
76
|
+
#endif
|
|
77
|
+
const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
|
|
78
|
+
#ifdef TERRAIN3D
|
|
79
|
+
highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
|
|
80
|
+
#else
|
|
81
|
+
return 1.0;
|
|
82
|
+
#endif
|
|
83
|
+
}float calculate_visibility(vec4 pos) {
|
|
84
|
+
#ifdef TERRAIN3D
|
|
85
|
+
vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
|
|
86
|
+
#else
|
|
87
|
+
return 1.0;
|
|
88
|
+
#endif
|
|
89
|
+
}float ele(vec2 pos) {
|
|
90
|
+
#ifdef TERRAIN3D
|
|
91
|
+
vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
|
|
92
|
+
#else
|
|
93
|
+
return 0.0;
|
|
94
|
+
#endif
|
|
95
|
+
}float get_elevation(vec2 pos) {
|
|
96
|
+
#ifdef TERRAIN3D
|
|
97
|
+
#ifdef GLOBE
|
|
98
|
+
if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
|
|
99
|
+
#endif
|
|
100
|
+
vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
|
|
101
|
+
#else
|
|
102
|
+
return 0.0;
|
|
103
|
+
#endif
|
|
104
|
+
}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:rt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:rt("",`#define GLOBE_RADIUS 6371008.8
|
|
105
|
+
uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
|
|
106
|
+
);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);
|
|
107
|
+
if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len
|
|
108
|
+
);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:rt(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
|
|
109
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
110
|
+
fragColor=vec4(1.0);
|
|
111
|
+
#endif
|
|
112
|
+
}`,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:rt(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;
|
|
113
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
114
|
+
fragColor=vec4(1.0);
|
|
115
|
+
#endif
|
|
116
|
+
}`,"uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:rt(`in vec3 v_data;in float v_visibility;
|
|
117
|
+
#pragma mapbox: define highp vec4 color
|
|
118
|
+
#pragma mapbox: define mediump float radius
|
|
119
|
+
#pragma mapbox: define lowp float blur
|
|
120
|
+
#pragma mapbox: define lowp float opacity
|
|
121
|
+
#pragma mapbox: define highp vec4 stroke_color
|
|
122
|
+
#pragma mapbox: define mediump float stroke_width
|
|
123
|
+
#pragma mapbox: define lowp float stroke_opacity
|
|
124
|
+
void main() {
|
|
125
|
+
#pragma mapbox: initialize highp vec4 color
|
|
126
|
+
#pragma mapbox: initialize mediump float radius
|
|
127
|
+
#pragma mapbox: initialize lowp float blur
|
|
128
|
+
#pragma mapbox: initialize lowp float opacity
|
|
129
|
+
#pragma mapbox: initialize highp vec4 stroke_color
|
|
130
|
+
#pragma mapbox: initialize mediump float stroke_width
|
|
131
|
+
#pragma mapbox: initialize lowp float stroke_opacity
|
|
132
|
+
vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}
|
|
133
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
134
|
+
fragColor=vec4(1.0);
|
|
135
|
+
#endif
|
|
136
|
+
}`,`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;
|
|
137
|
+
#pragma mapbox: define highp vec4 color
|
|
138
|
+
#pragma mapbox: define mediump float radius
|
|
139
|
+
#pragma mapbox: define lowp float blur
|
|
140
|
+
#pragma mapbox: define lowp float opacity
|
|
141
|
+
#pragma mapbox: define highp vec4 stroke_color
|
|
142
|
+
#pragma mapbox: define mediump float stroke_width
|
|
143
|
+
#pragma mapbox: define lowp float stroke_opacity
|
|
144
|
+
void main(void) {
|
|
145
|
+
#pragma mapbox: initialize highp vec4 color
|
|
146
|
+
#pragma mapbox: initialize mediump float radius
|
|
147
|
+
#pragma mapbox: initialize lowp float blur
|
|
148
|
+
#pragma mapbox: initialize lowp float opacity
|
|
149
|
+
#pragma mapbox: initialize highp vec4 stroke_color
|
|
150
|
+
#pragma mapbox: initialize mediump float stroke_width
|
|
151
|
+
#pragma mapbox: initialize lowp float stroke_opacity
|
|
152
|
+
vec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {
|
|
153
|
+
#ifdef GLOBE
|
|
154
|
+
vec3 center_vector=projectToSphere(circle_center);
|
|
155
|
+
#endif
|
|
156
|
+
float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {
|
|
157
|
+
#ifdef GLOBE
|
|
158
|
+
vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
|
|
159
|
+
#else
|
|
160
|
+
vec4 projected_center=projectTileWithElevation(circle_center,ele);
|
|
161
|
+
#endif
|
|
162
|
+
corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}
|
|
163
|
+
#ifdef GLOBE
|
|
164
|
+
vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
|
|
165
|
+
#else
|
|
166
|
+
gl_Position=projectTileWithElevation(corner_position,ele);
|
|
167
|
+
#endif
|
|
168
|
+
} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:rt(Xr,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:rt(`uniform highp float u_intensity;in vec2 v_extrude;
|
|
169
|
+
#pragma mapbox: define highp float weight
|
|
170
|
+
#define GAUSS_COEF 0.3989422804014327
|
|
171
|
+
void main() {
|
|
172
|
+
#pragma mapbox: initialize highp float weight
|
|
173
|
+
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);
|
|
174
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
175
|
+
fragColor=vec4(1.0);
|
|
176
|
+
#endif
|
|
177
|
+
}`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;
|
|
178
|
+
#pragma mapbox: define highp float weight
|
|
179
|
+
#pragma mapbox: define mediump float radius
|
|
180
|
+
const highp float ZERO=1.0/255.0/16.0;
|
|
181
|
+
#define GAUSS_COEF 0.3989422804014327
|
|
182
|
+
void main(void) {
|
|
183
|
+
#pragma mapbox: initialize highp float weight
|
|
184
|
+
#pragma mapbox: initialize mediump float radius
|
|
185
|
+
vec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);
|
|
186
|
+
#ifdef GLOBE
|
|
187
|
+
vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);
|
|
188
|
+
#else
|
|
189
|
+
gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
|
|
190
|
+
#endif
|
|
191
|
+
}`),heatmapTexture:rt(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;
|
|
192
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
193
|
+
fragColor=vec4(0.0);
|
|
194
|
+
#endif
|
|
195
|
+
}`,"uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:rt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:rt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {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;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:rt(`#ifdef GL_ES
|
|
196
|
+
precision highp float;
|
|
197
|
+
#endif
|
|
198
|
+
uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else
|
|
199
|
+
{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));
|
|
200
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
201
|
+
fragColor=vec4(1.0);
|
|
202
|
+
#endif
|
|
203
|
+
}`,"uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:rt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:rt(Xr,`in vec2 a_pos;void main() {
|
|
204
|
+
#ifdef GLOBE
|
|
205
|
+
gl_Position=projectTileFor3D(a_pos,0.0);
|
|
206
|
+
#else
|
|
207
|
+
gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
|
|
208
|
+
#endif
|
|
209
|
+
}`),fill:rt(`#pragma mapbox: define highp vec4 color
|
|
210
|
+
#pragma mapbox: define lowp float opacity
|
|
211
|
+
void main() {
|
|
212
|
+
#pragma mapbox: initialize highp vec4 color
|
|
213
|
+
#pragma mapbox: initialize lowp float opacity
|
|
214
|
+
fragColor=color*opacity;
|
|
215
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
216
|
+
fragColor=vec4(1.0);
|
|
217
|
+
#endif
|
|
218
|
+
}`,`uniform vec2 u_fill_translate;in vec2 a_pos;
|
|
219
|
+
#pragma mapbox: define highp vec4 color
|
|
220
|
+
#pragma mapbox: define lowp float opacity
|
|
221
|
+
void main() {
|
|
222
|
+
#pragma mapbox: initialize highp vec4 color
|
|
223
|
+
#pragma mapbox: initialize lowp float opacity
|
|
224
|
+
gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:rt(`in vec2 v_pos;
|
|
225
|
+
#ifdef GLOBE
|
|
226
|
+
in float v_depth;
|
|
227
|
+
#endif
|
|
228
|
+
#pragma mapbox: define highp vec4 outline_color
|
|
229
|
+
#pragma mapbox: define lowp float opacity
|
|
230
|
+
void main() {
|
|
231
|
+
#pragma mapbox: initialize highp vec4 outline_color
|
|
232
|
+
#pragma mapbox: initialize lowp float opacity
|
|
233
|
+
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
|
|
234
|
+
#ifdef GLOBE
|
|
235
|
+
if (v_depth > 1.0) {discard;}
|
|
236
|
+
#endif
|
|
237
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
238
|
+
fragColor=vec4(1.0);
|
|
239
|
+
#endif
|
|
240
|
+
}`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;
|
|
241
|
+
#ifdef GLOBE
|
|
242
|
+
out float v_depth;
|
|
243
|
+
#endif
|
|
244
|
+
#pragma mapbox: define highp vec4 outline_color
|
|
245
|
+
#pragma mapbox: define lowp float opacity
|
|
246
|
+
void main() {
|
|
247
|
+
#pragma mapbox: initialize highp vec4 outline_color
|
|
248
|
+
#pragma mapbox: initialize lowp float opacity
|
|
249
|
+
gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
|
250
|
+
#ifdef GLOBE
|
|
251
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
252
|
+
#endif
|
|
253
|
+
}`),fillOutlinePattern:rt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;
|
|
254
|
+
#ifdef GLOBE
|
|
255
|
+
in float v_depth;
|
|
256
|
+
#endif
|
|
257
|
+
#pragma mapbox: define lowp float opacity
|
|
258
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
259
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
260
|
+
void main() {
|
|
261
|
+
#pragma mapbox: initialize lowp float opacity
|
|
262
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
263
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
264
|
+
vec2 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=texture(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=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;
|
|
265
|
+
#ifdef GLOBE
|
|
266
|
+
if (v_depth > 1.0) {discard;}
|
|
267
|
+
#endif
|
|
268
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
269
|
+
fragColor=vec4(1.0);
|
|
270
|
+
#endif
|
|
271
|
+
}`,`uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;
|
|
272
|
+
#ifdef GLOBE
|
|
273
|
+
out float v_depth;
|
|
274
|
+
#endif
|
|
275
|
+
#pragma mapbox: define lowp float opacity
|
|
276
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
277
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
278
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
279
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
280
|
+
void main() {
|
|
281
|
+
#pragma mapbox: initialize lowp float opacity
|
|
282
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
283
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
284
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
285
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
286
|
+
vec2 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=projectTile(a_pos+u_fill_translate,a_pos);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;
|
|
287
|
+
#ifdef GLOBE
|
|
288
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
289
|
+
#endif
|
|
290
|
+
}`),fillPattern:rt(`#ifdef GL_ES
|
|
291
|
+
precision highp float;
|
|
292
|
+
#endif
|
|
293
|
+
uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
|
|
294
|
+
#pragma mapbox: define lowp float opacity
|
|
295
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
296
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
297
|
+
void main() {
|
|
298
|
+
#pragma mapbox: initialize lowp float opacity
|
|
299
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
300
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
301
|
+
vec2 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;
|
|
302
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
303
|
+
fragColor=vec4(1.0);
|
|
304
|
+
#endif
|
|
305
|
+
}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;
|
|
306
|
+
#pragma mapbox: define lowp float opacity
|
|
307
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
308
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
309
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
310
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
311
|
+
void main() {
|
|
312
|
+
#pragma mapbox: initialize lowp float opacity
|
|
313
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
314
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
315
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
316
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
317
|
+
vec2 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=projectTile(a_pos+u_fill_translate,a_pos);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);}`),fillExtrusion:rt(`in vec4 v_color;void main() {fragColor=v_color;
|
|
318
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
319
|
+
fragColor=vec4(1.0);
|
|
320
|
+
#endif
|
|
321
|
+
}`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;
|
|
322
|
+
#ifdef TERRAIN3D
|
|
323
|
+
in vec2 a_centroid;
|
|
324
|
+
#endif
|
|
325
|
+
out vec4 v_color;
|
|
326
|
+
#pragma mapbox: define highp float base
|
|
327
|
+
#pragma mapbox: define highp float height
|
|
328
|
+
#pragma mapbox: define highp vec4 color
|
|
329
|
+
void main() {
|
|
330
|
+
#pragma mapbox: initialize highp float base
|
|
331
|
+
#pragma mapbox: initialize highp float height
|
|
332
|
+
#pragma mapbox: initialize highp vec4 color
|
|
333
|
+
vec3 normal=a_normal_ed.xyz;
|
|
334
|
+
#ifdef TERRAIN3D
|
|
335
|
+
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
|
336
|
+
#else
|
|
337
|
+
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
|
338
|
+
#endif
|
|
339
|
+
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
|
|
340
|
+
#ifdef GLOBE
|
|
341
|
+
vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
|
342
|
+
#else
|
|
343
|
+
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
|
344
|
+
#endif
|
|
345
|
+
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;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
|
|
346
|
+
#ifdef GLOBE
|
|
347
|
+
mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
|
|
348
|
+
#endif
|
|
349
|
+
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;}`),fillExtrusionPattern:rt(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;
|
|
350
|
+
#pragma mapbox: define lowp float base
|
|
351
|
+
#pragma mapbox: define lowp float height
|
|
352
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
353
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
354
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
355
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
356
|
+
void main() {
|
|
357
|
+
#pragma mapbox: initialize lowp float base
|
|
358
|
+
#pragma mapbox: initialize lowp float height
|
|
359
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
360
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
361
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
362
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
363
|
+
vec2 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=texture(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=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;
|
|
364
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
365
|
+
fragColor=vec4(1.0);
|
|
366
|
+
#endif
|
|
367
|
+
}`,`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 vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;
|
|
368
|
+
#ifdef TERRAIN3D
|
|
369
|
+
in vec2 a_centroid;
|
|
370
|
+
#endif
|
|
371
|
+
#ifdef GLOBE
|
|
372
|
+
out vec3 v_sphere_pos;
|
|
373
|
+
#endif
|
|
374
|
+
out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
|
|
375
|
+
#pragma mapbox: define lowp float base
|
|
376
|
+
#pragma mapbox: define lowp float height
|
|
377
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
378
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
379
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
380
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
381
|
+
void main() {
|
|
382
|
+
#pragma mapbox: initialize lowp float base
|
|
383
|
+
#pragma mapbox: initialize lowp float height
|
|
384
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
385
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
386
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
387
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
388
|
+
vec2 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;
|
|
389
|
+
#ifdef TERRAIN3D
|
|
390
|
+
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
|
391
|
+
#else
|
|
392
|
+
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
|
393
|
+
#endif
|
|
394
|
+
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
|
|
395
|
+
#ifdef GLOBE
|
|
396
|
+
vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
|
397
|
+
#else
|
|
398
|
+
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
|
399
|
+
#endif
|
|
400
|
+
vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
|
|
401
|
+
? a_pos
|
|
402
|
+
: vec2(edgedistance,elevation*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;}`),hillshadePrepare:rt(`#ifdef GL_ES
|
|
403
|
+
precision highp float;
|
|
404
|
+
#endif
|
|
405
|
+
uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;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))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);
|
|
406
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
407
|
+
fragColor=vec4(1.0);
|
|
408
|
+
#endif
|
|
409
|
+
}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:rt(`uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];
|
|
410
|
+
#define PI 3.141592653589793
|
|
411
|
+
#define STANDARD 0
|
|
412
|
+
#define COMBINED 1
|
|
413
|
+
#define IGOR 2
|
|
414
|
+
#define MULTIDIRECTIONAL 3
|
|
415
|
+
#define BASIC 4
|
|
416
|
+
float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else
|
|
417
|
+
{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else
|
|
418
|
+
{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
|
|
419
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
420
|
+
fragColor=vec4(1.0);
|
|
421
|
+
#endif
|
|
422
|
+
}`,"uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:rt(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
|
|
423
|
+
#ifdef GLOBE
|
|
424
|
+
in float v_depth;
|
|
425
|
+
#endif
|
|
426
|
+
#pragma mapbox: define highp vec4 color
|
|
427
|
+
#pragma mapbox: define lowp float blur
|
|
428
|
+
#pragma mapbox: define lowp float opacity
|
|
429
|
+
void main() {
|
|
430
|
+
#pragma mapbox: initialize highp vec4 color
|
|
431
|
+
#pragma mapbox: initialize lowp float blur
|
|
432
|
+
#pragma mapbox: initialize lowp float opacity
|
|
433
|
+
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);fragColor=color*(alpha*opacity);
|
|
434
|
+
#ifdef GLOBE
|
|
435
|
+
if (v_depth > 1.0) {discard;}
|
|
436
|
+
#endif
|
|
437
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
438
|
+
fragColor=vec4(1.0);
|
|
439
|
+
#endif
|
|
440
|
+
}`,`
|
|
441
|
+
#define scale 0.015873016
|
|
442
|
+
in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
|
|
443
|
+
#ifdef GLOBE
|
|
444
|
+
out float v_depth;
|
|
445
|
+
#endif
|
|
446
|
+
#pragma mapbox: define highp vec4 color
|
|
447
|
+
#pragma mapbox: define lowp float blur
|
|
448
|
+
#pragma mapbox: define lowp float opacity
|
|
449
|
+
#pragma mapbox: define mediump float gapwidth
|
|
450
|
+
#pragma mapbox: define lowp float offset
|
|
451
|
+
#pragma mapbox: define mediump float width
|
|
452
|
+
void main() {
|
|
453
|
+
#pragma mapbox: initialize highp vec4 color
|
|
454
|
+
#pragma mapbox: initialize lowp float blur
|
|
455
|
+
#pragma mapbox: initialize lowp float opacity
|
|
456
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
457
|
+
#pragma mapbox: initialize lowp float offset
|
|
458
|
+
#pragma mapbox: initialize mediump float width
|
|
459
|
+
float 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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
460
|
+
#ifdef GLOBE
|
|
461
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
462
|
+
#endif
|
|
463
|
+
#ifdef TERRAIN3D
|
|
464
|
+
v_gamma_scale=1.0;
|
|
465
|
+
#else
|
|
466
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
467
|
+
#endif
|
|
468
|
+
v_width2=vec2(outset,inset);}`),lineGradient:rt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
|
|
469
|
+
#ifdef GLOBE
|
|
470
|
+
in float v_depth;
|
|
471
|
+
#endif
|
|
472
|
+
#pragma mapbox: define lowp float blur
|
|
473
|
+
#pragma mapbox: define lowp float opacity
|
|
474
|
+
void main() {
|
|
475
|
+
#pragma mapbox: initialize lowp float blur
|
|
476
|
+
#pragma mapbox: initialize lowp float opacity
|
|
477
|
+
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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
|
|
478
|
+
#ifdef GLOBE
|
|
479
|
+
if (v_depth > 1.0) {discard;}
|
|
480
|
+
#endif
|
|
481
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
482
|
+
fragColor=vec4(1.0);
|
|
483
|
+
#endif
|
|
484
|
+
}`,`
|
|
485
|
+
#define scale 0.015873016
|
|
486
|
+
in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
|
|
487
|
+
#ifdef GLOBE
|
|
488
|
+
out float v_depth;
|
|
489
|
+
#endif
|
|
490
|
+
#pragma mapbox: define lowp float blur
|
|
491
|
+
#pragma mapbox: define lowp float opacity
|
|
492
|
+
#pragma mapbox: define mediump float gapwidth
|
|
493
|
+
#pragma mapbox: define lowp float offset
|
|
494
|
+
#pragma mapbox: define mediump float width
|
|
495
|
+
void main() {
|
|
496
|
+
#pragma mapbox: initialize lowp float blur
|
|
497
|
+
#pragma mapbox: initialize lowp float opacity
|
|
498
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
499
|
+
#pragma mapbox: initialize lowp float offset
|
|
500
|
+
#pragma mapbox: initialize mediump float width
|
|
501
|
+
float 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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
502
|
+
#ifdef GLOBE
|
|
503
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
504
|
+
#endif
|
|
505
|
+
#ifdef TERRAIN3D
|
|
506
|
+
v_gamma_scale=1.0;
|
|
507
|
+
#else
|
|
508
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
509
|
+
#endif
|
|
510
|
+
v_width2=vec2(outset,inset);}`),linePattern:rt(`#ifdef GL_ES
|
|
511
|
+
precision highp float;
|
|
512
|
+
#endif
|
|
513
|
+
uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;
|
|
514
|
+
#ifdef GLOBE
|
|
515
|
+
in float v_depth;
|
|
516
|
+
#endif
|
|
517
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
518
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
519
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
520
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
521
|
+
#pragma mapbox: define lowp float blur
|
|
522
|
+
#pragma mapbox: define lowp float opacity
|
|
523
|
+
void main() {
|
|
524
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
525
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
526
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
527
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
528
|
+
#pragma mapbox: initialize lowp float blur
|
|
529
|
+
#pragma mapbox: initialize lowp float opacity
|
|
530
|
+
vec2 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(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;
|
|
531
|
+
#ifdef GLOBE
|
|
532
|
+
if (v_depth > 1.0) {discard;}
|
|
533
|
+
#endif
|
|
534
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
535
|
+
fragColor=vec4(1.0);
|
|
536
|
+
#endif
|
|
537
|
+
}`,`
|
|
538
|
+
#define scale 0.015873016
|
|
539
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
540
|
+
in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;
|
|
541
|
+
#ifdef GLOBE
|
|
542
|
+
out float v_depth;
|
|
543
|
+
#endif
|
|
544
|
+
#pragma mapbox: define lowp float blur
|
|
545
|
+
#pragma mapbox: define lowp float opacity
|
|
546
|
+
#pragma mapbox: define lowp float offset
|
|
547
|
+
#pragma mapbox: define mediump float gapwidth
|
|
548
|
+
#pragma mapbox: define mediump float width
|
|
549
|
+
#pragma mapbox: define lowp float floorwidth
|
|
550
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
551
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
552
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
553
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
554
|
+
void main() {
|
|
555
|
+
#pragma mapbox: initialize lowp float blur
|
|
556
|
+
#pragma mapbox: initialize lowp float opacity
|
|
557
|
+
#pragma mapbox: initialize lowp float offset
|
|
558
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
559
|
+
#pragma mapbox: initialize mediump float width
|
|
560
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
561
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
562
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
563
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
564
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
565
|
+
float 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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
566
|
+
#ifdef GLOBE
|
|
567
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
568
|
+
#endif
|
|
569
|
+
#ifdef TERRAIN3D
|
|
570
|
+
v_gamma_scale=1.0;
|
|
571
|
+
#else
|
|
572
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
573
|
+
#endif
|
|
574
|
+
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:rt(`uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
|
|
575
|
+
#ifdef GLOBE
|
|
576
|
+
in float v_depth;
|
|
577
|
+
#endif
|
|
578
|
+
#pragma mapbox: define highp vec4 color
|
|
579
|
+
#pragma mapbox: define lowp float blur
|
|
580
|
+
#pragma mapbox: define lowp float opacity
|
|
581
|
+
#pragma mapbox: define mediump float width
|
|
582
|
+
#pragma mapbox: define lowp float floorwidth
|
|
583
|
+
#pragma mapbox: define mediump vec4 dasharray_from
|
|
584
|
+
#pragma mapbox: define mediump vec4 dasharray_to
|
|
585
|
+
void main() {
|
|
586
|
+
#pragma mapbox: initialize highp vec4 color
|
|
587
|
+
#pragma mapbox: initialize lowp float blur
|
|
588
|
+
#pragma mapbox: initialize lowp float opacity
|
|
589
|
+
#pragma mapbox: initialize mediump float width
|
|
590
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
591
|
+
#pragma mapbox: initialize mediump vec4 dasharray_from
|
|
592
|
+
#pragma mapbox: initialize mediump vec4 dasharray_to
|
|
593
|
+
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 sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);
|
|
594
|
+
#ifdef GLOBE
|
|
595
|
+
if (v_depth > 1.0) {discard;}
|
|
596
|
+
#endif
|
|
597
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
598
|
+
fragColor=vec4(1.0);
|
|
599
|
+
#endif
|
|
600
|
+
}`,`
|
|
601
|
+
#define scale 0.015873016
|
|
602
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
603
|
+
in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
|
|
604
|
+
#ifdef GLOBE
|
|
605
|
+
out float v_depth;
|
|
606
|
+
#endif
|
|
607
|
+
#pragma mapbox: define highp vec4 color
|
|
608
|
+
#pragma mapbox: define lowp float blur
|
|
609
|
+
#pragma mapbox: define lowp float opacity
|
|
610
|
+
#pragma mapbox: define mediump float gapwidth
|
|
611
|
+
#pragma mapbox: define lowp float offset
|
|
612
|
+
#pragma mapbox: define mediump float width
|
|
613
|
+
#pragma mapbox: define lowp float floorwidth
|
|
614
|
+
#pragma mapbox: define mediump vec4 dasharray_from
|
|
615
|
+
#pragma mapbox: define mediump vec4 dasharray_to
|
|
616
|
+
void main() {
|
|
617
|
+
#pragma mapbox: initialize highp vec4 color
|
|
618
|
+
#pragma mapbox: initialize lowp float blur
|
|
619
|
+
#pragma mapbox: initialize lowp float opacity
|
|
620
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
621
|
+
#pragma mapbox: initialize lowp float offset
|
|
622
|
+
#pragma mapbox: initialize mediump float width
|
|
623
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
624
|
+
#pragma mapbox: initialize mediump vec4 dasharray_from
|
|
625
|
+
#pragma mapbox: initialize mediump vec4 dasharray_to
|
|
626
|
+
float 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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
627
|
+
#ifdef GLOBE
|
|
628
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
629
|
+
#endif
|
|
630
|
+
#ifdef TERRAIN3D
|
|
631
|
+
v_gamma_scale=1.0;
|
|
632
|
+
#else
|
|
633
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
634
|
+
#endif
|
|
635
|
+
float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),lineGradientSDF:rt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;
|
|
636
|
+
#ifdef GLOBE
|
|
637
|
+
in float v_depth;
|
|
638
|
+
#endif
|
|
639
|
+
#pragma mapbox: define lowp float blur
|
|
640
|
+
#pragma mapbox: define lowp float opacity
|
|
641
|
+
#pragma mapbox: define mediump float width
|
|
642
|
+
#pragma mapbox: define lowp float floorwidth
|
|
643
|
+
#pragma mapbox: define mediump vec4 dasharray_from
|
|
644
|
+
#pragma mapbox: define mediump vec4 dasharray_to
|
|
645
|
+
void main() {
|
|
646
|
+
#pragma mapbox: initialize lowp float blur
|
|
647
|
+
#pragma mapbox: initialize lowp float opacity
|
|
648
|
+
#pragma mapbox: initialize mediump float width
|
|
649
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
650
|
+
#pragma mapbox: initialize mediump vec4 dasharray_from
|
|
651
|
+
#pragma mapbox: initialize mediump vec4 dasharray_to
|
|
652
|
+
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);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);
|
|
653
|
+
#ifdef GLOBE
|
|
654
|
+
if (v_depth > 1.0) {discard;}
|
|
655
|
+
#endif
|
|
656
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
657
|
+
fragColor=vec4(1.0);
|
|
658
|
+
#endif
|
|
659
|
+
}`,`
|
|
660
|
+
#define scale 0.015873016
|
|
661
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
662
|
+
in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;
|
|
663
|
+
#ifdef GLOBE
|
|
664
|
+
out float v_depth;
|
|
665
|
+
#endif
|
|
666
|
+
#pragma mapbox: define lowp float blur
|
|
667
|
+
#pragma mapbox: define lowp float opacity
|
|
668
|
+
#pragma mapbox: define mediump float gapwidth
|
|
669
|
+
#pragma mapbox: define lowp float offset
|
|
670
|
+
#pragma mapbox: define mediump float width
|
|
671
|
+
#pragma mapbox: define lowp float floorwidth
|
|
672
|
+
#pragma mapbox: define mediump vec4 dasharray_from
|
|
673
|
+
#pragma mapbox: define mediump vec4 dasharray_to
|
|
674
|
+
void main() {
|
|
675
|
+
#pragma mapbox: initialize lowp float blur
|
|
676
|
+
#pragma mapbox: initialize lowp float opacity
|
|
677
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
678
|
+
#pragma mapbox: initialize lowp float offset
|
|
679
|
+
#pragma mapbox: initialize mediump float width
|
|
680
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
681
|
+
#pragma mapbox: initialize mediump vec4 dasharray_from
|
|
682
|
+
#pragma mapbox: initialize mediump vec4 dasharray_to
|
|
683
|
+
float 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;float texel_height=1.0/u_image_height;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
|
|
684
|
+
#ifdef GLOBE
|
|
685
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
686
|
+
#endif
|
|
687
|
+
#ifdef TERRAIN3D
|
|
688
|
+
v_gamma_scale=1.0;
|
|
689
|
+
#else
|
|
690
|
+
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
|
691
|
+
#endif
|
|
692
|
+
float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),raster:rt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in 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=texture(u_image0,v_pos0);vec4 color1=texture(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
|
|
693
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
694
|
+
fragColor=vec4(1.0);
|
|
695
|
+
#endif
|
|
696
|
+
}`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;
|
|
697
|
+
#ifdef GLOBE
|
|
698
|
+
if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}
|
|
699
|
+
#endif
|
|
700
|
+
v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:rt(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;
|
|
701
|
+
#pragma mapbox: define lowp float opacity
|
|
702
|
+
void main() {
|
|
703
|
+
#pragma mapbox: initialize lowp float opacity
|
|
704
|
+
lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;
|
|
705
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
706
|
+
fragColor=vec4(1.0);
|
|
707
|
+
#endif
|
|
708
|
+
}`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;
|
|
709
|
+
#pragma mapbox: define lowp float opacity
|
|
710
|
+
void main() {
|
|
711
|
+
#pragma mapbox: initialize lowp float opacity
|
|
712
|
+
vec2 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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
713
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
714
|
+
u_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=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
|
715
|
+
#ifdef GLOBE
|
|
716
|
+
if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
|
717
|
+
#endif
|
|
718
|
+
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;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;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:rt(`#define SDF_PX 8.0
|
|
719
|
+
uniform 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;in vec2 v_data0;in vec3 v_data1;
|
|
720
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
721
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
722
|
+
#pragma mapbox: define lowp float opacity
|
|
723
|
+
#pragma mapbox: define lowp float halo_width
|
|
724
|
+
#pragma mapbox: define lowp float halo_blur
|
|
725
|
+
void main() {
|
|
726
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
727
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
728
|
+
#pragma mapbox: initialize lowp float opacity
|
|
729
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
730
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
731
|
+
float 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 inner_edge=(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);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);
|
|
732
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
733
|
+
fragColor=vec4(1.0);
|
|
734
|
+
#endif
|
|
735
|
+
}`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;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_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;
|
|
736
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
737
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
738
|
+
#pragma mapbox: define lowp float opacity
|
|
739
|
+
#pragma mapbox: define lowp float halo_width
|
|
740
|
+
#pragma mapbox: define lowp float halo_blur
|
|
741
|
+
void main() {
|
|
742
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
743
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
744
|
+
#pragma mapbox: initialize lowp float opacity
|
|
745
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
746
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
747
|
+
vec2 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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
748
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
749
|
+
u_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=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
|
750
|
+
#ifdef GLOBE
|
|
751
|
+
if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
|
752
|
+
#endif
|
|
753
|
+
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:rt(`#define SDF_PX 8.0
|
|
754
|
+
#define SDF 1.0
|
|
755
|
+
#define ICON 0.0
|
|
756
|
+
uniform 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;in vec4 v_data0;in vec4 v_data1;
|
|
757
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
758
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
759
|
+
#pragma mapbox: define lowp float opacity
|
|
760
|
+
#pragma mapbox: define lowp float halo_width
|
|
761
|
+
#pragma mapbox: define lowp float halo_blur
|
|
762
|
+
void main() {
|
|
763
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
764
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
765
|
+
#pragma mapbox: initialize lowp float opacity
|
|
766
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
767
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
768
|
+
float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;
|
|
769
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
770
|
+
fragColor=vec4(1.0);
|
|
771
|
+
#endif
|
|
772
|
+
return;}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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);
|
|
773
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
774
|
+
fragColor=vec4(1.0);
|
|
775
|
+
#endif
|
|
776
|
+
}`,`in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in 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_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;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;
|
|
777
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
778
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
779
|
+
#pragma mapbox: define lowp float opacity
|
|
780
|
+
#pragma mapbox: define lowp float halo_width
|
|
781
|
+
#pragma mapbox: define lowp float halo_blur
|
|
782
|
+
void main() {
|
|
783
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
784
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
785
|
+
#pragma mapbox: initialize lowp float opacity
|
|
786
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
787
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
788
|
+
vec2 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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
|
|
789
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
790
|
+
u_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=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
|
|
791
|
+
#ifdef GLOBE
|
|
792
|
+
if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
|
|
793
|
+
#endif
|
|
794
|
+
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,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);}`),terrain:rt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:rt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:rt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:rt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:rt(`#ifdef GL_ES
|
|
795
|
+
precision highp float;
|
|
796
|
+
#endif
|
|
797
|
+
in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758
|
|
798
|
+
);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,"in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:rt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function rt(d,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=t.match(/in ([\w]+) ([\w]+)/g),c=d.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),f=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),g=f?f.concat(c):c,v={};return{fragmentSource:d=d.replace(n,((b,P,E,k,D)=>(v[D]=!0,P==="define"?`
|
|
799
|
+
#ifndef HAS_UNIFORM_u_${D}
|
|
800
|
+
in ${E} ${k} ${D};
|
|
801
|
+
#else
|
|
802
|
+
uniform ${E} ${k} u_${D};
|
|
803
|
+
#endif
|
|
804
|
+
`:`
|
|
805
|
+
#ifdef HAS_UNIFORM_u_${D}
|
|
806
|
+
${E} ${k} ${D} = u_${D};
|
|
807
|
+
#endif
|
|
808
|
+
`))),vertexSource:t=t.replace(n,((b,P,E,k,D)=>{const L=k==="float"?"vec2":"vec4",N=D.match(/color/)?"color":L;return v[D]?P==="define"?`
|
|
809
|
+
#ifndef HAS_UNIFORM_u_${D}
|
|
810
|
+
uniform lowp float u_${D}_t;
|
|
811
|
+
in ${E} ${L} a_${D};
|
|
812
|
+
out ${E} ${k} ${D};
|
|
813
|
+
#else
|
|
814
|
+
uniform ${E} ${k} u_${D};
|
|
815
|
+
#endif
|
|
816
|
+
`:N==="vec4"?`
|
|
817
|
+
#ifndef HAS_UNIFORM_u_${D}
|
|
818
|
+
${D} = a_${D};
|
|
819
|
+
#else
|
|
820
|
+
${E} ${k} ${D} = u_${D};
|
|
821
|
+
#endif
|
|
822
|
+
`:`
|
|
823
|
+
#ifndef HAS_UNIFORM_u_${D}
|
|
824
|
+
${D} = unpack_mix_${N}(a_${D}, u_${D}_t);
|
|
825
|
+
#else
|
|
826
|
+
${E} ${k} ${D} = u_${D};
|
|
827
|
+
#endif
|
|
828
|
+
`:P==="define"?`
|
|
829
|
+
#ifndef HAS_UNIFORM_u_${D}
|
|
830
|
+
uniform lowp float u_${D}_t;
|
|
831
|
+
in ${E} ${L} a_${D};
|
|
832
|
+
#else
|
|
833
|
+
uniform ${E} ${k} u_${D};
|
|
834
|
+
#endif
|
|
835
|
+
`:N==="vec4"?`
|
|
836
|
+
#ifndef HAS_UNIFORM_u_${D}
|
|
837
|
+
${E} ${k} ${D} = a_${D};
|
|
838
|
+
#else
|
|
839
|
+
${E} ${k} ${D} = u_${D};
|
|
840
|
+
#endif
|
|
841
|
+
`:`
|
|
842
|
+
#ifndef HAS_UNIFORM_u_${D}
|
|
843
|
+
${E} ${k} ${D} = unpack_mix_${N}(a_${D}, u_${D}_t);
|
|
844
|
+
#else
|
|
845
|
+
${E} ${k} ${D} = u_${D};
|
|
846
|
+
#endif
|
|
847
|
+
`})),staticAttributes:o,staticUniforms:g}}class Ft{constructor(t,n,o){this.vertexBuffer=t,this.indexBuffer=n,this.segments=o}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var vn=l.aU([{name:"a_pos",type:"Int16",components:2}]);const ri="#define PROJECTION_MERCATOR",yi="mercator";class ii{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return yi}get shaderDefine(){return ri}get shaderPreludeCode(){return tr.projectionMercator}get vertexShaderPreludeCode(){return tr.projectionMercator.vertexSource}get subdivisionGranularity(){return l.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,n,o,c,f){if(this._cachedMesh)return this._cachedMesh;const g=new l.aW;g.emplaceBack(0,0),g.emplaceBack(l.a5,0),g.emplaceBack(0,l.a5),g.emplaceBack(l.a5,l.a5);const v=t.createVertexBuffer(g,vn.members),b=l.aX.simpleSegment(0,0,4,2),P=new l.aY;P.emplaceBack(1,0,2),P.emplaceBack(1,2,3);const E=t.createIndexBuffer(P);return this._cachedMesh=new Ft(v,E,b),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class vs{constructor(t=0,n=0,o=0,c=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(o)||o<0||isNaN(c)||c<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=o,this.right=c}interpolate(t,n,o){return n.top!=null&&t.top!=null&&(this.top=l.G.number(t.top,n.top,o)),n.bottom!=null&&t.bottom!=null&&(this.bottom=l.G.number(t.bottom,n.bottom,o)),n.left!=null&&t.left!=null&&(this.left=l.G.number(t.left,n.left,o)),n.right!=null&&t.right!=null&&(this.right=l.G.number(t.right,n.right,o)),this}getCenter(t,n){const o=l.an((this.left+t-this.right)/2,0,t),c=l.an((this.top+n-this.bottom)/2,0,n);return new l.P(o,c)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new vs(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function xn(d,t){if(!d.renderWorldCopies||d.lngRange)return;const n=t.lng-d.center.lng;t.lng+=n>180?-360:n<-180?360:0}function gr(d){return Math.max(0,Math.floor(d))}class jn{constructor(t,n){var o;this.applyConstrain=(c,f)=>this._constrainOverride!==null?this._constrainOverride(c,f):this._callbacks.defaultConstrain(c,f),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=n?.renderWorldCopies===void 0||!!n?.renderWorldCopies,this._minZoom=n?.minZoom||0,this._maxZoom=n?.maxZoom||22,this._minPitch=n?.minPitch==null?0:n?.minPitch,this._maxPitch=n?.maxPitch==null?60:n?.maxPitch,this._constrainOverride=(o=n?.constrainOverride)!==null&&o!==void 0?o:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new l.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=gr(this._zoom),this._scale=l.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new vs,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,n,o){this._constrainOverride=t.constrainOverride,this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=gr(this._zoom),this._scale=l.aq(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new vs(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!o&&t.autoCalculateNearFarZ,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){t===void 0&&(t=null),this._constrainOverride!==t&&(this._constrainOverride=t,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new l.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){const n=l.W(t,-180,180)*Math.PI/180;var o,c,f,g,v,b,P,E,k;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=Se(),o=this._rotationMatrix,f=-this._bearingInRadians,g=(c=this._rotationMatrix)[0],v=c[1],b=c[2],P=c[3],E=Math.sin(f),k=Math.cos(f),o[0]=g*k+b*E,o[1]=v*k+P*E,o[2]=g*-E+b*k,o[3]=v*-E+P*k)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){const n=l.an(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){const n=t/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return l.aZ(this._fovInRadians)}setFov(t){t=l.an(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=l.ap(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){const n=this.applyConstrain(this._center,t).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=l.aq(n),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,n){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,o){this._unmodified=!1,this._edgeInsets.interpolate(t,n,o),this.constrainInternal(),this._calcMatrices()}resize(t,n,o=!0){this._width=t,this._height=n,o&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new er([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-l.ao,l.ao])}getCameraQueryGeometry(t,n){if(n.length===1)return[n[0],t];{const{minX:o,minY:c,maxX:f,maxY:g}=l.aa.fromPoints(n).extend(t);return[new l.P(o,c),new l.P(f,c),new l.P(f,g),new l.P(o,g),new l.P(o,c)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:n,zoom:o}=this.applyConstrain(this.center,this.zoom);this.setCenter(n),this.setZoom(o),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=l.ar(new Float64Array(16));l.Q(t,t,[this._width/2,-this._height/2,1]),l.O(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=l.ar(new Float64Array(16)),l.Q(t,t,[1,-1,1]),l.O(t,t,[-1,-1,0]),l.Q(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,n,o,c){const f=o!==void 0?o:this.bearing,g=c=c!==void 0?c:this.pitch,{distanceToCenter:v,clampedElevation:b}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,g),{x:P,y:E}=nt(g,f),k=l.a9.fromLngLat(t,n);let D,L,N=l.a_(1,k.y),q=0;do{if(q+=1,q>10)break;L=v/N,D=new l.a9(k.x+P*L,k.y+E*L),N=1/D.meterInMercatorCoordinateUnits()}while(Math.abs(v-L*N)>1e-12);return{center:D.toLngLat(),elevation:b,zoom:l.at(this.height/2/Math.tan(this.fovInRadians/2)/L/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const n=1/this.worldSize,o=l.as(1,this.center.lat)*this.worldSize,c=l.a9.fromLngLat(this.center,this.elevation),f=c.x/n,g=c.y/n,v=c.z/n,b=this.pitch,P=this.bearing,{x:E,y:k,z:D}=nt(b,P),L=this.cameraToCenterDistance,N=f+L*-E,q=g+L*-k,H=v+L*D,{distanceToCenter:W,clampedElevation:K}=this._distanceToCenterFromAltElevationPitch(H/o,t,b),re=W*o,Y=new l.a9((N+E*re)*n,(q+k*re)*n,0).toLngLat(),te=l.as(1,Y.lat),oe=l.at(this.height/2/Math.tan(this.fovInRadians/2)/W/te/this.tileSize);this._elevation=K,this._center=Y,this.setZoom(oe)}_distanceToCenterFromAltElevationPitch(t,n,o){const c=-Math.cos(l.ap(o)),f=t-n;let g,v=n;return c*f>=0||Math.abs(c)<.1?(g=1e4,v=t+g*c):g=-f/c,{distanceToCenter:g,clampedElevation:v}}getCameraPoint(){const t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new l.P(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const t=l.as(1,this.center.lat)*this.worldSize;return le(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];const n=t.canonical.z>=0?1<<t.canonical.z:Math.pow(2,t.canonical.z);return[t.canonical.x/n,t.canonical.y/n,1/n/l.a5,1/n/l.a5]}}class Ji{constructor(t,n){this.min=t,this.max=n,this.center=l.a$([],l.b0([],this.min,this.max),.5)}quadrant(t){const n=[t%2==0,t<2],o=l.b1(this.min),c=l.b1(this.max);for(let f=0;f<n.length;f++)o[f]=n[f]?this.min[f]:this.center[f],c[f]=n[f]?this.center[f]:this.max[f];return c[2]=this.max[2],new Ji(o,c)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let n=!0;for(let o=0;o<t.planes.length;o++){const c=this.intersectsPlane(t.planes[o]);if(c===0)return 0;c===1&&(n=!1)}return n?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let n=t[3],o=t[3];for(let c=0;c<3;c++)t[c]>0?(n+=t[c]*this.min[c],o+=t[c]*this.max[c]):(o+=t[c]*this.min[c],n+=t[c]*this.max[c]);return n>=0?2:o<0?0:1}}class na{distanceToTile2d(t,n,o,c){const f=c.distanceX([t,n]),g=c.distanceY([t,n]);return Math.hypot(f,g)}getWrap(t,n,o){return o}getTileBoundingVolume(t,n,o,c){var f,g;let v=0,b=0;if(c?.terrain){const E=new l.a2(t.z,n,t.z,t.x,t.y),k=c.terrain.getMinMaxElevation(E);v=(f=k.minElevation)!==null&&f!==void 0?f:Math.min(0,o),b=(g=k.maxElevation)!==null&&g!==void 0?g:Math.max(0,o)}const P=1<<t.z;return new Ji([n+t.x/P,t.y/P,v],[n+(t.x+1)/P,(t.y+1)/P,b])}allowVariableZoom(t,n){const o=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,c=l.an(78.5-o/2,0,60);return!!n.terrain||t.pitch>c}allowWorldCopies(){return!0}prepareNextFrame(){}}class ui{constructor(t,n,o){this.points=t,this.planes=n,this.aabb=o}static fromInvProjectionMatrix(t,n=1,o=0,c,f){const g=f?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],v=Math.pow(2,o),b=[[-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((D=>(function(L,N,q,H){const W=l.aH([],L,N),K=1/W[3]/q*H;return l.b6(W,W,[K,K,1/W[3],K])})(D,t,n,v)));c&&(function(D,L,N,q){const H=q?4:0,W=q?0:4;let K=0;const re=[],Y=[];for(let Q=0;Q<4;Q++){const ae=l.b2([],D[Q+W],D[Q+H]),ve=l.b7(ae);l.a$(ae,ae,1/ve),re.push(ve),Y.push(ae)}for(let Q=0;Q<4;Q++){const ae=l.b8(D[Q+H],Y[Q],N);K=ae!==null&&ae>=0?Math.max(K,ae):Math.max(K,re[Q])}const te=(function(Q,ae){const ve=l.b2([],Q[ae[0]],Q[ae[1]]),ge=l.b2([],Q[ae[2]],Q[ae[1]]),_e=[0,0,0,0];return l.b3(_e,l.b4([],ve,ge)),_e[3]=-l.b5(_e,Q[ae[0]]),_e})(D,L),oe=(function(Q,ae){const ve=l.b9(Q),ge=l.ba([],Q,1/ve),_e=l.b2([],ae,l.a$([],ge,l.b5(ae,ge))),ye=l.b9(_e);if(ye>0){const Re=Math.sqrt(1-ge[3]*ge[3]),Fe=l.a$([],ge,-ge[3]),Ee=l.b0([],Fe,l.a$([],_e,Re/ye));return l.bb(ae,Ee)}return null})(N,te);if(oe!==null){const Q=oe/l.b5(Y[0],te);K=Math.min(K,Q)}for(let Q=0;Q<4;Q++){const ae=Math.min(K,re[Q]);D[Q+W]=[D[Q+H][0]+Y[Q][0]*ae,D[Q+H][1]+Y[Q][1]*ae,D[Q+H][2]+Y[Q][2]*ae,1]}})(b,g[0],c,f);const P=g.map((D=>{const L=l.b2([],b[D[0]],b[D[1]]),N=l.b2([],b[D[2]],b[D[1]]),q=l.b3([],l.b4([],L,N)),H=-l.b5(q,b[D[1]]);return q.concat(H)})),E=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],k=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const D of b)for(let L=0;L<3;L++)E[L]=Math.min(E[L],D[L]),k[L]=Math.max(k[L],D[L]);return new ui(b,P,new Ji(E,k))}}class Nn{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,n,o){return this._helper.interpolatePadding(t,n,o)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,o=!0){this._helper.resize(t,n,o)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t,n){}constructor(t){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(n,o)=>{o=l.an(+o,this.minZoom,this.maxZoom);const c={center:new l.V(n.lng,n.lat),zoom:o};let f=this._helper._lngRange;if(!this._helper._renderWorldCopies&&f===null){const Y=179.9999999999;f=[-Y,Y]}const g=this.tileSize*l.aq(c.zoom);let v=0,b=g,P=0,E=g,k=0,D=0;const{x:L,y:N}=this.size;if(this._helper._latRange){const Y=this._helper._latRange;v=l.X(Y[1])*g,b=l.X(Y[0])*g,b-v<N&&(k=N/(b-v))}f&&(P=l.W(l.Y(f[0])*g,0,g),E=l.W(l.Y(f[1])*g,0,g),E<P&&(E+=g),E-P<L&&(D=L/(E-P)));const{x:q,y:H}=he(g,n);let W,K;const re=Math.max(D||0,k||0);if(re){const Y=new l.P(D?(E+P)/2:q,k?(b+v)/2:H);return c.center=Ce(g,Y).wrap(),c.zoom+=l.at(re),c}if(this._helper._latRange){const Y=N/2;H-Y<v&&(K=v+Y),H+Y>b&&(K=b-Y)}if(f){const Y=(P+E)/2;let te=q;this._helper._renderWorldCopies&&(te=l.W(q,Y-g/2,Y+g/2));const oe=L/2;te-oe<P&&(W=P+oe),te+oe>E&&(W=E-oe)}if(W!==void 0||K!==void 0){const Y=new l.P(W??q,K??H);c.center=Ce(g,Y).wrap()}return c},this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new jn({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},t),this._coveringTilesDetailsProvider=new na}clone(){const t=new Nn;return t.apply(this,!1),t}apply(t,n,o){this._helper.apply(t,n,o)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){const n=[new l.bc(0,t)];if(this._helper._renderWorldCopies){const o=this.screenPointToMercatorCoordinate(new l.P(0,0)),c=this.screenPointToMercatorCoordinate(new l.P(this._helper._width,0)),f=this.screenPointToMercatorCoordinate(new l.P(this._helper._width,this._helper._height)),g=this.screenPointToMercatorCoordinate(new l.P(0,this._helper._height)),v=Math.floor(Math.min(o.x,c.x,f.x,g.x)),b=Math.floor(Math.max(o.x,c.x,f.x,g.x)),P=1;for(let E=v-P;E<=b+P;E++)E!==0&&n.push(new l.bc(E,t))}return n}getCameraFrustum(){return ui.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const n=this.screenPointToLocation(this.centerPoint,t),o=t?t.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(o)}setLocationAtPoint(t,n){const o=l.as(this.elevation,this.center.lat),c=this.screenPointToMercatorCoordinateAtZ(n,o),f=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,o),g=l.a9.fromLngLat(t),v=new l.a9(g.x-(c.x-f.x),g.y-(c.y-f.y));this.setCenter(v?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,n){return n?this.coordinatePoint(l.a9.fromLngLat(t),n.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(l.a9.fromLngLat(t))}screenPointToLocation(t,n){var o;return(o=this.screenPointToMercatorCoordinate(t,n))===null||o===void 0?void 0:o.toLngLat()}screenPointToMercatorCoordinate(t,n){if(n){const o=n.pointCoordinate(t);if(o!=null)return o}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,n){const o=n||0,c=[t.x,t.y,0,1],f=[t.x,t.y,1,1];l.aH(c,c,this._pixelMatrixInverse),l.aH(f,f,this._pixelMatrixInverse);const g=c[3],v=f[3],b=c[1]/g,P=f[1]/v,E=c[2]/g,k=f[2]/v,D=E===k?0:(o-E)/(k-E);return new l.a9(l.G.number(c[0]/g,f[0]/v,D)/this.worldSize,l.G.number(b,P,D)/this.worldSize,o)}coordinatePoint(t,n=0,o=this._pixelMatrix){const c=[t.x*this.worldSize,t.y*this.worldSize,n,1];return l.aH(c,c,o),new l.P(c[0]/c[3],c[1]/c[3])}getBounds(){const t=Math.max(0,this._helper._height/2-be(this));return new er().extend(this.screenPointToLocation(new l.P(0,t))).extend(this.screenPointToLocation(new l.P(this._helper._width,t))).extend(this.screenPointToLocation(new l.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new l.P(0,this._helper._height)))}isPointOnMapSurface(t,n){return n?n.pointCoordinate(t)!=null:t.y>this.height/2-be(this)}calculatePosMatrix(t,n=!1,o){var c;const f=(c=t.key)!==null&&c!==void 0?c:l.bd(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),g=n?this._alignedPosMatrixCache:this._posMatrixCache;if(g.has(f)){const P=g.get(f);return o?P.f32:P.f64}const v=ke(t,this.worldSize);l.S(v,n?this._alignedProjMatrix:this._viewProjMatrix,v);const b={f64:v,f32:new Float32Array(v)};return g.set(f,b),o?b.f32:b.f64}calculateFogMatrix(t){const n=t.key,o=this._fogMatrixCacheF32;if(o.has(n))return o.get(n);const c=ke(t,this.worldSize);return l.S(c,this._fogMatrix,c),o.set(n,new Float32Array(c)),o.get(n)}calculateCenterFromCameraLngLatAlt(t,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,o,c)}_calculateNearFarZIfNeeded(t,n,o){if(!this._helper.autoCalculateNearFarZ)return;const c=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),f=t-c*this._helper._pixelPerMeter/Math.cos(n),g=c<0?f:t,v=Math.PI/2+this.pitchInRadians,b=l.ap(this.fov)*(Math.abs(Math.cos(l.ap(this.roll)))*this.height+Math.abs(Math.sin(l.ap(this.roll)))*this.width)/this.height*(.5+o.y/this.height),P=Math.sin(b)*g/Math.sin(l.an(Math.PI-v-b,.01,Math.PI-.01)),E=be(this),k=Math.atan(E/this._helper.cameraToCenterDistance),D=l.ap(.75),L=k>D?2*k*(.5+o.y/(2*E)):D,N=Math.sin(L)*g/Math.sin(l.an(Math.PI-v-L,.01,Math.PI-.01)),q=Math.min(P,N);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*q+g),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,n=he(this.worldSize,this.center),o=n.x,c=n.y;this._helper._pixelPerMeter=l.as(1,this.center.lat)*this.worldSize;const f=l.ap(Math.min(this.pitch,ue)),g=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(f));let v;this._calculateNearFarZIfNeeded(g,f,t),v=new Float64Array(16),l.be(v,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),l.aB(this._invProjMatrix,v),v[8]=2*-t.x/this._helper._width,v[9]=2*t.y/this._helper._height,this._projectionMatrix=l.bf(v),l.Q(v,v,[1,-1,1]),l.O(v,v,[0,0,-this._helper.cameraToCenterDistance]),l.bg(v,v,-this.rollInRadians),l.bh(v,v,this.pitchInRadians),l.bg(v,v,-this.bearingInRadians),l.O(v,v,[-o,-c,0]),this._mercatorMatrix=l.Q([],v,[this.worldSize,this.worldSize,this.worldSize]),l.Q(v,v,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=l.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,v),l.O(v,v,[0,0,-this.elevation]),this._viewProjMatrix=v,this._invViewProjMatrix=l.aB([],v);const b=[0,0,-1,1];l.aH(b,b,this._invViewProjMatrix),this._cameraPosition=[b[0]/b[3],b[1]/b[3],b[2]/b[3]],this._fogMatrix=new Float64Array(16),l.be(this._fogMatrix,this.fovInRadians,this.width/this.height,g,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,l.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),l.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),l.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),l.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),l.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),l.O(this._fogMatrix,this._fogMatrix,[-o,-c,0]),l.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),l.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=l.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,v);const P=this._helper._width%2/2,E=this._helper._height%2/2,k=Math.cos(this.bearingInRadians),D=Math.sin(-this.bearingInRadians),L=o-Math.round(o)+k*P+D*E,N=c-Math.round(c)+k*E+D*P,q=new Float64Array(v);if(l.O(q,q,[L>.5?L-1:L,N>.5?N-1:N,0]),this._alignedProjMatrix=q,v=l.aB(new Float64Array(16),this._pixelMatrix),!v)throw new Error("failed to invert matrix");this._pixelMatrixInverse=v,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const t=this.screenPointToMercatorCoordinate(new l.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return l.aH(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const t=l.as(1,this.center.lat)*this.worldSize;return le(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,n){const o=l.a9.fromLngLat(t),c=[o.x*this.worldSize,o.y*this.worldSize,n,1];return l.aH(c,c,this._viewProjMatrix),c[2]/c[3]}getProjectionData(t){const{overscaledTileID:n,aligned:o,applyTerrainMatrix:c}=t,f=this._helper.getMercatorTileCoordinates(n),g=n?this.calculatePosMatrix(n,o,!0):null;let v;return v=n&&n.terrainRttPosMatrix32f&&c?n.terrainRttPosMatrix32f:g||l.bi(),{mainMatrix:v,tileMercatorCoords:f,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:v}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,n,o){return 1}transformLightDirection(t){return l.b1(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,n,o,c){const f=this.calculatePosMatrix(o);let g;c?(g=[t,n,c(t,n),1],l.aH(g,g,f)):(g=[t,n,0,1],ta(g,g,f));const v=g[3];return{point:new l.P(g[0]/v,g[1]/v),signedDistanceFromCamera:v,isOccluded:!1}}populateCache(t){for(const n of t)this.calculatePosMatrix(n)}getMatrixForModel(t,n){const o=l.a9.fromLngLat(t,n),c=o.meterInMercatorCoordinateUnits(),f=l.bj();return l.O(f,f,[o.x,o.y,o.z]),l.bg(f,f,Math.PI),l.bh(f,f,Math.PI/2),l.Q(f,f,[-c,c,c]),f}getProjectionDataForCustomLayer(t=!0){const n=new l.a2(0,0,0,0,0),o=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:t}),c=ke(n,this.worldSize);l.S(c,this._viewProjMatrix,c),o.tileMercatorCoords=[0,0,1,1];const f=[l.a5,l.a5,this.worldSize/this._helper.pixelsPerMeter],g=l.bk();return l.Q(g,c,f),o.fallbackMatrix=g,o.mainMatrix=g,o}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function ln(){l.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Wc(d){if(d.useSlerp)if(d.k<1){const t=l.bl(d.startEulerAngles.roll,d.startEulerAngles.pitch,d.startEulerAngles.bearing),n=l.bl(d.endEulerAngles.roll,d.endEulerAngles.pitch,d.endEulerAngles.bearing),o=new Float64Array(4);l.bm(o,t,n,d.k);const c=l.bn(o);d.tr.setRoll(c.roll),d.tr.setPitch(c.pitch),d.tr.setBearing(c.bearing)}else d.tr.setRoll(d.endEulerAngles.roll),d.tr.setPitch(d.endEulerAngles.pitch),d.tr.setBearing(d.endEulerAngles.bearing);else d.tr.setRoll(l.G.number(d.startEulerAngles.roll,d.endEulerAngles.roll,d.k)),d.tr.setPitch(l.G.number(d.startEulerAngles.pitch,d.endEulerAngles.pitch,d.k)),d.tr.setBearing(l.G.number(d.startEulerAngles.bearing,d.endEulerAngles.bearing,d.k))}function _l(d,t,n,o,c){const f=c.padding,g=he(c.worldSize,n.getNorthWest()),v=he(c.worldSize,n.getNorthEast()),b=he(c.worldSize,n.getSouthEast()),P=he(c.worldSize,n.getSouthWest()),E=l.ap(-o),k=g.rotate(E),D=v.rotate(E),L=b.rotate(E),N=P.rotate(E),q=new l.P(Math.max(k.x,D.x,N.x,L.x),Math.max(k.y,D.y,N.y,L.y)),H=new l.P(Math.min(k.x,D.x,N.x,L.x),Math.min(k.y,D.y,N.y,L.y)),W=q.sub(H),K=(c.width-(f.left+f.right+t.left+t.right))/W.x,re=(c.height-(f.top+f.bottom+t.top+t.bottom))/W.y;if(re<0||K<0)return void ln();const Y=Math.min(l.at(c.scale*Math.min(K,re)),d.maxZoom),te=l.P.convert(d.offset),oe=new l.P((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(l.ap(o)),Q=te.add(oe).mult(c.scale/l.aq(Y));return{center:Ce(c.worldSize,g.add(b).div(2).sub(Q)),zoom:Y,bearing:o}}class Vn{get useGlobeControls(){return!1}handlePanInertia(t,n){const o=t.mag(),c=Math.abs(be(n));return{easingOffset:t.mult(Math.min(.75*c/o,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(t,n){t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta),t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta)}handleMapControlsPan(t,n,o){t.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(o,t.around)}cameraForBoxAndBearing(t,n,o,c,f){return _l(t,n,o,c,f)}handleJumpToCenterZoom(t,n){t.zoom!==(n.zoom!==void 0?+n.zoom:t.zoom)&&t.setZoom(+n.zoom),n.center!==void 0&&t.setCenter(l.V.convert(n.center))}handleEaseTo(t,n){const o=t.zoom,c=t.padding,f={roll:t.roll,pitch:t.pitch,bearing:t.bearing},g={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},v=n.zoom!==void 0,b=!t.isPaddingEqual(n.padding);let P=!1;const E=v?+n.zoom:t.zoom;let k=t.centerPoint.add(n.offsetAsPoint);const D=t.screenPointToLocation(k),{center:L,zoom:N}=t.applyConstrain(l.V.convert(n.center||D),E??o);xn(t,L);const q=he(t.worldSize,D),H=he(t.worldSize,L).sub(q),W=l.aq(N-o);return P=N!==o,{easeFunc:K=>{if(P&&t.setZoom(l.G.number(o,N,K)),l.bo(f,g)||Wc({startEulerAngles:f,endEulerAngles:g,tr:t,k:K,useSlerp:f.roll!=g.roll}),b&&(t.interpolatePadding(c,n.padding,K),k=t.centerPoint.add(n.offsetAsPoint)),n.around)t.setLocationAtPoint(n.around,n.aroundPoint);else{const re=l.aq(t.zoom-o),Y=N>o?Math.min(2,W):Math.max(.5,W),te=Math.pow(Y,1-K),oe=Ce(t.worldSize,q.add(H.mult(K*te)).mult(re));t.setLocationAtPoint(t.renderWorldCopies?oe.wrap():oe,k)}},isZooming:P,elevationCenter:L}}handleFlyTo(t,n){const o=n.zoom!==void 0,c=t.zoom,f=t.applyConstrain(l.V.convert(n.center||n.locationAtOffset),o?+n.zoom:c),g=f.center,v=f.zoom;xn(t,g);const b=he(t.worldSize,n.locationAtOffset),P=he(t.worldSize,g).sub(b),E=P.mag(),k=l.aq(v-c);let D;if(n.minZoom!==void 0){const L=Math.min(+n.minZoom,c,v),N=t.applyConstrain(g,L).zoom;D=l.aq(N-c)}return{easeFunc:(L,N,q,H)=>{t.setZoom(L===1?v:c+l.at(N));const W=L===1?g:Ce(t.worldSize,b.add(P.mult(q)).mult(N));t.setLocationAtPoint(t.renderWorldCopies?W.wrap():W,H)},scaleOfZoom:k,targetCenter:g,scaleOfMinZoom:D,pixelPathLength:E}}}class Lt{constructor(t,n,o){this.blendFunction=t,this.blendColor=n,this.mask=o}}Lt.Replace=[1,0],Lt.disabled=new Lt(Lt.Replace,l.bp.transparent,[!1,!1,!1,!1]),Lt.unblended=new Lt(Lt.Replace,l.bp.transparent,[!0,!0,!0,!0]),Lt.alphaBlended=new Lt([1,771],l.bp.transparent,[!0,!0,!0,!0]);const xs=2305;class yt{constructor(t,n,o){this.enable=t,this.mode=n,this.frontFace=o}}yt.disabled=new yt(!1,1029,xs),yt.backCCW=new yt(!0,1029,xs),yt.frontCCW=new yt(!0,1028,xs);class ut{constructor(t,n,o){this.func=t,this.mask=n,this.range=o}}ut.ReadOnly=!1,ut.ReadWrite=!0,ut.disabled=new ut(519,ut.ReadOnly,[0,1]);const bs=7680;class vt{constructor(t,n,o,c,f,g){this.test=t,this.ref=n,this.mask=o,this.fail=c,this.depthFail=f,this.pass=g}}vt.disabled=new vt({func:519,mask:0},0,0,bs,bs,bs);const oo=new WeakMap;function Pi(d){var t;if(oo.has(d))return oo.get(d);{const n=(t=d.getParameter(d.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return oo.set(d,n),n}}class ws{get awaitingQuery(){return!!this._readbackQueue}constructor(t){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=t;const n=t.context,o=n.gl;this._texFormat=o.RGBA,this._texType=o.UNSIGNED_BYTE;const c=new l.aW;c.emplaceBack(-1,-1),c.emplaceBack(2,-1),c.emplaceBack(-1,2);const f=new l.aY;f.emplaceBack(0,1,2),this._fullscreenTriangle=new Ft(n.createVertexBuffer(c,vn.members),n.createIndexBuffer(f),l.aX.simpleSegment(0,0,c.length,f.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(o.TEXTURE1);const g=o.createTexture();o.bindTexture(o.TEXTURE_2D,g),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texImage2D(o.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(g),Pi(o)&&(this._pbo=o.createBuffer(),o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.bufferData(o.PIXEL_PACK_BUFFER,4,o.STREAM_READ),o.bindBuffer(o.PIXEL_PACK_BUFFER,null))}destroy(){const t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,n){const o=this._updateCount;return this._readbackQueue?o>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():o>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,n),this._updateCount++,this._measuredError}_bindFramebuffer(){const t=this._cachedRenderContext.context,n=t.gl;t.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,n){const o=this._cachedRenderContext.context,c=o.gl;if(this._bindFramebuffer(),o.viewport.set([0,0,this._texWidth,this._texHeight]),o.clear({color:l.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(o,c.TRIANGLES,ut.disabled,vt.disabled,Lt.unblended,yt.disabled,((f,g)=>({u_input:f,u_output_expected:g}))(t,n),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Pi(c)){c.bindBuffer(c.PIXEL_PACK_BUFFER,this._pbo),c.readBuffer(c.COLOR_ATTACHMENT0),c.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null);const f=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);c.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:f}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const t=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Pi(t)){const n=t.clientWaitSync(this._readbackQueue.sync,0,0);if(n===t.WAIT_FAILED)return l.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===t.TIMEOUT_EXPIRED)return;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),t.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ws._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(t){let n=0;return n+=t[0]/256,n+=t[1]/65536,n+=t[2]/16777216,t[3]<127&&(n=-n),n/128}}const bn=l.a5/128;function Hc(d,t){const n=d.granularity!==void 0?Math.max(d.granularity,1):1,o=n+(d.generateBorders?2:0),c=n+(d.extendToNorthPole||d.generateBorders?1:0)+(d.extendToSouthPole||d.generateBorders?1:0),f=o+1,g=c+1,v=d.generateBorders?-1:0,b=d.generateBorders||d.extendToNorthPole?-1:0,P=n+(d.generateBorders?1:0),E=n+(d.generateBorders||d.extendToSouthPole?1:0),k=f*g,D=o*c*6,L=f*g>65536;if(L&&t==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const N=L||t==="32bit",q=new Int16Array(2*k);let H=0;for(let re=b;re<=E;re++)for(let Y=v;Y<=P;Y++){let te=Y/n*l.a5;Y===-1&&(te=-bn),Y===n+1&&(te=l.a5+bn);let oe=re/n*l.a5;re===-1&&(oe=d.extendToNorthPole?l.br:-bn),re===n+1&&(oe=d.extendToSouthPole?l.bs:l.a5+bn),q[H++]=te,q[H++]=oe}const W=N?new Uint32Array(D):new Uint16Array(D);let K=0;for(let re=0;re<c;re++)for(let Y=0;Y<o;Y++){const te=Y+1+re*f,oe=Y+(re+1)*f,Q=Y+1+(re+1)*f;W[K++]=Y+re*f,W[K++]=oe,W[K++]=te,W[K++]=te,W[K++]=oe,W[K++]=Q}return{vertices:q.buffer.slice(0),indices:W.buffer.slice(0),uses32bitIndices:N}}const ao=new l.aV({fill:new l.bt(128,2),line:new l.bt(512,0),tile:new l.bt(128,32),stencil:new l.bt(128,1),circle:3});class yl{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return tr.projectionGlobe}get vertexShaderPreludeCode(){return tr.projectionMercator.vertexSource}get subdivisionGranularity(){return ao}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new ws(t));const n=l.X(this._errorQueryLatitudeDegrees),o=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,c=this._errorMeasurement.updateErrorLoop(n,o),f=Qe();c!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=c,this._errorMeasurementLastChangeTime=f);const g=Math.min(Math.max((f-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=l.bu(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,l.bv(g))}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,n,o,c,f){const g=(f==="stencil"?ao.stencil:ao.tile).getGranularityForZoomLevel(n.z);return this._getMesh(t,{granularity:g,generateBorders:o,extendToNorthPole:n.y===0&&c,extendToSouthPole:n.y===(1<<n.z)-1&&c})}_getMesh(t,n){const o=this._getMeshKey(n);if(o in this._tileMeshCache)return this._tileMeshCache[o];const c=(function(f,g){const v=Hc(g,"16bit"),b=l.aW.deserialize({arrayBuffer:v.vertices,length:v.vertices.byteLength/2/2}),P=l.aY.deserialize({arrayBuffer:v.indices,length:v.indices.byteLength/2/3});return new Ft(f.createVertexBuffer(b,vn.members),f.createIndexBuffer(P),l.aX.simpleSegment(0,0,b.length,P.length))})(t,n);return this._tileMeshCache[o]=c,c}recalculate(t){}hasTransition(){const t=Qe();let n=!1;return n=n||(t-this._errorMeasurementLastChangeTime)/1e3<.7,n=n||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,n}setErrorQueryLatitudeDegrees(t){this._errorQueryLatitudeDegrees=t}}const zh=new l.t({type:new l.D(l.u.projection.type)});class Xc extends l.E{constructor(t){super(),this._transitionable=new l.x(zh,void 0),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new l.H(0)),this._mercatorProjection=new ii,this._verticalPerspectiveProjection=new yl}get transitionState(){const t=this.properties.get("type");if(typeof t=="string"&&t==="mercator")return 0;if(typeof t=="string"&&t==="vertical-perspective")return 1;if(t instanceof l.bw){if(t.from==="vertical-perspective"&&t.to==="mercator")return 1-t.transition;if(t.from==="mercator"&&t.to==="vertical-perspective")return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,n,o,c,f){return this.currentProjection.getMeshFromTileID(t,n,o,c,f)}setProjection(t){this._transitionable.setValue("type",t?.type||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}}function ni(d){const t=$n(d.worldSize,d.center.lat);return 2*Math.PI*t}function Qi(d,t,n,o,c){const f=1/(1<<c),g=t/l.a5*f+o*f,v=l.bz((d/l.a5*f+n*f)*Math.PI*2+Math.PI,2*Math.PI),b=2*Math.atan(Math.exp(Math.PI-g*Math.PI*2))-.5*Math.PI,P=Math.cos(b),E=new Float64Array(3);return E[0]=Math.sin(v)*P,E[1]=Math.sin(b),E[2]=Math.cos(v)*P,E}function Ht(d){return(function(t,n){const o=Math.cos(n),c=new Float64Array(3);return c[0]=Math.sin(t)*o,c[1]=Math.sin(n),c[2]=Math.cos(t)*o,c})(d.lng*Math.PI/180,d.lat*Math.PI/180)}function $n(d,t){return d/(2*Math.PI)/Math.cos(t*Math.PI/180)}function vl(d){const t=Math.asin(d[1])/Math.PI*180,n=Math.sqrt(d[0]*d[0]+d[2]*d[2]);if(n>1e-6){const o=d[0]/n,c=Math.acos(d[2]/n),f=(o>0?c:-c)/Math.PI*180;return new l.V(l.W(f,-180,180),t)}return new l.V(0,t)}function lo(d){return Math.cos(d*Math.PI/180)}function cr(d,t){const n=lo(d),o=lo(t);return l.at(o/n)}function Yc(d,t){const n=d.rotate(t.bearingInRadians),o=t.zoom+cr(t.center.lat,0),c=l.bu(1/lo(t.center.lat),1/lo(Math.min(Math.abs(t.center.lat),60)),l.bx(o,7,3,0,1)),f=360/ni({worldSize:t.worldSize,center:{lat:t.center.lat}});return new l.V(t.center.lng-n.x*f*c,l.an(t.center.lat+n.y*f,-l.ao,l.ao))}function xl(d){const t=.5*d,n=Math.sin(t),o=Math.cos(t);return Math.log(n+o)-Math.log(o-n)}function Kc(d,t,n,o){const c=d.lat+n*o;if(Math.abs(n)>1){const f=(Math.sign(d.lat+n)!==Math.sign(d.lat)?-Math.abs(d.lat):Math.abs(d.lat))*Math.PI/180,g=Math.abs(d.lat+n)*Math.PI/180,v=xl(f+o*(g-f)),b=xl(f),P=xl(g);return new l.V(d.lng+t*((v-b)/(P-b)),c)}return new l.V(d.lng+t*o,c)}class Dh{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;const t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,n,o,c){const f=`${t.z}_${t.x}_${t.y}_${c?.terrain?"t":""}`,g=this._cache.get(f);if(g)return g;const v=this._cachePrevious.get(f);if(v)return this._cache.set(f,v),v;const b=this._boundingVolumeFactory(t,n,o,c);return this._cache.set(f,b),this._hadAnyChanges=!0,b}}class Ts{constructor(t,n,o,c){this.min=o,this.max=c,this.points=t,this.planes=n}static fromAabb(t,n){const o=[];for(let c=0;c<8;c++)o.push([1&~c?t[0]:n[0],(c>>1&1)==1?n[1]:t[1],(c>>2&1)==1?n[2]:t[2]]);return new Ts(o,[[-1,0,0,n[0]],[1,0,0,-t[0]],[0,-1,0,n[1]],[0,1,0,-t[1]],[0,0,-1,n[2]],[0,0,1,-t[2]]],t,n)}static fromCenterSizeAngles(t,n,o){const c=l.bB([],o[0],o[1],o[2]),f=l.bC([],[n[0],0,0],c),g=l.bC([],[0,n[1],0],c),v=l.bC([],[0,0,n[2]],c),b=[...t],P=[...t];for(let k=0;k<8;k++)for(let D=0;D<3;D++){const L=t[D]+f[D]*(1&~k?-1:1)+g[D]*((k>>1&1)==1?1:-1)+v[D]*((k>>2&1)==1?1:-1);b[D]=Math.min(b[D],L),P[D]=Math.max(P[D],L)}const E=[];for(let k=0;k<8;k++){const D=[...t];l.b0(D,D,l.a$([],f,1&~k?-1:1)),l.b0(D,D,l.a$([],g,(k>>1&1)==1?1:-1)),l.b0(D,D,l.a$([],v,(k>>2&1)==1?1:-1)),E.push(D)}return new Ts(E,[[...f,-l.b5(f,E[0])],[...g,-l.b5(g,E[0])],[...v,-l.b5(v,E[0])],[-f[0],-f[1],-f[2],-l.b5(f,E[7])],[-g[0],-g[1],-g[2],-l.b5(g,E[7])],[-v[0],-v[1],-v[2],-l.b5(v,E[7])]],b,P)}intersectsFrustum(t){let n=!0;const o=this.points.length,c=this.planes.length,f=t.planes.length,g=t.points.length;for(let v=0;v<f;v++){const b=t.planes[v];let P=0;for(let E=0;E<o;E++){const k=this.points[E];b[0]*k[0]+b[1]*k[1]+b[2]*k[2]+b[3]>=0&&P++}if(P===0)return 0;P<o&&(n=!1)}if(n)return 2;for(let v=0;v<c;v++){const b=this.planes[v];let P=0;for(let E=0;E<g;E++){const k=t.points[E];b[0]*k[0]+b[1]*k[1]+b[2]*k[2]+b[3]>=0&&P++}if(P===0)return 0}return 1}intersectsPlane(t){const n=this.points.length;let o=0;for(let c=0;c<n;c++){const f=this.points[c];t[0]*f[0]+t[1]*f[1]+t[2]*f[2]+t[3]>=0&&o++}return o===n?2:o===0?0:1}}function sa(d,t,n){const o=d-t;return o<0?-o:Math.max(0,o-n)}function Ss(d,t,n,o,c){const f=d-n;let g;return g=f<0?Math.min(-f,1+f-c):f>1?Math.min(Math.max(f-c,0),1-f):0,Math.max(g,sa(t,o,c))}class bl{constructor(){this._boundingVolumeCache=new Dh(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,n,o,c){const f=1<<o.z,g=1/f,v=o.x/f,b=o.y/f;let P=2;return P=Math.min(P,Ss(t,n,v,b,g)),P=Math.min(P,Ss(t,n,v+.5,-b-g,g)),P=Math.min(P,Ss(t,n,v+.5,2-b-g,g)),P}getWrap(t,n,o){const c=1<<n.z,f=1/c,g=n.x/c,v=sa(t.x,g,f),b=sa(t.x,g-1,f),P=sa(t.x,g+1,f),E=Math.min(v,b,P);return E===P?1:E===b?-1:0}allowVariableZoom(t,n){return or(t,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,n,o,c){return this._boundingVolumeCache.getTileBoundingVolume(t,n,o,c)}_computeTileBoundingVolume(t,n,o,c){var f,g;let v=0,b=0;if(c?.terrain){const P=new l.a2(t.z,n,t.z,t.x,t.y),E=c.terrain.getMinMaxElevation(P);v=(f=E.minElevation)!==null&&f!==void 0?f:Math.min(0,o),b=(g=E.maxElevation)!==null&&g!==void 0?g:Math.max(0,o)}if(v/=l.bE,b/=l.bE,v+=1,b+=1,t.z<=0)return Ts.fromAabb([-b,-b,-b],[b,b,b]);if(t.z===1)return Ts.fromAabb([t.x===0?-b:0,t.y===0?0:-b,-b],[t.x===0?0:b,t.y===0?b:0,b]);{const P=[Qi(0,0,t.x,t.y,t.z),Qi(l.a5,0,t.x,t.y,t.z),Qi(l.a5,l.a5,t.x,t.y,t.z),Qi(0,l.a5,t.x,t.y,t.z)],E=[];for(const _e of P)E.push(l.a$([],_e,b));if(b!==v)for(const _e of P)E.push(l.a$([],_e,v));t.y===0&&E.push([0,1,0]),t.y===(1<<t.z)-1&&E.push([0,-1,0]);const k=[1,1,1],D=[-1,-1,-1];for(const _e of E)for(let ye=0;ye<3;ye++)k[ye]=Math.min(k[ye],_e[ye]),D[ye]=Math.max(D[ye],_e[ye]);const L=Qi(l.a5/2,l.a5/2,t.x,t.y,t.z),N=l.b4([],[0,1,0],L);l.b3(N,N);const q=l.b4([],L,N);l.b3(q,q);const H=l.b4([],P[2],P[1]);l.b3(H,H);const W=l.b4([],P[0],P[3]);l.b3(W,W),E.push(l.a$([],L,b)),t.y>=(1<<t.z)/2&&E.push(l.a$([],Qi(l.a5/2,0,t.x,t.y,t.z),b)),t.y<(1<<t.z)/2&&E.push(l.a$([],Qi(l.a5/2,l.a5,t.x,t.y,t.z),b));const K=co(L,E),re=co(q,E),Y=[-L[0],-L[1],-L[2],K.max],te=[L[0],L[1],L[2],-K.min],oe=[-q[0],-q[1],-q[2],re.max],Q=[q[0],q[1],q[2],-re.min],ae=[...H,0],ve=[...W,0],ge=[];return t.y===0?ge.push(l.bD(ve,ae,Y),l.bD(ve,ae,te)):ge.push(l.bD(oe,ae,Y),l.bD(oe,ae,te),l.bD(oe,ve,Y),l.bD(oe,ve,te)),t.y===(1<<t.z)-1?ge.push(l.bD(ve,ae,Y),l.bD(ve,ae,te)):ge.push(l.bD(Q,ae,Y),l.bD(Q,ae,te),l.bD(Q,ve,Y),l.bD(Q,ve,te)),new Ts(ge,[Y,te,oe,Q,ae,ve],k,D)}}}function co(d,t){let n=1/0,o=-1/0;for(const c of t){const f=l.b5(d,c);n=Math.min(n,f),o=Math.max(o,f)}return{min:n,max:o}}class Ps{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,n,o){return this._helper.interpolatePadding(t,n,o)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n){this._helper.resize(t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t){this._cachedClippingPlane=l.bF(),this._projectionMatrix=l.bj(),this._globeViewProjMatrix32f=l.bi(),this._globeViewProjMatrixNoCorrection=l.bj(),this._globeViewProjMatrixNoCorrectionInverted=l.bj(),this._globeProjMatrixInverted=l.bj(),this._cameraPosition=l.bA(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(n,o)=>{const c=l.an(n.lat,-l.ao,l.ao),f=l.an(+o,this.minZoom+cr(0,c),this.maxZoom);return{center:new l.V(n.lng,c),zoom:f}},this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new jn({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},t),this._coveringTilesDetailsProvider=new bl}clone(){const t=new Ps;return t.apply(this,!1),t}apply(t,n,o){this._globeLatitudeErrorCorrectionRadians=o||0,this._helper.apply(t,n)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=l.bA();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){const{overscaledTileID:n,applyGlobeMatrix:o}=t,c=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:c,clippingPlane:this._cachedClippingPlane,projectionTransition:o?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const n=this.pitchInRadians,o=this.cameraToCenterDistance/t,c=Math.sin(n)*o,f=Math.cos(n)*o+1,g=1/Math.sqrt(c*c+f*f)*1;let v=-c,b=f;const P=Math.sqrt(v*v+b*b);v/=P,b/=P;const E=[0,v,b];l.bG(E,E,[0,0,0],-this.bearingInRadians),l.bH(E,E,[0,0,0],-1*this.center.lat*Math.PI/180),l.bI(E,E,[0,0,0],this.center.lng*Math.PI/180);const k=1/l.b7(E);return l.a$(E,E,k),[...E,-g*k]}isLocationOccluded(t){return!this.isSurfacePointVisible(Ht(t))}transformLightDirection(t){const n=this._helper._center.lng*Math.PI/180,o=this._helper._center.lat*Math.PI/180,c=Math.cos(o),f=[Math.sin(n)*c,Math.sin(o),Math.cos(n)*c],g=[f[2],0,-f[0]],v=[0,0,0];l.b4(v,g,f),l.b3(g,g),l.b3(v,v);const b=[0,0,0];return l.b3(b,[g[0]*t[0]+v[0]*t[1]+f[0]*t[2],g[1]*t[0]+v[1]*t[1]+f[1]*t[2],g[2]*t[0]+v[2]*t[1]+f[2]*t[2]]),b}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,n,o){const c=(function(v,b,P){const E=1/(1<<P.z);return new l.a9(v/l.a5*E+P.x*E,b/l.a5*E+P.y*E)})(t,n,o.canonical),f=(g=c.y,[l.bz(c.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-g*Math.PI*2))-.5*Math.PI]);var g;return this.getCircleRadiusCorrection()/Math.cos(f[1])}projectTileCoordinates(t,n,o,c){const f=o.canonical,g=Qi(t,n,f.x,f.y,f.z),v=1+(c?c(t,n):0)/l.bE,b=[g[0]*v,g[1]*v,g[2]*v,1];l.aH(b,b,this._globeViewProjMatrixNoCorrection);const P=this._cachedClippingPlane,E=P[0]*g[0]+P[1]*g[1]+P[2]*g[2]+P[3]<0;return{point:new l.P(b[0]/b[3],b[1]/b[3]),signedDistanceFromCamera:b[3],isOccluded:E}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=$n(this.worldSize,this.center.lat),n=l.bk(),o=l.bk();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),l.be(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const c=this.centerOffset;n[8]=2*-c.x/this._helper._width,n[9]=2*c.y/this._helper._height,this._projectionMatrix=l.bf(n),this._globeProjMatrixInverted=l.bk(),l.aB(this._globeProjMatrixInverted,n),l.O(n,n,[0,0,-this.cameraToCenterDistance]),l.bg(n,n,this.rollInRadians),l.bh(n,n,-this.pitchInRadians),l.bg(n,n,this.bearingInRadians),l.O(n,n,[0,0,-t]);const f=l.bA();f[0]=t,f[1]=t,f[2]=t,l.bh(o,n,this.center.lat*Math.PI/180),l.bJ(o,o,-this.center.lng*Math.PI/180),l.Q(o,o,f),this._globeViewProjMatrixNoCorrection=o,l.bh(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),l.bJ(n,n,-this.center.lng*Math.PI/180),l.Q(n,n,f),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=l.bk(),l.aB(this._globeViewProjMatrixNoCorrectionInverted,o);const g=l.bA();this._cameraPosition=l.bA(),this._cameraPosition[2]=this.cameraToCenterDistance/t,l.bG(this._cameraPosition,this._cameraPosition,g,-this.rollInRadians),l.bH(this._cameraPosition,this._cameraPosition,g,this.pitchInRadians),l.bG(this._cameraPosition,this._cameraPosition,g,-this.bearingInRadians),l.b0(this._cameraPosition,this._cameraPosition,[0,0,1]),l.bH(this._cameraPosition,this._cameraPosition,g,-this.center.lat*Math.PI/180),l.bI(this._cameraPosition,this._cameraPosition,g,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);const v=l.bf(this._globeViewProjMatrixNoCorrectionInverted);l.Q(v,v,[1,1,-1]),this._cachedFrustum=ui.fromInvProjectionMatrix(v,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){l.w("calculateFogMatrix is not supported on globe projection.");const n=l.bk();return l.ar(n),n}getVisibleUnwrappedCoordinates(t){return[new l.bc(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t&&l.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){if(!this._globeViewProjMatrixNoCorrection)return 1;const o=Ht(t);l.a$(o,o,1+n/l.bE);const c=l.bF();return l.aH(c,[o[0],o[1],o[2],1],this._globeViewProjMatrixNoCorrection),c[2]/c[3]}populateCache(t){}getBounds(){const t=.5*this.width,n=.5*this.height,o=[new l.P(0,0),new l.P(t,0),new l.P(this.width,0),new l.P(this.width,n),new l.P(this.width,this.height),new l.P(t,this.height),new l.P(0,this.height),new l.P(0,n)],c=[];for(const k of o)c.push(this.unprojectScreenPoint(k));let f=0,g=0,v=0,b=0;const P=this.center;for(const k of c){const D=l.bK(P.lng,k.lng),L=l.bK(P.lat,k.lat);D<g&&(g=D),D>f&&(f=D),L<b&&(b=L),L>v&&(v=L)}const E=[P.lng+g,P.lat+b,P.lng+f,P.lat+v];return this.isSurfacePointOnScreen([0,1,0])&&(E[3]=90,E[0]=-180,E[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(E[1]=-90,E[0]=-180,E[2]=180),new er(E)}calculateCenterFromCameraLngLatAlt(t,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,o,c)}setLocationAtPoint(t,n){const o=Ht(this.unprojectScreenPoint(n)),c=Ht(t),f=l.bA();l.bL(f);const g=l.bA();l.bI(g,o,f,-this.center.lng*Math.PI/180),l.bH(g,g,f,this.center.lat*Math.PI/180);const v=c[0]*c[0]+c[2]*c[2],b=g[0]*g[0];if(v<b)return;const P=Math.sqrt(v-b),E=-P,k=l.bM(c[0],c[2],g[0],P),D=l.bM(c[0],c[2],g[0],E),L=l.bA();l.bI(L,c,f,-k);const N=l.bM(L[1],L[2],g[1],g[2]),q=l.bA();l.bI(q,c,f,-D);const H=l.bM(q[1],q[2],g[1],g[2]),W=.5*Math.PI,K=N>=-W&&N<=W,re=H>=-W&&H<=W;let Y,te;if(K&&re){const ve=this.center.lng*Math.PI/180,ge=this.center.lat*Math.PI/180;l.bN(k,ve)+l.bN(N,ge)<l.bN(D,ve)+l.bN(H,ge)?(Y=k,te=N):(Y=D,te=H)}else if(K)Y=k,te=N;else{if(!re)return;Y=D,te=H}const oe=Y/Math.PI*180,Q=te/Math.PI*180,ae=this.center.lat;this.setCenter(new l.V(oe,l.an(Q,-90,90))),this.setZoom(this.zoom+cr(ae,this.center.lat))}locationToScreenPoint(t,n){const o=Ht(t);if(n){const c=n.getElevationForLngLatZoom(t,this._helper._tileZoom);l.a$(o,o,1+c/l.bE)}return this._projectSurfacePointToScreen(o)}_projectSurfacePointToScreen(t){const n=l.bF();return l.aH(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new l.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,n){if(n){const o=n.pointCoordinate(t);if(o)return o}return l.a9.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,n){var o;return(o=this.screenPointToMercatorCoordinate(t,n))===null||o===void 0?void 0:o.toLngLat()}isPointOnMapSurface(t,n){const o=this._cameraPosition,c=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(o,c)}getRayDirectionFromPixel(t){const n=l.bF();n[0]=t.x/this.width*2-1,n[1]=-1*(t.y/this.height*2-1),n[2]=1,n[3]=1,l.aH(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];const o=l.bA();o[0]=n[0]-this._cameraPosition[0],o[1]=n[1]-this._cameraPosition[1],o[2]=n[2]-this._cameraPosition[2];const c=l.bA();return l.b3(c,o),c}isSurfacePointVisible(t){const n=this._cachedClippingPlane;return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;const n=l.bF();return l.aH(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(t,n){const o=l.b5(t,n),c=l.bA(),f=l.bA();l.a$(f,n,o),l.b2(c,t,f);const g=1-l.b5(c,c);if(g<0)return null;const v=l.b5(t,t)-1,b=-o+(o<0?1:-1)*Math.sqrt(g),P=v/b,E=b;return{tMin:Math.min(P,E),tMax:Math.max(P,E)}}unprojectScreenPoint(t){const n=this._cameraPosition,o=this.getRayDirectionFromPixel(t),c=this.rayPlanetIntersection(n,o);if(c){const E=l.bA();l.b0(E,n,[o[0]*c.tMin,o[1]*c.tMin,o[2]*c.tMin]);const k=l.bA();return l.b3(k,E),vl(k)}const f=this._cachedClippingPlane,g=f[0]*o[0]+f[1]*o[1]+f[2]*o[2],v=-l.bb(f,n)/g,b=l.bA();if(v>0)l.b0(b,n,[o[0]*v,o[1]*v,o[2]*v]);else{const E=l.bA();l.b0(E,n,[2*o[0],2*o[1],2*o[2]]);const k=l.bb(this._cachedClippingPlane,E);l.b2(b,E,[this._cachedClippingPlane[0]*k,this._cachedClippingPlane[1]*k,this._cachedClippingPlane[2]*k])}const P=(function(E){const k=l.bA();return k[0]=E[0]*-E[3],k[1]=E[1]*-E[3],k[2]=E[2]*-E[3],{center:k,radius:Math.sqrt(1-E[3]*E[3])}})(f);return vl((function(E,k,D){const L=l.bA();l.b2(L,D,E);const N=l.bA();return l.by(N,E,L,k/l.b9(L)),N})(P.center,P.radius,b))}getMatrixForModel(t,n){const o=l.V.convert(t),c=1/l.bE,f=l.bj();return l.bJ(f,f,o.lng/180*Math.PI),l.bh(f,f,-o.lat/180*Math.PI),l.O(f,f,[0,0,1+n/l.bE]),l.bh(f,f,.5*Math.PI),l.Q(f,f,[c,c,c]),f}getProjectionDataForCustomLayer(t=!0){const n=this.getProjectionData({overscaledTileID:new l.a2(0,0,0,0,0),applyGlobeMatrix:t});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(t){}}class Is{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,n,o){return this._helper.interpolatePadding(t,n,o)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,o=!0){this._helper.resize(t,n,o)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t,n){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(n,o)=>this.currentTransform.defaultConstrain(n,o),this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new jn({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},t),this._globeness=1,this._mercatorTransform=new Nn,this._verticalPerspectiveTransform=new Ps}clone(){const t=new Is;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this,!1),t}apply(t,n){this._helper.apply(t,n),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){const n=this._mercatorTransform.getProjectionData(t),o=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?o.mainMatrix:n.mainMatrix,clippingPlane:o.clippingPlane,tileMercatorCoords:o.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return l.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return l.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,n,o){const c=this._mercatorTransform.getPitchedTextCorrection(t,n,o),f=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,n,o);return l.bu(c,f,this._globeness)}projectTileCoordinates(t,n,o,c){return this.currentTransform.projectTileCoordinates(t,n,o,c)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this._mercatorTransform.recalculateZoomAndCenter(t),this._verticalPerspectiveTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){return this.currentTransform.lngLatToCameraDepth(t,n)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,o,c)}setLocationAtPoint(t,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,n),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(t,n),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,n){return this.currentTransform.locationToScreenPoint(t,n)}screenPointToMercatorCoordinate(t,n){return this.currentTransform.screenPointToMercatorCoordinate(t,n)}screenPointToLocation(t,n){return this.currentTransform.screenPointToLocation(t,n)}isPointOnMapSurface(t,n){return this.currentTransform.isPointOnMapSurface(t,n)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getMatrixForModel(t,n){return this.currentTransform.getMatrixForModel(t,n)}getProjectionDataForCustomLayer(t=!0){const n=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return n;const o=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return o.fallbackMatrix=n.mainMatrix,o}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class Mr{get useGlobeControls(){return!0}handlePanInertia(t,n){const o=Yc(t,n);return Math.abs(o.lng-n.center.lng)>180&&(o.lng=n.center.lng+179.5*Math.sign(o.lng-n.center.lng)),{easingCenter:o,easingOffset:new l.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,n){const o=t.around,c=n.screenPointToLocation(o);t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta);const f=n.zoom;t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta);const g=n.zoom-f;if(g===0)return;const v=l.bK(n.center.lng,c.lng),b=v/(Math.abs(v/180)+1),P=l.bK(n.center.lat,c.lat),E=n.getRayDirectionFromPixel(o),k=n.cameraPosition,D=-1*l.b5(k,E),L=l.bA();l.b0(L,k,[E[0]*D,E[1]*D,E[2]*D]);const N=l.b7(L)-1,q=Math.exp(.5*-Math.max(N-.3,0)),H=$n(n.worldSize,n.center.lat)/Math.min(n.width,n.height),W=l.bx(H,.9,.5,1,.25),K=(1-l.aq(-g))*Math.min(q,W),re=n.center.lat,Y=n.zoom,te=new l.V(n.center.lng+b*K,l.an(n.center.lat+P*K,-l.ao,l.ao));n.setLocationAtPoint(c,o);const oe=n.center,Q=l.bx(Math.abs(v),45,85,0,1),ae=l.bx(H,.75,.35,0,1),ve=Math.pow(Math.max(Q,ae),.25),ge=l.bK(oe.lng,te.lng),_e=l.bK(oe.lat,te.lat);n.setCenter(new l.V(oe.lng+ge*ve,oe.lat+_e*ve).wrap()),n.setZoom(Y+cr(re,n.center.lat))}handleMapControlsPan(t,n,o){if(!t.panDelta)return;const c=n.center.lat,f=n.zoom;n.setCenter(Yc(t.panDelta,n).wrap()),n.setZoom(f+cr(c,n.center.lat))}cameraForBoxAndBearing(t,n,o,c,f){const g=_l(t,n,o,c,f),v=n.left/f.width*2-1,b=(f.width-n.right)/f.width*2-1,P=n.top/f.height*-2+1,E=(f.height-n.bottom)/f.height*-2+1,k=l.bK(o.getWest(),o.getEast())<0,D=k?o.getEast():o.getWest(),L=k?o.getWest():o.getEast(),N=Math.max(o.getNorth(),o.getSouth()),q=Math.min(o.getNorth(),o.getSouth()),H=D+.5*l.bK(D,L),W=N+.5*l.bK(N,q),K=f.clone();K.setCenter(g.center),K.setBearing(g.bearing),K.setPitch(0),K.setRoll(0),K.setZoom(g.zoom);const re=K.modelViewProjectionMatrix,Y=[Ht(o.getNorthWest()),Ht(o.getNorthEast()),Ht(o.getSouthWest()),Ht(o.getSouthEast()),Ht(new l.V(L,W)),Ht(new l.V(D,W)),Ht(new l.V(H,N)),Ht(new l.V(H,q))],te=Ht(g.center);let oe=Number.POSITIVE_INFINITY;for(const Q of Y)v<0&&(oe=Mr.getLesserNonNegativeNonNull(oe,Mr.solveVectorScale(Q,te,re,"x",v))),b>0&&(oe=Mr.getLesserNonNegativeNonNull(oe,Mr.solveVectorScale(Q,te,re,"x",b))),P>0&&(oe=Mr.getLesserNonNegativeNonNull(oe,Mr.solveVectorScale(Q,te,re,"y",P))),E<0&&(oe=Mr.getLesserNonNegativeNonNull(oe,Mr.solveVectorScale(Q,te,re,"y",E)));if(Number.isFinite(oe)&&oe!==0)return g.zoom=K.zoom+l.at(oe),g;ln()}handleJumpToCenterZoom(t,n){const o=t.center.lat,c=t.applyConstrain(n.center?l.V.convert(n.center):t.center,t.zoom).center;t.setCenter(c.wrap());const f=n.zoom!==void 0?+n.zoom:t.zoom+cr(o,c.lat);t.zoom!==f&&t.setZoom(f)}handleEaseTo(t,n){const o=t.zoom,c=t.center,f=t.padding,g={roll:t.roll,pitch:t.pitch,bearing:t.bearing},v={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},b=n.zoom!==void 0,P=!t.isPaddingEqual(n.padding);let E=!1;const k=n.center?l.V.convert(n.center):c,D=t.applyConstrain(k,o).center;xn(t,D);const L=t.clone();L.setCenter(D),L.setZoom(b?+n.zoom:o+cr(c.lat,k.lat)),L.setBearing(n.bearing);const N=new l.P(l.an(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),l.an(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));L.setLocationAtPoint(D,N);const q=(n.offset&&n.offsetAsPoint.mag())>0?L.center:D,H=b?+n.zoom:o+cr(c.lat,q.lat),W=o+cr(c.lat,0),K=H+cr(q.lat,0),re=l.bK(c.lng,q.lng),Y=l.bK(c.lat,q.lat),te=l.aq(K-W);return E=H!==o,{easeFunc:oe=>{if(l.bo(g,v)||Wc({startEulerAngles:g,endEulerAngles:v,tr:t,k:oe,useSlerp:g.roll!=v.roll}),P&&t.interpolatePadding(f,n.padding,oe),n.around)l.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(n.around,n.aroundPoint);else{const Q=K>W?Math.min(2,te):Math.max(.5,te),ae=Math.pow(Q,1-oe),ve=Kc(c,re,Y,oe*ae);t.setCenter(ve.wrap())}if(E){const Q=l.G.number(W,K,oe)+cr(0,t.center.lat);t.setZoom(Q)}},isZooming:E,elevationCenter:q}}handleFlyTo(t,n){const o=n.zoom!==void 0,c=t.center,f=t.zoom,g=t.padding,v=!t.isPaddingEqual(n.padding),b=t.applyConstrain(l.V.convert(n.center||n.locationAtOffset),f).center,P=o?+n.zoom:t.zoom+cr(t.center.lat,b.lat),E=t.clone();E.setCenter(b),E.setZoom(P),E.setBearing(n.bearing);const k=new l.P(l.an(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),l.an(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));E.setLocationAtPoint(b,k);const D=E.center;xn(t,D);const L=(function(Y,te,oe){const Q=Ht(te),ae=Ht(oe),ve=l.b5(Q,ae),ge=Math.acos(ve),_e=ni(Y);return ge/(2*Math.PI)*_e})(t,c,D),N=f+cr(c.lat,0),q=P+cr(D.lat,0),H=l.aq(q-N);let W;if(typeof n.minZoom=="number"){const Y=+n.minZoom+cr(D.lat,0),te=Math.min(Y,N,q)+cr(0,D.lat),oe=t.applyConstrain(D,te).zoom+cr(D.lat,0);W=l.aq(oe-N)}const K=l.bK(c.lng,D.lng),re=l.bK(c.lat,D.lat);return{easeFunc:(Y,te,oe,Q)=>{const ae=Kc(c,K,re,oe);v&&t.interpolatePadding(g,n.padding,Y);const ve=Y===1?D:ae;t.setCenter(ve.wrap());const ge=N+l.at(te);t.setZoom(Y===1?P:ge+cr(0,ve.lat))},scaleOfZoom:H,targetCenter:D,scaleOfMinZoom:W,pixelPathLength:L}}static solveVectorScale(t,n,o,c,f){const g=c==="x"?[o[0],o[4],o[8],o[12]]:[o[1],o[5],o[9],o[13]],v=[o[3],o[7],o[11],o[15]],b=t[0]*g[0]+t[1]*g[1]+t[2]*g[2],P=t[0]*v[0]+t[1]*v[1]+t[2]*v[2],E=n[0]*g[0]+n[1]*g[1]+n[2]*g[2],k=n[0]*v[0]+n[1]*v[1]+n[2]*v[2];return E+f*P===b+f*k||v[3]*(b-E)+g[3]*(k-P)+b*k==E*P?null:(E+g[3]-f*k-f*v[3])/(E-b-f*k+f*P)}static getLesserNonNegativeNonNull(t,n){return n!==null&&n>=0&&n<t?n:t}}class Jc{constructor(t){this._globe=t,this._mercatorCameraHelper=new Vn,this._verticalPerspectiveCameraHelper=new Mr}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,n){return this.currentHelper.handlePanInertia(t,n)}handleMapControlsRollPitchBearingZoom(t,n){return this.currentHelper.handleMapControlsRollPitchBearingZoom(t,n)}handleMapControlsPan(t,n,o){this.currentHelper.handleMapControlsPan(t,n,o)}cameraForBoxAndBearing(t,n,o,c,f){return this.currentHelper.cameraForBoxAndBearing(t,n,o,c,f)}handleJumpToCenterZoom(t,n){this.currentHelper.handleJumpToCenterZoom(t,n)}handleEaseTo(t,n){return this.currentHelper.handleEaseTo(t,n)}handleFlyTo(t,n){return this.currentHelper.handleFlyTo(t,n)}}const Ms=(d,t)=>l.B(d,t&&t.filter((n=>n.identifier!=="source.canvas"))),uo=l.bO();class Zn extends l.E{constructor(t,n={}){var o,c;super(),this._rtlPluginLoaded=()=>{for(const g in this.tileManagers){const v=this.tileManagers[g].getSource().type;v!=="vector"&&v!=="geojson"||this.tileManagers[g].reload()}},this.map=t,this.dispatcher=new Xi(Hi(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((g,v)=>this.getGlyphs(g,v))),this.dispatcher.registerMessageHandler("GI",((g,v)=>this.getImages(g,v))),this.dispatcher.registerMessageHandler("GDA",((g,v)=>this.getDashes(g,v))),this.imageManager=new nr,this.imageManager.setEventedParent(this);const f=((o=t._container)===null||o===void 0?void 0:o.lang)||typeof document<"u"&&((c=document.documentElement)===null||c===void 0?void 0:c.lang)||void 0;this.glyphManager=new At(t._requestManager,n.localIdeographFontFamily,f),this.lineAtlas=new zt(256,512),this.crossTileSymbolIndex=new ci,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",l.bP()),$().on(ce,this._rtlPluginLoaded),this.on("data",(g=>{if(g.dataType!=="source"||g.sourceDataType!=="metadata")return;const v=this.tileManagers[g.sourceId];if(!v)return;const b=v.getSource();if(b&&b.vectorLayerIds)for(const P in this._layers){const E=this._layers[P];E.source===b.id&&this._validateLayer(E)}}))}_setInitialValues(){var t;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new l.bQ,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new(((t=this.crossTileSymbolIndex)===null||t===void 0?void 0:t.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,n){var o,c,f;this._checkLoaded();const g=n===null?(f=(c=(o=this.stylesheet.state)===null||o===void 0?void 0:o[t])===null||c===void 0?void 0:c.default)!==null&&f!==void 0?f:null:n;if(l.bR(g,this._globalState[t]))return this;this._globalState[t]=g,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();const n=[];for(const o in t)!l.bR(this._globalState[o],t[o].default)&&(n.push(o),this._globalState[o]=t[o].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(t){if(t.length===0)return;const n=new Set,o={};for(const c of t){o[c]=this._globalState[c];for(const f in this._layers){const g=this._layers[f],v=g.getLayoutAffectingGlobalStateRefs(),b=g.getPaintAffectingGlobalStateRefs(),P=g.getVisibilityAffectingGlobalStateRefs();if(v.has(c)&&n.add(g.source),b.has(c))for(const{name:E,value:k}of b.get(c))this._updatePaintProperty(g,E,k);P?.has(c)&&(g.recalculateVisibility(),this._updateLayer(g))}}this.dispatcher.broadcast("UGS",o);for(const c in this.tileManagers)n.has(c)&&(this._reloadSource(c),this._changed=!0)}loadURL(t,n={},o){this.fire(new l.l("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const c=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const f=this._loadStyleRequest;l.j(c,this._loadStyleRequest).then((g=>{this._loadStyleRequest=null,this._load(g.data,n,o)})).catch((g=>{this._loadStyleRequest=null,g&&!f.signal.aborted&&this.fire(new l.k(g))}))}loadJSON(t,n={},o){this.fire(new l.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,Ze.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,o)})).catch((()=>{}))}loadEmpty(){this.fire(new l.l("dataloading",{dataType:"style"})),this._load(uo,{validate:!1})}_load(t,n,o){var c,f;let g=n.transformStyle?n.transformStyle(o,t):t;if(!n.validate||!Ms(this,l.C(g))){g=Object.assign({},g),this._loaded=!0,this.stylesheet=g;for(const v in g.sources)this.addSource(v,g.sources[v],{validate:!1});g.sprite?this._loadSprite(g.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(g.glyphs),this._createLayers(),this.light=new Di(this.stylesheet.light),this._setProjectionInternal(((c=this.stylesheet.projection)===null||c===void 0?void 0:c.type)||"mercator"),this.sky=new at(this.stylesheet.sky),this.map.setTerrain((f=this.stylesheet.terrain)!==null&&f!==void 0?f:null),this.fire(new l.l("data",{dataType:"style"})),this.fire(new l.l("style.load"))}}_createLayers(){var t,n,o;const c=l.bS(this.stylesheet.layers);this.setGlobalState((t=this.stylesheet.state)!==null&&t!==void 0?t:null),this.dispatcher.broadcast("SL",c),this._order=c.map((f=>f.id)),this._layers={},this._serializedLayers=null;for(const f of c){const g=l.bT(f,this._globalState);if(g.setEventedParent(this,{layer:{id:f.id}}),this._layers[f.id]=g,l.bU(g)&&this.tileManagers[g.source]){const v=(o=(n=f.paint)===null||n===void 0?void 0:n["raster-fade-duration"])!==null&&o!==void 0?o:g.paint.get("raster-fade-duration");this.tileManagers[g.source].setRasterFadeDuration(v)}}}_loadSprite(t,n=!1,o=void 0){this.imageManager.setLoaded(!1);const c=new AbortController;let f;this._spriteRequest=c,(function(g,v,b,P){return l._(this,void 0,void 0,(function*(){const E=wr(g),k=b>1?"@2x":"",D={},L={};for(const{id:N,url:q}of E){const H=v.transformRequest(ei(q,k,".json"),"SpriteJSON");D[N]=l.j(H,P);const W=v.transformRequest(ei(q,k,".png"),"SpriteImage");L[N]=mt.getImage(W,P)}return yield Promise.all([...Object.values(D),...Object.values(L)]),(function(N,q){return l._(this,void 0,void 0,(function*(){const H={};for(const W in N){H[W]={};const K=Ze.getImageCanvasContext((yield q[W]).data),re=(yield N[W]).data;for(const Y in re){const{width:te,height:oe,x:Q,y:ae,sdf:ve,pixelRatio:ge,stretchX:_e,stretchY:ye,content:Re,textFitWidth:Fe,textFitHeight:Ee}=re[Y];H[W][Y]={data:null,pixelRatio:ge,sdf:ve,stretchX:_e,stretchY:ye,content:Re,textFitWidth:Fe,textFitHeight:Ee,spriteData:{width:te,height:oe,x:Q,y:ae,context:K}}}}return H}))})(D,L)}))})(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((g=>{if(this._spriteRequest=null,g)for(const v in g){this._spritesImagesIds[v]=[];const b=this._spritesImagesIds[v]?this._spritesImagesIds[v].filter((P=>!(P in g))):[];for(const P of b)this.imageManager.removeImage(P),this._changedImages[P]=!0;for(const P in g[v]){const E=v==="default"?P:`${v}:${P}`;this._spritesImagesIds[v].push(E),E in this.imageManager.images?this.imageManager.updateImage(E,g[v][P],!1):this.imageManager.addImage(E,g[v][P]),n&&(this._changedImages[E]=!0)}}})).catch((g=>{this._spriteRequest=null,f=g,c.signal.aborted||this.fire(new l.k(f))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"})),o&&o(f)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}_validateLayer(t){const n=this.tileManagers[t.source];if(!n)return;const o=t.sourceLayer;if(!o)return;const c=n.getSource();(c.type==="geojson"||c.vectorLayerIds&&c.vectorLayerIds.indexOf(o)===-1)&&this.fire(new l.k(new Error(`Source layer "${o}" does not exist on source "${c.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t,n=!1){const o=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n?l.bV(o):o);const c=[];for(const f of t)if(o[f]){const g=n?l.bV(o[f]):o[f];c.push(g)}return c}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const o of n){const c=this._layers[o];c.type!=="custom"&&(t[o]=c.serialize())}return t}hasTransitions(){var t,n,o;if(!((t=this.light)===null||t===void 0)&&t.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((o=this.projection)===null||o===void 0)&&o.hasTransition())return!0;for(const c in this.tileManagers)if(this.tileManagers[c].hasTransition())return!0;for(const c in this._layers)if(this._layers[c].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(n){const c=Object.keys(this._updatedLayers),f=Object.keys(this._removedLayers);(c.length||f.length)&&this._updateWorkerLayers(c,f);for(const g in this._updatedSources){const v=this._updatedSources[g];if(v==="reload")this._reloadSource(g);else{if(v!=="clear")throw new Error(`Invalid action ${v}`);this._clearSource(g)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const g in this._updatedPaintProps)this._layers[g].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const o={};for(const c in this.tileManagers){const f=this.tileManagers[c];o[c]=f.used,f.used=!1}for(const c of this._order){const f=this._layers[c];f.recalculate(t,this._availableImages),!f.isHidden(t.zoom)&&f.source&&(this.tileManagers[f.source].used=!0)}for(const c in o){const f=this.tileManagers[c];!!o[c]!=!!f.used&&f.fire(new l.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:c}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,n&&this.fire(new l.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.tileManagers)this.tileManagers[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){var o;this._checkLoaded();const c=this.serialize();if(t=n.transformStyle?n.transformStyle(c,t):t,((o=n.validate)===null||o===void 0||o)&&Ms(this,l.C(t)))return!1;(t=l.bV(t)).layers=l.bS(t.layers);const f=l.bW(c,t),g=this._getOperationsToPerform(f);if(g.unimplemented.length>0)throw new Error(`Unimplemented: ${g.unimplemented.join(", ")}.`);if(g.operations.length===0)return!1;for(const v of g.operations)v();return this.stylesheet=t,this._serializedLayers=null,this.fire(new l.l("style.load",{style:this})),!0}_getOperationsToPerform(t){const n=[],o=[];for(const c of t)switch(c.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":n.push((()=>this.addLayer.apply(this,c.args)));break;case"removeLayer":n.push((()=>this.removeLayer.apply(this,c.args)));break;case"setPaintProperty":n.push((()=>this.setPaintProperty.apply(this,c.args)));break;case"setLayoutProperty":n.push((()=>this.setLayoutProperty.apply(this,c.args)));break;case"setFilter":n.push((()=>this.setFilter.apply(this,c.args)));break;case"addSource":n.push((()=>this.addSource.apply(this,c.args)));break;case"removeSource":n.push((()=>this.removeSource.apply(this,c.args)));break;case"setLayerZoomRange":n.push((()=>this.setLayerZoomRange.apply(this,c.args)));break;case"setLight":n.push((()=>this.setLight.apply(this,c.args)));break;case"setGeoJSONSourceData":n.push((()=>this.setGeoJSONSourceData.apply(this,c.args)));break;case"setGlyphs":n.push((()=>this.setGlyphs.apply(this,c.args)));break;case"setSprite":n.push((()=>this.setSprite.apply(this,c.args)));break;case"setTerrain":n.push((()=>this.map.setTerrain.apply(this,c.args)));break;case"setSky":n.push((()=>this.setSky.apply(this,c.args)));break;case"setProjection":this.setProjection.apply(this,c.args);break;case"setGlobalState":n.push((()=>this.setGlobalState.apply(this,c.args)));break;case"setTransition":n.push((()=>{}));break;default:o.push(c.command)}return{operations:n,unimplemented:o}}addImage(t,n){if(this.getImage(t))return this.fire(new l.k(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new l.k(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,o={}){if(this._checkLoaded(),this.tileManagers[t]!==void 0)throw new Error(`Source "${t}" already exists.`);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(l.C.source,`sources.${t}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const c=this.tileManagers[t]=new mr(t,n,this.dispatcher);c.style=this,c.setEventedParent(this,(()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:t}))),c.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw new Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===t)return this.fire(new l.k(new Error(`Source "${t}" cannot be removed while layer "${o}" is using it.`)));const n=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],n.fire(new l.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const o=this.tileManagers[t].getSource();if(o.type!=="geojson")throw new Error(`geojsonSource.type is ${o.type}, which is !== 'geojson`);o.setData(n),this._changed=!0}getSource(t){return this.tileManagers[t]&&this.tileManagers[t].getSource()}addLayer(t,n,o={}){this._checkLoaded();const c=t.id;if(this.getLayer(c))return void this.fire(new l.k(new Error(`Layer "${c}" already exists on this map.`)));let f;if(t.type==="custom"){if(Ms(this,l.bX(t)))return;f=l.bT(t,this._globalState)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(c,t.source),t=l.bV(t),t=l.e(t,{source:c})),this._validate(l.C.layer,`layers.${c}`,t,{arrayIndex:-1},o))return;f=l.bT(t,this._globalState),this._validateLayer(f),f.setEventedParent(this,{layer:{id:c}})}const g=n?this._order.indexOf(n):this._order.length;if(n&&g===-1)this.fire(new l.k(new Error(`Cannot add layer "${c}" before non-existing layer "${n}".`)));else{if(this._order.splice(g,0,c),this._layerOrderChanged=!0,this._layers[c]=f,this._removedLayers[c]&&f.source&&f.type!=="custom"){const v=this._removedLayers[c];delete this._removedLayers[c],v.type!==f.type?this._updatedSources[f.source]="clear":(this._updatedSources[f.source]="reload",this.tileManagers[f.source].pause())}this._updateLayer(f),f.onAdd&&f.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new l.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const o=this._order.indexOf(t);this._order.splice(o,1);const c=n?this._order.indexOf(n):this._order.length;n&&c===-1?this.fire(new l.k(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(c,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new l.k(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const o=this._order.indexOf(t);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,o){this._checkLoaded();const c=this.getLayer(t);c?c.minzoom===n&&c.maxzoom===o||(n!=null&&(c.minzoom=n),o!=null&&(c.maxzoom=o),this._updateLayer(c)):this.fire(new l.k(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,o={}){this._checkLoaded();const c=this.getLayer(t);if(c){if(!l.bR(c.filter,n))return n==null?(c.setFilter(void 0),void this._updateLayer(c)):void(this._validate(l.C.filter,`layers.${c.id}.filter`,n,null,o)||(c.setFilter(l.bV(n)),this._updateLayer(c)))}else this.fire(new l.k(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return l.bV(this.getLayer(t).filter)}setLayoutProperty(t,n,o,c={}){this._checkLoaded();const f=this.getLayer(t);f?l.bR(f.getLayoutProperty(n),o)||(f.setLayoutProperty(n,o,c),this._updateLayer(f)):this.fire(new l.k(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const o=this.getLayer(t);if(o)return o.getLayoutProperty(n);this.fire(new l.k(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,o,c={}){this._checkLoaded();const f=this.getLayer(t);f?l.bR(f.getPaintProperty(n),o)||this._updatePaintProperty(f,n,o,c):this.fire(new l.k(new Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,n,o,c={}){t.setPaintProperty(n,o,c)&&this._updateLayer(t),l.bU(t)&&n==="raster-fade-duration"&&this.tileManagers[t.source].setRasterFadeDuration(o),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const o=t.source,c=t.sourceLayer,f=this.tileManagers[o];if(f===void 0)return void this.fire(new l.k(new Error(`The source '${o}' does not exist in the map's style.`)));const g=f.getSource().type;g==="geojson"&&c?this.fire(new l.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):g!=="vector"||c?(t.id===void 0&&this.fire(new l.k(new Error("The feature id parameter must be provided."))),f.setFeatureState(c,t.id,n)):this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const o=t.source,c=this.tileManagers[o];if(c===void 0)return void this.fire(new l.k(new Error(`The source '${o}' does not exist in the map's style.`)));const f=c.getSource().type,g=f==="vector"?t.sourceLayer:void 0;f!=="vector"||g?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new l.k(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(g,t.id,n):this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,o=t.sourceLayer,c=this.tileManagers[n];if(c!==void 0)return c.getSource().type!=="vector"||o?(t.id===void 0&&this.fire(new l.k(new Error("The feature id parameter must be provided."))),c.getFeatureState(o,t.id)):void this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new l.k(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return l.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=l.bY(this.tileManagers,(f=>f.serialize())),n=this._serializeByIds(this._order,!0),o=this.map.getTerrain()||void 0,c=this.stylesheet;return l.bZ({version:c.version,name:c.name,metadata:c.metadata,light:c.light,sky:c.sky,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,projection:c.projection,sources:t,layers:n,terrain:o},(f=>f!==void 0))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.tileManagers[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=g=>this._layers[g].type==="fill-extrusion",o={},c=[];for(let g=this._order.length-1;g>=0;g--){const v=this._order[g];if(n(v)){o[v]=g;for(const b of t){const P=b[v];if(P)for(const E of P)c.push(E)}}}c.sort(((g,v)=>v.intersectionZ-g.intersectionZ));const f=[];for(let g=this._order.length-1;g>=0;g--){const v=this._order[g];if(n(v))for(let b=c.length-1;b>=0;b--){const P=c[b].feature;if(o[P.layer.id]<g)break;f.push(P),c.pop()}else for(const b of t){const P=b[v];if(P)for(const E of P)f.push(E.feature)}}return f}queryRenderedFeatures(t,n,o){n&&n.filter&&this._validate(l.C.filter,"queryRenderedFeatures.filter",n.filter,null,n);const c={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new l.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const P of n.layers){const E=this._layers[P];if(!E)return this.fire(new l.k(new Error(`The layer '${P}' does not exist in the map's style and cannot be queried for features.`))),[];c[E.source]=!0}}const f=[];n.availableImages=this._availableImages;const g=this._serializedAllLayers(),v=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,b=Object.assign(Object.assign({},n),{layers:v,globalState:this._globalState});for(const P in this.tileManagers)n.layers&&!c[P]||f.push(Ko(this.tileManagers[P],this._layers,g,t,b,o,this.map.terrain?(E,k,D)=>this.map.terrain.getElevation(E,k,D):void 0));return this.placement&&f.push((function(P,E,k,D,L,N,q){const H={},W=N.queryRenderedSymbols(D),K=[];for(const re of Object.keys(W).map(Number))K.push(q[re]);K.sort(Or);for(const re of K){const Y=re.featureIndex.lookupSymbolFeatures(W[re.bucketInstanceId],E,re.bucketIndex,re.sourceLayerIndex,{filterSpec:L.filter,globalState:L.globalState},L.layers,L.availableImages,P);for(const te in Y){const oe=H[te]=H[te]||[],Q=Y[te];Q.sort(((ae,ve)=>{const ge=re.featureSortOrder;if(ge){const _e=ge.indexOf(ae.featureIndex);return ge.indexOf(ve.featureIndex)-_e}return ve.featureIndex-ae.featureIndex}));for(const ae of Q)oe.push(ae)}}return(function(re,Y,te){for(const oe in re)for(const Q of re[oe])Si(Q,te[Y[oe].source]);return re})(H,P,k)})(this._layers,g,this.tileManagers,t,b,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(f)}querySourceFeatures(t,n){n?.filter&&this._validate(l.C.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this.tileManagers[t];return o?(function(c,f){const g=c.getRenderableIds().map((P=>c.getTileByID(P))),v=[],b={};for(let P=0;P<g.length;P++){const E=g[P],k=E.tileID.canonical.key;b[k]||(b[k]=!0,E.querySourceFeatures(v,f))}return v})(o,n?Object.assign(Object.assign({},n),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const o=this.light.getLight();let c=!1;for(const g in t)if(!l.bR(t[g],o[g])){c=!0;break}if(!c)return;const f={now:Qe(),transition:l.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(f)}getProjection(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.projection}setProjection(t){if(this._checkLoaded(),this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=t,this._setProjectionInternal(t.type)}getSky(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.sky}setSky(t,n={}){this._checkLoaded();const o=this.getSky();let c=!1;if(!t&&!o)return;if(t&&!o)c=!0;else if(!t&&o)c=!0;else for(const g in t)if(!l.bR(t[g],o[g])){c=!0;break}if(!c)return;const f={now:Qe(),transition:l.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,n),this.sky.updateTransitions(f)}_setProjectionInternal(t){const n=(function(o,c){const f={constrainOverride:c};if(Array.isArray(o)){const g=new Xc({type:o});return{projection:g,transform:new Is(f),cameraHelper:new Jc(g)}}switch(o){case"mercator":return{projection:new ii,transform:new Nn(f),cameraHelper:new Vn};case"globe":{const g=new Xc({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:g,transform:new Is(f),cameraHelper:new Jc(g)}}case"vertical-perspective":return{projection:new yl,transform:new Ps(f),cameraHelper:new Mr};default:return l.w(`Unknown projection name: ${o}. Falling back to mercator projection.`),{projection:new ii,transform:new Nn(f),cameraHelper:new Vn}}})(t,this.map.transformConstrain);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const o in this.tileManagers)this.tileManagers[o].reload()}_validate(t,n,o,c,f={}){return(!f||f.validate!==!1)&&Ms(this,t.call(l.C,l.e({key:n,style:this.serialize(),value:o,styleSpec:l.u},c)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),$().off(ce,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.tileManagers){const o=this.tileManagers[n];o.setEventedParent(null),o.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(const n in this.tileManagers)this.tileManagers[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,n,o,c,f=!1){let g=!1,v=!1;const b={};for(const P of this._order){const E=this._layers[P];if(E.type!=="symbol")continue;if(!b[E.source]){const D=this.tileManagers[E.source];b[E.source]=D.getRenderableIds(!0).map((L=>D.getTileByID(L))).sort(((L,N)=>N.tileID.overscaledZ-L.tileID.overscaledZ||(L.tileID.isLessThan(N.tileID)?-1:1)))}const k=this.crossTileSymbolIndex.addLayer(E,b[E.source],t.center.lng);g=g||k}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((f=f||this._layerOrderChanged||o===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Qe(),t.zoom))&&(this.pauseablePlacement=new ys(t,this.map.terrain,this._order,f,n,o,c,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,b),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Qe()),v=!0),g&&this.pauseablePlacement.placement.setStale()),v||g)for(const P of this._order){const E=this._layers[P];E.type==="symbol"&&this.placement.updateLayerOpacities(E,b[E.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Qe())}_releaseSymbolFadeTiles(){for(const t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}getImages(t,n){return l._(this,void 0,void 0,(function*(){const o=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const c=this.tileManagers[n.source];return c&&c.setDependencies(n.tileID.key,n.type,n.icons),o}))}getGlyphs(t,n){return l._(this,void 0,void 0,(function*(){const o=yield this.glyphManager.getGlyphs(n.stacks),c=this.tileManagers[n.source];return c&&c.setDependencies(n.tileID.key,n.type,[""]),o}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(l.C.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}getDashes(t,n){return l._(this,void 0,void 0,(function*(){const o={};for(const[c,f]of Object.entries(n.dashes))o[c]=this.lineAtlas.getDash(f.dasharray,f.round);return o}))}addSprite(t,n,o={},c){this._checkLoaded();const f=[{id:t,url:n}],g=[...wr(this.stylesheet.sprite),...f];this._validate(l.C.sprite,"sprite",g,null,o)||(this.stylesheet.sprite=g,this._loadSprite(f,!0,c))}removeSprite(t){this._checkLoaded();const n=wr(this.stylesheet.sprite);if(n.find((o=>o.id===t))){if(this._spritesImagesIds[t])for(const o of this._spritesImagesIds[t])this.imageManager.removeImage(o),this._changedImages[o]=!0;n.splice(n.findIndex((o=>o.id===t)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}else this.fire(new l.k(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return wr(this.stylesheet.sprite)}setSprite(t,n={},o){this._checkLoaded(),t&&this._validate(l.C.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,o):(this._unloadSprite(),o&&o(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const t in this.tileManagers){const n=this.tileManagers[t];n.setEventedParent(null),n.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const t in this._layers){const n=this._layers[t];n.setEventedParent(null),n.onRemove&&n.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var kh=l.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class oa{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,o,c,f,g,v,b,P){this.context=t;let E=this.boundPaintVertexBuffers.length!==c.length;for(let k=0;!E&&k<c.length;k++)this.boundPaintVertexBuffers[k]!==c[k]&&(E=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==o||E||this.boundIndexBuffer!==f||this.boundVertexOffset!==g||this.boundDynamicVertexBuffer!==v||this.boundDynamicVertexBuffer2!==b||this.boundDynamicVertexBuffer3!==P?this.freshBind(n,o,c,f,g,v,b,P):(t.bindVertexArray.set(this.vao),v&&v.bind(),f&&f.dynamicDraw&&f.bind(),b&&b.bind(),P&&P.bind())}freshBind(t,n,o,c,f,g,v,b){const P=t.numAttributes,E=this.context,k=E.gl;this.vao&&this.destroy(),this.vao=E.createVertexArray(),E.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=o,this.boundIndexBuffer=c,this.boundVertexOffset=f,this.boundDynamicVertexBuffer=g,this.boundDynamicVertexBuffer2=v,this.boundDynamicVertexBuffer3=b,n.enableAttributes(k,t);for(const D of o)D.enableAttributes(k,t);g&&g.enableAttributes(k,t),v&&v.enableAttributes(k,t),b&&b.enableAttributes(k,t),n.bind(),n.setVertexAttribPointers(k,t,f);for(const D of o)D.bind(),D.setVertexAttribPointers(k,t,f);g&&(g.bind(),g.setVertexAttribPointers(k,t,f)),c&&c.bind(),v&&(v.bind(),v.setVertexAttribPointers(k,t,f)),b&&(b.bind(),b.setVertexAttribPointers(k,t,f)),E.currentNumAttributes=P}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Rh=(d,t,n,o,c)=>({u_texture:0,u_ele_delta:d,u_fog_matrix:t,u_fog_color:n?n.properties.get("fog-color"):l.bp.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:c?0:n?n.calculateFogBlendOpacity(o):0,u_horizon_color:n?n.properties.get("horizon-color"):l.bp.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:c?1:0}),Es={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function aa(d){const t=[];for(let n=0;n<d.length;n++){if(d[n]===null)continue;const o=d[n].split(" ");t.push(o.pop())}return t}class Qc{constructor(t,n,o,c,f,g,v,b,P=[]){const E=t.gl;this.program=E.createProgram();const k=aa(n.staticAttributes),D=o?o.getBinderAttributes():[],L=k.concat(D),N=tr.prelude.staticUniforms?aa(tr.prelude.staticUniforms):[],q=v.staticUniforms?aa(v.staticUniforms):[],H=n.staticUniforms?aa(n.staticUniforms):[],W=o?o.getBinderUniforms():[],K=N.concat(q).concat(H).concat(W),re=[];for(const ge of K)re.indexOf(ge)<0&&re.push(ge);const Y=o?o.defines():[];Pi(E)&&Y.unshift("#version 300 es"),f&&Y.push("#define OVERDRAW_INSPECTOR;"),g&&Y.push("#define TERRAIN3D;"),b&&Y.push(b),P&&Y.push(...P);let te=Y.concat(tr.prelude.fragmentSource,v.fragmentSource,n.fragmentSource).join(`
|
|
848
|
+
`),oe=Y.concat(tr.prelude.vertexSource,v.vertexSource,n.vertexSource).join(`
|
|
849
|
+
`);Pi(E)||(te=(function(ge){return ge.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")})(te),oe=(function(ge){return ge.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")})(oe));const Q=E.createShader(E.FRAGMENT_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(Q,te),E.compileShader(Q),!E.getShaderParameter(Q,E.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${E.getShaderInfoLog(Q)}`);E.attachShader(this.program,Q);const ae=E.createShader(E.VERTEX_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(ae,oe),E.compileShader(ae),!E.getShaderParameter(ae,E.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${E.getShaderInfoLog(ae)}`);E.attachShader(this.program,ae),this.attributes={};const ve={};this.numAttributes=L.length;for(let ge=0;ge<this.numAttributes;ge++)L[ge]&&(E.bindAttribLocation(this.program,ge,L[ge]),this.attributes[L[ge]]=ge);if(E.linkProgram(this.program),!E.getProgramParameter(this.program,E.LINK_STATUS))throw new Error(`Program failed to link: ${E.getProgramInfoLog(this.program)}`);E.deleteShader(ae),E.deleteShader(Q);for(let ge=0;ge<re.length;ge++){const _e=re[ge];if(_e&&!ve[_e]){const ye=E.getUniformLocation(this.program,_e);ye&&(ve[_e]=ye)}}this.fixedUniforms=c(t,ve),this.terrainUniforms=((ge,_e)=>({u_depth:new l.b_(ge,_e.u_depth),u_terrain:new l.b_(ge,_e.u_terrain),u_terrain_dim:new l.bq(ge,_e.u_terrain_dim),u_terrain_matrix:new l.c0(ge,_e.u_terrain_matrix),u_terrain_unpack:new l.c1(ge,_e.u_terrain_unpack),u_terrain_exaggeration:new l.bq(ge,_e.u_terrain_exaggeration)}))(t,ve),this.projectionUniforms=((ge,_e)=>({u_projection_matrix:new l.c0(ge,_e.u_projection_matrix),u_projection_tile_mercator_coords:new l.c1(ge,_e.u_projection_tile_mercator_coords),u_projection_clipping_plane:new l.c1(ge,_e.u_projection_clipping_plane),u_projection_transition:new l.bq(ge,_e.u_projection_transition),u_projection_fallback_matrix:new l.c0(ge,_e.u_projection_fallback_matrix)}))(t,ve),this.binderUniforms=o?o.getUniforms(t,ve):[]}draw(t,n,o,c,f,g,v,b,P,E,k,D,L,N,q,H,W,K,re){const Y=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(o),t.setStencilMode(c),t.setColorMode(f),t.setCullFace(g),b){t.activeTexture.set(Y.TEXTURE2),Y.bindTexture(Y.TEXTURE_2D,b.depthTexture),t.activeTexture.set(Y.TEXTURE3),Y.bindTexture(Y.TEXTURE_2D,b.texture);for(const oe in this.terrainUniforms)this.terrainUniforms[oe].set(b[oe])}if(P)for(const oe in P)this.projectionUniforms[Es[oe]].set(P[oe]);if(v)for(const oe in this.fixedUniforms)this.fixedUniforms[oe].set(v[oe]);H&&H.setUniforms(t,this.binderUniforms,N,{zoom:q});let te=0;switch(n){case Y.LINES:te=2;break;case Y.TRIANGLES:te=3;break;case Y.LINE_STRIP:te=1}for(const oe of L.get()){const Q=oe.vaos||(oe.vaos={});(Q[E]||(Q[E]=new oa)).bind(t,this,k,H?H.getPaintVertexBuffers():[],D,oe.vertexOffset,W,K,re),Y.drawElements(n,oe.primitiveLength*te,Y.UNSIGNED_SHORT,oe.primitiveOffset*te*2)}}}function eu(d,t,n){const o=1/l.aN(n,1,t.transform.tileZoom),c=Math.pow(2,n.tileID.overscaledZ),f=n.tileSize*Math.pow(2,t.transform.tileZoom)/c,g=f*(n.tileID.canonical.x+n.tileID.wrap*c),v=f*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[o,d.fromScale,d.toScale],u_fade:d.t,u_pixel_coord_upper:[g>>16,v>>16],u_pixel_coord_lower:[65535&g,65535&v]}}const wl=(d,t,n,o)=>{const c=d.style.light,f=c.properties.get("position"),g=[f.x,f.y,f.z],v=l.c4();c.properties.get("anchor")==="viewport"&&l.c5(v,d.transform.bearingInRadians),l.c6(g,g,v);const b=d.transform.transformLightDirection(g),P=c.properties.get("color");return{u_lightpos:g,u_lightpos_globe:b,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[P.r,P.g,P.b],u_vertical_gradient:+t,u_opacity:n,u_fill_translate:o}},Tl=(d,t,n,o,c,f,g)=>l.e(wl(d,t,n,o),eu(f,d,g),{u_height_factor:-Math.pow(2,c.overscaledZ)/g.tileSize/8}),Sl=(d,t,n,o)=>l.e(eu(t,d,n),{u_fill_translate:o}),tu=(d,t)=>({u_world:d,u_fill_translate:t}),ru=(d,t,n,o,c)=>l.e(Sl(d,t,n,c),{u_world:o}),iu=(d,t,n,o,c)=>{const f=d.transform;let g,v,b=0;if(n.paint.get("circle-pitch-alignment")==="map"){const P=l.aN(t,1,f.zoom);g=!0,v=[P,P],b=P/(l.a5*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*c}else g=!1,v=f.pixelsToGLUnits;return{u_camera_to_center_distance:f.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+g,u_device_pixel_ratio:d.pixelRatio,u_extrude_scale:v,u_globe_extrude_scale:b,u_translate:o}},Un=d=>({u_pixel_extrude_scale:[1/d.width,1/d.height]}),nu=d=>({u_viewport_size:[d.width,d.height]}),Pl=(d,t=1)=>({u_color:d,u_overlay:0,u_overlay_scale:t}),Cs=(d,t,n,o)=>{const c=l.aN(d,1,t)/(l.a5*Math.pow(2,d.tileID.overscaledZ))*2*Math.PI*o;return{u_extrude_scale:l.aN(d,1,t),u_intensity:n,u_globe_extrude_scale:c}},su=(d,t,n,o)=>{const c=l.N();l.c7(c,0,d.width,d.height,0,0,1);const f=d.context.gl;return{u_matrix:c,u_world:[f.drawingBufferWidth,f.drawingBufferHeight],u_image:n,u_color_ramp:o,u_opacity:t.paint.get("heatmap-opacity")}},la=(d,t,n)=>{const o=n.paint.get("hillshade-accent-color");let c;switch(n.paint.get("hillshade-method")){case"basic":c=4;break;case"combined":c=1;break;case"igor":c=2;break;case"multidirectional":c=3;break;default:c=0}const f=n.getIlluminationProperties();for(let g=0;g<f.directionRadians.length;g++)n.paint.get("hillshade-illumination-anchor")==="viewport"&&(f.directionRadians[g]+=d.transform.bearingInRadians);return{u_image:0,u_latrange:Lh(0,t.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:f.altitudeRadians,u_azimuths:f.directionRadians,u_accent:o,u_method:c,u_highlights:f.highlightColor,u_shadows:f.shadowColor}},Fh=(d,t)=>{const n=t.stride,o=l.N();return l.c7(o,0,l.a5,-l.a5,0,0,1),l.O(o,o,[0,-l.a5,0]),{u_matrix:o,u_image:1,u_dimension:[n,n],u_zoom:d.overscaledZ,u_unpack:t.getUnpackVector()}};function Lh(d,t){const n=Math.pow(2,t.canonical.z),o=t.canonical.y;return[new l.a9(0,o/n).toLngLat().lat,new l.a9(0,(o+1)/n).toLngLat().lat]}const ou=(d,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:d.paint.get("color-relief-opacity")}),ho=(d,t,n,o)=>{const c=d.transform;return{u_translation:ua(d,t,n),u_ratio:o/l.aN(t,1,c.zoom),u_device_pixel_ratio:d.pixelRatio,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},au=(d,t,n,o,c)=>l.e(ho(d,t,n,o),{u_image:0,u_image_height:c}),Il=(d,t,n,o,c)=>{const f=d.transform,g=Li(t,f);return{u_translation:ua(d,t,n),u_texsize:t.imageAtlasTexture.size,u_ratio:o/l.aN(t,1,f.zoom),u_device_pixel_ratio:d.pixelRatio,u_image:0,u_scale:[g,c.fromScale,c.toScale],u_fade:c.t,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},lu=(d,t,n,o,c)=>{const f=Li(t,d.transform);return l.e(ho(d,t,n,o),{u_tileratio:f,u_crossfade_from:c.fromScale,u_crossfade_to:c.toScale,u_image:0,u_mix:c.t,u_lineatlas_width:d.lineAtlas.width,u_lineatlas_height:d.lineAtlas.height})},ca=(d,t,n,o,c,f)=>{const g=Li(t,d.transform);return l.e(ho(d,t,n,o),{u_image:0,u_image_height:f,u_tileratio:g,u_crossfade_from:c.fromScale,u_crossfade_to:c.toScale,u_image_dash:1,u_mix:c.t,u_lineatlas_width:d.lineAtlas.width,u_lineatlas_height:d.lineAtlas.height})};function Li(d,t){return 1/l.aN(d,1,t.tileZoom)}function ua(d,t,n){return l.aO(d.transform,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Ml=(d,t,n,o,c)=>{return{u_tl_parent:d,u_scale_parent:t,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(g=o.paint.get("raster-saturation"),g>0?1-1/(1.001-g):-g),u_contrast_factor:(f=o.paint.get("raster-contrast"),f>0?1/(1-f):1+f),u_spin_weights:El(o.paint.get("raster-hue-rotate")),u_coords_top:[c[0].x,c[0].y,c[1].x,c[1].y],u_coords_bottom:[c[3].x,c[3].y,c[2].x,c[2].y]};var f,g};function El(d){d*=Math.PI/180;const t=Math.sin(d),n=Math.cos(d);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const Cl=(d,t,n,o,c,f,g,v,b,P,E,k,D)=>{const L=g.transform;return{u_is_size_zoom_constant:+(d==="constant"||d==="source"),u_is_size_feature_constant:+(d==="constant"||d==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:L.cameraToCenterDistance,u_pitch:L.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:L.width/L.height,u_fade_change:g.options.fadeDuration?g.symbolFadeChange:1,u_label_plane_matrix:v,u_coord_matrix:b,u_is_text:+E,u_pitch_with_map:+o,u_is_along_line:c,u_is_variable_anchor:f,u_texsize:k,u_texture:0,u_translation:P,u_pitched_scale:D}},ha=(d,t,n,o,c,f,g,v,b,P,E,k,D,L)=>{const N=g.transform;return l.e(Cl(d,t,n,o,c,f,g,v,b,P,E,k,L),{u_gamma_scale:o?Math.cos(N.pitch*Math.PI/180)*N.cameraToCenterDistance:1,u_device_pixel_ratio:g.pixelRatio,u_is_halo:1})},Gn=(d,t,n,o,c,f,g,v,b,P,E,k,D)=>l.e(ha(d,t,n,o,c,f,g,v,b,P,!0,E,0,D),{u_texsize_icon:k,u_texture_icon:1}),Al=(d,t)=>({u_opacity:d,u_color:t}),Oh=(d,t,n,o,c)=>l.e((function(f,g,v,b){const P=v.imageManager.getPattern(f.from.toString()),E=v.imageManager.getPattern(f.to.toString()),{width:k,height:D}=v.imageManager.getPixelSize(),L=Math.pow(2,b.tileID.overscaledZ),N=b.tileSize*Math.pow(2,v.transform.tileZoom)/L,q=N*(b.tileID.canonical.x+b.tileID.wrap*L),H=N*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:P.tl,u_pattern_br_a:P.br,u_pattern_tl_b:E.tl,u_pattern_br_b:E.br,u_texsize:[k,D],u_mix:g.t,u_pattern_size_a:P.displaySize,u_pattern_size_b:E.displaySize,u_scale_a:g.fromScale,u_scale_b:g.toScale,u_tile_units_to_pixels:1/l.aN(b,1,v.transform.tileZoom),u_pixel_coord_upper:[q>>16,H>>16],u_pixel_coord_lower:[65535&q,65535&H]}})(n,c,t,o),{u_opacity:d}),cu=(d,t)=>{},Bh={fillExtrusion:(d,t)=>({u_lightpos:new l.c2(d,t.u_lightpos),u_lightpos_globe:new l.c2(d,t.u_lightpos_globe),u_lightintensity:new l.bq(d,t.u_lightintensity),u_lightcolor:new l.c2(d,t.u_lightcolor),u_vertical_gradient:new l.bq(d,t.u_vertical_gradient),u_opacity:new l.bq(d,t.u_opacity),u_fill_translate:new l.c3(d,t.u_fill_translate)}),fillExtrusionPattern:(d,t)=>({u_lightpos:new l.c2(d,t.u_lightpos),u_lightpos_globe:new l.c2(d,t.u_lightpos_globe),u_lightintensity:new l.bq(d,t.u_lightintensity),u_lightcolor:new l.c2(d,t.u_lightcolor),u_vertical_gradient:new l.bq(d,t.u_vertical_gradient),u_height_factor:new l.bq(d,t.u_height_factor),u_opacity:new l.bq(d,t.u_opacity),u_fill_translate:new l.c3(d,t.u_fill_translate),u_image:new l.b_(d,t.u_image),u_texsize:new l.c3(d,t.u_texsize),u_pixel_coord_upper:new l.c3(d,t.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(d,t.u_pixel_coord_lower),u_scale:new l.c2(d,t.u_scale),u_fade:new l.bq(d,t.u_fade)}),fill:(d,t)=>({u_fill_translate:new l.c3(d,t.u_fill_translate)}),fillPattern:(d,t)=>({u_image:new l.b_(d,t.u_image),u_texsize:new l.c3(d,t.u_texsize),u_pixel_coord_upper:new l.c3(d,t.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(d,t.u_pixel_coord_lower),u_scale:new l.c2(d,t.u_scale),u_fade:new l.bq(d,t.u_fade),u_fill_translate:new l.c3(d,t.u_fill_translate)}),fillOutline:(d,t)=>({u_world:new l.c3(d,t.u_world),u_fill_translate:new l.c3(d,t.u_fill_translate)}),fillOutlinePattern:(d,t)=>({u_world:new l.c3(d,t.u_world),u_image:new l.b_(d,t.u_image),u_texsize:new l.c3(d,t.u_texsize),u_pixel_coord_upper:new l.c3(d,t.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(d,t.u_pixel_coord_lower),u_scale:new l.c2(d,t.u_scale),u_fade:new l.bq(d,t.u_fade),u_fill_translate:new l.c3(d,t.u_fill_translate)}),circle:(d,t)=>({u_camera_to_center_distance:new l.bq(d,t.u_camera_to_center_distance),u_scale_with_map:new l.b_(d,t.u_scale_with_map),u_pitch_with_map:new l.b_(d,t.u_pitch_with_map),u_extrude_scale:new l.c3(d,t.u_extrude_scale),u_device_pixel_ratio:new l.bq(d,t.u_device_pixel_ratio),u_globe_extrude_scale:new l.bq(d,t.u_globe_extrude_scale),u_translate:new l.c3(d,t.u_translate)}),collisionBox:(d,t)=>({u_pixel_extrude_scale:new l.c3(d,t.u_pixel_extrude_scale)}),collisionCircle:(d,t)=>({u_viewport_size:new l.c3(d,t.u_viewport_size)}),debug:(d,t)=>({u_color:new l.b$(d,t.u_color),u_overlay:new l.b_(d,t.u_overlay),u_overlay_scale:new l.bq(d,t.u_overlay_scale)}),depth:cu,clippingMask:cu,heatmap:(d,t)=>({u_extrude_scale:new l.bq(d,t.u_extrude_scale),u_intensity:new l.bq(d,t.u_intensity),u_globe_extrude_scale:new l.bq(d,t.u_globe_extrude_scale)}),heatmapTexture:(d,t)=>({u_matrix:new l.c0(d,t.u_matrix),u_world:new l.c3(d,t.u_world),u_image:new l.b_(d,t.u_image),u_color_ramp:new l.b_(d,t.u_color_ramp),u_opacity:new l.bq(d,t.u_opacity)}),hillshade:(d,t)=>({u_image:new l.b_(d,t.u_image),u_latrange:new l.c3(d,t.u_latrange),u_exaggeration:new l.bq(d,t.u_exaggeration),u_altitudes:new l.c9(d,t.u_altitudes),u_azimuths:new l.c9(d,t.u_azimuths),u_accent:new l.b$(d,t.u_accent),u_method:new l.b_(d,t.u_method),u_shadows:new l.c8(d,t.u_shadows),u_highlights:new l.c8(d,t.u_highlights)}),hillshadePrepare:(d,t)=>({u_matrix:new l.c0(d,t.u_matrix),u_image:new l.b_(d,t.u_image),u_dimension:new l.c3(d,t.u_dimension),u_zoom:new l.bq(d,t.u_zoom),u_unpack:new l.c1(d,t.u_unpack)}),colorRelief:(d,t)=>({u_image:new l.b_(d,t.u_image),u_unpack:new l.c1(d,t.u_unpack),u_dimension:new l.c3(d,t.u_dimension),u_elevation_stops:new l.b_(d,t.u_elevation_stops),u_color_stops:new l.b_(d,t.u_color_stops),u_color_ramp_size:new l.b_(d,t.u_color_ramp_size),u_opacity:new l.bq(d,t.u_opacity)}),line:(d,t)=>({u_translation:new l.c3(d,t.u_translation),u_ratio:new l.bq(d,t.u_ratio),u_device_pixel_ratio:new l.bq(d,t.u_device_pixel_ratio),u_units_to_pixels:new l.c3(d,t.u_units_to_pixels)}),lineGradient:(d,t)=>({u_translation:new l.c3(d,t.u_translation),u_ratio:new l.bq(d,t.u_ratio),u_device_pixel_ratio:new l.bq(d,t.u_device_pixel_ratio),u_units_to_pixels:new l.c3(d,t.u_units_to_pixels),u_image:new l.b_(d,t.u_image),u_image_height:new l.bq(d,t.u_image_height)}),linePattern:(d,t)=>({u_translation:new l.c3(d,t.u_translation),u_texsize:new l.c3(d,t.u_texsize),u_ratio:new l.bq(d,t.u_ratio),u_device_pixel_ratio:new l.bq(d,t.u_device_pixel_ratio),u_image:new l.b_(d,t.u_image),u_units_to_pixels:new l.c3(d,t.u_units_to_pixels),u_scale:new l.c2(d,t.u_scale),u_fade:new l.bq(d,t.u_fade)}),lineSDF:(d,t)=>({u_translation:new l.c3(d,t.u_translation),u_ratio:new l.bq(d,t.u_ratio),u_device_pixel_ratio:new l.bq(d,t.u_device_pixel_ratio),u_units_to_pixels:new l.c3(d,t.u_units_to_pixels),u_image:new l.b_(d,t.u_image),u_mix:new l.bq(d,t.u_mix),u_tileratio:new l.bq(d,t.u_tileratio),u_crossfade_from:new l.bq(d,t.u_crossfade_from),u_crossfade_to:new l.bq(d,t.u_crossfade_to),u_lineatlas_width:new l.bq(d,t.u_lineatlas_width),u_lineatlas_height:new l.bq(d,t.u_lineatlas_height)}),lineGradientSDF:(d,t)=>({u_translation:new l.c3(d,t.u_translation),u_ratio:new l.bq(d,t.u_ratio),u_device_pixel_ratio:new l.bq(d,t.u_device_pixel_ratio),u_units_to_pixels:new l.c3(d,t.u_units_to_pixels),u_image:new l.b_(d,t.u_image),u_image_height:new l.bq(d,t.u_image_height),u_tileratio:new l.bq(d,t.u_tileratio),u_crossfade_from:new l.bq(d,t.u_crossfade_from),u_crossfade_to:new l.bq(d,t.u_crossfade_to),u_image_dash:new l.b_(d,t.u_image_dash),u_mix:new l.bq(d,t.u_mix),u_lineatlas_width:new l.bq(d,t.u_lineatlas_width),u_lineatlas_height:new l.bq(d,t.u_lineatlas_height)}),raster:(d,t)=>({u_tl_parent:new l.c3(d,t.u_tl_parent),u_scale_parent:new l.bq(d,t.u_scale_parent),u_buffer_scale:new l.bq(d,t.u_buffer_scale),u_fade_t:new l.bq(d,t.u_fade_t),u_opacity:new l.bq(d,t.u_opacity),u_image0:new l.b_(d,t.u_image0),u_image1:new l.b_(d,t.u_image1),u_brightness_low:new l.bq(d,t.u_brightness_low),u_brightness_high:new l.bq(d,t.u_brightness_high),u_saturation_factor:new l.bq(d,t.u_saturation_factor),u_contrast_factor:new l.bq(d,t.u_contrast_factor),u_spin_weights:new l.c2(d,t.u_spin_weights),u_coords_top:new l.c1(d,t.u_coords_top),u_coords_bottom:new l.c1(d,t.u_coords_bottom)}),symbolIcon:(d,t)=>({u_is_size_zoom_constant:new l.b_(d,t.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(d,t.u_is_size_feature_constant),u_size_t:new l.bq(d,t.u_size_t),u_size:new l.bq(d,t.u_size),u_camera_to_center_distance:new l.bq(d,t.u_camera_to_center_distance),u_pitch:new l.bq(d,t.u_pitch),u_rotate_symbol:new l.b_(d,t.u_rotate_symbol),u_aspect_ratio:new l.bq(d,t.u_aspect_ratio),u_fade_change:new l.bq(d,t.u_fade_change),u_label_plane_matrix:new l.c0(d,t.u_label_plane_matrix),u_coord_matrix:new l.c0(d,t.u_coord_matrix),u_is_text:new l.b_(d,t.u_is_text),u_pitch_with_map:new l.b_(d,t.u_pitch_with_map),u_is_along_line:new l.b_(d,t.u_is_along_line),u_is_variable_anchor:new l.b_(d,t.u_is_variable_anchor),u_texsize:new l.c3(d,t.u_texsize),u_texture:new l.b_(d,t.u_texture),u_translation:new l.c3(d,t.u_translation),u_pitched_scale:new l.bq(d,t.u_pitched_scale)}),symbolSDF:(d,t)=>({u_is_size_zoom_constant:new l.b_(d,t.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(d,t.u_is_size_feature_constant),u_size_t:new l.bq(d,t.u_size_t),u_size:new l.bq(d,t.u_size),u_camera_to_center_distance:new l.bq(d,t.u_camera_to_center_distance),u_pitch:new l.bq(d,t.u_pitch),u_rotate_symbol:new l.b_(d,t.u_rotate_symbol),u_aspect_ratio:new l.bq(d,t.u_aspect_ratio),u_fade_change:new l.bq(d,t.u_fade_change),u_label_plane_matrix:new l.c0(d,t.u_label_plane_matrix),u_coord_matrix:new l.c0(d,t.u_coord_matrix),u_is_text:new l.b_(d,t.u_is_text),u_pitch_with_map:new l.b_(d,t.u_pitch_with_map),u_is_along_line:new l.b_(d,t.u_is_along_line),u_is_variable_anchor:new l.b_(d,t.u_is_variable_anchor),u_texsize:new l.c3(d,t.u_texsize),u_texture:new l.b_(d,t.u_texture),u_gamma_scale:new l.bq(d,t.u_gamma_scale),u_device_pixel_ratio:new l.bq(d,t.u_device_pixel_ratio),u_is_halo:new l.b_(d,t.u_is_halo),u_translation:new l.c3(d,t.u_translation),u_pitched_scale:new l.bq(d,t.u_pitched_scale)}),symbolTextAndIcon:(d,t)=>({u_is_size_zoom_constant:new l.b_(d,t.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(d,t.u_is_size_feature_constant),u_size_t:new l.bq(d,t.u_size_t),u_size:new l.bq(d,t.u_size),u_camera_to_center_distance:new l.bq(d,t.u_camera_to_center_distance),u_pitch:new l.bq(d,t.u_pitch),u_rotate_symbol:new l.b_(d,t.u_rotate_symbol),u_aspect_ratio:new l.bq(d,t.u_aspect_ratio),u_fade_change:new l.bq(d,t.u_fade_change),u_label_plane_matrix:new l.c0(d,t.u_label_plane_matrix),u_coord_matrix:new l.c0(d,t.u_coord_matrix),u_is_text:new l.b_(d,t.u_is_text),u_pitch_with_map:new l.b_(d,t.u_pitch_with_map),u_is_along_line:new l.b_(d,t.u_is_along_line),u_is_variable_anchor:new l.b_(d,t.u_is_variable_anchor),u_texsize:new l.c3(d,t.u_texsize),u_texsize_icon:new l.c3(d,t.u_texsize_icon),u_texture:new l.b_(d,t.u_texture),u_texture_icon:new l.b_(d,t.u_texture_icon),u_gamma_scale:new l.bq(d,t.u_gamma_scale),u_device_pixel_ratio:new l.bq(d,t.u_device_pixel_ratio),u_is_halo:new l.b_(d,t.u_is_halo),u_translation:new l.c3(d,t.u_translation),u_pitched_scale:new l.bq(d,t.u_pitched_scale)}),background:(d,t)=>({u_opacity:new l.bq(d,t.u_opacity),u_color:new l.b$(d,t.u_color)}),backgroundPattern:(d,t)=>({u_opacity:new l.bq(d,t.u_opacity),u_image:new l.b_(d,t.u_image),u_pattern_tl_a:new l.c3(d,t.u_pattern_tl_a),u_pattern_br_a:new l.c3(d,t.u_pattern_br_a),u_pattern_tl_b:new l.c3(d,t.u_pattern_tl_b),u_pattern_br_b:new l.c3(d,t.u_pattern_br_b),u_texsize:new l.c3(d,t.u_texsize),u_mix:new l.bq(d,t.u_mix),u_pattern_size_a:new l.c3(d,t.u_pattern_size_a),u_pattern_size_b:new l.c3(d,t.u_pattern_size_b),u_scale_a:new l.bq(d,t.u_scale_a),u_scale_b:new l.bq(d,t.u_scale_b),u_pixel_coord_upper:new l.c3(d,t.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(d,t.u_pixel_coord_lower),u_tile_units_to_pixels:new l.bq(d,t.u_tile_units_to_pixels)}),terrain:(d,t)=>({u_texture:new l.b_(d,t.u_texture),u_ele_delta:new l.bq(d,t.u_ele_delta),u_fog_matrix:new l.c0(d,t.u_fog_matrix),u_fog_color:new l.b$(d,t.u_fog_color),u_fog_ground_blend:new l.bq(d,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new l.bq(d,t.u_fog_ground_blend_opacity),u_horizon_color:new l.b$(d,t.u_horizon_color),u_horizon_fog_blend:new l.bq(d,t.u_horizon_fog_blend),u_is_globe_mode:new l.bq(d,t.u_is_globe_mode)}),terrainDepth:(d,t)=>({u_ele_delta:new l.bq(d,t.u_ele_delta)}),terrainCoords:(d,t)=>({u_texture:new l.b_(d,t.u_texture),u_terrain_coords_id:new l.bq(d,t.u_terrain_coords_id),u_ele_delta:new l.bq(d,t.u_ele_delta)}),projectionErrorMeasurement:(d,t)=>({u_input:new l.bq(d,t.u_input),u_output_expected:new l.bq(d,t.u_output_expected)}),atmosphere:(d,t)=>({u_sun_pos:new l.c2(d,t.u_sun_pos),u_atmosphere_blend:new l.bq(d,t.u_atmosphere_blend),u_globe_position:new l.c2(d,t.u_globe_position),u_globe_radius:new l.bq(d,t.u_globe_radius),u_inv_proj_matrix:new l.c0(d,t.u_inv_proj_matrix)}),sky:(d,t)=>({u_sky_color:new l.b$(d,t.u_sky_color),u_horizon_color:new l.b$(d,t.u_horizon_color),u_horizon:new l.c3(d,t.u_horizon),u_horizon_normal:new l.c3(d,t.u_horizon_normal),u_sky_horizon_blend:new l.bq(d,t.u_sky_horizon_blend),u_sky_blend:new l.bq(d,t.u_sky_blend)})};class jh{constructor(t,n,o){this.context=t;const c=t.gl;this.buffer=c.createBuffer(),this.dynamicDraw=!!o,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const uu={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Nh{constructor(t,n,o,c){this.length=n.length,this.attributes=o,this.itemSize=n.bytesPerElement,this.dynamicDraw=c,this.context=t;const f=t.gl;this.buffer=f.createBuffer(),t.bindVertexBuffer.set(this.buffer),f.bufferData(f.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let o=0;o<this.attributes.length;o++){const c=n.attributes[this.attributes[o].name];c!==void 0&&t.enableVertexAttribArray(c)}}setVertexAttribPointers(t,n,o){for(let c=0;c<this.attributes.length;c++){const f=this.attributes[c],g=n.attributes[f.name];g!==void 0&&t.vertexAttribPointer(g,f.components,t[uu[f.type]],!1,this.itemSize,f.offset+this.itemSize*(o||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class St{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class da extends St{getDefault(){return l.bp.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class pa extends St{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class fa extends St{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class zl extends St{getDefault(){return[!0,!0,!0,!0]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class qn extends St{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class po extends St{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class As extends St{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const n=this.current;(t.func!==n.func||t.ref!==n.ref||t.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Ii extends St{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class hu extends St{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}}class du extends St{getDefault(){return[0,1]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Dl extends St{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}}class Wn extends St{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class ma extends St{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}}class ga extends St{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class fo extends St{getDefault(){return l.bp.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class _a extends St{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class pu extends St{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}}class zs extends St{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Ds extends St{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class fu extends St{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class kl extends St{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class ft extends St{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class ya extends St{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Vh extends St{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class mu extends St{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class mo extends St{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class $h extends St{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Zh extends St{getDefault(){return null}set(t){var n;if(t===this.current&&!this.dirty)return;const o=this.gl;Pi(o)?o.bindVertexArray(t):(n=o.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class gu extends St{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class Uh extends St{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Rl extends St{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class ks extends St{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class go extends ks{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class va extends ks{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Fl extends ks{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}const Ll="Framebuffer is not complete";class xa{constructor(t,n,o,c,f){this.context=t,this.width=n,this.height=o;const g=t.gl,v=this.framebuffer=g.createFramebuffer();if(this.colorAttachment=new go(t,v),c)this.depthAttachment=f?new Fl(t,v):new va(t,v);else if(f)throw new Error("Stencil cannot be set without depth");if(g.checkFramebufferStatus(g.FRAMEBUFFER)!==g.FRAMEBUFFER_COMPLETE)throw new Error(Ll)}destroy(){const t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){const o=this.depthAttachment.get();o&&t.deleteRenderbuffer(o)}t.deleteFramebuffer(this.framebuffer)}}class ba{constructor(t){var n,o;if(this.gl=t,this.clearColor=new da(this),this.clearDepth=new pa(this),this.clearStencil=new fa(this),this.colorMask=new zl(this),this.depthMask=new qn(this),this.stencilMask=new po(this),this.stencilFunc=new As(this),this.stencilOp=new Ii(this),this.stencilTest=new hu(this),this.depthRange=new du(this),this.depthTest=new Dl(this),this.depthFunc=new Wn(this),this.blend=new ma(this),this.blendFunc=new ga(this),this.blendColor=new fo(this),this.blendEquation=new _a(this),this.cullFace=new pu(this),this.cullFaceSide=new zs(this),this.frontFace=new Ds(this),this.program=new fu(this),this.activeTexture=new kl(this),this.viewport=new ft(this),this.bindFramebuffer=new ya(this),this.bindRenderbuffer=new Vh(this),this.bindTexture=new mu(this),this.bindVertexBuffer=new mo(this),this.bindElementBuffer=new $h(this),this.bindVertexArray=new Zh(this),this.pixelStoreUnpack=new gu(this),this.pixelStoreUnpackPremultiplyAlpha=new Uh(this),this.pixelStoreUnpackFlipY=new Rl(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),Pi(t)){this.HALF_FLOAT=t.HALF_FLOAT;const c=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=t.RGBA16F)!==null&&n!==void 0?n:c?.RGBA16F_EXT,this.RGB16F=(o=t.RGB16F)!==null&&o!==void 0?o:c?.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const c=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=c?.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,n){return new jh(this,t,n)}createVertexBuffer(t,n,o){return new Nh(this,t,n,o)}createRenderbuffer(t,n,o){const c=this.gl,f=c.createRenderbuffer();return this.bindRenderbuffer.set(f),c.renderbufferStorage(c.RENDERBUFFER,t,n,o),this.bindRenderbuffer.set(null),f}createFramebuffer(t,n,o,c){return new xa(this,t,n,o,c)}clear({color:t,depth:n,stencil:o}){const c=this.gl;let f=0;t&&(f|=c.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(f|=c.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),o!==void 0&&(f|=c.STENCIL_BUFFER_BIT,this.clearStencil.set(o),this.stencilMask.set(255)),c.clear(f)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){l.bR(t.blendFunction,Lt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return Pi(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var n;return Pi(this.gl)?this.gl.deleteVertexArray(t):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}let wn;function Hn(d,t,n,o,c){const f=d.context,g=d.transform,v=f.gl,b=d.useProgram("collisionBox"),P=[];let E=0,k=0;for(let W=0;W<o.length;W++){const K=o[W],re=t.getTile(K).getBucket(n);if(!re)continue;const Y=c?re.textCollisionBox:re.iconCollisionBox,te=re.collisionCircleArray;te.length>0&&(P.push({circleArray:te,circleOffset:k,coord:K}),E+=te.length/4,k=E),Y&&b.draw(f,v.LINES,ut.disabled,vt.disabled,d.colorModeForRenderPass(),yt.disabled,Un(d.transform),d.style.map.terrain&&d.style.map.terrain.getTerrainData(K),g.getProjectionData({overscaledTileID:K,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,Y.layoutVertexBuffer,Y.indexBuffer,Y.segments,null,d.transform.zoom,null,null,Y.collisionVertexBuffer)}if(!c||!P.length)return;const D=d.useProgram("collisionCircle"),L=new l.ca;L.resize(4*E),L._trim();let N=0;for(const W of P)for(let K=0;K<W.circleArray.length/4;K++){const re=4*K,Y=W.circleArray[re+0],te=W.circleArray[re+1],oe=W.circleArray[re+2],Q=W.circleArray[re+3];L.emplace(N++,Y,te,oe,Q,0),L.emplace(N++,Y,te,oe,Q,1),L.emplace(N++,Y,te,oe,Q,2),L.emplace(N++,Y,te,oe,Q,3)}(!wn||wn.length<2*E)&&(wn=(function(W){const K=2*W,re=new l.cc;re.resize(K),re._trim();for(let Y=0;Y<K;Y++){const te=6*Y;re.uint16[te+0]=4*Y+0,re.uint16[te+1]=4*Y+1,re.uint16[te+2]=4*Y+2,re.uint16[te+3]=4*Y+2,re.uint16[te+4]=4*Y+3,re.uint16[te+5]=4*Y+0}return re})(E));const q=f.createIndexBuffer(wn,!0),H=f.createVertexBuffer(L,l.cb.members,!0);for(const W of P){const K=nu(d.transform);D.draw(f,v.TRIANGLES,ut.disabled,vt.disabled,d.colorModeForRenderPass(),yt.disabled,K,d.style.map.terrain&&d.style.map.terrain.getTerrainData(W.coord),null,n.id,H,q,l.aX.simpleSegment(0,2*W.circleOffset,W.circleArray.length,W.circleArray.length/2),null,d.transform.zoom,null,null,null)}H.destroy(),q.destroy()}const Ol=l.ar(new Float32Array(16));function Gh(d,t,n,o,c,f){const{horizontalAlign:g,verticalAlign:v}=l.aS(d);return new l.P((-(g-.5)*t/c+o[0])*f,(-(v-.5)*n/c+o[1])*f)}function _o(d,t,n,o,c,f){const g=t.tileAnchorPoint.add(new l.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let v=o.mult(f);n||(v=v.rotate(-c));const b=g.add(v);return ct(b.x,b.y,t.pitchedLabelPlaneMatrix,t.getElevation).point}if(n){const v=Ct(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(d),b=Math.atan(v.y/v.x)+(v.x<0?Math.PI:0);return d.add(o.rotate(b))}return d.add(o)}function qh(d,t,n,o,c,f,g,v,b,P,E,k){const D=d.text.placedSymbolArray,L=d.text.dynamicLayoutVertexArray,N=d.icon.dynamicLayoutVertexArray,q={};L.clear();for(let H=0;H<D.length;H++){const W=D.get(H),K=W.hidden||!W.crossTileID||d.allowVerticalPlacement&&!W.placedOrientation?null:o[W.crossTileID];if(K){const re=new l.P(W.anchorX,W.anchorY),Y={getElevation:k,width:c.width,height:c.height,pitchedLabelPlaneMatrix:f,pitchWithMap:n,transform:c,tileAnchorPoint:re,translation:P,unwrappedTileID:E},te=n?gs(re.x,re.y,Y):Ct(re.x,re.y,Y),oe=Js(c.cameraToCenterDistance,te.signedDistanceFromCamera);let Q=l.aA(d.textSizeData,v,W)*oe/l.aM;n&&(Q*=d.tilePixelRatio/g);const{width:ae,height:ve,anchor:ge,textOffset:_e,textBoxScale:ye}=K,Re=Gh(ge,ae,ve,_e,ye,Q),Fe=c.getPitchedTextCorrection(re.x+P[0],re.y+P[1],E),Ee=_o(te.point,Y,t,Re,-c.bearingInRadians,Fe),je=d.allowVerticalPlacement&&W.placedOrientation===l.az.vertical?Math.PI/2:0;for(let st=0;st<W.numGlyphs;st++)l.aG(L,Ee,je);b&&W.associatedIconIndex>=0&&(q[W.associatedIconIndex]={shiftedAnchor:Ee,angle:je})}else Bn(W.numGlyphs,L)}if(b){N.clear();const H=d.icon.placedSymbolArray;for(let W=0;W<H.length;W++){const K=H.get(W);if(K.hidden)Bn(K.numGlyphs,N);else{const re=q[W];if(re)for(let Y=0;Y<K.numGlyphs;Y++)l.aG(N,re.shiftedAnchor,re.angle);else Bn(K.numGlyphs,N)}}d.icon.dynamicLayoutVertexBuffer.updateData(N)}d.text.dynamicLayoutVertexBuffer.updateData(L)}function _u(d,t,n){return n.iconsInText&&t?"symbolTextAndIcon":d?"symbolSDF":"symbolIcon"}function yo(d,t,n,o,c,f,g,v,b,P,E,k,D){const L=d.context,N=L.gl,q=d.transform,H=v==="map",W=b==="map",K=v!=="viewport"&&n.layout.get("symbol-placement")!=="point",re=H&&!W&&!K,Y=!n.layout.get("symbol-sort-key").isConstant();let te=!1;const oe=d.getDepthModeForSublayer(0,ut.ReadOnly),Q=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),ae=[],ve=q.getCircleRadiusCorrection();for(const ge of o){const _e=t.getTile(ge),ye=_e.getBucket(n);if(!ye)continue;const Re=c?ye.text:ye.icon;if(!Re||!Re.segments.get().length||!Re.hasVisibleVertices)continue;const Fe=Re.programConfigurations.get(n.id),Ee=c||ye.sdfIcons,je=c?ye.textSizeData:ye.iconSizeData,st=W||q.pitch!==0,Mt=d.useProgram(_u(Ee,c,ye),Fe),qt=l.ay(je,q.zoom),Ot=d.style.map.terrain&&d.style.map.terrain.getTerrainData(ge);let Xt,Bt,ur,Yt,jr=[0,0],Sr=null;if(c)Bt=_e.glyphAtlasTexture,ur=N.LINEAR,Xt=_e.glyphAtlasTexture.size,ye.iconsInText&&(jr=_e.imageAtlasTexture.size,Sr=_e.imageAtlasTexture,Yt=st||d.options.rotating||d.options.zooming||je.kind==="composite"||je.kind==="camera"?N.LINEAR:N.NEAREST);else{const Ut=n.layout.get("icon-size").constantOr(0)!==1||ye.iconsNeedLinear;Bt=_e.imageAtlasTexture,ur=Ee||d.options.rotating||d.options.zooming||Ut||st?N.LINEAR:N.NEAREST,Xt=_e.imageAtlasTexture.size}const vr=l.aN(_e,1,d.transform.zoom),qr=_i(H,d.transform,vr),Mn=l.N();l.aB(Mn,qr);const un=Jo(W,H,d.transform,vr),en=l.aO(q,_e,f,g),hi=q.getProjectionData({overscaledTileID:ge,applyGlobeMatrix:!D,applyTerrainMatrix:!0}),es=Q&&ye.hasTextData(),Bo=n.layout.get("icon-text-fit")!=="none"&&es&&ye.hasIconData();if(K){const Ut=d.style.map.terrain?(Rr,Fr)=>d.style.map.terrain.getElevation(ge,Rr,Fr):null,jt=n.layout.get("text-rotation-alignment")==="map";Qo(ye,d,c,qr,Mn,W,P,jt,ge.toUnwrapped(),q.width,q.height,en,Ut)}const ts=c&&Q||Bo,Ci=K||ts?Ol:W?qr:d.transform.clipSpaceToPixelsMatrix,tn=Ee&&n.paint.get(c?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Vi;Vi=Ee?ye.iconsInText?Gn(je.kind,qt,re,W,K,ts,d,Ci,un,en,Xt,jr,ve):ha(je.kind,qt,re,W,K,ts,d,Ci,un,en,c,Xt,0,ve):Cl(je.kind,qt,re,W,K,ts,d,Ci,un,en,c,Xt,ve);const $i={program:Mt,buffers:Re,uniformValues:Vi,projectionData:hi,atlasTexture:Bt,atlasTextureIcon:Sr,atlasInterpolation:ur,atlasInterpolationIcon:Yt,isSDF:Ee,hasHalo:tn};if(Y&&ye.canOverlap){te=!0;const Ut=Re.segments.get();for(const jt of Ut)ae.push({segments:new l.aX([jt]),sortKey:jt.sortKey,state:$i,terrainData:Ot})}else ae.push({segments:Re.segments,sortKey:0,state:$i,terrainData:Ot})}te&&ae.sort(((ge,_e)=>ge.sortKey-_e.sortKey));for(const ge of ae){const _e=ge.state;if(L.activeTexture.set(N.TEXTURE0),_e.atlasTexture.bind(_e.atlasInterpolation,N.CLAMP_TO_EDGE),_e.atlasTextureIcon&&(L.activeTexture.set(N.TEXTURE1),_e.atlasTextureIcon&&_e.atlasTextureIcon.bind(_e.atlasInterpolationIcon,N.CLAMP_TO_EDGE)),_e.isSDF){const ye=_e.uniformValues;_e.hasHalo&&(ye.u_is_halo=1,wa(_e.buffers,ge.segments,n,d,_e.program,oe,E,k,ye,_e.projectionData,ge.terrainData)),ye.u_is_halo=0}wa(_e.buffers,ge.segments,n,d,_e.program,oe,E,k,_e.uniformValues,_e.projectionData,ge.terrainData)}}function wa(d,t,n,o,c,f,g,v,b,P,E){const k=o.context;c.draw(k,k.gl.TRIANGLES,f,g,v,yt.backCCW,b,E,P,n.id,d.layoutVertexBuffer,d.indexBuffer,t,n.paint,o.transform.zoom,d.programConfigurations.get(n.id),d.dynamicLayoutVertexBuffer,d.opacityVertexBuffer)}function yu(d,t,n,o,c){const f=d.context,g=f.gl,v=vt.disabled,b=new Lt([g.ONE,g.ONE],l.bp.transparent,[!0,!0,!0,!0]),P=t.getBucket(n);if(!P)return;const E=o.key;let k=n.heatmapFbos.get(E);k||(k=vo(f,t.tileSize,t.tileSize),n.heatmapFbos.set(E,k)),f.bindFramebuffer.set(k.framebuffer),f.viewport.set([0,0,t.tileSize,t.tileSize]),f.clear({color:l.bp.transparent});const D=P.programConfigurations.get(n.id),L=d.useProgram("heatmap",D,!c),N=d.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),q=d.style.map.terrain.getTerrainData(o);L.draw(f,g.TRIANGLES,ut.disabled,v,b,yt.disabled,Cs(t,d.transform.zoom,n.paint.get("heatmap-intensity"),1),q,N,n.id,P.layoutVertexBuffer,P.indexBuffer,P.segments,n.paint,d.transform.zoom,D)}function vu(d,t,n,o,c){const f=d.context,g=f.gl,v=d.transform;f.setColorMode(d.colorModeForRenderPass());const b=Ta(f,t),P=n.key,E=t.heatmapFbos.get(P);if(!E)return;f.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,E.colorAttachment.get()),f.activeTexture.set(g.TEXTURE1),b.bind(g.LINEAR,g.CLAMP_TO_EDGE);const k=v.getProjectionData({overscaledTileID:n,applyTerrainMatrix:c,applyGlobeMatrix:!o});d.useProgram("heatmapTexture").draw(f,g.TRIANGLES,ut.disabled,vt.disabled,d.colorModeForRenderPass(),yt.disabled,su(d,t,0,1),null,k,t.id,d.rasterBoundsBuffer,d.quadTriangleIndexBuffer,d.rasterBoundsSegments,t.paint,v.zoom),E.destroy(),t.heatmapFbos.delete(P)}function vo(d,t,n){var o,c;const f=d.gl,g=f.createTexture();f.bindTexture(f.TEXTURE_2D,g),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.LINEAR),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.LINEAR);const v=(o=d.HALF_FLOAT)!==null&&o!==void 0?o:f.UNSIGNED_BYTE,b=(c=d.RGBA16F)!==null&&c!==void 0?c:f.RGBA;f.texImage2D(f.TEXTURE_2D,0,b,t,n,0,f.RGBA,v,null);const P=d.createFramebuffer(t,n,!1,!1);return P.colorAttachment.set(g),P}function Ta(d,t){return t.colorRampTexture||(t.colorRampTexture=new l.T(d,t.colorRamp,d.gl.RGBA)),t.colorRampTexture}function xu(d,t,n,o,c,f,g,v){let b=256;if(c.stepInterpolant){const P=t.getSource().maxzoom,E=g.canonical.z===P?Math.ceil(1<<d.transform.maxZoom-g.canonical.z):1;b=l.an(l.ce(f.maxLineLength/l.a5*1024*E),256,n.maxTextureSize)}return v.gradient=l.cf({expression:c.gradientExpression(),evaluationKey:"lineProgress",resolution:b,image:v.gradient||void 0,clips:f.lineClipsArray}),v.texture?v.texture.update(v.gradient):v.texture=new l.T(n,v.gradient,o.RGBA),v.version=c.gradientVersion,v.texture}function bu(d,t,n,o,c){d.activeTexture.set(t.TEXTURE0),n.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),o.updatePaintBuffers(c)}function _r(d,t,n,o,c,f){(c||d.lineAtlas.dirty)&&(t.activeTexture.set(n.TEXTURE0),d.lineAtlas.bind(t)),o.updatePaintBuffers(f)}function Xn(d,t,n,o,c,f,g){const v=f.gradients[c.id];let b=v.texture;c.gradientVersion!==v.version&&(b=xu(d,t,n,o,c,f,g,v)),n.activeTexture.set(o.TEXTURE0),b.bind(c.stepInterpolant?o.NEAREST:o.LINEAR,o.CLAMP_TO_EDGE)}function vi(d,t,n,o,c,f,g,v,b){const P=f.gradients[c.id];let E=P.texture;c.gradientVersion!==P.version&&(E=xu(d,t,n,o,c,f,g,P)),n.activeTexture.set(o.TEXTURE0),E.bind(c.stepInterpolant?o.NEAREST:o.LINEAR,o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE1),d.lineAtlas.bind(n),v.updatePaintBuffers(b)}function Sa(d,t,n,o,c){if(!n||!o||!o.imageAtlas)return;const f=o.imageAtlas.patternPositions;let g=f[n.to.toString()],v=f[n.from.toString()];if(!g&&v&&(g=v),!v&&g&&(v=g),!g||!v){const b=c.getPaintProperty(t);g=f[b],v=f[b]}g&&v&&d.setConstantPatternPositions(g,v)}function xo(d,t,n,o,c,f,g,v){const b=d.context.gl,P="fill-pattern",E=n.paint.get(P),k=E&&E.constantOr(1),D=n.getCrossfadeParameters();let L,N,q,H,W;const K=d.transform,re=n.paint.get("fill-translate"),Y=n.paint.get("fill-translate-anchor");g?(N=k&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",L=b.LINES):(N=k?"fillPattern":"fill",L=b.TRIANGLES);const te=E.constantOr(null);for(const oe of o){const Q=t.getTile(oe);if(k&&!Q.patternsLoaded())continue;const ae=Q.getBucket(n);if(!ae)continue;const ve=ae.programConfigurations.get(n.id),ge=d.useProgram(N,ve),_e=d.style.map.terrain&&d.style.map.terrain.getTerrainData(oe);k&&(d.context.activeTexture.set(b.TEXTURE0),Q.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),ve.updatePaintBuffers(D)),Sa(ve,P,te,Q,n);const ye=K.getProjectionData({overscaledTileID:oe,applyGlobeMatrix:!v,applyTerrainMatrix:!0}),Re=l.aO(K,Q,re,Y);if(g){H=ae.indexBuffer2,W=ae.segments2;const Ee=[b.drawingBufferWidth,b.drawingBufferHeight];q=N==="fillOutlinePattern"&&k?ru(d,D,Q,Ee,Re):tu(Ee,Re)}else H=ae.indexBuffer,W=ae.segments,q=k?Sl(d,D,Q,Re):{u_fill_translate:Re};const Fe=d.stencilModeForClipping(oe);ge.draw(d.context,L,c,Fe,f,yt.backCCW,q,_e,ye,n.id,ae.layoutVertexBuffer,H,W,n.paint,d.transform.zoom,ve)}}function Pa(d,t,n,o,c,f,g,v){const b=d.context,P=b.gl,E="fill-extrusion-pattern",k=n.paint.get(E),D=k.constantOr(1),L=n.getCrossfadeParameters(),N=n.paint.get("fill-extrusion-opacity"),q=k.constantOr(null),H=d.transform;for(const W of o){const K=t.getTile(W),re=K.getBucket(n);if(!re)continue;const Y=d.style.map.terrain&&d.style.map.terrain.getTerrainData(W),te=re.programConfigurations.get(n.id),oe=d.useProgram(D?"fillExtrusionPattern":"fillExtrusion",te);D&&(d.context.activeTexture.set(P.TEXTURE0),K.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),te.updatePaintBuffers(L));const Q=H.getProjectionData({overscaledTileID:W,applyGlobeMatrix:!v,applyTerrainMatrix:!0});Sa(te,E,q,K,n);const ae=l.aO(H,K,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ve=n.paint.get("fill-extrusion-vertical-gradient"),ge=D?Tl(d,ve,N,ae,W,L,K):wl(d,ve,N,ae);oe.draw(b,b.gl.TRIANGLES,c,f,g,yt.backCCW,ge,Y,Q,n.id,re.layoutVertexBuffer,re.indexBuffer,re.segments,n.paint,d.transform.zoom,te,d.style.map.terrain&&re.centroidVertexBuffer)}}function Tn(d,t,n,o,c,f,g,v,b){var P;const E=d.style.projection,k=d.context,D=d.transform,L=k.gl,N=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],q=d.useProgram("hillshade",null,!1,N),H=!d.options.moving;for(const W of o){const K=t.getTile(W),re=K.fbo;if(!re)continue;const Y=E.getMeshFromTileID(k,W.canonical,v,!0,"raster"),te=(P=d.style.map.terrain)===null||P===void 0?void 0:P.getTerrainData(W);k.activeTexture.set(L.TEXTURE0),L.bindTexture(L.TEXTURE_2D,re.colorAttachment.get());const oe=D.getProjectionData({overscaledTileID:W,aligned:H,applyGlobeMatrix:!b,applyTerrainMatrix:!0});q.draw(k,L.TRIANGLES,f,c[W.overscaledZ],g,yt.backCCW,la(d,K,n),te,oe,n.id,Y.vertexBuffer,Y.indexBuffer,Y.segments)}}function bo(d,t,n,o,c,f,g,v,b){var P;const E=d.style.projection,k=d.context,D=d.transform,L=k.gl,N=d.useProgram("colorRelief"),q=!d.options.moving;let H=!0,W=0;for(const K of o){const re=t.getTile(K),Y=re.dem;if(H){const ge=L.getParameter(L.MAX_TEXTURE_SIZE),{elevationTexture:_e,colorTexture:ye}=n.getColorRampTextures(k,ge,Y.getUnpackVector());k.activeTexture.set(L.TEXTURE1),_e.bind(L.NEAREST,L.CLAMP_TO_EDGE),k.activeTexture.set(L.TEXTURE4),ye.bind(L.LINEAR,L.CLAMP_TO_EDGE),H=!1,W=_e.size[0]}if(!Y||!Y.data)continue;const te=Y.stride,oe=Y.getPixels();if(k.activeTexture.set(L.TEXTURE0),k.pixelStoreUnpackPremultiplyAlpha.set(!1),re.demTexture=re.demTexture||d.getTileTexture(te),re.demTexture){const ge=re.demTexture;ge.update(oe,{premultiply:!1}),ge.bind(L.LINEAR,L.CLAMP_TO_EDGE)}else re.demTexture=new l.T(k,oe,L.RGBA,{premultiply:!1}),re.demTexture.bind(L.LINEAR,L.CLAMP_TO_EDGE);const Q=E.getMeshFromTileID(k,K.canonical,v,!0,"raster"),ae=(P=d.style.map.terrain)===null||P===void 0?void 0:P.getTerrainData(K),ve=D.getProjectionData({overscaledTileID:K,aligned:q,applyGlobeMatrix:!b,applyTerrainMatrix:!0});N.draw(k,L.TRIANGLES,f,c[K.overscaledZ],g,yt.backCCW,ou(n,re.dem,W),ae,ve,n.id,Q.vertexBuffer,Q.indexBuffer,Q.segments)}}const Yn=[new l.P(0,0),new l.P(l.a5,0),new l.P(l.a5,l.a5),new l.P(0,l.a5)];function Rs(d,t,n,o,c,f,g,v,b=!1,P=!1){const E=o[o.length-1].overscaledZ,k=d.context,D=k.gl,L=d.useProgram("raster"),N=d.transform,q=d.style.projection,H=d.colorModeForRenderPass(),W=!d.options.moving,K=n.paint.get("raster-opacity"),re=n.paint.get("raster-resampling"),Y=n.paint.get("raster-fade-duration"),te=!!d.style.map.terrain;for(const oe of o){const Q=d.getDepthModeForSublayer(oe.overscaledZ-E,K===1?ut.ReadWrite:ut.ReadOnly,D.LESS),ae=t.getTile(oe),ve=re==="nearest"?D.NEAREST:D.LINEAR;k.activeTexture.set(D.TEXTURE0),ae.texture.bind(ve,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),k.activeTexture.set(D.TEXTURE1);const{parentTile:ge,parentScaleBy:_e,parentTopLeft:ye,fadeValues:Re}=wu(ae,t,Y,te);ae.fadeOpacity=Re.tileOpacity,ge?(ge.fadeOpacity=Re.parentTileOpacity,ge.texture.bind(ve,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST)):ae.texture.bind(ve,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),ae.texture.useMipmap&&k.extTextureFilterAnisotropic&&d.transform.pitch>20&&D.texParameterf(D.TEXTURE_2D,k.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,k.extTextureFilterAnisotropicMax);const Fe=d.style.map.terrain&&d.style.map.terrain.getTerrainData(oe),Ee=N.getProjectionData({overscaledTileID:oe,aligned:W,applyGlobeMatrix:!P,applyTerrainMatrix:!0}),je=Ml(ye,_e,Re.fadeMix,n,v),st=q.getMeshFromTileID(k,oe.canonical,f,g,"raster");L.draw(k,D.TRIANGLES,Q,c?c[oe.overscaledZ]:vt.disabled,H,b?yt.frontCCW:yt.backCCW,je,Fe,Ee,n.id,st.vertexBuffer,st.indexBuffer,st.segments)}}function wu(d,t,n,o){const c={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(n===0||o)return c;if(d.fadingParentID){const f=t.getLoadedTile(d.fadingParentID);if(!f)return c;const g=Math.pow(2,f.tileID.overscaledZ-d.tileID.overscaledZ),v=[d.tileID.canonical.x*g%1,d.tileID.canonical.y*g%1],b=(function(P,E,k){const D=Qe(),L=(D-E.timeAdded)/k,N=P.fadingDirection===se.Incoming,q=l.an((D-P.timeAdded)/k,0,1),H=l.an(1-L,0,1),W=N?q:H;return{tileOpacity:W,parentTileOpacity:N?H:q,fadeMix:{opacity:1,mix:1-W}}})(d,f,n);return{parentTile:f,parentScaleBy:g,parentTopLeft:v,fadeValues:b}}if(d.selfFading){const f=(function(g,v){const b=(Qe()-g.timeAdded)/v,P=l.an(b,0,1);return{tileOpacity:P,fadeMix:{opacity:P,mix:0}}})(d,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:f}}return c}const Tu=new l.bp(1,0,0,1),Su=new l.bp(0,1,0,1),Pu=new l.bp(0,0,1,1),Iu=new l.bp(1,0,1,1),Sn=new l.bp(0,1,1,1);function Bl(d,t,n,o){wo(d,0,t+n/2,d.transform.width,n,o)}function jl(d,t,n,o){wo(d,t-n/2,0,n,d.transform.height,o)}function wo(d,t,n,o,c,f){const g=d.context,v=g.gl;v.enable(v.SCISSOR_TEST),v.scissor(t*d.pixelRatio,n*d.pixelRatio,o*d.pixelRatio,c*d.pixelRatio),g.clear({color:f}),v.disable(v.SCISSOR_TEST)}function Mu(d,t,n){const o=d.context,c=o.gl,f=d.useProgram("debug"),g=ut.disabled,v=vt.disabled,b=d.colorModeForRenderPass(),P="$debug",E=d.style.map.terrain&&d.style.map.terrain.getTerrainData(n);o.activeTexture.set(c.TEXTURE0);const k=t.getTileByID(n.key).latestRawTileData,D=Math.floor((k&&k.byteLength||0)/1024),L=t.getTile(n).tileSize,N=512/Math.min(L,512)*(n.overscaledZ/d.transform.zoom)*.5;let q=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(q+=` => ${n.overscaledZ}`),(function(W,K){W.initDebugOverlayCanvas();const re=W.debugOverlayCanvas,Y=W.context.gl,te=W.debugOverlayCanvas.getContext("2d");te.clearRect(0,0,re.width,re.height),te.shadowColor="white",te.shadowBlur=2,te.lineWidth=1.5,te.strokeStyle="white",te.textBaseline="top",te.font="bold 36px Open Sans, sans-serif",te.fillText(K,5,5),te.strokeText(K,5,5),W.debugOverlayTexture.update(re),W.debugOverlayTexture.bind(Y.LINEAR,Y.CLAMP_TO_EDGE)})(d,`${q} ${D}kB`);const H=d.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});f.draw(o,c.TRIANGLES,g,v,Lt.alphaBlended,yt.disabled,Pl(l.bp.transparent,N),null,H,P,d.debugBuffer,d.quadTriangleIndexBuffer,d.debugSegments),f.draw(o,c.LINE_STRIP,g,v,b,yt.disabled,Pl(l.bp.red),E,H,P,d.debugBuffer,d.tileBorderIndexBuffer,d.debugSegments)}function Nl(d,t,n,o){const{isRenderingGlobe:c}=o,f=d.context,g=f.gl,v=d.transform,b=d.colorModeForRenderPass(),P=d.getDepthModeFor3D(),E=d.useProgram("terrain");f.bindFramebuffer.set(null),f.viewport.set([0,0,d.width,d.height]);for(const k of n){const D=t.getTerrainMesh(k.tileID),L=d.renderToTexture.getTexture(k),N=t.getTerrainData(k.tileID);f.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,L.texture);const q=t.getMeshFrameDelta(v.zoom),H=v.calculateFogMatrix(k.tileID.toUnwrapped()),W=Rh(q,H,d.style.sky,v.pitch,c),K=v.getProjectionData({overscaledTileID:k.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});E.draw(f,g.TRIANGLES,P,vt.disabled,b,yt.backCCW,W,N,K,"terrain",D.vertexBuffer,D.indexBuffer,D.segments)}}function Vl(d,t){if(!t.mesh){const n=new l.aW;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const o=new l.aY;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),t.mesh=new Ft(d.createVertexBuffer(n,vn.members),d.createIndexBuffer(o),l.aX.simpleSegment(0,0,n.length,o.length))}return t.mesh}class Eu{constructor(t,n){this.context=new ba(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:l.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=mr.maxOverzooming+mr.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ci}resize(t,n,o){if(this.width=Math.floor(t*o),this.height=Math.floor(n*o),this.pixelRatio=o,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const c of this.style._order)this.style._layers[c].resize()}setup(){const t=this.context,n=new l.aW;n.emplaceBack(0,0),n.emplaceBack(l.a5,0),n.emplaceBack(0,l.a5),n.emplaceBack(l.a5,l.a5),this.tileExtentBuffer=t.createVertexBuffer(n,vn.members),this.tileExtentSegments=l.aX.simpleSegment(0,0,4,2);const o=new l.aW;o.emplaceBack(0,0),o.emplaceBack(l.a5,0),o.emplaceBack(0,l.a5),o.emplaceBack(l.a5,l.a5),this.debugBuffer=t.createVertexBuffer(o,vn.members),this.debugSegments=l.aX.simpleSegment(0,0,4,5);const c=new l.ch;c.emplaceBack(0,0,0,0),c.emplaceBack(l.a5,0,l.a5,0),c.emplaceBack(0,l.a5,0,l.a5),c.emplaceBack(l.a5,l.a5,l.a5,l.a5),this.rasterBoundsBuffer=t.createVertexBuffer(c,kh.members),this.rasterBoundsSegments=l.aX.simpleSegment(0,0,4,2);const f=new l.aW;f.emplaceBack(0,0),f.emplaceBack(l.a5,0),f.emplaceBack(0,l.a5),f.emplaceBack(l.a5,l.a5),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(f,vn.members),this.rasterBoundsSegmentsPosOnly=l.aX.simpleSegment(0,0,4,5);const g=new l.aW;g.emplaceBack(0,0),g.emplaceBack(1,0),g.emplaceBack(0,1),g.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(g,vn.members),this.viewportSegments=l.aX.simpleSegment(0,0,4,2);const v=new l.ci;v.emplaceBack(0),v.emplaceBack(1),v.emplaceBack(3),v.emplaceBack(2),v.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(v);const b=new l.aY;b.emplaceBack(1,0,2),b.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(b);const P=this.context.gl;this.stencilClearMode=new vt({func:P.ALWAYS,mask:0},0,255,P.ZERO,P.ZERO,P.ZERO),this.tileExtentMesh=new Ft(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const o=l.N();l.c7(o,0,this.width,this.height,0,0,1),l.Q(o,o,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const c={mainMatrix:o,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:o};this.useProgram("clippingMask",null,!0).draw(t,n.TRIANGLES,ut.disabled,this.stencilClearMode,Lt.disabled,yt.disabled,null,null,c,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n,o){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source,this.nextStencilID+n.length>256&&this.clearStencil();const c=this.context;c.setColorMode(Lt.disabled),c.setDepthMode(ut.disabled);const f={};for(const g of n)f[g.key]=this.nextStencilID++;this._renderTileMasks(f,n,o,!0),this._renderTileMasks(f,n,o,!1),this._tileClippingMaskIDs=f}_renderTileMasks(t,n,o,c){const f=this.context,g=f.gl,v=this.style.projection,b=this.transform,P=this.useProgram("clippingMask");for(const E of n){const k=t[E.key],D=this.style.map.terrain&&this.style.map.terrain.getTerrainData(E),L=v.getMeshFromTileID(this.context,E.canonical,c,!0,"stencil"),N=b.getProjectionData({overscaledTileID:E,applyGlobeMatrix:!o,applyTerrainMatrix:!0});P.draw(f,g.TRIANGLES,ut.disabled,new vt({func:g.ALWAYS,mask:0},k,255,g.KEEP,g.KEEP,g.REPLACE),Lt.disabled,o?yt.disabled:yt.backCCW,null,D,N,"$clipping",L.vertexBuffer,L.indexBuffer,L.segments)}}_renderTilesDepthBuffer(){const t=this.context,n=t.gl,o=this.style.projection,c=this.transform,f=this.useProgram("depth"),g=this.getDepthModeFor3D(),v=Zt(c,{tileSize:c.tileSize});for(const b of v){const P=this.style.map.terrain&&this.style.map.terrain.getTerrainData(b),E=o.getMeshFromTileID(this.context,b.canonical,!0,!0,"raster"),k=c.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!0,applyTerrainMatrix:!0});f.draw(t,n.TRIANGLES,g,vt.disabled,Lt.disabled,yt.backCCW,null,P,k,"$clipping",E.vertexBuffer,E.indexBuffer,E.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new vt({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new vt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const n=this.context.gl,o=t.sort(((g,v)=>v.overscaledZ-g.overscaledZ)),c=o[o.length-1].overscaledZ,f=o[0].overscaledZ-c+1;if(f>1){this.currentStencilSource=void 0,this.nextStencilID+f>256&&this.clearStencil();const g={};for(let v=0;v<f;v++)g[v+c]=new vt({func:n.GEQUAL,mask:255},v+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=f,[g,o]}return[{[c]:vt.disabled},o]}stencilConfigForOverlapTwoPass(t){const n=this.context.gl,o=t.sort(((g,v)=>v.overscaledZ-g.overscaledZ)),c=o[o.length-1].overscaledZ,f=o[0].overscaledZ-c+1;if(this.clearStencil(),f>1){const g={},v={};for(let b=0;b<f;b++)g[b+c]=new vt({func:n.GREATER,mask:255},f+1+b,255,n.KEEP,n.KEEP,n.REPLACE),v[b+c]=new vt({func:n.GREATER,mask:255},1+b,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*f+1,[g,v,o]}return this.nextStencilID=3,[{[c]:new vt({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[c]:new vt({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},o]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new Lt([t.CONSTANT_COLOR,t.ONE],new l.bp(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Lt.unblended:Lt.alphaBlended}getDepthModeForSublayer(t,n,o){if(!this.opaquePassEnabledForLayer())return ut.disabled;const c=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ut(o||this.context.gl.LEQUAL,n,[c,c])}getDepthModeFor3D(){return new ut(this.context.gl.LEQUAL,ut.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,n){var o,c;this.style=t,this.options=n,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(Qe()),this.imageManager.beginFrame();const f=this.style._order,g=this.style.tileManagers,v={},b={},P={},E={isRenderingToTexture:!1,isRenderingGlobe:((o=t.projection)===null||o===void 0?void 0:o.transitionState)>0};for(const D in g){const L=g[D];L.used&&L.prepare(this.context),v[D]=L.getVisibleCoordinates(!1),b[D]=v[D].slice().reverse(),P[D]=L.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let D=0;D<f.length;D++)if(this.style._layers[f[D]].is3D()){this.opaquePassCutoff=D;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const D of f){const L=this.style._layers[D];if(!L.hasOffscreenPass()||L.isHidden(this.transform.zoom))continue;const N=b[L.source];(L.type==="custom"||N.length)&&this.renderLayer(this,g[L.source],L,N,E)}if((c=this.style.projection)===null||c===void 0||c.updateGPUdependent({context:this.context,useProgram:D=>this.useProgram(D)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?l.bp.black:l.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(D,L){const N=D.context,q=N.gl,H=((oe,Q,ae)=>{const ve=Math.cos(Q.rollInRadians),ge=Math.sin(Q.rollInRadians),_e=be(Q),ye=Q.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:oe.properties.get("sky-color"),u_horizon_color:oe.properties.get("horizon-color"),u_horizon:[(Q.width/2-_e*ge)*ae,(Q.height/2+_e*ve)*ae],u_horizon_normal:[-ge,ve],u_sky_horizon_blend:oe.properties.get("sky-horizon-blend")*Q.height/2*ae,u_sky_blend:ye}})(L,D.style.map.transform,D.pixelRatio),W=new ut(q.LEQUAL,ut.ReadWrite,[0,1]),K=vt.disabled,re=D.colorModeForRenderPass(),Y=D.useProgram("sky"),te=Vl(N,L);Y.draw(N,q.TRIANGLES,W,K,re,yt.disabled,H,null,void 0,"sky",te.vertexBuffer,te.indexBuffer,te.segments)})(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=f.length-1;this.currentLayer>=0;this.currentLayer--){const D=this.style._layers[f[this.currentLayer]],L=g[D.source],N=v[D.source];this._renderTileClippingMasks(D,N,!1),this.renderLayer(this,L,D,N,E)}this.renderPass="translucent";let k=!1;for(this.currentLayer=0;this.currentLayer<f.length;this.currentLayer++){const D=this.style._layers[f[this.currentLayer]],L=g[D.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(D,E))continue;this.opaquePassEnabledForLayer()||k||(k=!0,E.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const N=(D.type==="symbol"?P:b)[D.source];this._renderTileClippingMasks(D,v[D.source],!!this.renderToTexture),this.renderLayer(this,L,D,N,E)}if(E.isRenderingGlobe&&(function(D,L,N){const q=D.context,H=q.gl,W=D.useProgram("atmosphere"),K=new ut(H.LEQUAL,ut.ReadOnly,[0,1]),re=D.transform,Y=(function(ye,Re){const Fe=ye.properties.get("position"),Ee=[-Fe.x,-Fe.y,-Fe.z],je=l.ar(new Float64Array(16));return ye.properties.get("anchor")==="map"&&(l.bg(je,je,Re.rollInRadians),l.bh(je,je,-Re.pitchInRadians),l.bg(je,je,Re.bearingInRadians),l.bh(je,je,Re.center.lat*Math.PI/180),l.bJ(je,je,-Re.center.lng*Math.PI/180)),l.cg(Ee,Ee,je),Ee})(N,D.transform),te=re.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),oe=L.properties.get("atmosphere-blend")*te.projectionTransition;if(oe===0)return;const Q=$n(re.worldSize,re.center.lat),ae=re.inverseProjectionMatrix,ve=new Float64Array(4);ve[3]=1,l.aH(ve,ve,re.modelViewProjectionMatrix),ve[0]/=ve[3],ve[1]/=ve[3],ve[2]/=ve[3],ve[3]=1,l.aH(ve,ve,ae),ve[0]/=ve[3],ve[1]/=ve[3],ve[2]/=ve[3],ve[3]=1;const ge=((ye,Re,Fe,Ee,je)=>({u_sun_pos:ye,u_atmosphere_blend:Re,u_globe_position:Fe,u_globe_radius:Ee,u_inv_proj_matrix:je}))(Y,oe,[ve[0],ve[1],ve[2]],Q,ae),_e=Vl(q,L);W.draw(q,H.TRIANGLES,K,vt.disabled,Lt.alphaBlended,yt.disabled,ge,null,null,"atmosphere",_e.vertexBuffer,_e.indexBuffer,_e.segments)})(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const D=(function(L,N){let q=null;const H=Object.values(L._layers).flatMap((Y=>Y.source&&!Y.isHidden(N)?[L.tileManagers[Y.source]]:[])),W=H.filter((Y=>Y.getSource().type==="vector")),K=H.filter((Y=>Y.getSource().type!=="vector")),re=Y=>{(!q||q.getSource().maxzoom<Y.getSource().maxzoom)&&(q=Y)};return W.forEach((Y=>re(Y))),q||K.forEach((Y=>re(Y))),q})(this.style,this.transform.zoom);D&&(function(L,N,q){for(let H=0;H<q.length;H++)Mu(L,N,q[H])})(this,D,D.getVisibleCoordinates())}this.options.showPadding&&(function(D){const L=D.transform.padding;Bl(D,D.transform.height-(L.top||0),3,Tu),Bl(D,L.bottom||0,3,Su),jl(D,L.left||0,3,Pu),jl(D,D.transform.width-(L.right||0),3,Iu);const N=D.transform.centerPoint;(function(q,H,W,K){wo(q,H-1,W-10,2,20,K),wo(q,H-10,W-1,20,2,K)})(D,N.x,D.transform.height-N.y,Sn)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,o=this.transform.modelViewProjectionMatrix;let c=this.terrainFacilitator.dirty;c||(c=t?!l.cj(n,o):!l.ck(n,o)),c||(c=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),c&&(l.cl(n,o),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(f,g){const v=f.context,b=v.gl,P=f.transform,E=Lt.unblended,k=new ut(b.LEQUAL,ut.ReadWrite,[0,1]),D=g.tileManager.getRenderableTiles(),L=f.useProgram("terrainDepth");v.bindFramebuffer.set(g.getFramebuffer("depth").framebuffer),v.viewport.set([0,0,f.width/devicePixelRatio,f.height/devicePixelRatio]),v.clear({color:l.bp.transparent,depth:1});for(const N of D){const q=g.getTerrainMesh(N.tileID),H=g.getTerrainData(N.tileID),W=P.getProjectionData({overscaledTileID:N.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),K={u_ele_delta:g.getMeshFrameDelta(P.zoom)};L.draw(v,b.TRIANGLES,k,vt.disabled,E,yt.backCCW,K,H,W,"terrain",q.vertexBuffer,q.indexBuffer,q.segments)}v.bindFramebuffer.set(null),v.viewport.set([0,0,f.width,f.height])})(this,this.style.map.terrain),(function(f,g){const v=f.context,b=v.gl,P=f.transform,E=Lt.unblended,k=new ut(b.LEQUAL,ut.ReadWrite,[0,1]),D=g.getCoordsTexture(),L=g.tileManager.getRenderableTiles(),N=f.useProgram("terrainCoords");v.bindFramebuffer.set(g.getFramebuffer("coords").framebuffer),v.viewport.set([0,0,f.width/devicePixelRatio,f.height/devicePixelRatio]),v.clear({color:l.bp.transparent,depth:1}),g.coordsIndex=[];for(const q of L){const H=g.getTerrainMesh(q.tileID),W=g.getTerrainData(q.tileID);v.activeTexture.set(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,D.texture);const K={u_terrain_coords_id:(255-g.coordsIndex.length)/255,u_texture:0,u_ele_delta:g.getMeshFrameDelta(P.zoom)},re=P.getProjectionData({overscaledTileID:q.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});N.draw(v,b.TRIANGLES,k,vt.disabled,E,yt.backCCW,K,W,re,"terrain",H.vertexBuffer,H.indexBuffer,H.segments),g.coordsIndex.push(q.tileID.key)}v.bindFramebuffer.set(null),v.viewport.set([0,0,f.width,f.height])})(this,this.style.map.terrain))}renderLayer(t,n,o,c,f){o.isHidden(this.transform.zoom)||(o.type==="background"||o.type==="custom"||(c||[]).length)&&(this.id=o.id,l.cm(o)?(function(g,v,b,P,E,k){if(g.renderPass!=="translucent")return;const{isRenderingToTexture:D}=k,L=vt.disabled,N=g.colorModeForRenderPass();(b._unevaluatedLayout.hasValue("text-variable-anchor")||b._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(q,H,W,K,re,Y,te,oe,Q){const ae=H.transform,ve=H.style.map.terrain,ge=re==="map",_e=Y==="map";for(const ye of q){const Re=K.getTile(ye),Fe=Re.getBucket(W);if(!Fe||!Fe.text||!Fe.text.segments.get().length)continue;const Ee=l.ay(Fe.textSizeData,ae.zoom),je=l.aN(Re,1,H.transform.zoom),st=_i(ge,H.transform,je),Mt=W.layout.get("icon-text-fit")!=="none"&&Fe.hasIconData();if(Ee){const qt=Math.pow(2,ae.zoom-Re.tileID.overscaledZ),Ot=ve?(Xt,Bt)=>ve.getElevation(ye,Xt,Bt):null;qh(Fe,ge,_e,Q,ae,st,qt,Ee,Mt,l.aO(ae,Re,te,oe),ye.toUnwrapped(),Ot)}}})(P,g,b,v,b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),E),b.paint.get("icon-opacity").constantOr(1)!==0&&yo(g,v,b,P,!1,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),b.layout.get("icon-rotation-alignment"),b.layout.get("icon-pitch-alignment"),b.layout.get("icon-keep-upright"),L,N,D),b.paint.get("text-opacity").constantOr(1)!==0&&yo(g,v,b,P,!0,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),b.layout.get("text-keep-upright"),L,N,D),v.map.showCollisionBoxes&&(Hn(g,v,b,P,!0),Hn(g,v,b,P,!1))})(t,n,o,c,this.style.placement.variableOffsets,f):l.cn(o)?(function(g,v,b,P,E){if(g.renderPass!=="translucent")return;const{isRenderingToTexture:k}=E,D=b.paint.get("circle-opacity"),L=b.paint.get("circle-stroke-width"),N=b.paint.get("circle-stroke-opacity"),q=!b.layout.get("circle-sort-key").isConstant();if(D.constantOr(1)===0&&(L.constantOr(1)===0||N.constantOr(1)===0))return;const H=g.context,W=H.gl,K=g.transform,re=g.getDepthModeForSublayer(0,ut.ReadOnly),Y=vt.disabled,te=g.colorModeForRenderPass(),oe=[],Q=K.getCircleRadiusCorrection();for(let ae=0;ae<P.length;ae++){const ve=P[ae],ge=v.getTile(ve),_e=ge.getBucket(b);if(!_e)continue;const ye=b.paint.get("circle-translate"),Re=b.paint.get("circle-translate-anchor"),Fe=l.aO(K,ge,ye,Re),Ee=_e.programConfigurations.get(b.id),je=g.useProgram("circle",Ee),st=_e.layoutVertexBuffer,Mt=_e.indexBuffer,qt=g.style.map.terrain&&g.style.map.terrain.getTerrainData(ve),Ot={programConfiguration:Ee,program:je,layoutVertexBuffer:st,indexBuffer:Mt,uniformValues:iu(g,ge,b,Fe,Q),terrainData:qt,projectionData:K.getProjectionData({overscaledTileID:ve,applyGlobeMatrix:!k,applyTerrainMatrix:!0})};if(q){const Xt=_e.segments.get();for(const Bt of Xt)oe.push({segments:new l.aX([Bt]),sortKey:Bt.sortKey,state:Ot})}else oe.push({segments:_e.segments,sortKey:0,state:Ot})}q&&oe.sort(((ae,ve)=>ae.sortKey-ve.sortKey));for(const ae of oe){const{programConfiguration:ve,program:ge,layoutVertexBuffer:_e,indexBuffer:ye,uniformValues:Re,terrainData:Fe,projectionData:Ee}=ae.state;ge.draw(H,W.TRIANGLES,re,Y,te,yt.backCCW,Re,Fe,Ee,b.id,_e,ye,ae.segments,b.paint,g.transform.zoom,ve)}})(t,n,o,c,f):l.co(o)?(function(g,v,b,P,E){if(b.paint.get("heatmap-opacity")===0)return;const k=g.context,{isRenderingToTexture:D,isRenderingGlobe:L}=E;if(g.style.map.terrain){for(const N of P){const q=v.getTile(N);v.hasRenderableParent(N)||(g.renderPass==="offscreen"?yu(g,q,b,N,L):g.renderPass==="translucent"&&vu(g,b,N,D,L))}k.viewport.set([0,0,g.width,g.height])}else g.renderPass==="offscreen"?(function(N,q,H,W){const K=N.context,re=K.gl,Y=N.transform,te=vt.disabled,oe=new Lt([re.ONE,re.ONE],l.bp.transparent,[!0,!0,!0,!0]);(function(Q,ae,ve){const ge=Q.gl;Q.activeTexture.set(ge.TEXTURE1),Q.viewport.set([0,0,ae.width/4,ae.height/4]);let _e=ve.heatmapFbos.get(l.cd);_e?(ge.bindTexture(ge.TEXTURE_2D,_e.colorAttachment.get()),Q.bindFramebuffer.set(_e.framebuffer)):(_e=vo(Q,ae.width/4,ae.height/4),ve.heatmapFbos.set(l.cd,_e))})(K,N,H),K.clear({color:l.bp.transparent});for(let Q=0;Q<W.length;Q++){const ae=W[Q];if(q.hasRenderableParent(ae))continue;const ve=q.getTile(ae),ge=ve.getBucket(H);if(!ge)continue;const _e=ge.programConfigurations.get(H.id),ye=N.useProgram("heatmap",_e),Re=Y.getProjectionData({overscaledTileID:ae,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),Fe=Y.getCircleRadiusCorrection();ye.draw(K,re.TRIANGLES,ut.disabled,te,oe,yt.backCCW,Cs(ve,Y.zoom,H.paint.get("heatmap-intensity"),Fe),null,Re,H.id,ge.layoutVertexBuffer,ge.indexBuffer,ge.segments,H.paint,Y.zoom,_e)}K.viewport.set([0,0,N.width,N.height])})(g,v,b,P):g.renderPass==="translucent"&&(function(N,q){const H=N.context,W=H.gl;H.setColorMode(N.colorModeForRenderPass());const K=q.heatmapFbos.get(l.cd);K&&(H.activeTexture.set(W.TEXTURE0),W.bindTexture(W.TEXTURE_2D,K.colorAttachment.get()),H.activeTexture.set(W.TEXTURE1),Ta(H,q).bind(W.LINEAR,W.CLAMP_TO_EDGE),N.useProgram("heatmapTexture").draw(H,W.TRIANGLES,ut.disabled,vt.disabled,N.colorModeForRenderPass(),yt.disabled,su(N,q,0,1),null,null,q.id,N.viewportBuffer,N.quadTriangleIndexBuffer,N.viewportSegments,q.paint,N.transform.zoom))})(g,b)})(t,n,o,c,f):l.cp(o)?(function(g,v,b,P,E){if(g.renderPass!=="translucent")return;const{isRenderingToTexture:k}=E,D=b.paint.get("line-opacity"),L=b.paint.get("line-width");if(D.constantOr(1)===0||L.constantOr(1)===0)return;const N=g.getDepthModeForSublayer(0,ut.ReadOnly),q=g.colorModeForRenderPass(),H=b.paint.get("line-dasharray"),W=H.constantOr(1),K=b.paint.get("line-pattern"),re=K.constantOr(1),Y=b.paint.get("line-gradient"),te=b.getCrossfadeParameters();let oe;oe=re?"linePattern":W&&Y?"lineGradientSDF":W?"lineSDF":Y?"lineGradient":"line";const Q=g.context,ae=Q.gl,ve=g.transform;let ge=!0;for(const _e of P){const ye=v.getTile(_e);if(re&&!ye.patternsLoaded())continue;const Re=ye.getBucket(b);if(!Re)continue;const Fe=Re.programConfigurations.get(b.id),Ee=g.context.program.get(),je=g.useProgram(oe,Fe),st=ge||je.program!==Ee,Mt=g.style.map.terrain&&g.style.map.terrain.getTerrainData(_e),qt=K.constantOr(null),Ot=H&&H.constantOr(null);if(qt&&ye.imageAtlas){const jr=ye.imageAtlas,Sr=jr.patternPositions[qt.to.toString()],vr=jr.patternPositions[qt.from.toString()];Sr&&vr&&Fe.setConstantPatternPositions(Sr,vr)}else if(Ot){const jr=b.layout.get("line-cap")==="round",Sr=g.lineAtlas.getDash(Ot.to,jr),vr=g.lineAtlas.getDash(Ot.from,jr);Fe.setConstantDashPositions(Sr,vr)}const Xt=ve.getProjectionData({overscaledTileID:_e,applyGlobeMatrix:!k,applyTerrainMatrix:!0}),Bt=ve.getPixelScale();let ur;re?(ur=Il(g,ye,b,Bt,te),bu(Q,ae,ye,Fe,te)):W&&Y?(ur=ca(g,ye,b,Bt,te,Re.lineClipsArray.length),vi(g,v,Q,ae,b,Re,_e,Fe,te)):W?(ur=lu(g,ye,b,Bt,te),_r(g,Q,ae,Fe,st,te)):Y?(ur=au(g,ye,b,Bt,Re.lineClipsArray.length),Xn(g,v,Q,ae,b,Re,_e)):ur=ho(g,ye,b,Bt);const Yt=g.stencilModeForClipping(_e);je.draw(Q,ae.TRIANGLES,N,Yt,q,yt.disabled,ur,Mt,Xt,b.id,Re.layoutVertexBuffer,Re.indexBuffer,Re.segments,b.paint,g.transform.zoom,Fe,Re.layoutVertexBuffer2),ge=!1}})(t,n,o,c,f):l.cq(o)?(function(g,v,b,P,E){const k=b.paint.get("fill-color"),D=b.paint.get("fill-opacity");if(D.constantOr(1)===0)return;const{isRenderingToTexture:L}=E,N=g.colorModeForRenderPass(),q=b.paint.get("fill-pattern"),H=g.opaquePassEnabledForLayer()&&!q.constantOr(1)&&k.constantOr(l.bp.transparent).a===1&&D.constantOr(0)===1?"opaque":"translucent";if(g.renderPass===H){const W=g.getDepthModeForSublayer(1,g.renderPass==="opaque"?ut.ReadWrite:ut.ReadOnly);xo(g,v,b,P,W,N,!1,L)}if(g.renderPass==="translucent"&&b.paint.get("fill-antialias")){const W=g.getDepthModeForSublayer(b.getPaintProperty("fill-outline-color")?2:0,ut.ReadOnly);xo(g,v,b,P,W,N,!0,L)}})(t,n,o,c,f):l.cr(o)?(function(g,v,b,P,E){const k=b.paint.get("fill-extrusion-opacity");if(k===0)return;const{isRenderingToTexture:D}=E;if(g.renderPass==="translucent"){const L=new ut(g.context.gl.LEQUAL,ut.ReadWrite,g.depthRangeFor3D);if(k!==1||b.paint.get("fill-extrusion-pattern").constantOr(1))Pa(g,v,b,P,L,vt.disabled,Lt.disabled,D),Pa(g,v,b,P,L,g.stencilModeFor3D(),g.colorModeForRenderPass(),D);else{const N=g.colorModeForRenderPass();Pa(g,v,b,P,L,vt.disabled,N,D)}}})(t,n,o,c,f):l.cs(o)?(function(g,v,b,P,E){if(g.renderPass!=="offscreen"&&g.renderPass!=="translucent")return;const{isRenderingToTexture:k}=E,D=g.context,L=g.style.projection.useSubdivision,N=g.getDepthModeForSublayer(0,ut.ReadOnly),q=g.colorModeForRenderPass();if(g.renderPass==="offscreen")(function(H,W,K,re,Y,te,oe){const Q=H.context,ae=Q.gl;for(const ve of K){const ge=W.getTile(ve),_e=ge.dem;if(!_e||!_e.data||!ge.needsHillshadePrepare)continue;const ye=_e.dim,Re=_e.stride,Fe=_e.getPixels();if(Q.activeTexture.set(ae.TEXTURE1),Q.pixelStoreUnpackPremultiplyAlpha.set(!1),ge.demTexture=ge.demTexture||H.getTileTexture(Re),ge.demTexture){const je=ge.demTexture;je.update(Fe,{premultiply:!1}),je.bind(ae.NEAREST,ae.CLAMP_TO_EDGE)}else ge.demTexture=new l.T(Q,Fe,ae.RGBA,{premultiply:!1}),ge.demTexture.bind(ae.NEAREST,ae.CLAMP_TO_EDGE);Q.activeTexture.set(ae.TEXTURE0);let Ee=ge.fbo;if(!Ee){const je=new l.T(Q,{width:ye,height:ye,data:null},ae.RGBA);je.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),Ee=ge.fbo=Q.createFramebuffer(ye,ye,!0,!1),Ee.colorAttachment.set(je.texture)}Q.bindFramebuffer.set(Ee.framebuffer),Q.viewport.set([0,0,ye,ye]),H.useProgram("hillshadePrepare").draw(Q,ae.TRIANGLES,Y,te,oe,yt.disabled,Fh(ge.tileID,_e),null,null,re.id,H.rasterBoundsBuffer,H.quadTriangleIndexBuffer,H.rasterBoundsSegments),ge.needsHillshadePrepare=!1}})(g,v,P,b,N,vt.disabled,q),D.viewport.set([0,0,g.width,g.height]);else if(g.renderPass==="translucent")if(L){const[H,W,K]=g.stencilConfigForOverlapTwoPass(P);Tn(g,v,b,K,H,N,q,!1,k),Tn(g,v,b,K,W,N,q,!0,k)}else{const[H,W]=g.getStencilConfigForOverlapAndUpdateStencilID(P);Tn(g,v,b,W,H,N,q,!1,k)}})(t,n,o,c,f):l.ct(o)?(function(g,v,b,P,E){if(g.renderPass!=="translucent"||!P.length)return;const{isRenderingToTexture:k}=E,D=g.style.projection.useSubdivision,L=g.getDepthModeForSublayer(0,ut.ReadOnly),N=g.colorModeForRenderPass();if(D){const[q,H,W]=g.stencilConfigForOverlapTwoPass(P);bo(g,v,b,W,q,L,N,!1,k),bo(g,v,b,W,H,L,N,!0,k)}else{const[q,H]=g.getStencilConfigForOverlapAndUpdateStencilID(P);bo(g,v,b,H,q,L,N,!1,k)}})(t,n,o,c,f):l.bU(o)?(function(g,v,b,P,E){if(g.renderPass!=="translucent"||b.paint.get("raster-opacity")===0||!P.length)return;const{isRenderingToTexture:k}=E,D=v.getSource(),L=g.style.projection.useSubdivision;if(D instanceof gi)Rs(g,v,b,P,null,!1,!1,D.tileCoords,D.flippedWindingOrder,k);else if(L){const[N,q,H]=g.stencilConfigForOverlapTwoPass(P);Rs(g,v,b,H,N,!1,!0,Yn,!1,k),Rs(g,v,b,H,q,!0,!0,Yn,!1,k)}else{const[N,q]=g.getStencilConfigForOverlapAndUpdateStencilID(P);Rs(g,v,b,q,N,!1,!0,Yn,!1,k)}})(t,n,o,c,f):l.cu(o)?(function(g,v,b,P,E){const k=b.paint.get("background-color"),D=b.paint.get("background-opacity");if(D===0)return;const{isRenderingToTexture:L}=E,N=g.context,q=N.gl,H=g.style.projection,W=g.transform,K=W.tileSize,re=b.paint.get("background-pattern");if(g.isPatternMissing(re))return;const Y=!re&&k.a===1&&D===1&&g.opaquePassEnabledForLayer()?"opaque":"translucent";if(g.renderPass!==Y)return;const te=vt.disabled,oe=g.getDepthModeForSublayer(0,Y==="opaque"?ut.ReadWrite:ut.ReadOnly),Q=g.colorModeForRenderPass(),ae=g.useProgram(re?"backgroundPattern":"background"),ve=P||Zt(W,{tileSize:K,terrain:g.style.map.terrain});re&&(N.activeTexture.set(q.TEXTURE0),g.imageManager.bind(g.context));const ge=b.getCrossfadeParameters();for(const _e of ve){const ye=W.getProjectionData({overscaledTileID:_e,applyGlobeMatrix:!L,applyTerrainMatrix:!0}),Re=re?Oh(D,g,re,{tileID:_e,tileSize:K},ge):Al(D,k),Fe=g.style.map.terrain&&g.style.map.terrain.getTerrainData(_e),Ee=H.getMeshFromTileID(N,_e.canonical,!1,!0,"raster");ae.draw(N,q.TRIANGLES,oe,te,Q,yt.backCCW,Re,Fe,ye,b.id,Ee.vertexBuffer,Ee.indexBuffer,Ee.segments)}})(t,0,o,c,f):l.cv(o)&&(function(g,v,b,P){const{isRenderingGlobe:E}=P,k=g.context,D=b.implementation,L=g.style.projection,N=g.transform,q=N.getProjectionDataForCustomLayer(E),H={farZ:N.farZ,nearZ:N.nearZ,fov:N.fov*Math.PI/180,modelViewProjectionMatrix:N.modelViewProjectionMatrix,projectionMatrix:N.projectionMatrix,shaderData:{variantName:L.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
|
|
850
|
+
uniform mat4 u_projection_matrix;
|
|
851
|
+
${L.shaderPreludeCode.vertexSource}`,define:L.shaderDefine},defaultProjectionData:q},W=D.renderingMode?D.renderingMode:"2d";if(g.renderPass==="offscreen"){const K=D.prerender;K&&(g.setCustomLayerDefaults(),k.setColorMode(g.colorModeForRenderPass()),K.call(D,k.gl,H),k.setDirty(),g.setBaseState())}else if(g.renderPass==="translucent"){g.setCustomLayerDefaults(),k.setColorMode(g.colorModeForRenderPass()),k.setStencilMode(vt.disabled);const K=W==="3d"?g.getDepthModeFor3D():g.getDepthModeForSublayer(0,ut.ReadOnly);k.setDepthMode(K),D.render(k.gl,H),k.setDirty(),g.setBaseState(),k.bindFramebuffer.set(null)}})(t,0,o,f))}saveTileTexture(t){const n=this._tileTextures[t.size[0]];n?n.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const n=this._tileTextures[t];return n&&n.length>0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),o=this.imageManager.getPattern(t.to.toString());return!n||!o}useProgram(t,n,o=!1,c=[]){this.cache=this.cache||{};const f=!!this.style.map.terrain,g=this.style.projection,v=o?tr.projectionMercator:g.shaderPreludeCode,b=o?ri:g.shaderDefine,P=t+(n?n.cacheKey:"")+`/${o?yi:g.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(f?"/terrain":"")+(c?`/${c.join("/")}`:"");return this.cache[P]||(this.cache[P]=new Qc(this.context,tr[t],n,Bh[t],this._showOverdrawInspector,f,v,b,c)),this.cache[P]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new l.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var t,n;if(this._tileTextures){for(const o in this._tileTextures){const c=this._tileTextures[o];if(c)for(const f of c)f.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((t=this.tileExtentMesh.vertexBuffer)===null||t===void 0||t.destroy()),this.tileExtentMesh&&((n=this.tileExtentMesh.indexBuffer)===null||n===void 0||n.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const o in this.cache){const c=this.cache[o];c&&c.program&&this.context.gl.deleteProgram(c.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}function $l(d,t){let n,o=!1,c=null,f=null;const g=()=>{c=null,o&&(d.apply(f,n),c=setTimeout(g,t),o=!1)};return(...v)=>(o=!0,f=this,n=v,c||g(),c)}class Zl{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let o;return n.split("&").map((c=>c.split("="))).forEach((c=>{c[0]===this._hashName&&(o=c)})),(o&&o[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const o=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:o,pitch:+(n[4]||0)}),!0},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const o=n.join("/");let c=o;c.split("&").length>0&&(c=c.split("&")[0]),this._hashName&&(c=`${this._hashName}=${o}`);let f=window.location.hash.replace(c,"");f.startsWith("#&")?f=f.slice(0,1)+f.slice(2):f==="#"&&(f="");let g=window.location.href.replace(/(#.+)?$/,f);g=g.replace("&&","&"),window.history.replaceState(window.history.state,null,g)},this._updateHash=$l(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const n=this._map.getCenter(),o=Math.round(100*this._map.getZoom())/100,c=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),f=Math.pow(10,c),g=Math.round(n.lng*f)/f,v=Math.round(n.lat*f)/f,b=this._map.getBearing(),P=this._map.getPitch();let E="";if(E+=t?`/${g}/${v}/${o}`:`${o}/${v}/${g}`,(b||P)&&(E+="/"+Math.round(10*b)/10),P&&(E+=`/${Math.round(P)}`),this._hashName){const k=this._hashName;let D=!1;const L=window.location.hash.slice(1).split("&").map((N=>{const q=N.split("=")[0];return q===k?(D=!0,`${q}=${E}`):N})).filter((N=>N));return D||L.push(`${k}=${E}`),`#${L.join("&")}`}return`#${E}`}_isValidHash(t){if(t.length<3||t.some(isNaN))return!1;try{new l.V(+t[2],+t[1])}catch{return!1}const n=+t[0],o=+(t[3]||0),c=+(t[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&o>=-180&&o<=180&&c>=this._map.getMinPitch()&&c<=this._map.getMaxPitch()}}const Pn={linearity:.3,easing:l.cw(0,0,.3,1)},Cu=l.e({deceleration:2500,maxSpeed:1400},Pn),Mi=l.e({deceleration:20,maxSpeed:1400},Pn),Oi=l.e({deceleration:1e3,maxSpeed:360},Pn),Au=l.e({deceleration:1e3,maxSpeed:90},Pn),Bi=l.e({deceleration:1e3,maxSpeed:360},Pn);class Wh{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Qe(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=Qe();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,roll:0,pan:new l.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:f}of this._inertiaBuffer)n.zoom+=f.zoomDelta||0,n.bearing+=f.bearingDelta||0,n.pitch+=f.pitchDelta||0,n.roll+=f.rollDelta||0,f.panDelta&&n.pan._add(f.panDelta),f.around&&(n.around=f.around),f.pinchAround&&(n.pinchAround=f.pinchAround);const o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(n.pan.mag()){const f=So(n.pan.mag(),o,l.e({},Cu,t||{})),g=n.pan.mult(f.amount/n.pan.mag()),v=this._map.cameraHelper.handlePanInertia(g,this._map.transform);c.center=v.easingCenter,c.offset=v.easingOffset,To(c,f)}if(n.zoom){const f=So(n.zoom,o,Mi),g=l.cx(this._map.transform.zoom+f.amount,this._map.getZoomSnap(),f.amount);c.zoom=g,To(c,f)}if(n.bearing){const f=So(n.bearing,o,Oi);c.bearing=this._map.transform.bearing+l.an(f.amount,-179,179),To(c,f)}if(n.pitch){const f=So(n.pitch,o,Au);c.pitch=this._map.transform.pitch+f.amount,To(c,f)}if(n.roll){const f=So(n.roll,o,Bi);c.roll=this._map.transform.roll+l.an(f.amount,-179,179),To(c,f)}if(c.zoom||c.bearing){const f=n.pinchAround===void 0?n.around:n.pinchAround;c.around=f?this._map.unproject(f):this._map.getCenter()}return this.clear(),l.e(c,{noMoveStart:!0})}}function To(d,t){(!d.duration||d.duration<t.duration)&&(d.duration=t.duration,d.easing=t.easing)}function So(d,t,n){const{maxSpeed:o,linearity:c,deceleration:f}=n,g=l.an(d*c/(t/1e3),-o,o),v=Math.abs(g)/(f*c);return{easing:n.easing,duration:1e3*v,amount:g*(v/2)}}class Br extends l.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,o,c={}){o=o instanceof MouseEvent?o:new MouseEvent(t,o);const f=me.mousePos(n.getCanvas(),o),g=n.unproject(f);super(t,l.e({point:f,lngLat:g,originalEvent:o},c)),this._defaultPrevented=!1,this.target=n}}class Po extends l.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,o){const c=t==="touchend"?o.changedTouches:o.touches,f=me.touchPos(n.getCanvasContainer(),c),g=f.map((b=>n.unproject(b))),v=f.reduce(((b,P,E,k)=>b.add(P.div(k.length))),new l.P(0,0));super(t,{points:f,point:v,lngLats:g,lngLat:n.unproject(v),originalEvent:o}),this._defaultPrevented=!1}}class zu extends l.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,o){super(t,{originalEvent:o}),this._defaultPrevented=!1}}class Hh{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new zu(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Br(t.type,this._map,t))}mouseup(t){this._map.fire(new Br(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Br(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Br(t.type,this._map,t))}mouseover(t){this._map.fire(new Br(t.type,this._map,t))}mouseout(t){this._map.fire(new Br(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Po(t.type,this._map,t))}touchmove(t){this._map.fire(new Po(t.type,this._map,t))}touchend(t){this._map.fire(new Po(t.type,this._map,t))}touchcancel(t){this._map.fire(new Po(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Xh{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Br(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Br("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Br(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Fs{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.screenPointToLocation(l.P.convert(t),this._map.terrain)}}class Ls{constructor(t,n){this._map=t,this._tr=new Fs(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(me.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const o=n;if(this._lastPos.equals(o)||!this._box&&o.dist(this._startPos)<this._clickTolerance)return;const c=this._startPos;this._lastPos=o,this._box||(this._box=me.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const f=Math.min(c.x,o.x),g=Math.max(c.x,o.x),v=Math.min(c.y,o.y),b=Math.max(c.y,o.y);me.setTransform(this._box,`translate(${f}px,${v}px)`),this._box.style.width=g-f+"px",this._box.style.height=b-v+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const o=this._startPos,c=n;if(this.reset(),me.suppressClick(),o.x!==c.x||o.y!==c.y)return this._map.fire(new l.l("boxzoomend",{originalEvent:t})),{cameraAnimation:f=>f.fitScreenCoordinates(o,c,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(me.remove(this._box),this._box=null),me.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new l.l(t,{originalEvent:n}))}}function ji(d,t){if(d.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${d.length}, points ${t.length}`);const n={};for(let o=0;o<d.length;o++)n[d[o].identifier]=t[o];return n}class Ue{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,o){(this.centroid||o.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),o.length===this.numTouches&&(this.centroid=(function(c){const f=new l.P(0,0);for(const g of c)f._add(g);return f.div(c.length)})(n),this.touches=ji(o,n)))}touchmove(t,n,o){if(this.aborted||!this.centroid)return;const c=ji(o,n);for(const f in this.touches){const g=c[f];(!g||g.dist(this.touches[f])>30)&&(this.aborted=!0)}}touchend(t,n,o){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),o.length===0){const c=!this.aborted&&this.centroid;if(this.reset(),c)return c}}}class Ia{constructor(t){this.singleTap=new Ue(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,o){this.singleTap.touchstart(t,n,o)}touchmove(t,n,o){this.singleTap.touchmove(t,n,o)}touchend(t,n,o){const c=this.singleTap.touchend(t,n,o);if(c){const f=t.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(c)<30;if(f&&g||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=c,this.count===this.numTaps)return this.reset(),c}}}class Ul{constructor(t){this._tr=new Fs(t),this._zoomIn=new Ia({numTouches:1,numTaps:2}),this._zoomOut=new Ia({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,o){this._zoomIn.touchstart(t,n,o),this._zoomOut.touchstart(t,n,o)}touchmove(t,n,o){this._zoomIn.touchmove(t,n,o),this._zoomOut.touchmove(t,n,o)}touchend(t,n,o){const c=this._zoomIn.touchend(t,n,o),f=this._zoomOut.touchend(t,n,o),g=this._tr;return c?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:v=>v.easeTo({duration:300,zoom:l.cx(g.zoom+1,v.getZoomSnap()),around:g.unproject(c)},{originalEvent:t})}):f?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:v=>v.easeTo({duration:300,zoom:l.cx(g.zoom-1,v.getZoomSnap()),around:g.unproject(f)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Os{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.rollDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const o=this._lastPoint;if(!o)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const c=Array.isArray(n)?n[0]:n;return!this._moved&&c.dist(o)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=c,this._move(o,c))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&me.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const Io=0,Mo=2,Gl={[Io]:1,[Mo]:2};class Eo{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=me.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(n,o){const c=Gl[o];return n.buttons===void 0||(n.buttons&c)!==c})(t,this._eventButton)}isValidEndEvent(t){return me.mouseButton(t)===this._eventButton}}class ql{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}class Du{constructor(t=new Eo({checkCorrectEvent:()=>!0}),n=new ql){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(t,n,o){return t instanceof MouseEvent?n(t):typeof TouchEvent<"u"&&t instanceof TouchEvent?o(t):void 0}startMove(t){this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.startMove(n)),(n=>this.oneFingerTouchMoveStateManager.startMove(n)))}endMove(t){this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.endMove(n)),(n=>this.oneFingerTouchMoveStateManager.endMove(n)))}isValidStartEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidStartEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidStartEvent(n)))}isValidMoveEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidMoveEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(n)))}isValidEndEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidEndEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidEndEvent(n)))}}const Bs=d=>{d.mousedown=d.dragStart,d.mousemoveWindow=d.dragMove,d.mouseup=d.dragEnd,d.contextmenu=t=>{t.preventDefault()}};class Yh{constructor(t,n){this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new l.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,n,o){return this._calculateTransform(t,n,o)}touchmove(t,n,o){if(this._active){if(!this._shouldBePrevented(o.length))return t.preventDefault(),this._calculateTransform(t,n,o);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,n,o){this._calculateTransform(t,n,o),this._active&&this._shouldBePrevented(o.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,o){o.length>0&&(this._active=!0);const c=ji(o,n),f=new l.P(0,0),g=new l.P(0,0);let v=0;for(const P in c){const E=c[P],k=this._touches[P];k&&(f._add(E),g._add(E.sub(k)),v++,c[P]=E)}if(this._touches=c,this._shouldBePrevented(v)||!g.mag())return;const b=g.div(v);return this._sum._add(b),this._sum.mag()<this._clickTolerance?void 0:{around:f.div(v),panDelta:b}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ma{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,n,o){this._firstTwoTouches||o.length<2||(this._firstTwoTouches=[o[0].identifier,o[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,o){if(!this._firstTwoTouches)return;t.preventDefault();const[c,f]=this._firstTwoTouches,g=Ea(o,n,c),v=Ea(o,n,f);if(!g||!v)return;const b=this._aroundCenter?null:g.add(v).div(2);return this._move([g,v],b,t)}touchend(t,n,o){if(!this._firstTwoTouches)return;const[c,f]=this._firstTwoTouches,g=Ea(o,n,c),v=Ea(o,n,f);g&&v||(this._active&&me.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Ea(d,t,n){for(let o=0;o<d.length;o++)if(d[o].identifier===n)return t[o]}function ku(d,t){return Math.log(d/t)/Math.LN2}class Wl extends Ma{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const o=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(ku(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:ku(this._distance,o),pinchAround:n}}}function Ru(d,t){return 180*d.angleWith(t)/Math.PI}class Hl extends Ma{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,n,o){const c=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Ru(this._vector,c),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,o=Ru(t,this._startVector);return Math.abs(o)<n}}function Xl(d){return Math.abs(d.y)>Math.abs(d.x)}class Fu extends Ma{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,o){super.touchstart(t,n,o),this._currentTouchCount=o.length}_start(t){this._lastPoints=t,Xl(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,o){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const c=t[0].sub(this._lastPoints[0]),f=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(c,f,o.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(c.y+f.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,o){if(this._valid!==void 0)return this._valid;const c=t.mag()>=2,f=n.mag()>=2;if(!c&&!f)return;if(!c||!f)return this._firstMove===void 0&&(this._firstMove=o),o-this._firstMove<100&&void 0;const g=t.y>0==n.y>0;return Xl(t)&&Xl(n)&&g}}const In={panStep:100,bearingStep:15,pitchStep:10};class Dt{constructor(t){this._tr=new Fs(t);const n=In;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,o=0,c=0,f=0,g=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?o=-1:(t.preventDefault(),f=-1);break;case 39:t.shiftKey?o=1:(t.preventDefault(),f=1);break;case 38:t.shiftKey?c=1:(t.preventDefault(),g=-1);break;case 40:t.shiftKey?c=-1:(t.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(o=0,c=0),{cameraAnimation:v=>{const b=this._tr;v.easeTo({duration:300,easeId:"keyboardHandler",easing:Kh,zoom:n?l.cx(b.zoom+n*(t.shiftKey?2:1),v.getZoomSnap()):b.zoom,bearing:b.bearing+o*this._bearingStep,pitch:b.pitch+c*this._pitchStep,offset:[-f*this._panStep,-g*this._panStep],center:b.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Kh(d){return d*(2-d)}const Co=4.000244140625,Ca=1/450;class Aa{constructor(t,n){this._onTimeout=o=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)},this._map=t,this._tr=new Fs(t),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Ca}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const o=Qe(),c=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,n!==0&&n%Co==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":c>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(c*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=me.mousePos(this._map.getCanvas(),t),o=this._tr;this._aroundPoint=this._aroundCenter?o.transform.locationToScreenPoint(l.V.convert(o.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const v=t.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=v),typeof this._targetZoom=="number"&&(this._targetZoom+=v)}if(this._delta!==0){const v=this._type==="wheel"&&Math.abs(this._delta)>Co?this._wheelZoomRate:this._defaultZoomRate;let b=2/(1+Math.exp(-Math.abs(this._delta*v)));this._delta<0&&b!==0&&(b=1/b);const P=typeof this._targetZoom!="number"?t.scale:l.aq(this._targetZoom),E=t.applyConstrain(t.getCameraLngLat(),l.at(P*b)).zoom,k=this._map.getZoomSnap();if(this._type==="wheel"&&k>0){const D=l.cx(t.zoom,k);this._targetZoom=l.cx(E,k,E-D)}else this._targetZoom=E;this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom!="number"?t.zoom:this._targetZoom,o=this._startZoom,c=this._easing;let f,g=!1;if(this._type==="wheel"&&o&&c){const v=Qe()-this._lastWheelEventTime,b=Math.min((v+5)/200,1),P=c(b);f=l.G.number(o,n,P),b<1?this._frameId||(this._frameId=!0):g=!0}else f=n,g=!0;return this._active=!0,g&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=f,{noInertia:!0,needsRenderFrame:!g,zoomDelta:f-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=l.cz;if(this._prevEase){const o=this._prevEase,c=(Qe()-o.start)/o.duration,f=o.easing(c+.01)-o.easing(c),g=.27/Math.sqrt(f*f+1e-4)*.01,v=Math.sqrt(.0729-g*g);n=l.cw(g,v,.25,1)}return this._prevEase={start:Qe(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Yl{constructor(t,n){this._clickZoom=t,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Lu{constructor(t){this._tr=new Fs(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:o=>{o.easeTo({duration:300,zoom:l.cx(this._tr.zoom+(t.shiftKey?-1:1),o.getZoomSnap()),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ou{constructor(){this._tap=new Ia({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,o){if(!this._swipePoint)if(this._tapTime){const c=n[0],f=t.timeStamp-this._tapTime<500,g=this._tapPoint.dist(c)<30;f&&g?o.length>0&&(this._swipePoint=c,this._swipeTouch=o[0].identifier):this.reset()}else this._tap.touchstart(t,n,o)}touchmove(t,n,o){if(this._tapTime){if(this._swipePoint){if(o[0].identifier!==this._swipeTouch)return;const c=n[0],f=c.y-this._swipePoint.y;return this._swipePoint=c,t.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(t,n,o)}touchend(t,n,o){if(this._tapTime)this._swipePoint&&o.length===0&&this.reset();else{const c=this._tap.touchend(t,n,o);c&&(this._tapTime=t.timeStamp,this._tapPoint=c)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Bu{constructor(t,n,o){this._el=t,this._mousePan=n,this._touchPan=o}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ni{constructor(t,n,o,c){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=n,this._mousePitch=o,this._mouseRoll=c}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Ao{constructor(t,n,o,c){this._el=t,this._touchZoom=n,this._touchRotate=o,this._tapDragZoom=c,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Xe{constructor(t,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=me.create("div","maplibregl-cooperative-gesture-screen",t);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const o=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),c=document.createElement("div");c.className="maplibregl-desktop-message",c.textContent=n,this._container.appendChild(c);const f=document.createElement("div");f.className="maplibregl-mobile-message",f.textContent=o,this._container.appendChild(f),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(me.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,n){this._enabled&&(this._map.fire(new l.l("cooperativegestureprevented",{gestureType:t,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const et=d=>d.zoom||d.drag||d.roll||d.pitch||d.rotate;class zo extends l.l{}function za(d){return d.panDelta&&d.panDelta.mag()||d.zoomDelta||d.bearingDelta||d.pitchDelta||d.rollDelta}class Da{get _ownerDocument(){var t;return((t=this._el)===null||t===void 0?void 0:t.ownerDocument)||document}get _ownerWindow(){var t,n;return((n=(t=this._el)===null||t===void 0?void 0:t.ownerDocument)===null||n===void 0?void 0:n.defaultView)||window}constructor(t,n){this.handleWindowEvent=c=>{this.handleEvent(c,`${c.type}Window`)},this.handleEvent=(c,f)=>{if(c.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const g=c.type==="renderFrame"?void 0:c,v={needsRenderFrame:!1},b={},P={};for(const{handlerName:D,handler:L,allowed:N}of this._handlers){if(!L.isEnabled())continue;let q;if(this._blockedByActive(P,N,D))L.reset();else if(L[f||c.type]){if(l.cA(c,f||c.type)){const H=me.mousePos(this._map.getCanvas(),c);q=L[f||c.type](c,H)}else if(l.cB(c,f||c.type)){const H=this._getMapTouches(c.touches),W=me.touchPos(this._map.getCanvas(),H);q=L[f||c.type](c,W,H)}else l.cC(f||c.type)||(q=L[f||c.type](c));this.mergeHandlerResult(v,b,q,D,g),q&&q.needsRenderFrame&&this._triggerRenderFrame()}(q||L.isActive())&&(P[D]=L)}const E={};for(const D in this._previousActiveHandlers)P[D]||(E[D]=g);this._previousActiveHandlers=P,(Object.keys(E).length||za(v))&&(this._changes.push([v,b,E]),this._triggerRenderFrame()),(Object.keys(P).length||za(v))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:k}=v;k&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],k(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wh(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[c,f,g]of this._listeners)me.addEventListener(c,f,c===this._ownerDocument?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[t,n,o]of this._listeners)me.removeEventListener(t,n,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,o)}_addDefaultHandlers(t){const n=this._map,o=n.getCanvasContainer();this._add("mapEvent",new Hh(n,t));const c=n.boxZoom=new Ls(n,t);this._add("boxZoom",c),t.interactive&&t.boxZoom&&c.enable();const f=n.cooperativeGestures=new Xe(n,t.cooperativeGestures);this._add("cooperativeGestures",f),t.cooperativeGestures&&f.enable();const g=new Ul(n),v=new Lu(n);n.doubleClickZoom=new Yl(v,g),this._add("tapZoom",g),this._add("clickZoom",v),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const b=new Ou;this._add("tapDragZoom",b);const P=n.touchPitch=new Fu(n);this._add("touchPitch",P),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const E=()=>n.project(n.getCenter()),k=(function({enable:Y,clickTolerance:te,aroundCenter:oe=!0,minPixelCenterThreshold:Q=100,rotateDegreesPerPixelMoved:ae=.8},ve){const ge=new Eo({checkCorrectEvent:_e=>me.mouseButton(_e)===0&&_e.ctrlKey||me.mouseButton(_e)===2&&!_e.ctrlKey});return new Os({clickTolerance:te,move:(_e,ye)=>{const Re=ve();if(oe&&Math.abs(Re.y-_e.y)>Q)return{bearingDelta:l.cy(new l.P(_e.x,ye.y),ye,Re)};let Fe=(ye.x-_e.x)*ae;return oe&&ye.y<Re.y&&(Fe=-Fe),{bearingDelta:Fe}},moveStateManager:ge,enable:Y,assignEvents:Bs})})(t,E),D=(function({enable:Y,clickTolerance:te,pitchDegreesPerPixelMoved:oe=-.5}){const Q=new Eo({checkCorrectEvent:ae=>me.mouseButton(ae)===0&&ae.ctrlKey||me.mouseButton(ae)===2});return new Os({clickTolerance:te,move:(ae,ve)=>({pitchDelta:(ve.y-ae.y)*oe}),moveStateManager:Q,enable:Y,assignEvents:Bs})})(t),L=(function({enable:Y,clickTolerance:te,rollDegreesPerPixelMoved:oe=.3},Q){const ae=new Eo({checkCorrectEvent:ve=>me.mouseButton(ve)===2&&ve.ctrlKey});return new Os({clickTolerance:te,move:(ve,ge)=>{const _e=Q();let ye=(ge.x-ve.x)*oe;return ge.y<_e.y&&(ye=-ye),{rollDelta:ye}},moveStateManager:ae,enable:Y,assignEvents:Bs})})(t,E);n.dragRotate=new Ni(t,k,D,L),this._add("mouseRotate",k,["mousePitch"]),this._add("mousePitch",D,["mouseRotate","mouseRoll"]),this._add("mouseRoll",L,["mousePitch"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const N=(function({enable:Y,clickTolerance:te}){const oe=new Eo({checkCorrectEvent:Q=>me.mouseButton(Q)===0&&!Q.ctrlKey});return new Os({clickTolerance:te,move:(Q,ae)=>({around:ae,panDelta:ae.sub(Q)}),activateOnStart:!0,moveStateManager:oe,enable:Y,assignEvents:Bs})})(t),q=new Yh(t,n);n.dragPan=new Bu(o,N,q),this._add("mousePan",N),this._add("touchPan",q,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const H=new Hl,W=new Wl;n.touchZoomRotate=new Ao(o,W,H,b),this._add("touchRotate",H,["touchPan","touchZoom"]),this._add("touchZoom",W,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new Xh(n));const K=n.scrollZoom=new Aa(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",K,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const re=n.keyboard=new Dt(n);this._add("keyboard",re),t.interactive&&t.keyboard&&n.keyboard.enable()}_add(t,n,o){this._handlers.push({handlerName:t,handler:n,allowed:o}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!et(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,o){for(const c in t)if(c!==o&&(!n||n.indexOf(c)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const o of t)this._el.contains(o.target)&&n.push(o);return n}mergeHandlerResult(t,n,o,c,f){if(!o)return;l.e(t,o);const g={handlerName:c,originalEvent:o.originalEvent||f};o.zoomDelta!==void 0&&(n.zoom=g),o.panDelta!==void 0&&(n.drag=g),o.rollDelta!==void 0&&(n.roll=g),o.pitchDelta!==void 0&&(n.pitch=g),o.bearingDelta!==void 0&&(n.rotate=g)}_applyChanges(){const t={},n={},o={};for(const[c,f,g]of this._changes)c.panDelta&&(t.panDelta=(t.panDelta||new l.P(0,0))._add(c.panDelta)),c.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+c.pitchDelta),c.rollDelta&&(t.rollDelta=(t.rollDelta||0)+c.rollDelta),c.around!==void 0&&(t.around=c.around),c.pinchAround!==void 0&&(t.pinchAround=c.pinchAround),c.noInertia&&(t.noInertia=c.noInertia),l.e(n,f),l.e(o,g);this._updateMapTransform(t,n,o),this._changes=[]}_updateMapTransform(t,n,o){const c=this._map,f=c._getTransformForUpdate(),g=c.terrain;if(!(za(t)||g&&this._terrainMovement))return this._fireEvents(n,o,!0);c._stop(!0);let{panDelta:v,zoomDelta:b,bearingDelta:P,pitchDelta:E,rollDelta:k,around:D,pinchAround:L}=t;L!==void 0&&(D=L),D=D||c.transform.centerPoint,g&&!f.isPointOnMapSurface(D)&&(D=f.centerPoint);const N={panDelta:v,zoomDelta:b,rollDelta:k,pitchDelta:E,bearingDelta:P,around:D};this._map.cameraHelper.useGlobeControls&&!f.isPointOnMapSurface(D)&&(D=f.centerPoint);const q=D.distSqr(f.centerPoint)<.01?f.center:f.screenPointToLocation(v?D.sub(v):D);this._handleMapControls({terrain:g,tr:f,deltasForHelper:N,preZoomAroundLoc:q,combinedEventsInProgress:n,panDelta:v}),c._applyUpdatedTransform(f),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,o,!0)}_handleMapControls({terrain:t,tr:n,deltasForHelper:o,preZoomAroundLoc:c,combinedEventsInProgress:f,panDelta:g}){const v=this._map.cameraHelper;if(v.handleMapControlsRollPitchBearingZoom(o,n),t)return v.useGlobeControls?(this._terrainMovement||!f.drag&&!f.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void v.handleMapControlsPan(o,n,c)):this._terrainMovement||!f.drag&&!f.zoom?void(f.drag&&this._terrainMovement&&g?n.setCenter(n.screenPointToLocation(n.centerPoint.sub(g))):v.handleMapControlsPan(o,n,c)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void v.handleMapControlsPan(o,n,c));v.handleMapControlsPan(o,n,c)}_fireEvents(t,n,o){const c=et(this._eventsInProgress),f=et(t),g={};for(const k in t){const{originalEvent:D}=t[k];this._eventsInProgress[k]||(g[`${k}start`]=D),this._eventsInProgress[k]=t[k]}!c&&f&&this._fireEvent("movestart",f.originalEvent);for(const k in g)this._fireEvent(k,g[k]);f&&this._fireEvent("move",f.originalEvent);for(const k in t){const{originalEvent:D}=t[k];this._fireEvent(k,D)}const v={};let b;for(const k in this._eventsInProgress){const{handlerName:D,originalEvent:L}=this._eventsInProgress[k];this._handlersById[D].isActive()||(delete this._eventsInProgress[k],b=n[D]||L,v[`${k}end`]=b)}for(const k in v)this._fireEvent(k,v[k]);const P=et(this._eventsInProgress),E=(c||f)&&!P;if(E&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const k=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&k.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(k)}if(o&&E){this._updatingCamera=!0;const k=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),D=L=>L!==0&&-this._bearingSnap<L&&L<this._bearingSnap;!k||!k.essential&&Ze.prefersReducedMotion?(this._map.fire(new l.l("moveend",{originalEvent:b})),D(this._map.getBearing())&&this._map.resetNorth()):(D(k.bearing||this._map.getBearing())&&(k.bearing=0),k.freezeElevation=!0,this._map.easeTo(k,{originalEvent:b})),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new l.l(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new zo("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class si extends l.E{constructor(t,n,o){super(),this._renderFrameCallback=()=>{const c=Math.min((Qe()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(c)),c<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=o.bearingSnap,this._zoomSnap=o.zoomSnap,this.cameraHelper=n,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,n){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=n}getCenter(){return new l.V(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,n){return this.jumpTo({elevation:t},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,n,o){return t=l.P.convert(t).mult(-1),this.panTo(this.transform.center,l.e({offset:t},n),o)}panTo(t,n,o){return this.easeTo(l.e({center:t},n),o)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,o){return this.easeTo(l.e({zoom:t},n),o)}zoomIn(t,n){return this.zoomTo(l.cx(this.getZoom()+1,this._zoomSnap),t,n),this}zoomOut(t,n){return this.zoomTo(l.cx(this.getZoom()-1,this._zoomSnap),t,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,n){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new l.l("movestart",n)).fire(new l.l("move",n)).fire(new l.l("moveend",n))),this}getBearing(){return this.transform.bearing}setZoomSnap(t){return this._zoomSnap=t,this}getZoomSnap(){return this._zoomSnap}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,o){return this.easeTo(l.e({bearing:t},n),o)}resetNorth(t,n){return this.rotateTo(0,l.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(l.e({bearing:0,pitch:0,roll:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,n):this}getPitch(){return this.transform.pitch}setPitch(t,n){return this.jumpTo({pitch:t},n),this}getRoll(){return this.transform.roll}setRoll(t,n){return this.jumpTo({roll:t},n),this}cameraForBounds(t,n){t=er.convert(t).adjustAntiMeridian();const o=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),o,n)}_cameraForBoxAndBearing(t,n,o,c){const f={top:0,bottom:0,right:0,left:0};if(typeof(c=l.e({padding:f,offset:[0,0],maxZoom:this.transform.maxZoom},c)).padding=="number"){const P=c.padding;c.padding={top:P,bottom:P,right:P,left:P}}const g=l.e(f,c.padding);c.padding=g;const v=this.transform,b=new er(t,n);return this.cameraHelper.cameraForBoxAndBearing(c,g,b,o,v)}fitBounds(t,n,o){return this._fitInternal(this.cameraForBounds(t,n),n,o)}fitScreenCoordinates(t,n,o,c,f){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(l.P.convert(t)),this.transform.screenPointToLocation(l.P.convert(n)),o,c),c,f)}_fitInternal(t,n,o){return t?(delete(n=l.e(t,n)).padding,n.linear?this.easeTo(n,o):this.flyTo(n,o)):this}jumpTo(t,n){this.stop();const o=this._getTransformForUpdate();let c=!1,f=!1,g=!1;const v=o.zoom;this.cameraHelper.handleJumpToCenterZoom(o,t);const b=o.zoom!==v;return"elevation"in t&&o.elevation!==+t.elevation&&o.setElevation(+t.elevation),"bearing"in t&&o.bearing!==+t.bearing&&(c=!0,o.setBearing(+t.bearing)),"pitch"in t&&o.pitch!==+t.pitch&&(f=!0,o.setPitch(+t.pitch)),"roll"in t&&o.roll!==+t.roll&&(g=!0,o.setRoll(+t.roll)),t.padding==null||o.isPaddingEqual(t.padding)||o.setPadding(t.padding),this._applyUpdatedTransform(o),this.fire(new l.l("movestart",n)).fire(new l.l("move",n)),b&&this.fire(new l.l("zoomstart",n)).fire(new l.l("zoom",n)).fire(new l.l("zoomend",n)),c&&this.fire(new l.l("rotatestart",n)).fire(new l.l("rotate",n)).fire(new l.l("rotateend",n)),f&&this.fire(new l.l("pitchstart",n)).fire(new l.l("pitch",n)).fire(new l.l("pitchend",n)),g&&this.fire(new l.l("rollstart",n)).fire(new l.l("roll",n)).fire(new l.l("rollend",n)),this.fire(new l.l("moveend",n))}calculateCameraOptionsFromTo(t,n,o,c=0){const f=l.a9.fromLngLat(t,n),g=l.a9.fromLngLat(o,c),v=g.x-f.x,b=g.y-f.y,P=g.z-f.z,E=Math.hypot(v,b,P);if(E===0)throw new Error("Can't calculate camera options with same From and To");const k=Math.hypot(v,b),D=l.at(this.transform.cameraToCenterDistance/E/this.transform.tileSize),L=180*Math.atan2(v,-b)/Math.PI;let N=180*Math.acos(k/E)/Math.PI;return N=P<0?90-N:90+N,{center:g.toLngLat(),elevation:c,zoom:D,pitch:N,bearing:L}}calculateCameraOptionsFromCameraLngLatAltRotation(t,n,o,c,f){const g=this.transform.calculateCenterFromCameraLngLatAlt(t,n,o,c);return{center:g.center,elevation:g.elevation,zoom:g.zoom,bearing:o,pitch:c,roll:f}}easeTo(t,n){this._stop(!1,t.easeId),((t=l.e({offset:[0,0],duration:500,easing:l.cz},t)).animate===!1||!t.essential&&Ze.prefersReducedMotion)&&(t.duration=0);const o=this._getTransformForUpdate(),c=this.getBearing(),f=o.pitch,g=o.roll,v="bearing"in t?this._normalizeBearing(t.bearing,c):c,b="pitch"in t?+t.pitch:f,P="roll"in t?this._normalizeBearing(t.roll,g):g,E="padding"in t?t.padding:o.padding,k=l.P.convert(t.offset);let D,L;t.around&&(D=l.V.convert(t.around),L=o.locationToScreenPoint(D));const N={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},q=this.cameraHelper.handleEaseTo(o,{bearing:v,pitch:b,roll:P,padding:E,around:D,aroundPoint:L,offsetAsPoint:k,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating=this._rotating||c!==v,this._pitching=this._pitching||b!==f,this._rolling=this._rolling||P!==g,this._padding=!o.isPaddingEqual(E),this._zooming=this._zooming||q.isZooming,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,N),this.terrain&&this._prepareElevation(q.elevationCenter),this._ease((H=>{q.easeFunc(H),this.terrain&&!t.freezeElevation&&this._updateElevation(H),this._applyUpdatedTransform(o),this._fireMoveEvents(n)}),(H=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n,H)}),t),this}_prepareEase(t,n,o={}){this._moving=!0,n||o.moving||this.fire(new l.l("movestart",t)),this._zooming&&!o.zooming&&this.fire(new l.l("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new l.l("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new l.l("pitchstart",t)),this._rolling&&!o.rolling&&this.fire(new l.l("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const o=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(o-(n-(o*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.setElevation(l.G.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};const n=t.getCameraLngLat(),o=t.getCameraAltitude(),c=this.terrain?this.terrain.getElevationForLngLatZoom(n,t.zoom):0;if(o<c){const f=this.calculateCameraOptionsFromTo(n,c,t.center,t.elevation);return{pitch:f.pitch,zoom:f.zoom}}return{}}_applyUpdatedTransform(t){const n=[];if(n.push((c=>this._elevateCameraIfInsideTerrain(c))),this.transformCameraUpdate&&n.push((c=>this.transformCameraUpdate(c))),!n.length)return;const o=t.clone();for(const c of n){const f=o.clone(),{center:g,zoom:v,roll:b,pitch:P,bearing:E,elevation:k}=c(f);g&&f.setCenter(g),k!==void 0&&f.setElevation(k),v!==void 0&&f.setZoom(v),b!==void 0&&f.setRoll(b),P!==void 0&&f.setPitch(P),E!==void 0&&f.setBearing(E),o.apply(f,!1)}this.transform.apply(o,!1)}_fireMoveEvents(t){this.fire(new l.l("move",t)),this._zooming&&this.fire(new l.l("zoom",t)),this._rotating&&this.fire(new l.l("rotate",t)),this._pitching&&this.fire(new l.l("pitch",t)),this._rolling&&this.fire(new l.l("roll",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const o=this._zooming,c=this._rotating,f=this._pitching,g=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,o&&this.fire(new l.l("zoomend",t)),c&&this.fire(new l.l("rotateend",t)),f&&this.fire(new l.l("pitchend",t)),g&&this.fire(new l.l("rollend",t)),this.fire(new l.l("moveend",t))}flyTo(t,n){if(!t.essential&&Ze.prefersReducedMotion){const ye=l.U(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(ye,n)}this.stop(),t=l.e({offset:[0,0],speed:1.2,curve:1.42,easing:l.cz},t);const o=this._getTransformForUpdate(),c=o.bearing,f=o.pitch,g=o.roll,v=o.padding,b="bearing"in t?this._normalizeBearing(t.bearing,c):c,P="pitch"in t?+t.pitch:f,E="roll"in t?this._normalizeBearing(t.roll,g):g,k="padding"in t?t.padding:o.padding,D=l.P.convert(t.offset);let L=o.centerPoint.add(D);const N=o.screenPointToLocation(L),q=this.cameraHelper.handleFlyTo(o,{bearing:b,pitch:P,roll:E,padding:k,locationAtOffset:N,offsetAsPoint:D,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let H=t.curve;const W=Math.max(o.width,o.height),K=W/q.scaleOfZoom,re=q.pixelPathLength;typeof q.scaleOfMinZoom=="number"&&(H=Math.sqrt(W/q.scaleOfMinZoom/re*2));const Y=H*H;function te(ye){const Re=(K*K-W*W+(ye?-1:1)*Y*Y*re*re)/(2*(ye?K:W)*Y*re);return Math.log(Math.sqrt(Re*Re+1)-Re)}function oe(ye){return(Math.exp(ye)-Math.exp(-ye))/2}function Q(ye){return(Math.exp(ye)+Math.exp(-ye))/2}const ae=te(!1);let ve=function(ye){return Q(ae)/Q(ae+H*ye)},ge=function(ye){return W*((Q(ae)*(oe(Re=ae+H*ye)/Q(Re))-oe(ae))/Y)/re;var Re},_e=(te(!0)-ae)/H;if(Math.abs(re)<2e-6||!isFinite(_e)){if(Math.abs(W-K)<1e-6)return this.easeTo(t,n);const ye=K<W?-1:1;_e=Math.abs(Math.log(K/W))/H,ge=()=>0,ve=Re=>Math.exp(ye*H*Re)}return t.duration="duration"in t?+t.duration:1e3*_e/("screenSpeed"in t?+t.screenSpeed/H:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=c!==b,this._pitching=P!==f,this._rolling=E!==g,this._padding=!o.isPaddingEqual(k),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(q.targetCenter),this._ease((ye=>{const Re=ye*_e,Fe=1/ve(Re),Ee=ge(Re);this._rotating&&o.setBearing(l.G.number(c,b,ye)),this._pitching&&o.setPitch(l.G.number(f,P,ye)),this._rolling&&o.setRoll(l.G.number(g,E,ye)),this._padding&&(o.interpolatePadding(v,k,ye),L=o.centerPoint.add(D)),q.easeFunc(ye,Fe,Ee,L),this.terrain&&!t.freezeElevation&&this._updateElevation(ye),this._applyUpdatedTransform(o),this._fireMoveEvents(n)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){var o;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const c=this._onEaseEnd;delete this._onEaseEnd,c.call(this,n)}return t||(o=this.handlers)===null||o===void 0||o.stop(!1),this}_ease(t,n,o){o.animate===!1||o.duration===0?(t(1),n()):(this._easeStart=Qe(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=l.W(t,-180,180);const o=Math.abs(t-n);return Math.abs(t-360-n)<o&&(t-=360),Math.abs(t+360-n)<o&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(l.V.convert(t),this.transform):null}}const Ei={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Kl{constructor(t=Ei){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=me.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=me.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=me.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){me.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,n){const o=this._map._getUIString(`AttributionControl.${n}`);t.title=o,t.setAttribute("aria-label",o)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((c=>typeof c!="string"?"":c))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const c=this._map.style.stylesheet;this.styleOwner=c.owner,this.styleId=c.id}const n=this._map.style.tileManagers;for(const c in n){const f=n[c];if(f.used||f.usedForTerrain){const g=f.getSource();g.attribution&&t.indexOf(g.attribution)<0&&t.push(g.attribution)}}t=t.filter((c=>String(c).trim())),t.sort(((c,f)=>c.length-f.length)),t=t.filter(((c,f)=>{for(let g=f+1;g<t.length;g++)if(t[g].indexOf(c)>=0)return!1;return!0}));const o=t.join(" | ");o!==this._attribHTML&&(this._attribHTML=o,t.length?(this._innerContainer.innerHTML=me.sanitize(o),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class ju{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const o=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&o.classList.add("maplibregl-compact"):o.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=me.create("div","maplibregl-ctrl");const n=me.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){me.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Jh{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,o=n?this._queue.concat(n):this._queue;for(const c of o)if(c.id===t)return void(c.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const o of n)if(!o.cancelled&&(o.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Qh=l.aU([{name:"a_pos3d",type:"Int16",components:3}]);class Do extends l.E{constructor(t){super(),this._lastTilesetChange=Qe(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(t,n){this.tileManager.update(t,n),this._renderableTilesKeys=[];const o={};for(const c of Zt(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))o[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.terrainRttPosMatrix32f=new Float64Array(16),l.c7(c.terrainRttPosMatrix32f,0,l.a5,l.a5,0,0,1),this._tiles[c.key]=new pe(c,this.tileSize),this._lastTilesetChange=Qe());for(const c in this._tiles)o[c]||delete this._tiles[c]}freeRtt(t){for(const n in this._tiles){const o=this._tiles[n];(!t||o.tileID.equals(t)||o.tileID.isChildOf(t)||t.isChildOf(o.tileID))&&(o.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,n){return n?this._getTerrainCoordsForTileRanges(t,n):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){const n={};for(const o of this._renderableTilesKeys){const c=this._tiles[o].tileID,f=t.clone(),g=l.bk();if(c.canonical.equals(t.canonical))l.c7(g,0,l.a5,l.a5,0,0,1);else if(c.canonical.isChildOf(t.canonical)){const v=c.canonical.z-t.canonical.z,b=c.canonical.x-(c.canonical.x>>v<<v),P=c.canonical.y-(c.canonical.y>>v<<v),E=l.a5>>v;l.c7(g,0,E,E,0,0,1),l.O(g,g,[-b*E,-P*E,0])}else{if(!t.canonical.isChildOf(c.canonical))continue;{const v=t.canonical.z-c.canonical.z,b=t.canonical.x-(t.canonical.x>>v<<v),P=t.canonical.y-(t.canonical.y>>v<<v),E=l.a5>>v;l.c7(g,0,l.a5,l.a5,0,0,1),l.O(g,g,[b*E,P*E,0]),l.Q(g,g,[1/2**v,1/2**v,0])}}f.terrainRttPosMatrix32f=new Float32Array(g),n[o]=f}return n}_getTerrainCoordsForTileRanges(t,n){const o={};for(const c of this._renderableTilesKeys){const f=this._tiles[c].tileID;if(!this._isWithinTileRanges(f,n))continue;const g=t.clone(),v=l.bk();if(f.canonical.z===t.canonical.z){const b=t.canonical.x-f.canonical.x+t.wrap*(1<<t.canonical.z),P=t.canonical.y-f.canonical.y;l.c7(v,0,l.a5,l.a5,0,0,1),l.O(v,v,[b*l.a5,P*l.a5,0])}else if(f.canonical.z>t.canonical.z){const b=f.canonical.z-t.canonical.z,P=f.canonical.x-(f.canonical.x>>b<<b)+t.wrap*(1<<f.canonical.z),E=f.canonical.y-(f.canonical.y>>b<<b),k=t.canonical.x-(f.canonical.x>>b),D=t.canonical.y-(f.canonical.y>>b),L=l.a5>>b;l.c7(v,0,L,L,0,0,1),l.O(v,v,[-P*L+k*l.a5,-E*L+D*l.a5,0])}else{const b=t.canonical.z-f.canonical.z,P=t.canonical.x-(t.canonical.x>>b<<b)+t.wrap*(1<<t.canonical.z),E=t.canonical.y-(t.canonical.y>>b<<b),k=(t.canonical.x>>b)-f.canonical.x,D=(t.canonical.y>>b)-f.canonical.y,L=l.a5<<b;l.c7(v,0,L,L,0,0,1),l.O(v,v,[P*l.a5+k*L,E*l.a5+D*L,0])}g.terrainRttPosMatrix32f=new Float32Array(v),o[c]=g}return o}getSourceTile(t,n){const o=this.tileManager._source;let c=t.overscaledZ-this.deltaZoom;if(c>o.maxzoom&&(c=o.maxzoom),c<o.minzoom)return;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(c).key);let f=this.findTileInCaches(this._sourceTileCache[t.key]);if(!f?.dem&&n)for(;c>=o.minzoom&&!f?.dem;)f=this.findTileInCaches(t.scaledTo(c--).key);return f}findTileInCaches(t){let n=this.tileManager.getTileByID(t);return n||(n=this.tileManager._outOfViewCache.getByKey(t),n)}anyTilesAfterTime(t=Date.now()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,n){const o=n[t.canonical.z];return!!o&&(t.wrap>o.minWrap||t.wrap<o.maxWrap||t.canonical.x>=o.minTileXWrapped&&t.canonical.x<=o.maxTileXWrapped&&t.canonical.y>=o.minTileY&&t.canonical.y<=o.maxTileY)}}class rr{constructor(t,n,o){this._meshCache={},this.painter=t,this.tileManager=new Do(n),this.options=o,this.exaggeration=typeof o.exaggeration=="number"?o.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,o,c=l.a5){var f;if(!(n>=0&&n<c&&o>=0&&o<c))return 0;const g=this.getTerrainData(t),v=(f=g.tile)===null||f===void 0?void 0:f.dem;if(!v)return 0;const b=l.cD([],[n/c*l.a5,o/c*l.a5],g.u_terrain_matrix),P=[b[0]*v.dim,b[1]*v.dim],E=Math.floor(P[0]),k=Math.floor(P[1]),D=P[0]-E,L=P[1]-k;return v.get(E,k)*(1-D)*(1-L)+v.get(E+1,k)*D*(1-L)+v.get(E,k+1)*(1-D)*L+v.get(E+1,k+1)*D*L}getElevationForLngLatZoom(t,n){if(!l.cE(n,t.wrap()))return 0;const{tileID:o,mercatorX:c,mercatorY:f}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(o,c%l.a5,f%l.a5,l.a5)}getElevationForLngLat(t,n){const o=Zt(n,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let c=0;for(const f of o)f.canonical.z>c&&(c=Math.min(f.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,c)}getElevation(t,n,o,c=l.a5){return this.getDEMElevation(t,n,o,c)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const c=this.painter.context,f=new l.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new l.T(c,f,c.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new l.T(c,new l.R({width:1,height:1}),c.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(c.gl.NEAREST,c.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=l.ar([])}const n=this.tileManager.getSourceTile(t,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const c=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new l.T(c,n.dem.getPixels(),c.gl.RGBA,{premultiply:!1}),n.demTexture.bind(c.gl.NEAREST,c.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const o=n&&n.toString()+n.tileID.key+t.key;if(o&&!this._demMatrixCache[o]){const c=this.tileManager.getSource().maxzoom;let f=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=c?f=t.canonical.z-c:l.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const g=t.canonical.x-(t.canonical.x>>f<<f),v=t.canonical.y-(t.canonical.y>>f<<f),b=l.cF(new Float64Array(16),[1/(l.a5<<f),1/(l.a5<<f),0]);l.O(b,b,[g*l.a5,v*l.a5,0]),this._demMatrixCache[t.key]={matrix:b,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:o?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(t){const n=this.painter,o=n.width/devicePixelRatio,c=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===o&&this._fbo.height===c||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new l.T(n.context,{width:o,height:c,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new l.T(n.context,{width:o,height:c,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(o,c,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,o,c))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let f=0,g=0;f<this._coordsTextureSize;f++)for(let v=0;v<this._coordsTextureSize;v++,g+=4)n[g+0]=255&v,n[g+1]=255&f,n[g+2]=v>>8<<4|f>>8,n[g+3]=0;const o=new l.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),c=new l.T(t,o,t.gl.RGBA,{premultiply:!1});return c.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),o=this.painter.context,c=o.gl,f=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),g=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),v=Math.round(this.painter.height/devicePixelRatio);o.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(f,v-g-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null);const b=n[0]+(n[2]>>4<<8),P=n[1]+((15&n[2])<<8),E=this.coordsIndex[255-n[3]],k=E&&this.tileManager.getTileByID(E);if(!k)return null;const D=this._coordsTextureSize,L=(1<<k.tileID.canonical.z)*D;return new l.a9((k.tileID.canonical.x*D+b)/L+k.tileID.wrap,(k.tileID.canonical.y*D+P)/L,this.getElevation(k.tileID,b,P,D))}depthAtPoint(t){const n=new Uint8Array(4),o=this.painter.context,c=o.gl;return o.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),c.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(t){var n;const o=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,c=o&&t.canonical.y===0,f=o&&t.canonical.y===(1<<t.canonical.z)-1,g=`m_${c?"n":""}_${f?"s":""}`;if(this._meshCache[g])return this._meshCache[g];const v=this.painter.context,b=new l.cG,P=new l.aY,E=this.meshSize,k=l.a5/E,D=E*E;for(let Q=0;Q<=E;Q++)for(let ae=0;ae<=E;ae++)b.emplaceBack(ae*k,Q*k,0);for(let Q=0;Q<D;Q+=E+1)for(let ae=0;ae<E;ae++)P.emplaceBack(ae+Q,E+ae+Q+1,E+ae+Q+2),P.emplaceBack(ae+Q,E+ae+Q+2,ae+Q+1);const L=b.length,N=L+(E+1),q=(E+1)*E,H=c?l.br:0,W=c?0:1,K=f?l.bs:l.a5,re=f?0:1;for(let Q=0;Q<=E;Q++)b.emplaceBack(Q*k,H,W);for(let Q=0;Q<=E;Q++)b.emplaceBack(Q*k,K,re);for(let Q=0;Q<E;Q++)P.emplaceBack(q+Q,N+Q,N+Q+1),P.emplaceBack(q+Q,N+Q+1,q+Q+1),P.emplaceBack(0+Q,L+Q+1,L+Q),P.emplaceBack(0+Q,0+Q+1,L+Q+1);const Y=b.length,te=Y+2*(E+1);for(const Q of[0,1])for(let ae=0;ae<=E;ae++)for(const ve of[0,1])b.emplaceBack(Q*l.a5,ae*k,ve);for(let Q=0;Q<2*E;Q+=2)P.emplaceBack(Y+Q,Y+Q+1,Y+Q+3),P.emplaceBack(Y+Q,Y+Q+3,Y+Q+2),P.emplaceBack(te+Q,te+Q+3,te+Q+1),P.emplaceBack(te+Q,te+Q+2,te+Q+3);const oe=new Ft(v.createVertexBuffer(b,Qh.members),v.createIndexBuffer(P),l.aX.simpleSegment(0,0,b.length,P.length));return this._meshCache[g]=oe,oe}getMeshFrameDelta(t){return 2*Math.PI*l.bE/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,n){var o;if(!l.cE(n,t.wrap()))return 0;const{tileID:c}=this._getOverscaledTileIDFromLngLatZoom(t,n);return(o=this.getMinMaxElevation(c).minElevation)!==null&&o!==void 0?o:0}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,o={minElevation:null,maxElevation:null};return n&&n.dem&&(o.minElevation=n.dem.min*this.exaggeration,o.maxElevation=n.dem.max*this.exaggeration),o}_getOverscaledTileIDFromLngLatZoom(t,n){const o=l.a9.fromLngLat(t.wrap()),c=(1<<n)*l.a5,f=o.x*c,g=o.y*c,v=Math.floor(f/l.a5),b=Math.floor(g/l.a5);return{tileID:new l.a2(n,0,n,v,b),mercatorX:f,mercatorY:g}}}class yr{constructor(t,n,o){this._context=t,this._size=n,this._tileSize=o,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),o=new l.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return o.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(o.texture),{id:t,fbo:n,texture:o,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((n=>t.id!==n)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some((t=>!t.inUse))===!1}}const Kn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class ko{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new yr(t.context,30,n.tileManager.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((o=>!t._layers[o].isHidden(n))),this._coordsAscending={};for(const o in t.tileManagers){this._coordsAscending[o]={};const c=t.tileManagers[o].getVisibleCoordinates(),f=t.tileManagers[o].getSource(),g=f instanceof gi?f.terrainTileRanges:null;for(const v of c){const b=this.terrain.tileManager.getTerrainCoords(v,g);for(const P in b)this._coordsAscending[o][P]||(this._coordsAscending[o][P]=[]),this._coordsAscending[o][P].push(b[P])}}this._coordsAscendingStr={};for(const o of t._order){const c=t._layers[o],f=c.source;if(Kn[c.type]&&!this._coordsAscendingStr[f]){this._coordsAscendingStr[f]={};for(const g in this._coordsAscending[f])this._coordsAscendingStr[f][g]=this._coordsAscending[f][g].map((v=>v.key)).sort().join()}}for(const o of this._renderableTiles)for(const c in this._coordsAscendingStr){const f=this._coordsAscendingStr[c][o.tileID.key];f&&f!==o.rttCoords[c]&&(o.rtt=[])}}renderLayer(t,n){if(t.isHidden(this.painter.transform.zoom))return!1;const o=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),c=t.type,f=this.painter,g=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Kn[c]&&(this._prevType&&Kn[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(t.id),!g))return!0;if(Kn[this._prevType]||Kn[c]&&g){this._prevType=c;const v=this._stacks.length-1,b=this._stacks[v]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(Nl(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[v]){const k=this.pool.getObjectForId(P.rtt[v].id);if(k.stamp===P.rtt[v].stamp){this.pool.useObject(k);continue}}const E=this.pool.getOrCreateFreeObject();this.pool.useObject(E),this.pool.stampObject(E),P.rtt[v]={id:E.id,stamp:E.stamp},f.context.bindFramebuffer.set(E.fbo.framebuffer),f.context.clear({color:l.bp.transparent,stencil:0}),f.currentStencilSource=void 0;for(let k=0;k<b.length;k++){const D=f.style._layers[b[k]],L=D.source?this._coordsAscending[D.source][P.tileID.key]:[P.tileID];f.context.viewport.set([0,0,E.fbo.width,E.fbo.height]),f._renderTileClippingMasks(D,L,!0),f.renderLayer(f,f.style.tileManagers[D.source],D,L,o),D.source&&(P.rttCoords[D.source]=this._coordsAscendingStr[D.source][P.tileID.key])}}return Nl(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects(),Kn[c]}return!1}}const ka={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use β + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Jl=ne,Ra={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Ei,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:l.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0},Ql={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Ro{constructor(t,n,o=!1){this.mousedown=f=>{this.startMove(f,me.mousePos(this.element,f)),me.addEventListener(window,"mousemove",this.mousemove),me.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=f=>{this.move(f,me.mousePos(this.element,f))},this.mouseup=f=>{this._rotatePitchHandler.dragEnd(f),this.offTemp()},this.touchstart=f=>{f.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=me.touchPos(this.element,f.targetTouches)[0],this.startMove(f,this._startPos),me.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),me.addEventListener(window,"touchend",this.touchend))},this.touchmove=f=>{f.targetTouches.length!==1?this.reset():(this._lastPos=me.touchPos(this.element,f.targetTouches)[0],this.move(f,this._lastPos))},this.touchend=f=>{f.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n;const c=new Du;this._rotatePitchHandler=new Os({clickTolerance:3,move:(f,g)=>{const v=n.getBoundingClientRect(),b=new l.P((v.bottom-v.top)/2,(v.right-v.left)/2);return{bearingDelta:l.cy(new l.P(f.x,g.y),g,b),pitchDelta:o?-.5*(g.y-f.y):void 0}},moveStateManager:c,enable:!0,assignEvents:()=>{}}),this.map=t,me.addEventListener(n,"mousedown",this.mousedown),me.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),me.addEventListener(n,"touchcancel",this.reset)}startMove(t,n){this._rotatePitchHandler.dragStart(t,n),me.disableDrag()}move(t,n){const o=this.map,{bearingDelta:c,pitchDelta:f}=this._rotatePitchHandler.dragMove(t,n)||{};c&&o.setBearing(o.getBearing()+c),f&&o.setPitch(o.getPitch()+f)}off(){const t=this.element;me.removeEventListener(t,"mousedown",this.mousedown),me.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),me.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),me.removeEventListener(window,"touchend",this.touchend),me.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){me.enableDrag(),me.removeEventListener(window,"mousemove",this.mousemove),me.removeEventListener(window,"mouseup",this.mouseup),me.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),me.removeEventListener(window,"touchend",this.touchend)}}let cn;function Fa(d,t,n,o=!1){if(o||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return d?.wrap();const c=new l.V(d.lng,d.lat);if(d=new l.V(d.lng,d.lat),t){const f=new l.V(d.lng-360,d.lat),g=new l.V(d.lng+360,d.lat),v=n.locationToScreenPoint(d).distSqr(t);n.locationToScreenPoint(f).distSqr(t)<v?d=f:n.locationToScreenPoint(g).distSqr(t)<v&&(d=g)}for(;Math.abs(d.lng-n.center.lng)>180;){const f=n.locationToScreenPoint(d);if(f.x>=0&&f.y>=0&&f.x<=n.width&&f.y<=n.height)break;d.lng>n.center.lng?d.lng-=360:d.lng+=360}return d.lng!==c.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(d))?d:c}const Fo={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function La(d,t,n){const o=d.classList;for(const c in Fo)o.remove(`maplibregl-${n}-anchor-${c}`);o.add(`maplibregl-${n}-anchor-${t}`)}class Lo extends l.E{constructor(t){if(super(),this._onKeyPress=n=>{const o=n.code,c=n.charCode||n.keyCode;o!=="Space"&&o!=="Enter"&&c!==32&&c!==13||this.togglePopup()},this._onMapClick=n=>{const o=n.originalEvent.target,c=this._element;this._popup&&(o===c||c.contains(o))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();(n?.type==="terrain"||n?.type==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=Fa(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let f="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?f="rotateX(0deg)":this._pitchAlignment==="map"&&(f=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),me.setTransform(this._element,`${Fo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${f} ${c}`),Ze.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity(n&&n.type==="moveend")})).catch((()=>{}))},this._onMove=n=>{if(!this._isDragging){const o=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=o}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new l.l("dragstart"))),this.fire(new l.l("drag")))},this._onUp=()=>{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),this._state==="active"&&this.fire(new l.l("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.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))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,this.setOpacity(t?.opacity,t?.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=l.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=me.create("div");const n=me.createNS("http://www.w3.org/2000/svg","svg"),o=41,c=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${o}px`),n.setAttributeNS(null,"width",`${c}px`),n.setAttributeNS(null,"viewBox",`0 0 ${c} ${o}`);const f=me.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"stroke","none"),f.setAttributeNS(null,"stroke-width","1"),f.setAttributeNS(null,"fill","none"),f.setAttributeNS(null,"fill-rule","evenodd");const g=me.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const v=me.createNS("http://www.w3.org/2000/svg","g");v.setAttributeNS(null,"transform","translate(3.0, 29.0)"),v.setAttributeNS(null,"fill","#000000");const b=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const W of b){const K=me.createNS("http://www.w3.org/2000/svg","ellipse");K.setAttributeNS(null,"opacity","0.04"),K.setAttributeNS(null,"cx","10.5"),K.setAttributeNS(null,"cy","5.80029008"),K.setAttributeNS(null,"rx",W.rx),K.setAttributeNS(null,"ry",W.ry),v.appendChild(K)}const P=me.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"fill",this._color);const E=me.createNS("http://www.w3.org/2000/svg","path");E.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),P.appendChild(E);const k=me.createNS("http://www.w3.org/2000/svg","g");k.setAttributeNS(null,"opacity","0.25"),k.setAttributeNS(null,"fill","#000000");const D=me.createNS("http://www.w3.org/2000/svg","path");D.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),k.appendChild(D);const L=me.createNS("http://www.w3.org/2000/svg","g");L.setAttributeNS(null,"transform","translate(6.0, 7.0)"),L.setAttributeNS(null,"fill","#FFFFFF");const N=me.createNS("http://www.w3.org/2000/svg","g");N.setAttributeNS(null,"transform","translate(8.0, 8.0)");const q=me.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#000000"),q.setAttributeNS(null,"opacity","0.25"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962");const H=me.createNS("http://www.w3.org/2000/svg","circle");H.setAttributeNS(null,"fill","#FFFFFF"),H.setAttributeNS(null,"cx","5.5"),H.setAttributeNS(null,"cy","5.5"),H.setAttributeNS(null,"r","5.4999962"),N.appendChild(q),N.appendChild(H),g.appendChild(v),g.appendChild(P),g.appendChild(k),g.appendChild(L),g.appendChild(N),n.appendChild(g),n.setAttributeNS(null,"height",o*this._scale+"px"),n.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(n),this._offset=l.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(n=>{n.preventDefault()})),this._element.addEventListener("mousedown",(n=>{n.preventDefault()})),La(this._element,this._anchor,"marker"),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),me.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=l.V.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const c=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[c,-1*(38.1-13.5+c)],"bottom-right":[-c,-1*(38.1-13.5+c)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var n,o;const c=(n=this._map)===null||n===void 0?void 0:n.terrain,f=this._map.transform.isLocationOccluded(this._lngLat);if(!c||f){const L=f?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==L&&(this._element.style.opacity=L))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const g=this._map,v=g.terrain.depthAtPoint(this._pos),b=g.terrain.getElevationForLngLat(this._lngLat,g.transform);if(g.transform.lngLatToCameraDepth(this._lngLat,b)-v<.006)return void(this._element.style.opacity=this._opacity);const P=-this._offset.y/g.transform.pixelsPerMeter,E=Math.sin(g.getPitch()*Math.PI/180)*P,k=g.terrain.depthAtPoint(new l.P(this._pos.x,this._pos.y-this._offset.y)),D=g.transform.lngLatToCameraDepth(this._lngLat,b+E)-k>.006;!((o=this._popup)===null||o===void 0)&&o.isOpen()&&D&&this._popup.remove(),this._element.style.opacity=D?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=l.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(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}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,n){return(this._opacity===void 0||t===void 0&&n===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const ec={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let js=0,Jn=!1;const tc={maxWidth:100,unit:"metric"};function Oo(d,t,n){const o=n&&n.maxWidth||100,c=d._container.clientHeight/2,f=d._container.clientWidth/2,g=d.unproject([f-o/2,c]),v=d.unproject([f+o/2,c]),b=Math.round(d.project(v).x-d.project(g).x),P=Math.min(o,b,d._container.clientWidth),E=g.distanceTo(v);if(n&&n.unit==="imperial"){const k=3.2808*E;k>5280?Qn(t,P,k/5280,d._getUIString("ScaleControl.Miles")):Qn(t,P,k,d._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Qn(t,P,E/1852,d._getUIString("ScaleControl.NauticalMiles")):E>=1e3?Qn(t,P,E/1e3,d._getUIString("ScaleControl.Kilometers")):Qn(t,P,E,d._getUIString("ScaleControl.Meters"))}function Qn(d,t,n,o){const c=(function(f){const g=Math.pow(10,`${Math.floor(f)}`.length-1);let v=f/g;return v=v>=10?10:v>=5?5:v>=3?3:v>=2?2:v>=1?1:(function(b){const P=Math.pow(10,Math.ceil(-Math.log(b)/Math.LN10));return Math.round(b*P)/P})(v),g*v})(n);d.style.width=t*(c/n)+"px",d.innerHTML=`${c} ${o}`}const rc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},Oa=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ba(d){if(d){if(typeof d=="number"){const t=Math.round(Math.abs(d)/Math.SQRT2);return{center:new l.P(0,0),top:new l.P(0,d),"top-left":new l.P(t,t),"top-right":new l.P(-t,t),bottom:new l.P(0,-d),"bottom-left":new l.P(t,-t),"bottom-right":new l.P(-t,-t),left:new l.P(d,0),right:new l.P(-d,0)}}if(d instanceof l.P||Array.isArray(d)){const t=l.P.convert(d);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:l.P.convert(d.center||[0,0]),top:l.P.convert(d.top||[0,0]),"top-left":l.P.convert(d["top-left"]||[0,0]),"top-right":l.P.convert(d["top-right"]||[0,0]),bottom:l.P.convert(d.bottom||[0,0]),"bottom-left":l.P.convert(d["bottom-left"]||[0,0]),"bottom-right":l.P.convert(d["bottom-right"]||[0,0]),left:l.P.convert(d.left||[0,0]),right:l.P.convert(d.right||[0,0])}}return Ba(new l.P(0,0))}const ic=ne;S.AJAXError=l.cJ,S.Event=l.l,S.Evented=l.E,S.LngLat=l.V,S.MercatorCoordinate=l.a9,S.Point=l.P,S.addProtocol=l.cK,S.config=l.c,S.removeProtocol=l.cL,S.AttributionControl=Kl,S.BoxZoomHandler=Ls,S.CanvasSource=Ks,S.CooperativeGesturesHandler=Xe,S.DoubleClickZoomHandler=Yl,S.DragPanHandler=Bu,S.DragRotateHandler=Ni,S.EdgeInsets=vs,S.FullscreenControl=class extends l.E{constructor(d={}){super(),this._onFullscreenChange=()=>{var t;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=n?.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,d&&d.container&&(d.container instanceof HTMLElement?this._container=d.container:l.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(d){return this._map=d,this._container||(this._container=this._map.getContainer()),this._controlContainer=me.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){me.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const d=this._fullscreenButton=me.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);me.create("span","maplibregl-ctrl-icon",d).setAttribute("aria-hidden","true"),d.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const d=this._getTitle();this._fullscreenButton.setAttribute("aria-label",d),this._fullscreenButton.title=d}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new l.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new l.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},S.GeoJSONSource=hs,S.GeolocateControl=class extends l.E{constructor(d){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new l.l("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new l.l("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new l.V(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,c=this._map.getBearing(),f=l.e({bearing:c},this.options.fitBoundsOptions),g=er.fromLngLat(n,o);this._map.fitBounds(g,f,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new l.V(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Jn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new l.l("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=me.create("button","maplibregl-ctrl-geolocate",this._container),me.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){l.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=me.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Lo({element:this._dotElement}),this._circleElement=me.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Lo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(n=>{const o=n?.[0]instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||o||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new l.l("trackuserlocationend")),this.fire(new l.l("userlocationlostfocus")))}))}},this.options=l.e({},ec,d)}onAdd(d){return this._map=d,this._container=me.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return l._(this,arguments,void 0,(function*(t=!1){if(cn!==void 0&&!t)return cn;if(window.navigator.permissions===void 0)return cn=!!window.navigator.geolocation,cn;try{cn=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{cn=!!window.navigator.geolocation}return cn}))})().then((t=>this._finishSetupUI(t))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(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(),me.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,js=0,Jn=!1}_isOutOfMapMaxBounds(d){const t=this._map.getMaxBounds(),n=d.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const d=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&d))return;const t=this._map.project(d),n=this._map.unproject([t.x+100,t.y]),o=d.distanceTo(n)/100,c=2*this._accuracy/o;this._circleElement.style.width=`${c.toFixed(2)}px`,this._circleElement.style.height=`${c.toFixed(2)}px`}trigger(){if(!this._setup)return l.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new l.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":js--,Jn=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new l.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new l.l("trackuserlocationstart")),this.fire(new l.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let d;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),js++,js>1?(d={maximumAge:6e5,timeout:0},Jn=!0):(d=this.options.positionOptions,Jn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,d)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},S.GlobeControl=class{constructor(){this._toggleProjection=()=>{var d;const t=(d=this._map.getProjection())===null||d===void 0?void 0:d.type;this._map.setProjection(t!=="mercator"&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var d;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((d=this._map.getProjection())===null||d===void 0?void 0:d.type)==="globe"?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(d){return this._map=d,this._container=me.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=me.create("button","maplibregl-ctrl-globe",this._container),me.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){me.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},S.Hash=Zl,S.ImageSource=gi,S.KeyboardHandler=Dt,S.LngLatBounds=er,S.LogoControl=ju,S.Map=class extends si{get _ownerWindow(){var d,t;return((t=(d=this._container)===null||d===void 0?void 0:d.ownerDocument)===null||t===void 0?void 0:t.defaultView)||window}constructor(d){var t,n;l.cH.mark(l.cI.create);const o=Object.assign(Object.assign(Object.assign({},Ra),d),{canvasContextAttributes:Object.assign(Object.assign({},Ra.canvasContextAttributes),d.canvasContextAttributes)});if(o.minZoom!=null&&o.maxZoom!=null&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(o.minPitch!=null&&o.maxPitch!=null&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(o.minPitch!=null&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(o.maxPitch!=null&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const c=new Nn,f=new Vn;o.minZoom!==void 0&&c.setMinZoom(o.minZoom),o.maxZoom!==void 0&&c.setMaxZoom(o.maxZoom),o.minPitch!==void 0&&c.setMinPitch(o.minPitch),o.maxPitch!==void 0&&c.setMaxPitch(o.maxPitch),o.renderWorldCopies!==void 0&&c.setRenderWorldCopies(o.renderWorldCopies),o.transformConstrain!==null&&c.setConstrainOverride(o.transformConstrain),super(c,f,{bearingSnap:o.bearingSnap,zoomSnap:o.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Jh,this._controls=[],this._mapId=l.af(),this._lostContextStyle={style:null,images:null},this._contextLost=v=>{v.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const b of Object.values(this.style._layers))if(b.type==="custom"&&console.warn(`Custom layer with id '${b.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),b._listeners)for(const[P]of Object.entries(b._listeners))console.warn(`Custom layer with id '${b.id}' had event listeners for event '${P}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new l.l("webglcontextlost",{originalEvent:v}))},this._contextRestored=v=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new l.l("webglcontextrestored",{originalEvent:v}))},this._onMapScroll=v=>{if(v.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=o.trackResize===!0,this._bearingSnap=o.bearingSnap,this._zoomSnap=o.zoomSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=o.refreshExpiredTiles===!0,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=o.crossSourceCollisions===!0,this._collectResourceTiming=o.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},ka),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this._zoomLevelsToOverscale=o.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=o.transformCameraUpdate,this.transformConstrain=o.transformConstrain,this.cancelPendingTileRequestsWhileZooming=o.cancelPendingTileRequestsWhileZooming===!0,o.reduceMotion!==void 0&&(Ze.prefersReducedMotion=o.reduceMotion),this._imageQueueHandle=mt.addThrottleControl((()=>this.isMoving())),this._requestManager=new Qt(o.transformRequest),this._container=this._resolveContainer(o.container),o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Da(this,o),this._hash=o.hash&&new Zl(typeof o.hash=="string"&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,l.e({},o.fitBoundsOptions,{duration:0}))));const g=typeof o.style=="string"||((n=(t=o.style)===null||t===void 0?void 0:t.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,g),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new Kl(typeof o.attributionControl=="boolean"?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new ju,o.logoPosition),this.on("style.load",(()=>{if(g||this._resizeTransform(),this.transform.unmodified){const v=l.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(v)}})),this.on("data",(v=>{this._update(v.dataType==="style"),this.fire(new l.l(`${v.dataType}data`,v))})),this.on("dataloading",(v=>{this.fire(new l.l(`${v.dataType}dataloading`,v))})),this.on("dataabort",(v=>{this.fire(new l.l("sourcedataabort",v))}))}_getMapId(){return this._mapId}setGlobalStateProperty(d,t){return this.style.setGlobalStateProperty(d,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(d,t){if(t===void 0&&(t=d.getDefaultPosition?d.getDefaultPosition():"top-right"),!d||!d.onAdd)return this.fire(new l.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=d.onAdd(this);this._controls.push(d);const o=this._controlPositions[t];return t.indexOf("bottom")!==-1?o.insertBefore(n,o.firstChild):o.appendChild(n),this}removeControl(d){if(!d||!d.onRemove)return this.fire(new l.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(d);return t>-1&&this._controls.splice(t,1),d.onRemove(this),this}hasControl(d){return this._controls.indexOf(d)>-1}coveringTiles(d){return Zt(this.transform,d)}calculateCameraOptionsFromTo(d,t,n,o){return o==null&&this.terrain&&(o=this.terrain.getElevationForLngLat(n,this.transform)),super.calculateCameraOptionsFromTo(d,t,n,o)}resize(d,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);const n=!this._moving;return n&&(this.stop(),this.fire(new l.l("movestart",d)).fire(new l.l("move",d))),this.fire(new l.l("resize",d)),n&&this.fire(new l.l("moveend",d)),this}_resizeInternal(d=!0){const[t,n]=this._containerDimensions(),o=this._getClampedPixelRatio(t,n);if(this._resizeCanvas(t,n,o),this.painter.resize(t,n,o),this.painter.overLimit()){const c=this.painter.context.gl;this._maxCanvasSize=[c.drawingBufferWidth,c.drawingBufferHeight];const f=this._getClampedPixelRatio(t,n);this._resizeCanvas(t,n,f),this.painter.resize(t,n,f)}this._resizeTransform(d)}_resizeTransform(d=!0){var t;const[n,o]=this._containerDimensions();this.transform.resize(n,o,d),(t=this._requestedCameraState)===null||t===void 0||t.resize(n,o,d)}_getClampedPixelRatio(d,t){const{0:n,1:o}=this._maxCanvasSize,c=this.getPixelRatio(),f=d*c,g=t*c;return Math.min(f>n?n/f:1,g>o?o/g:1)*c}getPixelRatio(){var d;return(d=this._overridePixelRatio)!==null&&d!==void 0?d:devicePixelRatio}setPixelRatio(d){this._overridePixelRatio=d,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(d){return this.transform.setMaxBounds(er.convert(d)),this._update()}setMinZoom(d){if((d=d??-2)>=-2&&d<=this.transform.maxZoom){const t=this.transform.zoom,n=this._getTransformForUpdate();return n.setMinZoom(d),this._applyUpdatedTransform(n),this._update(),t!==this.transform.zoom&&this.fire(new l.l("zoomstart")).fire(new l.l("zoom")).fire(new l.l("zoomend")).fire(new l.l("movestart")).fire(new l.l("move")).fire(new l.l("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(d){if((d=d??22)>=this.transform.minZoom){const t=this.transform.zoom,n=this._getTransformForUpdate();return n.setMaxZoom(d),this._applyUpdatedTransform(n),this._update(),t!==this.transform.zoom&&this.fire(new l.l("zoomstart")).fire(new l.l("zoom")).fire(new l.l("zoomend")).fire(new l.l("movestart")).fire(new l.l("move")).fire(new l.l("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(d){if((d=d??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(d>=0&&d<=this.transform.maxPitch){const t=this.transform.pitch,n=this._getTransformForUpdate();return n.setMinPitch(d),this._applyUpdatedTransform(n),this._update(),t!==this.transform.pitch&&this.fire(new l.l("pitchstart")).fire(new l.l("pitch")).fire(new l.l("pitchend")).fire(new l.l("movestart")).fire(new l.l("move")).fire(new l.l("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(d){if((d=d??60)>180)throw new Error("maxPitch must be less than or equal to 180");if(d>=this.transform.minPitch){const t=this.transform.pitch,n=this._getTransformForUpdate();return n.setMaxPitch(d),this._applyUpdatedTransform(n),this._update(),t!==this.transform.pitch&&this.fire(new l.l("pitchstart")).fire(new l.l("pitch")).fire(new l.l("pitchend")).fire(new l.l("movestart")).fire(new l.l("move")).fire(new l.l("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(d){return this.transform.setRenderWorldCopies(d),this._update()}setTransformConstrain(d){return this.transform.setConstrainOverride(d),this._update()}project(d){return this.transform.locationToScreenPoint(l.V.convert(d),this.style&&this.terrain)}unproject(d){return this.transform.screenPointToLocation(l.P.convert(d),this.terrain)}isMoving(){var d;return this._moving||((d=this.handlers)===null||d===void 0?void 0:d.isMoving())}isZooming(){var d;return this._zooming||((d=this.handlers)===null||d===void 0?void 0:d.isZooming())}isRotating(){var d;return this._rotating||((d=this.handlers)===null||d===void 0?void 0:d.isRotating())}_createDelegatedListener(d,t,n){if(d==="mouseenter"||d==="mouseover"){let o=!1;return{layers:t,listener:n,delegates:{mousemove:f=>{const g=t.filter((b=>this.getLayer(b))),v=g.length!==0?this.queryRenderedFeatures(f.point,{layers:g}):[];v.length?o||(o=!0,n.call(this,new Br(d,this,f.originalEvent,{features:v}))):o=!1},mouseout:()=>{o=!1}}}}if(d==="mouseleave"||d==="mouseout"){let o=!1;return{layers:t,listener:n,delegates:{mousemove:g=>{const v=t.filter((b=>this.getLayer(b)));(v.length!==0?this.queryRenderedFeatures(g.point,{layers:v}):[]).length?o=!0:o&&(o=!1,n.call(this,new Br(d,this,g.originalEvent)))},mouseout:g=>{o&&(o=!1,n.call(this,new Br(d,this,g.originalEvent)))}}}}{const o=c=>{const f=t.filter((v=>this.getLayer(v))),g=f.length!==0?this.queryRenderedFeatures(c.point,{layers:f}):[];g.length&&(c.features=g,n.call(this,c),delete c.features)};return{layers:t,listener:n,delegates:{[d]:o}}}}_saveDelegatedListener(d,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[d]=this._delegatedListeners[d]||[],this._delegatedListeners[d].push(t)}_removeDelegatedListener(d,t,n){if(!this._delegatedListeners||!this._delegatedListeners[d])return;const o=this._delegatedListeners[d];for(let c=0;c<o.length;c++){const f=o[c];if(f.listener===n&&f.layers.length===t.length&&f.layers.every((g=>t.includes(g)))){for(const g in f.delegates)this.off(g,f.delegates[g]);return void o.splice(c,1)}}}on(d,t,n){if(n===void 0)return super.on(d,t);const o=typeof t=="string"?[t]:t,c=this._createDelegatedListener(d,o,n);this._saveDelegatedListener(d,c);for(const f in c.delegates)this.on(f,c.delegates[f]);return{unsubscribe:()=>{this._removeDelegatedListener(d,o,n)}}}once(d,t,n){if(n===void 0)return super.once(d,t);const o=typeof t=="string"?[t]:t,c=this._createDelegatedListener(d,o,n);for(const f in c.delegates){const g=c.delegates[f];c.delegates[f]=(...v)=>{this._removeDelegatedListener(d,o,n),g(...v)}}this._saveDelegatedListener(d,c);for(const f in c.delegates)this.once(f,c.delegates[f]);return this}off(d,t,n){return n===void 0?super.off(d,t):(this._removeDelegatedListener(d,typeof t=="string"?[t]:t,n),this)}queryRenderedFeatures(d,t){if(!this.style)return[];let n;const o=d instanceof l.P||Array.isArray(d),c=o?d:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(o?{}:d)||{},c instanceof l.P||typeof c[0]=="number")n=[l.P.convert(c)];else{const f=l.P.convert(c[0]),g=l.P.convert(c[1]);n=[f,new l.P(g.x,f.y),g,new l.P(f.x,g.y),f]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(d,t){return this.style.querySourceFeatures(d,t)}setStyle(d,t){return(t=l.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&d?(this._diffStyle(d,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(d,t))}setTransformRequest(d){return this._requestManager.setTransformRequest(d),this}_getUIString(d){const t=this._locale[d];if(t==null)throw new Error(`Missing UI string '${d}'`);return t}_updateStyle(d,t){var n,o;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(d,t)));const c=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!d)),d?(this.style=new Zn(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof d=="string"?this.style.loadURL(d,t,c):this.style.loadJSON(d,t,c),this):((o=(n=this.style)===null||n===void 0?void 0:n.projection)===null||o===void 0||o.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Zn(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(d,t){if(typeof d=="string"){const n=this._requestManager.transformRequest(d,"Style");l.j(n,new AbortController).then((o=>{this._updateDiff(o.data,t)})).catch((o=>{o&&this.fire(new l.k(o))}))}else typeof d=="object"&&this._updateDiff(d,t)}_updateDiff(d,t){try{this.style.setState(d,t)&&this._update(!0)}catch(n){l.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(d,t)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():l.w("There is no style added to the map.")}addSource(d,t){return this._lazyInitEmptyStyle(),this.style.addSource(d,t),this._update(!0)}isSourceLoaded(d){const t=this.style&&this.style.tileManagers[d];if(t!==void 0)return t.loaded();this.fire(new l.k(new Error(`There is no tile manager with ID '${d}'`)))}setTerrain(d){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),d){const t=this.style.tileManagers[d.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${d.source}`);this.terrain===null&&t.reload();for(const n in this.style._layers){const o=this.style._layers[n];o.type==="hillshade"&&o.source===d.source&&l.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),o.type==="color-relief"&&o.source===d.source&&l.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new rr(this.painter,t,d),this.painter.renderToTexture=new ko(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=n=>{var o;n.dataType==="style"?this.terrain.tileManager.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==d.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),((o=n.source)===null||o===void 0?void 0:o.type)==="image"?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new l.l("terrain",{terrain:d})),this}getTerrain(){var d,t;return(t=(d=this.terrain)===null||d===void 0?void 0:d.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const d=this.style&&this.style.tileManagers;for(const t of Object.values(d))if(!t.areTilesLoaded())return!1;return!0}removeSource(d){return this.style.removeSource(d),this._update(!0)}getSource(d){return this.style.getSource(d)}setSourceTileLodParams(d,t,n){if(n){const o=this.getSource(n);if(!o)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);o.calculateTileZoom=Ke(Math.max(1,d),Math.max(1,t))}else for(const o in this.style.tileManagers)this.style.tileManagers[o].getSource().calculateTileZoom=Ke(Math.max(1,d),Math.max(1,t));return this._update(!0),this}refreshTiles(d,t){const n=this.style.tileManagers[d];if(!n)throw new Error(`There is no tile manager with ID "${d}", cannot refresh tile`);t===void 0?n.reload(!0):n.refreshTiles(t.map((o=>new l.ac(o.z,o.x,o.y))))}addImage(d,t,n={}){const{pixelRatio:o=1,sdf:c=!1,stretchX:f,stretchY:g,content:v,textFitWidth:b,textFitHeight:P}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||l.b(t))){if(t.width===void 0||t.height===void 0)return this.fire(new l.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:E,height:k,data:D}=t,L=t;return this.style.addImage(d,{data:new l.R({width:E,height:k},new Uint8Array(D)),pixelRatio:o,stretchX:f,stretchY:g,content:v,textFitWidth:b,textFitHeight:P,sdf:c,version:0,userImage:L}),L.onAdd&&L.onAdd(this,d),this}}{const{width:E,height:k,data:D}=Ze.getImageData(t);this.style.addImage(d,{data:new l.R({width:E,height:k},D),pixelRatio:o,stretchX:f,stretchY:g,content:v,textFitWidth:b,textFitHeight:P,sdf:c,version:0})}}updateImage(d,t){const n=this.style.getImage(d);if(!n)return this.fire(new l.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=t instanceof HTMLImageElement||l.b(t)?Ze.getImageData(t):t,{width:c,height:f,data:g}=o;if(c===void 0||f===void 0)return this.fire(new l.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(c!==n.data.width||f!==n.data.height)return this.fire(new l.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const v=!(t instanceof HTMLImageElement||l.b(t));return n.data.replace(g,v),this.style.updateImage(d,n),this}getImage(d){return this.style.getImage(d)}hasImage(d){return d?!!this.style.getImage(d):(this.fire(new l.k(new Error("Missing required image id"))),!1)}removeImage(d){this.style.removeImage(d)}loadImage(d){return mt.getImage(this._requestManager.transformRequest(d,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(d,t){return this._lazyInitEmptyStyle(),this.style.addLayer(d,t),this._update(!0)}moveLayer(d,t){return this.style.moveLayer(d,t),this._update(!0)}removeLayer(d){return this.style.removeLayer(d),this._update(!0)}getLayer(d){return this.style.getLayer(d)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(d,t,n){return this.style.setLayerZoomRange(d,t,n),this._update(!0)}setFilter(d,t,n={}){return this.style.setFilter(d,t,n),this._update(!0)}getFilter(d){return this.style.getFilter(d)}setPaintProperty(d,t,n,o={}){return this.style.setPaintProperty(d,t,n,o),this._update(!0)}getPaintProperty(d,t){return this.style.getPaintProperty(d,t)}setLayoutProperty(d,t,n,o={}){return this.style.setLayoutProperty(d,t,n,o),this._update(!0)}getLayoutProperty(d,t){return this.style.getLayoutProperty(d,t)}setGlyphs(d,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(d,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(d,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(d,t,n,(o=>{o||this._update(!0)})),this}removeSprite(d){return this._lazyInitEmptyStyle(),this.style.removeSprite(d),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(d,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(d,t,(n=>{n||this._update(!0)})),this}setLight(d,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(d,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(d,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(d,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(d,t){return this.style.setFeatureState(d,t),this._update()}removeFeatureState(d,t){return this.style.removeFeatureState(d,t),this._update()}getFeatureState(d){return this.style.getFeatureState(d)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let d=0,t=0;return this._container&&(d=this._container.clientWidth||400,t=this._container.clientHeight||300),[d,t]}_setupResizeObserver(){var d;let t=!1;const n=$l((c=>{this._trackResize&&!this._removed&&(this.resize(c),this.redraw())}),50),o=(d=this._ownerWindow.ResizeObserver)!==null&&d!==void 0?d:ResizeObserver;this._resizeObserver=new o((c=>{t?n(c):t=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(d){if(typeof d=="string"){const t=document.getElementById(d);if(!t)throw new Error(`Container '${d}' not found.`);return t}if(d instanceof HTMLElement||d&&typeof d=="object"&&d.nodeType===1)return d;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const d=this._container;d.classList.add("maplibregl-map");const t=this._canvasContainer=me.create("div","maplibregl-canvas-container",d);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=me.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),o=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],o);const c=this._controlContainer=me.create("div","maplibregl-control-container",d),f=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((g=>{f[g]=me.create("div",`maplibregl-ctrl-${g} `,c)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(d,t,n){this._canvas.width=Math.floor(n*d),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${d}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const d=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(o=>{t={requestedAttributes:d},o&&(t.statusMessage=o.statusMessage,t.type=o.type)}),{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,d):this._canvas.getContext("webgl2",d)||this._canvas.getContext("webgl",d),!n){const o="Failed to initialize WebGL";throw t?(t.message=o,new Error(JSON.stringify(t))):new Error(o)}this.painter=new Eu(n,this.transform),Vt.testSupport(n)}migrateProjection(d,t){super.migrateProjection(d,t),this.painter.transform=d,this.fire(new l.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(d){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||d,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(d){return this._update(),this._renderTaskQueue.add(d)}_cancelRenderFrame(d){this._renderTaskQueue.remove(d)}_render(d){var t,n,o,c,f;const g=this._idleTriggered?this._fadeDuration:0,v=((t=this.style.projection)===null||t===void 0?void 0:t.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(d),this._removed)return;let b=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const k=this.transform.zoom,D=Qe();this.style.zoomHistory.update(k,D);const L=new l.H(k,{now:D,fadeDuration:g,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),N=L.crossFadingFactor();N===1&&N===this._crossFadingFactor||(b=!0,this._crossFadingFactor=N),this.style.update(L)}const P=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==v;(o=this.style.projection)===null||o===void 0||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((c=this.style.projection)===null||c===void 0?void 0:c.transitionState,(f=this.style.projection)===null||f===void 0?void 0:f.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||P)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,g,this._crossSourceCollisions,P),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:g,showPadding:this.showPadding}),this.fire(new l.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,l.cH.mark(l.cI.load),this.fire(new l.l("load"))),this.style&&(this.style.hasTransitions()||b)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const E=this._sourcesDirty||this._styleDirty||this._placementDirty;return E||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new l.l("idle")),!this._loaded||this._fullyLoaded||E||(this._fullyLoaded=!0,l.cH.mark(l.cI.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var d;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),mt.removeThrottleControl(this._imageQueueHandle),(d=this._resizeObserver)===null||d===void 0||d.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t?.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),me.remove(this._canvasContainer),me.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),l.cH.clearMetrics(),this._removed=!0,this.fire(new l.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Ze.frame(this._frameRequest,(d=>{l.cH.frame(d),this._frameRequest=null;try{this._render(d)}catch(t){if(!l.Z(t)&&!(function(n){return n.message===Ll})(t))throw t}}),(()=>{}),this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(d){this._showTileBoundaries!==d&&(this._showTileBoundaries=d,this._update())}get showPadding(){return!!this._showPadding}set showPadding(d){this._showPadding!==d&&(this._showPadding=d,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(d){this._showCollisionBoxes!==d&&(this._showCollisionBoxes=d,d?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(d){this._showOverdrawInspector!==d&&(this._showOverdrawInspector=d,this._update())}get repaint(){return!!this._repaint}set repaint(d){this._repaint!==d&&(this._repaint=d,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(d){this._vertices=d,this._update()}get version(){return Jl}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(d){return this._lazyInitEmptyStyle(),this.style.setProjection(d),this._update(!0)}},S.MapMouseEvent=Br,S.MapTouchEvent=Po,S.MapWheelEvent=zu,S.Marker=Lo,S.NavigationControl=class{constructor(d){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),o=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(t,n)=>{const o=this._map._getUIString(`NavigationControl.${n}`);t.title=o,t.setAttribute("aria-label",o)},this.options=l.e({},Ql,d),this._container=me.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),me.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),me.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=me.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(d){return this._map=d,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ro(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){me.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(d,t){const n=me.create("button",d,this._container);return n.type="button",n.addEventListener("click",t),n}},S.Popup=class extends l.E{constructor(d){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&me.remove(this._content),this._container&&(me.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),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new l.l("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=me.create("div","maplibregl-popup",this._map.getContainer()),this._tip=me.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const g of this.options.className.split(" "))this._container.classList.add(g);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Fa(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!t)return;const n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let o=this.options.anchor;const c=Ba(this.options.offset);if(!o){const g=this._container.offsetWidth,v=this._container.offsetHeight,b=(function(E){var k,D,L,N;return E?{top:(k=E.top)!==null&&k!==void 0?k:0,right:(D=E.right)!==null&&D!==void 0?D:0,bottom:(L=E.bottom)!==null&&L!==void 0?L:0,left:(N=E.left)!==null&&N!==void 0?N:0}:{top:0,right:0,bottom:0,left:0}})(this.options.padding);let P;P=n.y+c.bottom.y<v+b.top?["top"]:n.y>this._map.transform.height-v-b.bottom?["bottom"]:[],n.x<g/2+b.left?P.push("left"):n.x>this._map.transform.width-g/2-b.right&&P.push("right"),o=P.length===0?"bottom":P.join("-")}let f=n.add(c[o]);this.options.subpixelPositioning||(f=f.round()),me.setTransform(this._container,`${Fo[o]} translate(${f.x}px,${f.y}px)`),La(this._container,o,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=l.e(Object.create(rc),d)}addTo(d){return this._map&&this.remove(),this._map=d,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"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new l.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(d){return this._lngLat=l.V.convert(d),this._pos=null,this._flatPos=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"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=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"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(d){return this.setDOMContent(document.createTextNode(d))}setHTML(d){const t=document.createDocumentFragment(),n=document.createElement("body");let o;for(n.innerHTML=d;o=n.firstChild,o;)t.appendChild(o);return this.setDOMContent(t)}getMaxWidth(){var d;return(d=this._container)===null||d===void 0?void 0:d.style.maxWidth}setMaxWidth(d){return this.options.maxWidth=d,this._update(),this}setDOMContent(d){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=me.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(d),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(d){return this._container&&this._container.classList.add(d),this}removeClassName(d){return this._container&&this._container.classList.remove(d),this}setOffset(d){return this.options.offset=d,this._update(),this}toggleClassName(d){if(this._container)return this._container.classList.toggle(d)}setSubpixelPositioning(d){this.options.subpixelPositioning=d}setPadding(d){this.options.padding=d,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=me.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const d=this._container.querySelector(Oa);d&&d.focus()}},S.RasterDEMTileSource=Ki,S.RasterTileSource=us,S.ScaleControl=class{constructor(d){this._onMove=()=>{Oo(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Oo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},tc),d)}getDefaultPosition(){return"bottom-left"}onAdd(d){return this._map=d,this._container=me.create("div","maplibregl-ctrl maplibregl-ctrl-scale",d.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){me.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},S.ScrollZoomHandler=Aa,S.Style=Zn,S.TerrainControl=class{constructor(d){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=d}onAdd(d){return this._map=d,this._container=me.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=me.create("button","maplibregl-ctrl-terrain",this._container),me.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){me.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},S.TwoFingersTouchPitchHandler=Fu,S.TwoFingersTouchRotateHandler=Hl,S.TwoFingersTouchZoomHandler=Wl,S.TwoFingersTouchZoomRotateHandler=Ao,S.VectorTileSource=cs,S.VideoSource=_n,S.addSourceType=(d,t)=>l._(void 0,void 0,void 0,(function*(){if(ps(d))throw new Error(`A source type called "${d}" already exists.`);((n,o)=>{ds[n]=o})(d,t)})),S.clearPrewarmedResources=function(){const d=kt;d&&(d.isPreloaded()&&d.numActive()===1?(d.release($t),kt=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()"))},S.createTileMesh=Hc,S.getMaxParallelImageRequests=function(){return l.c.MAX_PARALLEL_IMAGE_REQUESTS},S.getRTLTextPluginStatus=function(){return $().getRTLTextPluginStatus()},S.getVersion=function(){return ic},S.getWorkerCount=function(){return ai.workerCount},S.getWorkerUrl=function(){return l.c.WORKER_URL},S.importScriptInWorkers=function(d){return Yi().broadcast("IS",d)},S.isTimeFrozen=function(){return wt.isFrozen()},S.now=Qe,S.prewarm=function(){Hi().acquire($t)},S.restoreNow=function(){wt.restoreNow()},S.setMaxParallelImageRequests=function(d){l.c.MAX_PARALLEL_IMAGE_REQUESTS=d},S.setNow=function(d){wt.setNow(d)},S.setRTLTextPlugin=function(d,t){return $().setRTLTextPlugin(d,t)},S.setWorkerCount=function(d){ai.workerCount=d},S.setWorkerUrl=function(d){l.c.WORKER_URL=d}}));var V=T;return V}))})(jc)),jc.exports}var pf=V0();const $0=Cg({__proto__:null,default:Ag(pf)},[pf]);nn.ObjectMap=uf,nn.ObjectMapRenderer=hf,Object.defineProperty(nn,Symbol.toStringTag,{value:"Module"})}));
|